[jboss-svn-commits] JBL Code SVN: r26616 - in labs/jbossesb/trunk/product/rosetta: tests/src/org/jboss/soa/esb/addressing/eprs and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue May 19 08:17:17 EDT 2009
Author: beve
Date: 2009-05-19 08:17:17 -0400 (Tue, 19 May 2009)
New Revision: 26616
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2503 "Fix JMSEpr address encoding"
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java 2009-05-19 11:32:27 UTC (rev 26615)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java 2009-05-19 12:17:17 UTC (rev 26616)
@@ -544,6 +544,7 @@
addr.setAddress(getJmsAddress(uri, name));
addr.addExtension(DESTINATION_TYPE_TAG, destinationType);
+ addr.addExtension(DESTINATION_NAME_TAG, destinationName);
addr.addExtension(SPECIFICATION_VERSION_TAG, protocol);
@@ -602,18 +603,23 @@
public final String getDestinationName()
{
- try
- {
- URI uri = new URI(getAddr().getAddress());
+ final String name = getAddr().getExtensionValue(DESTINATION_NAME_TAG);
+ if (name != null)
+ {
+ return name ;
+ }
+ try
+ {
+ URI uri = new URI(getAddr().getAddress());
- return uri.getPath().substring(1);
- }
- catch (URISyntaxException ex)
- {
- _logger.warn("Unexpected parsing exception!", ex);
+ return uri.getPath().substring(1);
+ }
+ catch (URISyntaxException ex)
+ {
+ _logger.warn("Unexpected parsing exception!", ex);
- return null;
- }
+ return null;
+ }
}
/**
@@ -762,16 +768,8 @@
private String getJmsAddress(final String uri, final String name)
{
try {
- final URI uriVal = new URI(uri) ;
- final String host = uriVal.getHost() ;
- if (host != null) {
- final int port = uriVal.getPort() ;
- if (port > 0) {
- return JMS_PROTOCOL + PROTOCOL_SEPARATOR + host + ":" + port + "/" + name;
- } else {
- return JMS_PROTOCOL + PROTOCOL_SEPARATOR + host + "/" + name;
- }
- }
+ final URI result = new URI(JMS_PROTOCOL, uri, name) ;
+ return result.toString();
} catch (final URISyntaxException urise) {}
return JMS_PROTOCOL + PROTOCOL_SEPARATOR + uri + "/" + name;
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java 2009-05-19 11:32:27 UTC (rev 26615)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java 2009-05-19 12:17:17 UTC (rev 26616)
@@ -204,20 +204,20 @@
// should default address to system property
final JMSEpr firstEpr = new JMSEpr(ONE_ONE_PROTOCOL, expectedDestinationType,
queueName, "connection", null, null, true, null, null, null, true) ;
- assertEquals("System JNDI_SERVER_URL", "jms://" + defaultProvider + "/" + queueName, firstEpr.getAddr().getAddress()) ;
+ assertEquals("System JNDI_SERVER_URL", "jms:" + JNDI_PREFIX + defaultProvider + "#" + queueName, firstEpr.getAddr().getAddress()) ;
// should use Provider URL extension
final Properties environment = new Properties() ;
environment.setProperty(Context.PROVIDER_URL, JNDI_PREFIX + extensionProvider) ;
final JMSEpr secondEpr = new JMSEpr(ONE_ONE_PROTOCOL, expectedDestinationType,
queueName, "connection", environment, null, true, null, null, null, true) ;
- assertEquals("Extension Context.PROVIDER_URL", "jms://" + extensionProvider + "/" + queueName, secondEpr.getAddr().getAddress()) ;
+ assertEquals("Extension Context.PROVIDER_URL", "jms:" + JNDI_PREFIX + extensionProvider + "#" + queueName, secondEpr.getAddr().getAddress()) ;
// should use jndi-URL property
environment.setProperty(JNDI_URL_TAG, JNDI_PREFIX + propertyJndi) ;
final JMSEpr thirdEpr = new JMSEpr(ONE_ONE_PROTOCOL, expectedDestinationType,
queueName, "connection", environment, null, true, null, null, null, true) ;
- assertEquals("Extension Context.PROVIDER_URL", "jms://" + propertyJndi + "/" + queueName, thirdEpr.getAddr().getAddress()) ;
+ assertEquals("Extension Context.PROVIDER_URL", "jms:" + JNDI_PREFIX + propertyJndi + "#" + queueName, thirdEpr.getAddr().getAddress()) ;
}
finally
{
@@ -315,6 +315,43 @@
assertEquals("Second extension", testExtension2Value, eprProperties.get(testExtension2)) ;
}
+ @Test
+ public void testDefaultURIConfig() throws URISyntaxException
+ {
+ testEPRConfig(JMSEpr.QUEUE_TYPE, "queue/destinationName",
+ "ConnectionFactory", "jnp://localhost:1099",
+ "org.jnp.interfaces.NamingContextFactory",
+ "org.jboss.naming:org.jnp.interfaces") ;
+ }
+
+ @Test
+ public void testNonStandardURIConfig() throws URISyntaxException
+ {
+ testEPRConfig(JMSEpr.QUEUE_TYPE, "abc/def/ghi",
+ "ConnectionFactory", "scheme://host:port/config#123456?abc=def",
+ "MyNonStandardContextFactory", "MyPkgInterfaces") ;
+ }
+
+ private void testEPRConfig(final String destinationType, final String destinationName,
+ final String connectionFactory, final String jndiURL, final String contextFactory,
+ final String pkgPrefix) throws URISyntaxException
+ {
+ final Properties env = new Properties() ;
+ env.put(Context.PROVIDER_URL, jndiURL) ;
+ env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory) ;
+ env.put(Context.URL_PKG_PREFIXES, pkgPrefix) ;
+
+ final JMSEpr jmsEpr = new JMSEpr(destinationType, destinationName, connectionFactory, env, null) ;
+ assertEquals("destinationType", destinationType, jmsEpr.getDestinationType()) ;
+ assertEquals("destinationName", destinationName, jmsEpr.getDestinationName()) ;
+ assertEquals("connectionFactory", connectionFactory, jmsEpr.getConnectionFactory()) ;
+
+ final Properties jmsEprEnv = jmsEpr.getJndiEnvironment() ;
+ assertEquals(Context.PROVIDER_URL, jndiURL, jmsEprEnv.getProperty(Context.PROVIDER_URL)) ;
+ assertEquals(Context.INITIAL_CONTEXT_FACTORY, contextFactory, jmsEprEnv.getProperty(Context.INITIAL_CONTEXT_FACTORY)) ;
+ assertEquals(Context.URL_PKG_PREFIXES, pkgPrefix, jmsEprEnv.getProperty(Context.URL_PKG_PREFIXES)) ;
+ }
+
private void assertDefaults(final String destination, final String connectionFactory, final String destinationType)
{
assertEquals( expectedDestination, destination );
More information about the jboss-svn-commits
mailing list