Skip to content

Commit

Permalink
Updates to support Solace 1.0 tile (#7)
Browse files Browse the repository at this point in the history
* fixes #4 Replaced managementHttpUris with managementHostnames
* Removed the webMessaging properties, as they are only used by JavaScript applications. The VCAP_SERVICES properties smfHosts, smfTlsHosts, smfZipHosts, jmsJndiUris and jmsJndiTlsUris are now JSON arrays, but are presented as single comma-separated strings in the SolaceMessagingInfo class.
* Moved to JDK 1.8.
  • Loading branch information
damaru-inc authored and mdspielman committed Mar 13, 2017
1 parent a1f0d18 commit ab0ed8f
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 97 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ hs_err_pid*

# Apple
.DS_Store
/.gradle/
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
language: java
sudo: false
script: mvn clean package
jdk:
- oraclejdk8
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ session.connect();

TODO: Add details.


## Using it in your Application

This releases from this project are hosted in [Maven Central](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.solace.labs.cloud.cloudfoundry%22%20AND%20a%3A%22solace-labs-spring-cloud-connector%22)
The releases from this project are hosted in [Maven Central](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.solace.labs.cloud.cloudfoundry%22%20AND%20a%3A%22solace-labs-spring-cloud-connector%22)

##Here is how to include it in your project using Gradle and Maven.

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
<version>3.5.1</version>
<configuration>
<!-- or whatever version you use -->
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public class SolaceMessagingInfoCreator extends CloudFoundryServiceInfoCreator<S

// This creator will accept and parse any credentials that have the matching tag or label.
// Therefore the default accept method is sufficient and doesn't need further specification.


// Some URI properties are represented in VCAP_SERVICES as JSON arrays, but
// the JCSMP Java client library expects them as comma-separated strings.
// Therefore we do that transformation.

static private String solaceMessagingTag = "solace-messaging";

public SolaceMessagingInfoCreator() {
Expand All @@ -44,13 +50,11 @@ public SolaceMessagingInfo createServiceInfo(Map<String, Object> serviceData) {
String clientUsername = null;
String clientPassword = null;
String msgVpnName = null;
String smfHost = null;
String smfTlsHost = null;
String smfZipHost = null;
String webMessagingUri = null;
String webMessagingTlsUri = null;
String jmsJndiUri = null;
String jmsJndiTlsUri = null;
List<String> smfHosts = null;
List<String> smfTlsHosts = null;
List<String> smfZipHosts = null;
List<String> jmsJndiUris = null;
List<String> jmsJndiTlsUris = null;
List<String> restUris = null;
List<String> restTlsUris = null;
List<String> mqttUris = null;
Expand Down Expand Up @@ -84,26 +88,20 @@ public SolaceMessagingInfo createServiceInfo(Map<String, Object> serviceData) {
case "msgVpnName":
msgVpnName = (String) value;
break;
case "smfHost":
smfHost = (String) value;
break;
case "smfTlsHost":
smfTlsHost = (String) value;
case "smfHosts":
smfHosts = (List<String>) value;
break;
case "smfZipHost":
smfZipHost = (String) value;
case "smfTlsHosts":
smfTlsHosts = (List<String>) value;
break;
case "webMessagingUri":
webMessagingUri = (String) value;
case "smfZipHosts":
smfZipHosts = (List<String>) value;
break;
case "webMessagingTlsUri":
webMessagingTlsUri = (String) value;
case "jmsJndiUris":
jmsJndiUris = (List<String>) value;
break;
case "jmsJndiUri":
jmsJndiUri = (String) value;
break;
case "jmsJndiTlsUri":
jmsJndiTlsUri = (String) value;
case "jmsJndiTlsUris":
jmsJndiTlsUris = (List<String>) value;
break;
case "managementUsername":
managementUsername = (String) value;
Expand Down Expand Up @@ -134,9 +132,24 @@ public SolaceMessagingInfo createServiceInfo(Map<String, Object> serviceData) {
break;
}
}


// Convert Lists to comma-separated strings on these properties, to be compatible with the JCSMP Java client library.
String smfHost = null;
String smfTlsHost = null;
String smfZipHost = null;
String jmsJndiUri = null;
String jmsJndiTlsUri = null;


if (smfHosts != null) smfHost = String.join(",", smfHosts);
if (smfTlsHosts != null) smfTlsHost = String.join(",", smfTlsHosts);
if (smfZipHosts != null) smfZipHost = String.join(",", smfZipHosts);
if (jmsJndiUris != null) jmsJndiUri = String.join(",", jmsJndiUris);
if (jmsJndiTlsUris != null) jmsJndiTlsUri = String.join(",", jmsJndiTlsUris);

SolaceMessagingInfo solMessagingInfo = new SolaceMessagingInfo(id, clientUsername, clientPassword, msgVpnName,
smfHost, smfTlsHost, smfZipHost, webMessagingUri, webMessagingTlsUri, jmsJndiUri, jmsJndiTlsUri, restUris, restTlsUris, mqttUris,
smfHost, smfTlsHost, smfZipHost, jmsJndiUri, jmsJndiTlsUri, restUris, restTlsUris, mqttUris,
mqttTlsUris, mqttWsUris, mqttWssUris, managementHostnames, managementPassword, managementUsername);

return solMessagingInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* For more details see the GitHub project:
* - https://github.com/SolaceLabs/sl-solace-messaging-service-info
*
*
*/
@ServiceLabel("solacemessaging")
public class SolaceMessagingInfo extends BaseServiceInfo {
Expand All @@ -42,7 +42,6 @@ public class SolaceMessagingInfo extends BaseServiceInfo {
private String smfHost;
private String smfTlsHost;
private String smfZipHost;
private String webMessagingUri;
private String jmsJndiUri;
private String jmsJndiTlsUri;
private List<String> restUris;
Expand All @@ -54,15 +53,15 @@ public class SolaceMessagingInfo extends BaseServiceInfo {
private List<String> managementHostnames;
private String managementPassword;
private String managementUsername;
private String webMessagingTlsUri;


// Default constructor to enable bean unit testing.
public SolaceMessagingInfo() {
super(null);
}

public SolaceMessagingInfo(String id, String clientUsername, String clientPassword, String msgVpnName,
String smfHost, String smfTlsHost, String smfZipHost, String webMessagingUri,String webMessagingTlsUri, String jmsJndiUri, String jmsJndiTlsUri,
String smfHost, String smfTlsHost, String smfZipHost, String jmsJndiUri, String jmsJndiTlsUri,
List<String> restUris, List<String> restTlsUris, List<String> mqttUris, List<String> mqttTlsUris,
List<String> mqttWsUris, List<String> mqttWssUris, List<String> managementHostnames,
String managementPassword, String managementUsername) {
Expand All @@ -73,8 +72,6 @@ public SolaceMessagingInfo(String id, String clientUsername, String clientPasswo
this.smfHost = smfHost;
this.smfTlsHost = smfTlsHost;
this.smfZipHost = smfZipHost;
this.webMessagingUri = webMessagingUri;
this.webMessagingTlsUri = webMessagingTlsUri;
this.jmsJndiUri = jmsJndiUri;
this.jmsJndiTlsUri = jmsJndiTlsUri;
this.restUris = restUris;
Expand Down Expand Up @@ -138,22 +135,6 @@ public String getSmfZipHost() {
return smfZipHost;
}

/**
* @return the webMessagingUri
*/
@ServiceProperty
public String getWebMessagingUri() {
return webMessagingUri;
}

/**
* @return the webMessagingTlsUri
*/
@ServiceProperty
public String getWebMessagingTlsUri() {
return webMessagingTlsUri;
}

/**
* @return the jmsJndiUri
*/
Expand Down Expand Up @@ -218,6 +199,7 @@ public List<String> getMqttWssUris() {
return mqttWssUris;
}


/**
* @return the managementHostnames
*/
Expand Down Expand Up @@ -279,8 +261,6 @@ public int hashCode() {
result = prime * result + ((smfTlsHost == null) ? 0 : smfTlsHost.hashCode());
result = prime * result + ((smfHost == null) ? 0 : smfHost.hashCode());
result = prime * result + ((smfZipHost == null) ? 0 : smfZipHost.hashCode());
result = prime * result + ((webMessagingUri == null) ? 0 : webMessagingUri.hashCode());
result = prime * result + ((webMessagingTlsUri == null) ? 0 : webMessagingTlsUri.hashCode());
return result;
}

Expand Down Expand Up @@ -388,16 +368,6 @@ public boolean equals(Object obj) {
return false;
} else if (!smfZipHost.equals(other.smfZipHost))
return false;
if (webMessagingUri == null) {
if (other.webMessagingUri != null)
return false;
} else if (!webMessagingUri.equals(other.webMessagingUri))
return false;
if (webMessagingTlsUri == null) {
if (other.webMessagingTlsUri != null)
return false;
} else if (!webMessagingTlsUri.equals(other.webMessagingTlsUri))
return false;
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void missingKeyValueTest() {

@SuppressWarnings("unchecked")
Map<String, Object> exCred = (Map<String, Object>) exVcapServices.get("credentials");
exCred.remove("smfHost");
exCred.remove("smfHosts");

SolaceMessagingInfoCreator smic = new SolaceMessagingInfoCreator();

Expand All @@ -103,8 +103,7 @@ public void missingKeyValueTest() {

// Validate smf is null. Others are not
assertNull(smi.getSmfHost());
assertEquals("tcps://192.168.1.50:7003", smi.getSmfTlsHost());

assertEquals("tcps://192.168.1.50:7003,tcps://192.168.1.51:7003", smi.getSmfTlsHost());
}

@Test
Expand Down Expand Up @@ -150,17 +149,17 @@ private Map<String, Object> createVcapMap() {
exCred.put("clientUsername", "sample-client-username");
exCred.put("clientPassword", "sample-client-password");
exCred.put("msgVpnName", "sample-msg-vpn");
exCred.put("smfHost", "tcp://192.168.1.50:7000");
exCred.put("smfTlsHost", "tcps://192.168.1.50:7003");
exCred.put("smfZipHost", "tcp://192.168.1.50:7001");
exCred.put("webMessagingUri", "http://192.168.1.50:80");
exCred.put("webMessagingTlsUri", "https://192.168.1.50:80");
exCred.put("jmsJndiUri", "smf://192.168.1.50:7000");
exCred.put("jmsJndiTlsUri", "smfs://192.168.1.50:7003");
exCred.put("smfHosts", Arrays.asList("tcp://192.168.1.50:7000"));
exCred.put("smfTlsHosts", Arrays.asList("tcps://192.168.1.50:7003", "tcps://192.168.1.51:7003"));
exCred.put("smfZipHosts", Arrays.asList("tcp://192.168.1.50:7001"));
exCred.put("webMessagingUris", Arrays.asList("http://192.168.1.50:80"));
exCred.put("webMessagingTlsUris", Arrays.asList("https://192.168.1.50:80"));
exCred.put("jmsJndiUris", Arrays.asList("smf://192.168.1.50:7000"));
exCred.put("jmsJndiTlsUris", Arrays.asList("smfs://192.168.1.50:7003", "smfs://192.168.1.51:7003"));
exCred.put("mqttUris", Arrays.asList("tcp://192.168.1.50:7020"));
exCred.put("mqttTlsUris", Arrays.asList("ssl://192.168.1.50:7021"));
exCred.put("mqttTlsUris", Arrays.asList("ssl://192.168.1.50:7021", "ssl://192.168.1.51:7021"));
exCred.put("mqttWsUris", Arrays.asList("ws://192.168.1.50:7022"));
exCred.put("mqttWssUris", Arrays.asList("wss://192.168.1.50:7023"));
exCred.put("mqttWssUris", Arrays.asList("wss://192.168.1.50:7023", "wss://192.168.1.51:7023"));
exCred.put("restUris", Arrays.asList("http://192.168.1.50:7018"));
exCred.put("restTlsUris", Arrays.asList("https://192.168.1.50:7019"));
exCred.put("managementHostnames", Arrays.asList("vmr-Medium-VMR-0"));
Expand Down Expand Up @@ -188,17 +187,18 @@ private void validateExampleSmi(SolaceMessagingInfo smi) {

// Check SMF
assertEquals("tcp://192.168.1.50:7000", smi.getSmfHost());
assertEquals("tcps://192.168.1.50:7003", smi.getSmfTlsHost());
assertEquals("tcps://192.168.1.50:7003,tcps://192.168.1.51:7003", smi.getSmfTlsHost());
assertEquals("tcp://192.168.1.50:7001", smi.getSmfZipHost());

// Check Web Messsaging
assertEquals("http://192.168.1.50:80", smi.getWebMessagingUri());

// Check JMS
assertEquals("smf://192.168.1.50:7000", smi.getJmsJndiUri());
assertEquals("smfs://192.168.1.50:7003,smfs://192.168.1.51:7003", smi.getJmsJndiTlsUri());

// Check MQTT
assertThat(smi.getMqttUris(), is(Arrays.asList("tcp://192.168.1.50:7020")));
assertThat(smi.getMqttTlsUris(), is(Arrays.asList("ssl://192.168.1.50:7021")));
assertThat(smi.getMqttTlsUris(), is(Arrays.asList("ssl://192.168.1.50:7021", "ssl://192.168.1.51:7021")));
assertThat(smi.getMqttWsUris(), is(Arrays.asList("ws://192.168.1.50:7022")));
assertThat(smi.getMqttWssUris(), is(Arrays.asList("wss://192.168.1.50:7023")));
assertThat(smi.getMqttWssUris(), is(Arrays.asList("wss://192.168.1.50:7023", "wss://192.168.1.51:7023")));

// Check REST
assertThat(smi.getRestUris(), is(Arrays.asList("http://192.168.1.50:7018")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,20 @@ public void fullSetGetCredentialsTest() throws IllegalAccessException, Invocatio
String smfHost = "tcp://192.168.1.50:7000";
String smfTlsHost = "tcps://192.168.1.50:7003";
String smfZipHost = "tcp://192.168.1.50:7001";
String webMessagingUri = "http://192.168.1.50:80";
String webMessagingTlsUri = "https://192.168.1.50:80";
String jmsJndiUri = "smf://192.168.1.50:7000";
String jmsJndiTlsUri = "smfs://192.168.1.50:7003";
List<String> mqttUris = Arrays.asList("tcp://192.168.1.50:7020");
List<String> mqttTlsUris = Arrays.asList("ssl://192.168.1.50:7021");
List<String> mqttTlsUris = Arrays.asList("ssl://192.168.1.50:7021", "ssl://192.168.1.51:7021");
List<String> mqttWsUris = Arrays.asList("ws://192.168.1.50:7022");
List<String> mqttWssUris = Arrays.asList("wss://192.168.1.50:7023");
List<String> mqttWssUris = Arrays.asList("wss://192.168.1.50:7023", "wss://192.168.1.51:7023");
List<String> restUris = Arrays.asList("http://192.168.1.50:7018");
List<String> restTlsUris = Arrays.asList("https://192.168.1.50:7019");
List<String> managementHostnames = Arrays.asList("vmr-Medium-VMR-0");
String managementUsername = "sample-mgmt-username";
String managementPassword = "sample-mgmt-password";

SolaceMessagingInfo smi = new SolaceMessagingInfo(id, clientUsername, clientPassword, msgVpnName, smfHost,
smfTlsHost, smfZipHost, webMessagingUri, webMessagingTlsUri, jmsJndiUri, jmsJndiTlsUri, restUris, restTlsUris, mqttUris, mqttTlsUris,
smfTlsHost, smfZipHost, jmsJndiUri, jmsJndiTlsUri, restUris, restTlsUris, mqttUris, mqttTlsUris,
mqttWsUris, mqttWssUris, managementHostnames, managementPassword, managementUsername);

// Check Top Level stuff
Expand All @@ -68,22 +66,19 @@ public void fullSetGetCredentialsTest() throws IllegalAccessException, Invocatio
assertEquals(msgVpnName, smi.getMsgVpnName());

// Check SMF
assertEquals(smfHost, smi.getSmfHost());
assertEquals(smfTlsHost, smi.getSmfTlsHost());
assertEquals(smfZipHost, smi.getSmfZipHost());

// Check Web Messsaging
assertEquals(webMessagingUri, smi.getWebMessagingUri());
assertEquals("tcp://192.168.1.50:7000", smi.getSmfHost());
assertEquals("tcps://192.168.1.50:7003", smi.getSmfTlsHost());
assertEquals("tcp://192.168.1.50:7001", smi.getSmfZipHost());

// Check JMS
assertEquals(jmsJndiUri, smi.getJmsJndiUri());
assertEquals(jmsJndiTlsUri, smi.getJmsJndiTlsUri());
assertEquals("smf://192.168.1.50:7000", smi.getJmsJndiUri());
assertEquals("smfs://192.168.1.50:7003", smi.getJmsJndiTlsUri());

// Check MQTT
assertThat(smi.getMqttUris(), is(mqttUris));
assertThat(smi.getMqttTlsUris(), is(mqttTlsUris));
assertThat(smi.getMqttWsUris(), is(mqttWsUris));
assertThat(smi.getMqttWssUris(), is(mqttWssUris));
assertThat(smi.getMqttUris(), is(Arrays.asList("tcp://192.168.1.50:7020")));
assertThat(smi.getMqttTlsUris(), is(Arrays.asList("ssl://192.168.1.50:7021", "ssl://192.168.1.51:7021")));
assertThat(smi.getMqttWsUris(), is(Arrays.asList("ws://192.168.1.50:7022")));
assertThat(smi.getMqttWssUris(), is(Arrays.asList("wss://192.168.1.50:7023", "wss://192.168.1.51:7023")));

// Check REST
assertThat(smi.getRestUris(), is(restUris));
Expand Down

0 comments on commit ab0ed8f

Please sign in to comment.