Author: ron.sigal(a)jboss.com
Date: 2010-08-04 22:16:33 -0400 (Wed, 04 Aug 2010)
New Revision: 6050
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.java 2010-08-05
02:15:41 UTC (rev 6049)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.java 2010-08-05
02:16:33 UTC (rev 6050)
@@ -1,148 +1,148 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.test.remoting.util;
-
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.transport.PortUtil;
-
-/**
- * Unit test for JBREM-1139.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 2320 $
- * <p>
- * Copyright July 13, 2009.
- * </p>
- */
-public class PortUtilRangeOnClientTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(PortUtilRangeOnClientTestCase.class);
-
-
- public void testUpdateRangeOnClient() throws Exception
- {
- log.info("entering " + getName());
-
- // Test initial values.
- assertEquals(1024, PortUtil.getMinPort());
- assertEquals(65535, PortUtil.getMaxPort());
-
- // Set new values using configuration map.
- Map clientConfig = new HashMap();
- clientConfig.put(PortUtil.MIN_PORT, "2000");
- clientConfig.put(PortUtil.MAX_PORT, "60000");
- String host = InetAddress.getLocalHost().getHostAddress();
- InvokerLocator locator = new InvokerLocator("socket://" + host);
- Client client = new Client(locator, clientConfig);
- assertEquals(2000, PortUtil.getMinPort());
- assertEquals(60000, PortUtil.getMaxPort());
-
- // Set more restrictive values using configuration map.
- clientConfig.put(PortUtil.MIN_PORT, "3000");
- clientConfig.put(PortUtil.MAX_PORT, "50000");
- client = new Client(locator, clientConfig);
- assertEquals(3000, PortUtil.getMinPort());
- assertEquals(50000, PortUtil.getMaxPort());
-
- // Set more restrictive values with InvokerLocator overriding configuration map.
- clientConfig.put(PortUtil.MIN_PORT, "3500");
- clientConfig.put(PortUtil.MAX_PORT, "45000");
- locator = new InvokerLocator("socket://" + host + "/?" +
PortUtil.MIN_PORT + "=4000&" + PortUtil.MAX_PORT + "=40000");
- client = new Client(locator, clientConfig);
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
-
- // Try to set less restrictive values - should have no effect.
- clientConfig.put(PortUtil.MIN_PORT, "2000");
- clientConfig.put(PortUtil.MAX_PORT, "60000");
- locator = new InvokerLocator("socket://" + host);
- client = new Client(locator, clientConfig);
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
-
- // Try to set invalid minPort - should have no effect.
- clientConfig.put(PortUtil.MIN_PORT, "60000");
- clientConfig.remove(PortUtil.MAX_PORT);
- try
- {
- log.info("=====================================");
- log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
- client = new Client(locator, clientConfig);
- }
- catch (Exception e)
- {
- log.info(e.getMessage());
- if (e instanceof IllegalStateException
- && e.getMessage() != null
- && e.getMessage().startsWith("trying to set minPort"))
- {
- log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
- log.info("=====================================");
- }
- else
- {
- fail("expected IllegalStateException");
- }
- }
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
-
- // Try to set invalid maxPort - should have no effect.
- clientConfig.remove(PortUtil.MIN_PORT);
- clientConfig.put(PortUtil.MAX_PORT, "2000");
- try
- {
- log.info("=====================================");
- log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
- client = new Client(locator, clientConfig);
- }
- catch (Exception e)
- {
- log.info(e.getMessage());
- if (e instanceof IllegalStateException
- && e.getMessage() != null
- && e.getMessage().startsWith("trying to set maxPort"))
- {
- log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
- log.info("=====================================");
- }
- else
- {
- fail("expected IllegalStateException");
- }
- }
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
-
- log.info(getName()+ " PASSES");
- }
-
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.test.remoting.util;
+
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.PortUtil;
+
+/**
+ * Unit test for JBREM-1139.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 2320 $
+ * <p>
+ * Copyright July 13, 2009.
+ * </p>
+ */
+public class PortUtilRangeOnClientTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(PortUtilRangeOnClientTestCase.class);
+
+
+ public void testUpdateRangeOnClient() throws Exception
+ {
+ log.info("entering " + getName());
+
+ // Test initial values.
+ assertEquals(1024, PortUtil.getMinPort());
+ assertEquals(65535, PortUtil.getMaxPort());
+
+ // Set new values using configuration map.
+ Map clientConfig = new HashMap();
+ clientConfig.put(PortUtil.MIN_PORT, "2000");
+ clientConfig.put(PortUtil.MAX_PORT, "60000");
+ String host = InetAddress.getLocalHost().getHostAddress();
+ InvokerLocator locator = new InvokerLocator("socket://" + host);
+ Client client = new Client(locator, clientConfig);
+ assertEquals(2000, PortUtil.getMinPort());
+ assertEquals(60000, PortUtil.getMaxPort());
+
+ // Set more restrictive values using configuration map.
+ clientConfig.put(PortUtil.MIN_PORT, "3000");
+ clientConfig.put(PortUtil.MAX_PORT, "50000");
+ client = new Client(locator, clientConfig);
+ assertEquals(3000, PortUtil.getMinPort());
+ assertEquals(50000, PortUtil.getMaxPort());
+
+ // Set more restrictive values with InvokerLocator overriding configuration map.
+ clientConfig.put(PortUtil.MIN_PORT, "3500");
+ clientConfig.put(PortUtil.MAX_PORT, "45000");
+ locator = new InvokerLocator("socket://" + host + "/?" +
PortUtil.MIN_PORT + "=4000&" + PortUtil.MAX_PORT + "=40000");
+ client = new Client(locator, clientConfig);
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+
+ // Try to set less restrictive values - should have no effect.
+ clientConfig.put(PortUtil.MIN_PORT, "2000");
+ clientConfig.put(PortUtil.MAX_PORT, "60000");
+ locator = new InvokerLocator("socket://" + host);
+ client = new Client(locator, clientConfig);
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+
+ // Try to set invalid minPort - should have no effect.
+ clientConfig.put(PortUtil.MIN_PORT, "60000");
+ clientConfig.remove(PortUtil.MAX_PORT);
+ try
+ {
+ log.info("=====================================");
+ log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
+ client = new Client(locator, clientConfig);
+ }
+ catch (Exception e)
+ {
+ log.info(e.getMessage());
+ if (e instanceof IllegalStateException
+ && e.getMessage() != null
+ && e.getMessage().startsWith("trying to set minPort"))
+ {
+ log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
+ log.info("=====================================");
+ }
+ else
+ {
+ fail("expected IllegalStateException");
+ }
+ }
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+
+ // Try to set invalid maxPort - should have no effect.
+ clientConfig.remove(PortUtil.MIN_PORT);
+ clientConfig.put(PortUtil.MAX_PORT, "2000");
+ try
+ {
+ log.info("=====================================");
+ log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
+ client = new Client(locator, clientConfig);
+ }
+ catch (Exception e)
+ {
+ log.info(e.getMessage());
+ if (e instanceof IllegalStateException
+ && e.getMessage() != null
+ && e.getMessage().startsWith("trying to set maxPort"))
+ {
+ log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
+ log.info("=====================================");
+ }
+ else
+ {
+ fail("expected IllegalStateException");
+ }
+ }
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+
+ log.info(getName()+ " PASSES");
+ }
+
}
\ No newline at end of file
Property changes on:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.java 2010-08-05
02:15:41 UTC (rev 6049)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.java 2010-08-05
02:16:33 UTC (rev 6050)
@@ -1,166 +1,166 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.test.remoting.util;
-
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-
-/**
- * Unit test for JBREM-1139.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 2320 $
- * <p>
- * Copyright July 13, 2009.
- * </p>
- */
-public class PortUtilRangeOnServerTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(PortUtilRangeOnServerTestCase.class);
-
-
-
- public void testUpdateRangeOnServer() throws Exception
- {
- log.info("entering " + getName());
-
- // Test initial values.
- assertEquals(1024, PortUtil.getMinPort());
- assertEquals(65535, PortUtil.getMaxPort());
-
- // Set new values using configuration mapr.
- Map serverConfig = new HashMap();
- serverConfig.put(PortUtil.MIN_PORT, "2000");
- serverConfig.put(PortUtil.MAX_PORT, "60000");
- String host = InetAddress.getLocalHost().getHostAddress();
- InvokerLocator locator = new InvokerLocator("socket://" + host);
- Connector connector = new Connector(locator, serverConfig);
- connector.start();
- log.info("InvokerLocator: " + connector.getInvokerLocator());
- assertEquals(2000, PortUtil.getMinPort());
- assertEquals(60000, PortUtil.getMaxPort());
- connector.stop();
-
- // Set more restrictive values using configuration map.
- serverConfig.put(PortUtil.MIN_PORT, "3000");
- serverConfig.put(PortUtil.MAX_PORT, "50000");
- connector = new Connector(locator, serverConfig);
- connector.start();
- log.info("InvokerLocator: " + connector.getInvokerLocator());
- assertEquals(3000, PortUtil.getMinPort());
- assertEquals(50000, PortUtil.getMaxPort());
- connector.stop();
-
- // Set more restrictive values with InvokerLocator overriding configuration map.
- serverConfig.put(PortUtil.MIN_PORT, "3500");
- serverConfig.put(PortUtil.MAX_PORT, "45000");
- locator = new InvokerLocator("socket://" + host + "/?" +
PortUtil.MIN_PORT + "=4000&" + PortUtil.MAX_PORT + "=40000");
- connector = new Connector(locator, serverConfig);
- connector.start();
- log.info("InvokerLocator: " + connector.getInvokerLocator());
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
- connector.stop();
-
- // Try to set less restrictive values - should have no effect.
- serverConfig.put(PortUtil.MIN_PORT, "2000");
- serverConfig.put(PortUtil.MAX_PORT, "60000");
- locator = new InvokerLocator("socket://" + host);
- connector = new Connector(locator, serverConfig);
- connector.start();
- log.info("InvokerLocator: " + connector.getInvokerLocator());
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
- connector.stop();
-
- // Try to set invalid minPort - should have no effect.
- serverConfig.put(PortUtil.MIN_PORT, "60000");
- serverConfig.remove(PortUtil.MAX_PORT);
- connector = new Connector(locator, serverConfig);
- try
- {
- log.info("=====================================");
- log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
- connector.start();
- }
- catch (Exception e)
- {
- log.info(e.getCause());
- if (e.getCause() instanceof IllegalStateException
- && e.getCause().getMessage() != null
- && e.getCause().getMessage().startsWith("trying to set
minPort"))
- {
- log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
- log.info("=====================================");
- }
- else
- {
- fail("expected IllegalStateException");
- }
- }
- log.info("InvokerLocator: " + connector.getInvokerLocator());
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
- connector.stop();
-
- // Try to set invalid maxPort - should have no effect.
- serverConfig.remove(PortUtil.MIN_PORT);
- serverConfig.put(PortUtil.MAX_PORT, "2000");
- connector = new Connector(locator, serverConfig);
- try
- {
- log.info("=====================================");
- log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
- connector.start();
- }
- catch (Exception e)
- {
- log.info(e.getCause());
- if (e.getCause() instanceof IllegalStateException
- && e.getCause().getMessage() != null
- && e.getCause().getMessage().startsWith("trying to set
maxPort"))
- {
- log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
- log.info("=====================================");
- }
- else
- {
- fail("expected IllegalStateException");
- }
- }
- log.info("InvokerLocator: " + connector.getInvokerLocator());
- assertEquals(4000, PortUtil.getMinPort());
- assertEquals(40000, PortUtil.getMaxPort());
- connector.stop();
-
- log.info(getName()+ " PASSES");
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.test.remoting.util;
+
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+/**
+ * Unit test for JBREM-1139.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 2320 $
+ * <p>
+ * Copyright July 13, 2009.
+ * </p>
+ */
+public class PortUtilRangeOnServerTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(PortUtilRangeOnServerTestCase.class);
+
+
+
+ public void testUpdateRangeOnServer() throws Exception
+ {
+ log.info("entering " + getName());
+
+ // Test initial values.
+ assertEquals(1024, PortUtil.getMinPort());
+ assertEquals(65535, PortUtil.getMaxPort());
+
+ // Set new values using configuration mapr.
+ Map serverConfig = new HashMap();
+ serverConfig.put(PortUtil.MIN_PORT, "2000");
+ serverConfig.put(PortUtil.MAX_PORT, "60000");
+ String host = InetAddress.getLocalHost().getHostAddress();
+ InvokerLocator locator = new InvokerLocator("socket://" + host);
+ Connector connector = new Connector(locator, serverConfig);
+ connector.start();
+ log.info("InvokerLocator: " + connector.getInvokerLocator());
+ assertEquals(2000, PortUtil.getMinPort());
+ assertEquals(60000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Set more restrictive values using configuration map.
+ serverConfig.put(PortUtil.MIN_PORT, "3000");
+ serverConfig.put(PortUtil.MAX_PORT, "50000");
+ connector = new Connector(locator, serverConfig);
+ connector.start();
+ log.info("InvokerLocator: " + connector.getInvokerLocator());
+ assertEquals(3000, PortUtil.getMinPort());
+ assertEquals(50000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Set more restrictive values with InvokerLocator overriding configuration map.
+ serverConfig.put(PortUtil.MIN_PORT, "3500");
+ serverConfig.put(PortUtil.MAX_PORT, "45000");
+ locator = new InvokerLocator("socket://" + host + "/?" +
PortUtil.MIN_PORT + "=4000&" + PortUtil.MAX_PORT + "=40000");
+ connector = new Connector(locator, serverConfig);
+ connector.start();
+ log.info("InvokerLocator: " + connector.getInvokerLocator());
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Try to set less restrictive values - should have no effect.
+ serverConfig.put(PortUtil.MIN_PORT, "2000");
+ serverConfig.put(PortUtil.MAX_PORT, "60000");
+ locator = new InvokerLocator("socket://" + host);
+ connector = new Connector(locator, serverConfig);
+ connector.start();
+ log.info("InvokerLocator: " + connector.getInvokerLocator());
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Try to set invalid minPort - should have no effect.
+ serverConfig.put(PortUtil.MIN_PORT, "60000");
+ serverConfig.remove(PortUtil.MAX_PORT);
+ connector = new Connector(locator, serverConfig);
+ try
+ {
+ log.info("=====================================");
+ log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
+ connector.start();
+ }
+ catch (Exception e)
+ {
+ log.info(e.getCause());
+ if (e.getCause() instanceof IllegalStateException
+ && e.getCause().getMessage() != null
+ && e.getCause().getMessage().startsWith("trying to set
minPort"))
+ {
+ log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
+ log.info("=====================================");
+ }
+ else
+ {
+ fail("expected IllegalStateException");
+ }
+ }
+ log.info("InvokerLocator: " + connector.getInvokerLocator());
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Try to set invalid maxPort - should have no effect.
+ serverConfig.remove(PortUtil.MIN_PORT);
+ serverConfig.put(PortUtil.MAX_PORT, "2000");
+ connector = new Connector(locator, serverConfig);
+ try
+ {
+ log.info("=====================================");
+ log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
+ connector.start();
+ }
+ catch (Exception e)
+ {
+ log.info(e.getCause());
+ if (e.getCause() instanceof IllegalStateException
+ && e.getCause().getMessage() != null
+ && e.getCause().getMessage().startsWith("trying to set
maxPort"))
+ {
+ log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
+ log.info("=====================================");
+ }
+ else
+ {
+ fail("expected IllegalStateException");
+ }
+ }
+ log.info("InvokerLocator: " + connector.getInvokerLocator());
+ assertEquals(4000, PortUtil.getMinPort());
+ assertEquals(40000, PortUtil.getMaxPort());
+ connector.stop();
+
+ log.info(getName()+ " PASSES");
+ }
}
\ No newline at end of file
Property changes on:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.java 2010-08-05
02:15:41 UTC (rev 6049)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.java 2010-08-05
02:16:33 UTC (rev 6050)
@@ -1,192 +1,192 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.test.remoting.util;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.net.InetAddress;
-
-import javax.management.MBeanServer;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-/**
- * Unit test for JBREM-1139.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 2320 $
- * <p>
- * Copyright July 13, 2009.
- * </p>
- */
-public class PortUtilRangeOnServerWithXMLTestCase extends TestCase
-{
- private static Logger log =
Logger.getLogger(PortUtilRangeOnServerWithXMLTestCase.class);
-
-
-
- public void testUpdateRangeOnServer() throws Exception
- {
- log.info("entering " + getName());
-
- // Test initial values.
- assertEquals(1024, PortUtil.getMinPort());
- assertEquals(65535, PortUtil.getMaxPort());
-
- // Set new values.
- Connector connector = new Connector();
- connector.setConfiguration(getXML(2000, 60000));
- connector.start();
- assertEquals(2000, PortUtil.getMinPort());
- assertEquals(60000, PortUtil.getMaxPort());
- connector.stop();
-
- // Set more restrictive values.
- connector = new Connector();
- connector.setConfiguration(getXML(3000, 50000));
- connector.start();
- assertEquals(3000, PortUtil.getMinPort());
- assertEquals(50000, PortUtil.getMaxPort());
- connector.stop();
-
- // Try to set less restrictive values - should have no effect.
- connector = new Connector();
- connector.setConfiguration(getXML(2000, 60000));
- connector.start();
- assertEquals(3000, PortUtil.getMinPort());
- assertEquals(50000, PortUtil.getMaxPort());
- connector.stop();
-
- // Try to set invalid minPort - should have no effect.
- connector = new Connector();
- connector.setConfiguration(getXML(60000, -1));
- try
- {
- log.info("=====================================");
- log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
- connector.start();
- }
- catch (Exception e)
- {
- log.info(e.getMessage());
- if (e instanceof IllegalStateException
- && e.getMessage() != null
- && e.getMessage().startsWith("Error configuring invoker for
connector."))
- {
- log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
- log.info("=====================================");
- }
- else
- {
- fail("expected IllegalStateException");
- }
- }
- assertEquals(3000, PortUtil.getMinPort());
- assertEquals(50000, PortUtil.getMaxPort());
- connector.stop();
-
- // Try to set invalid maxPort - should have no effect.
- connector = new Connector();
- connector.setConfiguration(getXML(-1, 2000));
- try
- {
- log.info("=====================================");
- log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
- connector.start();
- }
- catch (Exception e)
- {
- log.info(e.getMessage());
- if (e instanceof IllegalStateException
- && e.getMessage() != null
- && e.getMessage().startsWith("Error configuring invoker for
connector."))
- {
- log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
- log.info("=====================================");
- }
- else
- {
- fail("expected IllegalStateException");
- }
- }
- assertEquals(3000, PortUtil.getMinPort());
- assertEquals(50000, PortUtil.getMaxPort());
- connector.stop();
-
- log.info(getName()+ " PASSES");
- }
-
-
- Element getXML(int minPort, int maxPort) throws SAXException, IOException,
ParserConfigurationException
- {
- String host = InetAddress.getLocalHost().getHostAddress();
- StringBuffer buf = new StringBuffer();
- buf.append("<?xml version=\"1.0\"?>\n");
- buf.append("<config>\n");
- buf.append(" <invoker transport=\"socket\">\n");
- buf.append(" <attribute name=\"serverBindAddress\">"
+ host + "</attribute>\n");
- if (minPort > -1)
- {
- buf.append(" <attribute name=\"" + PortUtil.MIN_PORT +
"\">" + minPort + "</attribute>\n");
- }
- if (maxPort > -1)
- {
- buf.append(" <attribute name=\"" + PortUtil.MAX_PORT +
"\">" + maxPort + "</attribute>\n");
- }
- buf.append(" </invoker>\n");
- buf.append(" <handlers>\n");
- buf.append(" <handler subsystem=\"test\">" +
TestInvocationHandler.class.getName() + "</handler>\n");
- buf.append(" </handlers>\n");
- buf.append("</config>\n");
- log.info("\n\n" + buf.toString());
- ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes());
- Document xml =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
- return xml.getDocumentElement();
- }
-
-
- public static class TestInvocationHandler implements ServerInvocationHandler
- {
- public void addListener(InvokerCallbackHandler callbackHandler) {}
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.test.remoting.util;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+
+import javax.management.MBeanServer;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * Unit test for JBREM-1139.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 2320 $
+ * <p>
+ * Copyright July 13, 2009.
+ * </p>
+ */
+public class PortUtilRangeOnServerWithXMLTestCase extends TestCase
+{
+ private static Logger log =
Logger.getLogger(PortUtilRangeOnServerWithXMLTestCase.class);
+
+
+
+ public void testUpdateRangeOnServer() throws Exception
+ {
+ log.info("entering " + getName());
+
+ // Test initial values.
+ assertEquals(1024, PortUtil.getMinPort());
+ assertEquals(65535, PortUtil.getMaxPort());
+
+ // Set new values.
+ Connector connector = new Connector();
+ connector.setConfiguration(getXML(2000, 60000));
+ connector.start();
+ assertEquals(2000, PortUtil.getMinPort());
+ assertEquals(60000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Set more restrictive values.
+ connector = new Connector();
+ connector.setConfiguration(getXML(3000, 50000));
+ connector.start();
+ assertEquals(3000, PortUtil.getMinPort());
+ assertEquals(50000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Try to set less restrictive values - should have no effect.
+ connector = new Connector();
+ connector.setConfiguration(getXML(2000, 60000));
+ connector.start();
+ assertEquals(3000, PortUtil.getMinPort());
+ assertEquals(50000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Try to set invalid minPort - should have no effect.
+ connector = new Connector();
+ connector.setConfiguration(getXML(60000, -1));
+ try
+ {
+ log.info("=====================================");
+ log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
+ connector.start();
+ }
+ catch (Exception e)
+ {
+ log.info(e.getMessage());
+ if (e instanceof IllegalStateException
+ && e.getMessage() != null
+ && e.getMessage().startsWith("Error configuring invoker for
connector."))
+ {
+ log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
+ log.info("=====================================");
+ }
+ else
+ {
+ fail("expected IllegalStateException");
+ }
+ }
+ assertEquals(3000, PortUtil.getMinPort());
+ assertEquals(50000, PortUtil.getMaxPort());
+ connector.stop();
+
+ // Try to set invalid maxPort - should have no effect.
+ connector = new Connector();
+ connector.setConfiguration(getXML(-1, 2000));
+ try
+ {
+ log.info("=====================================");
+ log.info("EXPECT ILLEGAL_STATE_EXCEPTION");
+ connector.start();
+ }
+ catch (Exception e)
+ {
+ log.info(e.getMessage());
+ if (e instanceof IllegalStateException
+ && e.getMessage() != null
+ && e.getMessage().startsWith("Error configuring invoker for
connector."))
+ {
+ log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION");
+ log.info("=====================================");
+ }
+ else
+ {
+ fail("expected IllegalStateException");
+ }
+ }
+ assertEquals(3000, PortUtil.getMinPort());
+ assertEquals(50000, PortUtil.getMaxPort());
+ connector.stop();
+
+ log.info(getName()+ " PASSES");
+ }
+
+
+ Element getXML(int minPort, int maxPort) throws SAXException, IOException,
ParserConfigurationException
+ {
+ String host = InetAddress.getLocalHost().getHostAddress();
+ StringBuffer buf = new StringBuffer();
+ buf.append("<?xml version=\"1.0\"?>\n");
+ buf.append("<config>\n");
+ buf.append(" <invoker transport=\"socket\">\n");
+ buf.append(" <attribute name=\"serverBindAddress\">"
+ host + "</attribute>\n");
+ if (minPort > -1)
+ {
+ buf.append(" <attribute name=\"" + PortUtil.MIN_PORT +
"\">" + minPort + "</attribute>\n");
+ }
+ if (maxPort > -1)
+ {
+ buf.append(" <attribute name=\"" + PortUtil.MAX_PORT +
"\">" + maxPort + "</attribute>\n");
+ }
+ buf.append(" </invoker>\n");
+ buf.append(" <handlers>\n");
+ buf.append(" <handler subsystem=\"test\">" +
TestInvocationHandler.class.getName() + "</handler>\n");
+ buf.append(" </handlers>\n");
+ buf.append("</config>\n");
+ log.info("\n\n" + buf.toString());
+ ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes());
+ Document xml =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
+ return xml.getDocumentElement();
+ }
+
+
+ public static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
}
\ No newline at end of file
Property changes on:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native