[jboss-svn-commits] JBL Code SVN: r31003 - in labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta: tests/src/org/jboss/soa/esb/listeners/gateway and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jan 11 01:47:15 EST 2010


Author: kevin.conner at jboss.com
Date: 2010-01-11 01:47:15 -0500 (Mon, 11 Jan 2010)
New Revision: 31003

Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java
Log:
Support binding address in remoting gateway: JBESB-3100

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java	2010-01-11 06:45:41 UTC (rev 31002)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java	2010-01-11 06:47:15 UTC (rev 31003)
@@ -36,6 +36,7 @@
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.actions.ActionUtils;
 import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.common.Configuration;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.helpers.KeyValuePair;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
@@ -522,11 +523,7 @@
             throw new ConfigurationException("Invalid JBoss Remoting Gateway configuration [" + getConfig().getName() + "]. 'protocol' configuration attribute not specified.");
         }
         if (host == null || host.trim().equals("")) {
-            try {
-                host = InetAddress.getLocalHost().getHostName();
-            } catch (UnknownHostException e) {
-                throw new ConfigurationException("Invalid JBoss Remoting Gateway configuration [" + getConfig().getName() + "]. 'host' configuration attribute not specified and unablee to determine local hostname.", e);
-            }
+            host = Configuration.getBindAddress();
         }
         if (port == null || port.trim().equals("")) {
             throw new ConfigurationException("Invalid JBoss Remoting Gateway configuration [" + getConfig().getName() + "]. 'port' configuration attribute not specified.");

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java	2010-01-11 06:45:41 UTC (rev 31002)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java	2010-01-11 06:47:15 UTC (rev 31003)
@@ -36,6 +36,7 @@
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.common.Environment;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
@@ -143,6 +144,53 @@
         stopServer();
     }
 
+    @Test
+    public void test_binding_no_host() throws Exception {
+        final String origBinding = System.getProperty(Environment.ESB_BIND_ADDRESS) ;
+        final String host = "binding.example.com" ;
+        final String protocol = "http" ;
+        final String port = "8887" ;
+        final URI expected = new URI(protocol + "://" + host + ":" + port) ;
+        System.setProperty(Environment.ESB_BIND_ADDRESS, host) ;
+        try {
+            final ConfigTree config = getConfig("cat", "servicex", "http", "8887", -1L);
+            
+            final JBossRemotingGatewayListener listener = new JBossRemotingGatewayListener(config);
+            final URI locatorURI = listener.getJbrServerLocatorURI() ;
+            assertEquals("Locator URI", expected, locatorURI) ;
+        } finally {
+            if (origBinding == null) {
+                System.clearProperty(Environment.ESB_BIND_ADDRESS) ;
+            } else {
+                System.setProperty(Environment.ESB_BIND_ADDRESS, origBinding) ;
+            }
+        }
+    }
+
+    @Test
+    public void test_binding_empty_host() throws Exception {
+        final String origBinding = System.getProperty(Environment.ESB_BIND_ADDRESS) ;
+        final String host = "binding.example.com" ;
+        final String protocol = "http" ;
+        final String port = "8887" ;
+        final URI expected = new URI(protocol + "://" + host + ":" + port) ;
+        System.setProperty(Environment.ESB_BIND_ADDRESS, host) ;
+        try {
+            final ConfigTree config = getConfig("cat", "servicex", "http", "8887", -1L);
+            config.setAttribute(JBossRemotingGatewayListener.JBR_SERVER_HOST, "");
+            
+            final JBossRemotingGatewayListener listener = new JBossRemotingGatewayListener(config);
+            final URI locatorURI = listener.getJbrServerLocatorURI() ;
+            assertEquals("Locator URI", expected, locatorURI) ;
+        } finally {
+            if (origBinding == null) {
+                System.clearProperty(Environment.ESB_BIND_ADDRESS) ;
+            } else {
+                System.setProperty(Environment.ESB_BIND_ADDRESS, origBinding) ;
+            }
+        }
+    }
+
     public void x_test_profile() throws Throwable {
         startServer("http", false, "8889");
         for(int i = 0; i < 10000; i++) {



More information about the jboss-svn-commits mailing list