logs/
target/
+/bin/
+.checkstyle
+.project
+.settings
<!-- for Distribution Management -->
<sitePath>/content/sites/site/org/onap/dmaap/buscontroller/${artifact.version}</sitePath>
+ <nexusproxy>https://nexus.onap.org</nexusproxy>
</properties>
<description>Data Movement as a Platform (DMaaP) Bus Controller provides a REST API for other DCAE infrastructure components to provision DMaaP resources. A DMaaP resource is a Data Router Feed or a Message Router Topic, and their associated publishers and subscribers.</description>
</project>
this.status = status;
}
+ public void setStatus( String val ) {
+ if ( val == null || val.isEmpty() ) {
+ this.status = DmaapObject_Status.EMPTY;
+ } else if (val.compareToIgnoreCase("new") == 0 ) {
+ this.status = DmaapObject_Status.NEW;
+ } else if ( val.compareToIgnoreCase("staged" ) == 0) {
+ this.status = DmaapObject_Status.STAGED;
+ } else if ( val.compareToIgnoreCase("valid") == 0) {
+ this.status = DmaapObject_Status.VALID;
+ } else if ( val.compareToIgnoreCase("invalid") == 0) {
+ this.status = DmaapObject_Status.INVALID;
+ } else if ( val.compareToIgnoreCase("deleted") == 0) {
+ this.status = DmaapObject_Status.DELETED;
+ } else {
+ this.status = DmaapObject_Status.INVALID;
+ }
+ }
+
public boolean isStatusValid() {
if ( this.status == DmaapObject_Status.VALID ) {
return true;
public Feed ( String json ) {
JSONParser parser = new JSONParser();
JSONObject jsonObj;
- logger.info( "templog:Feed at 10" );
try {
jsonObj = (JSONObject) parser.parse( json );
} catch ( ParseException pe ) {
this.setStatus( DmaapObject_Status.INVALID );
return;
}
- logger.info( "templog:Feed at 11" );
this.setFeedName( (String) jsonObj.get("name"));
- logger.info( "templog:Feed at 12" );
-
this.setFeedVersion( (String) jsonObj.get("version"));
- logger.info( "templog:Feed at 13" );
this.setFeedDescription( (String) jsonObj.get("description"));
- logger.info( "templog:Feed at 14" );
this.setOwner( (String) jsonObj.get("publisher"));
- logger.info( "templog:Feed at 15" );
this.setSuspended( (boolean) jsonObj.get("suspend"));
- logger.info( "templog:Feed at 16" );
JSONObject links = (JSONObject) jsonObj.get("links");
- logger.info( "templog:Feed at 17" );
String url = (String) links.get("publish");
- logger.info( "templog:Feed at 18" );
this.setPublishURL( url );
- logger.info( "templog:Feed at 19" );
this.setFeedId( url.substring( url.lastIndexOf('/')+1, url.length() ));
- logger.info( "templog:Feed at 20" );
logger.info( "feedid="+ this.getFeedId() );
- logger.info( "templog:Feed at 21" );
this.setSubscribeURL( (String) links.get("subscribe") );
- logger.info( "templog:Feed at 22" );
this.setLogURL( (String) links.get("log") );
- logger.info( "templog:Feed at 23" );
JSONObject auth = (JSONObject) jsonObj.get("authorization");
- logger.info( "templog:Feed at 24" );
this.setAsprClassification( (String) auth.get("classification"));
- logger.info( "templog:Feed at 25" );
JSONArray pubs = (JSONArray) auth.get( "endpoint_ids");
- logger.info( "templog:Feed at 26" );
int i;
- logger.info( "templog:Feed at 27" );
ArrayList<DR_Pub> dr_pub = new ArrayList<DR_Pub>();
- logger.info( "templog:Feed at 28" );
this.subs = new ArrayList<DR_Sub>();
for( i = 0; i < pubs.size(); i++ ) {
- logger.info( "templog:Feed at 29 " + i );
JSONObject entry = (JSONObject) pubs.get(i);
- logger.info( "templog:Feed at 30" );
dr_pub.add( new DR_Pub( "someLocation",
(String) entry.get("id"),
(String) entry.get("password"),
this.getFeedId() + "." + DR_Pub.nextKey() ));
}
- logger.info( "templog:Feed at 31" );
this.setPubs( dr_pub );
- logger.info( "templog:Feed at 32" );
this.setStatus( DmaapObject_Status.VALID );
- logger.info( "templog:Feed at 33" );
}
package org.onap.dmaap.dbcapi.model;
-import java.util.Date;
-
import javax.xml.bind.annotation.XmlRootElement;
import org.onap.dmaap.dbcapi.util.DmaapTimestamp;
String[] h ) {
this.dcaeLocationName = dLN;
this.fqdn = f;
-logger.info( "templog:MR_Cluster at 10" );
this.hosts = new String[3];
this.hosts[0] = h[0];
-logger.info( "templog:MR_Cluster at 20" );
this.hosts[1] = h[1];
-logger.info( "templog:MR_Cluster at 30" );
this.hosts[2] = h[2];
-logger.info( "templog:MR_Cluster at 40" );
this.topicProtocol = defaultTopicProtocol;
-logger.info( "templog:MR_Cluster at 50" );
this.topicPort = defaultTopicPort;
this.lastMod = new DmaapTimestamp();
this.lastMod.mark();
debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
-logger.info( "templog:MR_Cluster at 60" );
}
public String getDcaeLocationName() {
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
-
+import org.json.simple.*;
+import org.json.simple.parser.*;
import javax.xml.bind.annotation.XmlRootElement;
this.fqtnStyle = FqtnType.Validator("none");
logger.debug( "Topic constructor " + this.getLastMod() );
}
+
+ // expects a String in JSON format, with known fields to populate Topic object
+ public Topic ( String json ) {
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObj;
+ try {
+ jsonObj = (JSONObject) parser.parse( json );
+ } catch ( ParseException pe ) {
+ logger.error( "Error parsing provisioning data: " + json );
+ this.setStatus( DmaapObject_Status.INVALID );
+ return;
+ }
+ this.setFqtn( (String) jsonObj.get( "fqtn" ) );
+ this.setTopicName( (String) jsonObj.get( "topicName" ) );
+ this.setTopicDescription( (String) jsonObj.get( "topicDescription" ));
+ this.setOwner( (String) jsonObj.get( "owner" ) );
+ //this.setLastMod();
+ this.setStatus( (String) jsonObj.get( "status" ) );
+ this.setReplicationCase( ReplicationType.Validator( (String) jsonObj.get( "replicationCase" ) ));
+ this.setFqtnStyle( FqtnType.Validator( (String) jsonObj.get( "fqtnStyle" ) ) );
+
+ }
public String getFqtn() {
return fqtn;
}
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.client;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.client;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.client;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.util.Singleton;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
+import org.onap.dmaap.dbcapi.aaf.database.DBSingleton;
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MRClientTest {
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MR_ClusterTest {
String d, fqdn, a;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class TopicTest {
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- assertTrue( resp.getStatus() == 201 );
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+
+ resp = target( "dcaeLocations").
+ path( loc.getDcaeLocationName()).request().get( Response.class );
+ System.out.println( "GET feed resp=" + resp.getStatus() );
+
+ assertTrue( resp.getStatus() == 200 );
}
@Test
public void PutTest() {
+ DcaeLocation loc = factory.genDcaeLocation( "edge" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
+ System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+
+
+ loc.setClli("ATLCTYNJ9999");
+ reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ resp = target( "dcaeLocations").
+ path( loc.getDcaeLocationName()).request().put( reqEntity, Response.class );
+ System.out.println( "PUT dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 201 );
+
}
+ @Test
+ public void DelTest() {
+ DcaeLocation loc = factory.genDcaeLocation( "edge" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
+ System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+
+ resp = target( "dcaeLocations").
+ path( loc.getDcaeLocationName()).request().delete( Response.class );
+ System.out.println( "DELETE dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 204 );
+ }
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.service.*;
-import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import java.util.*;
-import java.sql.*;
+import static org.junit.Assert.assertTrue;
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
public class MR_ClusterResourceTest extends JerseyTest {
@Override
protected Application configure() {
- return new ResourceConfig( MR_ClusterResource.class );
+
+ return new ResourceConfig()
+ .register( MR_ClusterResource.class )
+ .register( DcaeLocationResource.class );
}
private static final String fmt = "%24s: %s%n";
Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
Response resp = target( "mr_clusters").request().post( reqEntity, Response.class );
System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- assertTrue( resp.getStatus() == 201 );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201);
+ }
+ resp = target( "mr_clusters").
+ path( cluster.getDcaeLocationName()).request().get( Response.class );
+ System.out.println( "GET MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+
+ assertTrue( resp.getStatus() >= 200 && resp.getStatus() < 300 );
+
}
@Test
public void PutTest() {
-/*
+
try {
DcaeLocation loc = factory.genDcaeLocation( "central" );
Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ));
- assertTrue( resp.getStatus() == 201 );
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
} catch (Exception e ) {
}
-*/
+
String h[] = {"host4", "host5", "host6" };
- MR_Cluster cluster = factory.genMR_Cluster( "edge" );
+ MR_Cluster cluster = factory.genMR_Cluster( "central" );
Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
Response resp = target( "mr_clusters").request().post( reqEntity, Response.class );
// first, add it
System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- assertTrue( resp.getStatus() == 201 );
+ if( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 200 );
+ }
// now change a field
cluster.setHosts( h );
// update with incorrect key
resp = target( "mr_clusters")
- .path( cluster.getFqdn())
+ .path( cluster.getDcaeLocationName())
.request()
.put( reqEntity, Response.class );
System.out.println( "PUT MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity(String.class));
- assertTrue( resp.getStatus() == 404 );
+ assertTrue( resp.getStatus() == 200 );
// update with correct key
resp = target( "mr_clusters")
assertTrue( resp.getStatus() == 200 );
}
+ @Test
+ public void DelTest() {
+
+ try {
+ DcaeLocation loc = factory.genDcaeLocation( "edge" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
+ System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ));
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+ } catch (Exception e ) {
+ }
+
+
+ MR_Cluster cluster = factory.genMR_Cluster( "edge" );
+
+ Response resp = target( "mr_clusters").
+ path( cluster.getDcaeLocationName()).
+ request().
+ delete( Response.class );
+
+ // confirm cluster is not there
+ System.out.println( "DELETE MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 404 );
+
+ // now, add it
+ Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
+ resp = target( "mr_clusters").request().post( reqEntity, Response.class );
+
+
+ System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 201 );
+
+ // now really delete it
+ resp = target( "mr_clusters").
+ path( cluster.getDcaeLocationName()).
+ request().
+ delete( Response.class );
+ System.out.println( "DELETE MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 204 );
+
+ }
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dmaap.dbcapi.resources;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.Topic;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
+
+public class TopicResourceTest extends JerseyTest {
+
+ static DmaapObjectFactory factory = new DmaapObjectFactory();
+
+ @Override
+ protected Application configure() {
+
+ return new ResourceConfig()
+ .register( TopicResource.class )
+ .register( MR_ClusterResource.class )
+ .register( DcaeLocationResource.class );
+ }
+
+ private static final String fmt = "%24s: %s%n";
+
+
+
+
+ @Before
+ public void preTest() throws Exception {
+ try {
+ DcaeLocation loc = factory.genDcaeLocation( "central" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
+ System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ));
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+ } catch (Exception e ) {
+ }
+ try {
+ MR_Cluster cluster = factory.genMR_Cluster( "central" );
+ Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
+ Response resp = target( "mr_clusters").request().post( reqEntity, Response.class );
+ System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 200);
+ }
+ } catch (Exception e ) {
+
+ }
+
+ }
+ /* may conflict with test framework!
+ @After
+ public void tearDown() throws Exception {
+ }
+*/
+
+
+ @Test
+ public void GetTest() {
+ Response resp = target( "topics").request().get( Response.class );
+ System.out.println( "GET feed resp=" + resp.getStatus() );
+
+ assertTrue( resp.getStatus() == 200 );
+ }
+ @Test
+ public void PostTest() {
+ Topic topic = factory.genSimpleTopic( "test1" );
+ Entity<Topic> reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ Response resp = target( "topics").request().post( reqEntity, Response.class );
+ System.out.println( "POST Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201);
+ }
+ resp = target( "topics").
+ path( topic.genFqtn() ).request().get( Response.class );
+ System.out.println( "GET Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+
+ assertTrue( resp.getStatus() == 200 );
+
+ }
+
+ @Test
+ public void PutTest() {
+
+ Topic topic = factory.genSimpleTopic( "test2" );
+ Entity<Topic> reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ Response resp = target( "topics").request().post( reqEntity, Response.class );
+ String json = resp.readEntity(String.class);
+ System.out.println( "POST Topic resp=" + resp.getStatus() + " " + json );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201);
+ }
+
+
+ // now change a field
+ topic.setOwner( "newbody" );
+ reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+
+ // update with incorrect key
+ resp = target( "topics")
+ .path( "org.onap.dmaap.notATopic" )
+ .request()
+ .put( reqEntity, Response.class );
+
+ System.out.println( "PUT Topic resp=" + resp.getStatus() + " expect 400" );
+ assertTrue( resp.getStatus() == 400 );
+
+ // update with correct key
+ topic = new Topic( json );
+ reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ resp = target( "topics")
+ .path( topic.getFqtn())
+ .request()
+ .put( reqEntity, Response.class );
+ System.out.println( "PUT Topic resp=" + resp.getStatus() + " " + resp.readEntity(String.class));
+ assertTrue( resp.getStatus() == 400 ); // PUT is not allowed even with the right key
+ }
+
+ @Test
+ public void DelTest() {
+
+ Topic topic = factory.genSimpleTopic( "test3" );
+ topic.setFqtn( "org.onap.unittest.test3" );
+
+ Response resp = target( "topics").
+ path( topic.getFqtn() ).
+ request().
+ delete( Response.class );
+
+ // confirm topic is not there
+ System.out.println( "DELETE Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 404 );
+
+ // now, add it
+ Entity<Topic> reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ resp = target( "topics").request().post( reqEntity, Response.class );
+ String json = resp.readEntity( String.class );
+ System.out.println( "POST Topic resp=" + resp.getStatus() + " " + json );
+ assertTrue( resp.getStatus() == 201 );
+
+ topic = new Topic( json );
+ // now really delete it
+ resp = target( "topics").
+ path( topic.getFqtn()).
+ request().
+ delete( Response.class );
+ System.out.println( "DELETE Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 204 );
+
+ }
+
+
+
+}
+
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.server;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.server;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.aaf.*;
import org.onap.dmaap.dbcapi.resources.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.aaf.authentication.AuthenticationErrorException;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
private static final String fmt = "%24s: %s%n";
ReflectionHarness rh = new ReflectionHarness();
+ static DmaapObjectFactory factory = new DmaapObjectFactory();
DR_NodeService ns;
String locname = "central-demo";
DcaeLocationService dls = new DcaeLocationService();
- DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" );
+ DcaeLocation loc = factory.genDcaeLocation( "central" );
dls.addDcaeLocation( loc );
ApiError err = new ApiError();
}
-/*
- @Test
- public void test4() {
- List<MR_Client> l = cls.getAllMr_Clients();
-
- ArrayList<MR_Client> al = cls.getAllMrClients( "foo" );
-
- ArrayList<MR_Client> al2 = cls.getClientsByLocation( "central" );
- }
-
- @Test
- public void test5() {
- Topic topic = new Topic();
- ApiError err = new ApiError();
- topic.setTopicName( "test3" );
- topic.setFqtnStyle( FqtnType.Validator("none") );
- topic.getFqtn();
- Topic nTopic = ts.addTopic( topic, err );
- if ( nTopic != null ) {
- assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
- }
- String[] actions = { "pub", "view" };
- MR_Client c = new MR_Client( "central-onap", "org.onap.dmaap.demo.interestingTopic2", "org.onap.clientApp.publisher", actions );
-
- c = cls.addMr_Client( c, topic, err );
- if ( c != null ) {
- actions[0] = "sub";
- c.setAction( actions );
- c = cls.updateMr_Client( c, err );
- assertTrue( err.getCode() == 200 );
- }
- }
-*/
}
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.aaf.*;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.aaf.*;
import org.onap.dmaap.dbcapi.resources.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.aaf.authentication.AuthenticationErrorException;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
-import org.onap.dmaap.dbcapi.model.*;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
-import java.util.ArrayList;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.Topic;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MR_ClientServiceTest {
if ( nTopic != null ) {
assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
}
- MR_Client c = factory.genPublisher( "edge", topic.getFqtn() );
+ MR_Client c = factory.genPublisher( "central", topic.getFqtn() );
c = cls.addMr_Client( c, topic, err );
if ( c != null ) {
- c = factory.genSubscriber( "edge", topic.getFqtn() );
+ c = factory.genSubscriber( "central", topic.getFqtn() );
c = cls.updateMr_Client( c, err );
assertTrue( err.getCode() == 200 );
}
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.dmaap.dbcapi.model;
-
+package org.onap.dmaap.dbcapi.testframework;
+
+import org.onap.dmaap.dbcapi.model.DR_Node;
+import org.onap.dmaap.dbcapi.model.DR_Sub;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.Dmaap;
+import org.onap.dmaap.dbcapi.model.FqtnType;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.util.RandomInteger;
import static org.junit.Assert.*;
Topic t = new Topic();
t.setTopicName( tname );
t.setFqtnStyle( FqtnType.Validator("none") );
- t.getFqtn();
+ t.setTopicDescription( "a simple Topic named " + tname );
+ t.setOwner( "ut");
return t;
}
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.dmaap.dbcapi.model;
+package org.onap.dmaap.dbcapi.testframework;
import static org.junit.Assert.*;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.util;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.util;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.util;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;