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" );
}
public boolean makeTopicConnection( MR_Cluster cluster ) {
- logger.info( "connect to cluster: " + cluster.getDcaeLocationName());
-
+ boolean rc = false;
+ logger.info( "connect to cluster: " + cluster.getDcaeLocationName());
+
provURL = cluster.getTopicProtocol() + "://" + cluster.getFqdn() + ":" + cluster.getTopicPort() + "/topics/create";
if ( cluster.getTopicProtocol().equals( "https" ) ) {
- return makeSecureConnection( provURL );
+ rc = makeSecureConnection( provURL );
+ } else {
+ rc = makeConnection( provURL );
}
- return makeConnection( provURL );
+ if ( rc && unit_test.equals( "Yes" ) ) {
+ // set timeouts low so we don't hold up unit tests in build process
+ uc.setReadTimeout(5);
+ uc.setConnectTimeout(5);
+ }
+ return rc;
+
}
private boolean makeSecureConnection( String pURL ) {
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 );