private String authMethod;
private String user;
private String encPwd;
+ private String unit_test;
private boolean hostnameVerify;
public MrProvConnection() {
authMethod = p.getProperty("MR.authentication", "none");
topicMgrCred = getCred();
hostnameVerify= "true".equalsIgnoreCase(p.getProperty("MR.hostnameVerify", "true"));
+ unit_test = p.getProperty( "UnitTest", "No" );
}
err.setFields( uc.getURL().getHost());
return new String( "500: " + uhe.getMessage());
}catch ( ConnectException ce ) {
- errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, "HTTP Connection Exception" );
- err.setCode(500);
- err.setMessage("HTTP Connection Exception");
- err.setFields( uc.getURL().getHost());
+ if ( unit_test.equals( "Yes" ) ) {
+ err.setCode(200);
+ err.setMessage( "simulated response");
+ logger.info( "artificial 200 response from doPostMessage because unit_test =" + unit_test );
+ } else {
+ errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, "HTTP Connection Exception" );
+ err.setCode(500);
+ err.setMessage("HTTP Connection Exception");
+ err.setFields( uc.getURL().getHost());
return new String( "500: " + ce.getMessage());
+ }
}
rc = uc.getResponseCode();
logger.info( "http response code:" + rc );
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
- response.setCode(200);
+ response.setCode(201);
response.setMessage( "simulated response");
- logger.info( "artificial 200 response from doPostMessage because unit_test =" + unit_test );
+ logger.info( "artificial 201 response from doPostMessage because unit_test =" + unit_test );
} else {
response.setCode(500);
private static final String fmt = "%24s: %s%n";
+ private boolean is2xx(int val ) {
+ if ( val >= 200 && val < 300 ) {
+ return true;
+ }
+ return false;
+ }
@Before
public void preTest() throws Exception {
Dmaap dmaap = factory.genDmaap();
Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON );
- Response resp = target( "dmaap").request().put( reqEntity, Response.class );
- System.out.println( resp.getStatus() );
- assertTrue( resp.getStatus() == 200 );
+ Response resp = target( "dmaap").request().post( reqEntity, Response.class );
+ System.out.println( "POST dmaap resp=" + resp.getStatus() );
+ assertTrue( is2xx( resp.getStatus()) );
+
}catch (Exception e ) {
}
try {
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 );
+ assertTrue( is2xx( resp.getStatus()) );
}
} catch (Exception e ) {
}
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 );
+ assertTrue( is2xx( resp.getStatus()) );
}
} catch (Exception e ) {
if ( nTopic != null ) {
assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
}
- String[] actions = { "pub", "view" };
+
MR_Client c = factory.genPublisher( "edge", topic.getFqtn() );
c = cls.addMr_Client( c, topic, err );
}
@Test
- public void test5() {
+ public void AddSubscriberToTopic() {
Topic topic = factory.genSimpleTopic( "test5" );
ApiError err = new ApiError();
Topic nTopic = ts.addTopic( topic, err, false );
MR_Client c = factory.genPublisher( "central", topic.getFqtn() );
c = cls.addMr_Client( c, topic, err );
- if ( c != null ) {
- c = factory.genSubscriber( "central", topic.getFqtn() );
- c = cls.updateMr_Client( c, err );
- assertTrue( err.getCode() == 200 );
- }
- }
+ assertTrue( c != null );
+ c = factory.genSubscriber( "central", topic.getFqtn() );
+ c = cls.addMr_Client( c, topic, err );
+ assertTrue( err.getCode() == 200 );
+
+
+ }
+
}
private MR_ClusterService mcs;
private MR_ClientService cls;
private DcaeLocationService dls;
+
+ private Topic replicationTopic;
+
DmaapService ds;
String locname;
mcs.addMr_Cluster( node, err);
node = factory.genMR_Cluster("edge" );
mcs.addMr_Cluster(node, err);
+
+
+ String t = "org.onap.dmaap.bridgingTopic";
+ replicationTopic = factory.genSimpleTopic(t);
+ replicationTopic.setReplicationCase( ReplicationType.REPLICATION_EDGE_TO_CENTRAL );
+
+ String c = "publisher";
+ String[] a = { "sub", "view" };
+ MR_Client sub = factory.genMR_Client("central", replicationTopic.getFqtn(), c, a );
+ String[] b = { "pub", "view" };
+ MR_Client pub = factory.genMR_Client( "edge", replicationTopic.getFqtn(), c, b );
+ ArrayList<MR_Client> clients = new ArrayList<MR_Client>();
+
+ clients.add( sub );
+ clients.add( pub );
+
+ replicationTopic.setClients( clients );
+
}
@After
public void CreateMirrorMakerWithSingleTopic() {
ApiError err = new ApiError();
- String t = "org.onap.dmaap.bridgingTopic";
- Topic topic = factory.genSimpleTopic(t);
- topic.setReplicationCase( ReplicationType.REPLICATION_EDGE_TO_CENTRAL );
-
- String c = "publisher";
- String[] a = { "sub", "view" };
- MR_Client sub = factory.genMR_Client("central", topic.getFqtn(), c, a );
- String[] b = { "pub", "view" };
- MR_Client pub = factory.genMR_Client( "edge", topic.getFqtn(), c, b );
- ArrayList<MR_Client> clients = new ArrayList<MR_Client>();
-
- clients.add( sub );
- clients.add( pub );
-
- topic.setClients( clients );
- Topic nTopic = ts.updateTopic( topic, err );
+ Topic nTopic = ts.addTopic(replicationTopic, err, true );
assertTrue( err.getCode() == 200 );
@Test
public void DeleteMirrorMakerWithSingleTopic() {
+ ApiError err = new ApiError();
+ Topic nTopic = ts.addTopic(replicationTopic, err, true );
+ replicationTopic.setTopicDescription("modified topic");
+ nTopic = ts.updateTopic( replicationTopic, err );
+
+ assertTrue( err.getCode() == 200 );
+
List<String> mma = mms.getAllMirrorMakers();
ApiError err = new ApiError();
- String t = "org.onap.dmaap.bridgingTopic";
- Topic topic = factory.genSimpleTopic(t);
- topic.setReplicationCase( ReplicationType.REPLICATION_EDGE_TO_CENTRAL );
-
- String c = "publisher";
- String[] a = { "sub", "view" };
- MR_Client sub = factory.genMR_Client("central", topic.getFqtn(), c, a );
- String[] b = { "pub", "view" };
- MR_Client pub = factory.genMR_Client( "edge", topic.getFqtn(), c, b );
- ArrayList<MR_Client> clients = new ArrayList<MR_Client>();
-
- clients.add( sub );
- clients.add( pub );
- topic.setClients( clients );
+ Topic nTopic = ts.addTopic( replicationTopic, err, true );
+ replicationTopic.setTopicDescription("modified topic");
+ nTopic = ts.updateTopic( replicationTopic, err );
- Topic nTopic = ts.updateTopic( topic, err );
assertTrue( err.getCode() == 200 );
List<String> mma = mms.getAllMirrorMakers();