[jboss-remoting-commits] JBoss Remoting SVN: r5987 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Wed Aug 4 21:11:08 EDT 2010
Author: ron.sigal at jboss.com
Date: 2010-08-04 21:11:08 -0400 (Wed, 04 Aug 2010)
New Revision: 5987
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6HostWithNoBracketsTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6TestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6AddressTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6HostWithNoBracketsTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6HostWithNoBracketsTestCase.java 2010-08-05 01:10:03 UTC (rev 5986)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6HostWithNoBracketsTestCase.java 2010-08-05 01:11:08 UTC (rev 5987)
@@ -1,261 +1,261 @@
-/*
- * 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.ipv6;
-
-import java.io.ByteArrayInputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import javax.management.MBeanServer;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- * Unit tests for JBREM-1164.
- *
- * @author <a href="mailto:bclare at tpg.com.au">Ben Clare</a>
- * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
- *
- * @version $Rev$
- * <p>
- * Copyright Dec 20, 2009
- * </p>
- */
-public class IPv6HostWithNoBracketsTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(IPv6HostWithNoBracketsTestCase.class);
- private static boolean firstTime = true;
- private static int port = 8080;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testXMLWithoutBrackets() throws Throwable
- {
- log.info("entering " + getName());
-
- assertTrue(doXMLTest("::", ++port));
- assertTrue(doXMLTest("::1", ++port));
- assertTrue(doXMLTest("0:0:0:0:0:0:0:1", ++port));
- assertTrue(doXMLTest("0:0:0:0:0:0:127.0.0.1", ++port));
- assertTrue(doXMLTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf", ++port));
- String version = System.getProperty("java.version");
- if (version.startsWith("1.4"))
- {
- log.info("java version is " + version + ". Skipping test");
- }
- else
- {
- assertTrue(doXMLTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", ++port));
- }
-
- log.info(getName() + " PASSES");
- }
-
-
- public void testXMLWithBrackets() throws Throwable
- {
- log.info("entering " + getName());
-
- assertTrue(doXMLTest("[::]", ++port));
- assertTrue(doXMLTest("[::1]", ++port));
- assertTrue(doXMLTest("[0:0:0:0:0:0:0:1]", ++port));
- assertTrue(doXMLTest("[0:0:0:0:0:0:127.0.0.1]", ++port));
- assertTrue(doXMLTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", ++port));
- String version = System.getProperty("java.version");
- if (version.startsWith("1.4"))
- {
- log.info("java version is " + version + ". Skipping test");
- }
- else
- {
- assertTrue(doXMLTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", ++port));
- }
-
- log.info(getName() + " PASSES");
- }
-
-
- public void testXMLWithoutHost() throws Exception
- {
- log.info("entering " + getName());
-
- String xml = new StringBuffer()
- .append("<mbean code=\"org.jboss.remoting.transport.Connector\"\n")
- .append(" name=\"jboss.messaging:service=Connector,transport=socket\"\n")
- .append(" display-name=\"Connector\">\n")
- .append(" <attribute name=\"Configuration\">\n")
- .append(" <config>\n")
- .append(" <invoker transport=\"socket\">\n")
- .append(" <attribute name=\"" + ServerInvoker.SERVER_BIND_PORT_KEY + "\">" + port + "</attribute>\n")
- .append(" <attribute name=\"timeout\" isParam=\"true\">10000</attribute>\n")
- .append(" </invoker>\n")
- .append(" <handlers>\n")
- .append(" <handler subsystem=\"test\">" + SampleInvocationHandler.class.getName() + "</handler>\n")
- .append(" </handlers>\n")
- .append(" </config>\n")
- .append(" </attribute>\n")
- .append("</mbean>\n").toString();
- Connector connector = new Connector();
- ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
- Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
- Element element = doc.getDocumentElement();
- connector.setConfiguration(element);
- try
- {
- connector.create();
- InvokerLocator expected = new InvokerLocator("socket://" + getLocalHost() + ":" + port + "/?timeout=10000");
- InvokerLocator actual = connector.getLocator();
- log.info("Expected: " + expected);
- log.info("Actual: " + actual);InetAddress.getLocalHost();
- assertEquals(expected, actual);
- }
- catch (Exception e)
- {
- log.error("Exception caught " + e.getMessage());
- }
- finally
- {
- connector.stop();
- }
-
- log.info(getName() + " PASSES");
- }
-
-
- protected boolean doXMLTest(String host, int port) throws Exception
- {
- String xml = new StringBuffer()
- .append("<mbean code=\"org.jboss.remoting.transport.Connector\"\n")
- .append(" name=\"jboss.messaging:service=Connector,transport=socket\"\n")
- .append(" display-name=\"Connector\">\n")
- .append(" <attribute name=\"Configuration\">\n")
- .append(" <config>\n")
- .append(" <invoker transport=\"socket\">\n")
- .append(" <attribute name=\"" + ServerInvoker.SERVER_BIND_ADDRESS_KEY + "\">" + host + "</attribute>\n")
- .append(" <attribute name=\"" + ServerInvoker.SERVER_BIND_PORT_KEY + "\">" + port + "</attribute>\n")
- .append(" <attribute name=\"timeout\" isParam=\"true\">10000</attribute>\n")
- .append(" </invoker>\n")
- .append(" <handlers>\n")
- .append(" <handler subsystem=\"test\">" + SampleInvocationHandler.class.getName() + "</handler>\n")
- .append(" </handlers>\n")
- .append(" </config>\n")
- .append(" </attribute>\n")
- .append("</mbean>\n").toString();
- Connector connector = new Connector();
- ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
- Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
- Element element = doc.getDocumentElement();
- connector.setConfiguration(element);
- try
- {
- connector.create();
- InvokerLocator expected = new InvokerLocator("socket://" + fixHostnameForURL(host) + ":" + port + "/?timeout=10000");
- InvokerLocator actual = connector.getLocator();
- log.info("Expected: " + expected);
- log.info("Actual: " + actual);
- assertEquals(expected, actual);
- return true;
- }
- catch (Exception e)
- {
- log.error("Exception caught ", e);
- return false;
- }
- finally
- {
- connector.stop();
- }
- }
-
-
- static protected String fixHostnameForURL(String host)
- {
- if (host == null)
- return host ;
-
- // if the hostname is an IPv6 literal, enclose it in brackets
- if (host.indexOf(':') != -1 && host.indexOf("[") == -1)
- {
- System.out.println("HOST: [" + host + "]");
- return "[" + host + "]" ;
- }
- else
- {
- return host;
- }
- }
-
-
- static protected String getLocalHost() throws UnknownHostException
- {
- System.setProperty("java.net.preferIPv6Addresses", "true");
- return InetAddress.getLocalHost().getHostAddress();
- }
-
-
- public static class SampleInvocationHandler implements ServerInvocationHandler
- {
- public Object invoke(InvocationRequest invocation) throws Throwable
- {
- return invocation.getParameter();
- }
-
- public void addListener(InvokerCallbackHandler callbackHandler) {}
- 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.ipv6;
+
+import java.io.ByteArrayInputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import javax.management.MBeanServer;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+/**
+ * Unit tests for JBREM-1164.
+ *
+ * @author <a href="mailto:bclare at tpg.com.au">Ben Clare</a>
+ * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
+ *
+ * @version $Rev$
+ * <p>
+ * Copyright Dec 20, 2009
+ * </p>
+ */
+public class IPv6HostWithNoBracketsTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(IPv6HostWithNoBracketsTestCase.class);
+ private static boolean firstTime = true;
+ private static int port = 8080;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testXMLWithoutBrackets() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ assertTrue(doXMLTest("::", ++port));
+ assertTrue(doXMLTest("::1", ++port));
+ assertTrue(doXMLTest("0:0:0:0:0:0:0:1", ++port));
+ assertTrue(doXMLTest("0:0:0:0:0:0:127.0.0.1", ++port));
+ assertTrue(doXMLTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf", ++port));
+ String version = System.getProperty("java.version");
+ if (version.startsWith("1.4"))
+ {
+ log.info("java version is " + version + ". Skipping test");
+ }
+ else
+ {
+ assertTrue(doXMLTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", ++port));
+ }
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testXMLWithBrackets() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ assertTrue(doXMLTest("[::]", ++port));
+ assertTrue(doXMLTest("[::1]", ++port));
+ assertTrue(doXMLTest("[0:0:0:0:0:0:0:1]", ++port));
+ assertTrue(doXMLTest("[0:0:0:0:0:0:127.0.0.1]", ++port));
+ assertTrue(doXMLTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", ++port));
+ String version = System.getProperty("java.version");
+ if (version.startsWith("1.4"))
+ {
+ log.info("java version is " + version + ". Skipping test");
+ }
+ else
+ {
+ assertTrue(doXMLTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", ++port));
+ }
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testXMLWithoutHost() throws Exception
+ {
+ log.info("entering " + getName());
+
+ String xml = new StringBuffer()
+ .append("<mbean code=\"org.jboss.remoting.transport.Connector\"\n")
+ .append(" name=\"jboss.messaging:service=Connector,transport=socket\"\n")
+ .append(" display-name=\"Connector\">\n")
+ .append(" <attribute name=\"Configuration\">\n")
+ .append(" <config>\n")
+ .append(" <invoker transport=\"socket\">\n")
+ .append(" <attribute name=\"" + ServerInvoker.SERVER_BIND_PORT_KEY + "\">" + port + "</attribute>\n")
+ .append(" <attribute name=\"timeout\" isParam=\"true\">10000</attribute>\n")
+ .append(" </invoker>\n")
+ .append(" <handlers>\n")
+ .append(" <handler subsystem=\"test\">" + SampleInvocationHandler.class.getName() + "</handler>\n")
+ .append(" </handlers>\n")
+ .append(" </config>\n")
+ .append(" </attribute>\n")
+ .append("</mbean>\n").toString();
+ Connector connector = new Connector();
+ ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
+ Element element = doc.getDocumentElement();
+ connector.setConfiguration(element);
+ try
+ {
+ connector.create();
+ InvokerLocator expected = new InvokerLocator("socket://" + getLocalHost() + ":" + port + "/?timeout=10000");
+ InvokerLocator actual = connector.getLocator();
+ log.info("Expected: " + expected);
+ log.info("Actual: " + actual);InetAddress.getLocalHost();
+ assertEquals(expected, actual);
+ }
+ catch (Exception e)
+ {
+ log.error("Exception caught " + e.getMessage());
+ }
+ finally
+ {
+ connector.stop();
+ }
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected boolean doXMLTest(String host, int port) throws Exception
+ {
+ String xml = new StringBuffer()
+ .append("<mbean code=\"org.jboss.remoting.transport.Connector\"\n")
+ .append(" name=\"jboss.messaging:service=Connector,transport=socket\"\n")
+ .append(" display-name=\"Connector\">\n")
+ .append(" <attribute name=\"Configuration\">\n")
+ .append(" <config>\n")
+ .append(" <invoker transport=\"socket\">\n")
+ .append(" <attribute name=\"" + ServerInvoker.SERVER_BIND_ADDRESS_KEY + "\">" + host + "</attribute>\n")
+ .append(" <attribute name=\"" + ServerInvoker.SERVER_BIND_PORT_KEY + "\">" + port + "</attribute>\n")
+ .append(" <attribute name=\"timeout\" isParam=\"true\">10000</attribute>\n")
+ .append(" </invoker>\n")
+ .append(" <handlers>\n")
+ .append(" <handler subsystem=\"test\">" + SampleInvocationHandler.class.getName() + "</handler>\n")
+ .append(" </handlers>\n")
+ .append(" </config>\n")
+ .append(" </attribute>\n")
+ .append("</mbean>\n").toString();
+ Connector connector = new Connector();
+ ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
+ Element element = doc.getDocumentElement();
+ connector.setConfiguration(element);
+ try
+ {
+ connector.create();
+ InvokerLocator expected = new InvokerLocator("socket://" + fixHostnameForURL(host) + ":" + port + "/?timeout=10000");
+ InvokerLocator actual = connector.getLocator();
+ log.info("Expected: " + expected);
+ log.info("Actual: " + actual);
+ assertEquals(expected, actual);
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.error("Exception caught ", e);
+ return false;
+ }
+ finally
+ {
+ connector.stop();
+ }
+ }
+
+
+ static protected String fixHostnameForURL(String host)
+ {
+ if (host == null)
+ return host ;
+
+ // if the hostname is an IPv6 literal, enclose it in brackets
+ if (host.indexOf(':') != -1 && host.indexOf("[") == -1)
+ {
+ System.out.println("HOST: [" + host + "]");
+ return "[" + host + "]" ;
+ }
+ else
+ {
+ return host;
+ }
+ }
+
+
+ static protected String getLocalHost() throws UnknownHostException
+ {
+ System.setProperty("java.net.preferIPv6Addresses", "true");
+ return InetAddress.getLocalHost().getHostAddress();
+ }
+
+
+ public static class SampleInvocationHandler implements ServerInvocationHandler
+ {
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ 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/ipv6/IPv6HostWithNoBracketsTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestCase.java 2010-08-05 01:10:03 UTC (rev 5986)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestCase.java 2010-08-05 01:11:08 UTC (rev 5987)
@@ -1,137 +1,137 @@
-/*
-* 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.ipv6;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.transport.Connector;
-
-
-/**
- * Unit tests for JBREM-1175.
- *
- * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jan 8, 2010
- */
-public class IPv6InvokerLocatorTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(IPv6InvokerLocatorTestCase.class);
-
- private static boolean firstTime = true;
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testHostWithBrackets()
- {
- log.info("entering " + getName());
-
- Map params = new HashMap();
- params.put("x", "y");
- assertTrue(doTest("socket", "[::]", 1234, "a/b", params, "socket://[::]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "[::1]", 1234, "a/b", params, "socket://[::1]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "[0:0:0:0:0:0:0:1]", 1234, "a/b", params, "socket://[0:0:0:0:0:0:0:1]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "[0:0:0:0:0:0:127.0.0.1]", 1234, "a/b", params, "socket://[0:0:0:0:0:0:127.0.0.1]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]:1234/a/b?x=y"));
-
- String version = System.getProperty("java.version");
- if (version.startsWith("1.4"))
- {
- log.info("java version is " + version + ". Skipping test");
- }
- else
- {
- assertTrue(doTest("socket", "[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]:1234/a/b?x=y"));
- }
-
- log.info(getName() + " PASSES");
- }
-
-
- public void testHostWithoutBrackets()
- {
- log.info("entering " + getName());
-
- Map params = new HashMap();
- params.put("x", "y");
- assertTrue(doTest("socket", "::", 1234, "a/b", params, "socket://[::]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "::1", 1234, "a/b", params, "socket://[::1]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "0:0:0:0:0:0:0:1", 1234, "a/b", params, "socket://[0:0:0:0:0:0:0:1]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "0:0:0:0:0:0:127.0.0.1", 1234, "a/b", params, "socket://[0:0:0:0:0:0:127.0.0.1]:1234/a/b?x=y"));
- assertTrue(doTest("socket", "3ffe:1900:4545:3:200:f8ff:fe21:67cf", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]:1234/a/b?x=y"));
-
- String version = System.getProperty("java.version");
- if (version.startsWith("1.4"))
- {
- log.info("java version is " + version + ". Skipping test");
- }
- else
- {
- assertTrue(doTest("socket", "3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]:1234/a/b?x=y"));
- }
-
- log.info(getName() + " PASSES");
- }
-
-
- protected boolean doTest(String protocol, String host, int port, String path, Map params, String expected)
- {
-
- InvokerLocator locator = new InvokerLocator(protocol, host, port, path, params);
- log.info(host + " -> " + locator.getLocatorURI());
- return expected.equals(locator.getLocatorURI());
- }
+/*
+* 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.ipv6;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.Connector;
+
+
+/**
+ * Unit tests for JBREM-1175.
+ *
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jan 8, 2010
+ */
+public class IPv6InvokerLocatorTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(IPv6InvokerLocatorTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testHostWithBrackets()
+ {
+ log.info("entering " + getName());
+
+ Map params = new HashMap();
+ params.put("x", "y");
+ assertTrue(doTest("socket", "[::]", 1234, "a/b", params, "socket://[::]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "[::1]", 1234, "a/b", params, "socket://[::1]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "[0:0:0:0:0:0:0:1]", 1234, "a/b", params, "socket://[0:0:0:0:0:0:0:1]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "[0:0:0:0:0:0:127.0.0.1]", 1234, "a/b", params, "socket://[0:0:0:0:0:0:127.0.0.1]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]:1234/a/b?x=y"));
+
+ String version = System.getProperty("java.version");
+ if (version.startsWith("1.4"))
+ {
+ log.info("java version is " + version + ". Skipping test");
+ }
+ else
+ {
+ assertTrue(doTest("socket", "[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]:1234/a/b?x=y"));
+ }
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testHostWithoutBrackets()
+ {
+ log.info("entering " + getName());
+
+ Map params = new HashMap();
+ params.put("x", "y");
+ assertTrue(doTest("socket", "::", 1234, "a/b", params, "socket://[::]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "::1", 1234, "a/b", params, "socket://[::1]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "0:0:0:0:0:0:0:1", 1234, "a/b", params, "socket://[0:0:0:0:0:0:0:1]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "0:0:0:0:0:0:127.0.0.1", 1234, "a/b", params, "socket://[0:0:0:0:0:0:127.0.0.1]:1234/a/b?x=y"));
+ assertTrue(doTest("socket", "3ffe:1900:4545:3:200:f8ff:fe21:67cf", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]:1234/a/b?x=y"));
+
+ String version = System.getProperty("java.version");
+ if (version.startsWith("1.4"))
+ {
+ log.info("java version is " + version + ". Skipping test");
+ }
+ else
+ {
+ assertTrue(doTest("socket", "3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]:1234/a/b?x=y"));
+ }
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected boolean doTest(String protocol, String host, int port, String path, Map params, String expected)
+ {
+
+ InvokerLocator locator = new InvokerLocator(protocol, host, port, path, params);
+ log.info(host + " -> " + locator.getLocatorURI());
+ return expected.equals(locator.getLocatorURI());
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6TestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6TestCase.java 2010-08-05 01:10:03 UTC (rev 5986)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6TestCase.java 2010-08-05 01:11:08 UTC (rev 5987)
@@ -1,227 +1,227 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.ipv6;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.Callback;
-import org.jboss.remoting.callback.HandleCallbackException;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-
-
-/**
- *
- * Unit test for JBREM-852.
- *
- * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 4, 2007
- * </p>
- */
-public class IPv6TestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(IPv6TestCase.class);
-
- private static boolean firstTime = true;
-
- // remoting server connector
- private Connector connector;
- private InvokerLocator serverLocator;
- private TestInvocationHandler invocationHandler;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testRawIPv6() throws Throwable
- {
- log.info("entering " + getName());
- final InetAddress addr = InetAddress.getByName("[::1]");
-
- new Thread()
- {
- public void run()
- {
- try
- {
- ServerSocket ss = new ServerSocket(4446, 200, addr);
- log.info("ss address: " + ss.getInetAddress());
- Socket s = ss.accept();
- InputStream is = s.getInputStream();
- log.info("read: " + is.read());
- s.close();
- ss.close();
- }
- catch (Exception e)
- {
- log.error("error", e);
- }
- }
- }.start();
-
-
- Thread.sleep(2000);
-
- Socket s = new Socket(addr, 4446);
- log.info("s address: " + s.getInetAddress());
- log.info("s local address: " + s.getLocalAddress());
- OutputStream os = s.getOutputStream();
- os.write(17);
- log.info("wrote 17");
- s.close();
- log.info(getName() + " PASSES");
-
- }
-
-
- public void testRemotingIPv6Loopback() throws Throwable
- {
- log.info("entering " + getName());
- doRemotingTest("[::1]");
- log.info(getName() + " PASSES");
- }
-
-
- public void testRemotingIPv6Any() throws Throwable
- {
- log.info("entering " + getName());
- doRemotingTest("[::]");
- log.info(getName() + " PASSES");
- }
-
-
- public void testRemotingIPv4Mapped() throws Throwable
- {
- doRemotingTest("[::ffff:127.0.0.1]");
- }
-
-
- protected void doRemotingTest(String host) throws Throwable
- {
- // Start server.
- InetAddress[] addresses = InetAddress.getAllByName("localhost");
- for (int i = 0; i < addresses.length; i++)
- {
- log.info("addresses[" + i + "]: " + addresses[i]);
- }
-
- int port = PortUtil.findFreePort(host);
- String locatorURI = "socket://" + host + ":" + port + "/?timeout=10000";
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraServerConfig(config);
- connector = new Connector(serverLocator, config);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("sample", invocationHandler);
- connector.start();
-
- // Create client.
- InvokerLocator clientLocator1 = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator1, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- client.disconnect();
- connector.stop();
- }
-
-
- protected String getTransport()
- {
- return "socket";
- }
-
-
- protected void addExtraClientConfig(Map config) {}
- protected void addExtraServerConfig(Map config) {}
-
-
- 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) {}
- }
-
-
- static class TestCallbackHandler implements InvokerCallbackHandler
- {
- public void handleCallback(Callback callback) throws HandleCallbackException
- {
- log.info("received callback");
- }
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ipv6;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ *
+ * Unit test for JBREM-852.
+ *
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 4, 2007
+ * </p>
+ */
+public class IPv6TestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(IPv6TestCase.class);
+
+ private static boolean firstTime = true;
+
+ // remoting server connector
+ private Connector connector;
+ private InvokerLocator serverLocator;
+ private TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testRawIPv6() throws Throwable
+ {
+ log.info("entering " + getName());
+ final InetAddress addr = InetAddress.getByName("[::1]");
+
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ ServerSocket ss = new ServerSocket(4446, 200, addr);
+ log.info("ss address: " + ss.getInetAddress());
+ Socket s = ss.accept();
+ InputStream is = s.getInputStream();
+ log.info("read: " + is.read());
+ s.close();
+ ss.close();
+ }
+ catch (Exception e)
+ {
+ log.error("error", e);
+ }
+ }
+ }.start();
+
+
+ Thread.sleep(2000);
+
+ Socket s = new Socket(addr, 4446);
+ log.info("s address: " + s.getInetAddress());
+ log.info("s local address: " + s.getLocalAddress());
+ OutputStream os = s.getOutputStream();
+ os.write(17);
+ log.info("wrote 17");
+ s.close();
+ log.info(getName() + " PASSES");
+
+ }
+
+
+ public void testRemotingIPv6Loopback() throws Throwable
+ {
+ log.info("entering " + getName());
+ doRemotingTest("[::1]");
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRemotingIPv6Any() throws Throwable
+ {
+ log.info("entering " + getName());
+ doRemotingTest("[::]");
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRemotingIPv4Mapped() throws Throwable
+ {
+ doRemotingTest("[::ffff:127.0.0.1]");
+ }
+
+
+ protected void doRemotingTest(String host) throws Throwable
+ {
+ // Start server.
+ InetAddress[] addresses = InetAddress.getAllByName("localhost");
+ for (int i = 0; i < addresses.length; i++)
+ {
+ log.info("addresses[" + i + "]: " + addresses[i]);
+ }
+
+ int port = PortUtil.findFreePort(host);
+ String locatorURI = "socket://" + host + ":" + port + "/?timeout=10000";
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("sample", invocationHandler);
+ connector.start();
+
+ // Create client.
+ InvokerLocator clientLocator1 = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator1, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ client.disconnect();
+ connector.stop();
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ 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) {}
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ log.info("received callback");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/IPv6TestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6AddressTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6AddressTestCase.java 2010-08-05 01:10:03 UTC (rev 5986)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6AddressTestCase.java 2010-08-05 01:11:08 UTC (rev 5987)
@@ -1,206 +1,206 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.ipv6;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.Callback;
-import org.jboss.remoting.callback.HandleCallbackException;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.network.NetworkRegistry;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-
-
-public class ObjectNameWithIPv6AddressTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ObjectNameWithIPv6AddressTestCase.class);
-
- private static boolean firstTime = true;
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
- protected TestInvocationHandler invocationHandler;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testIPv6Loopback() throws Throwable
- {
- log.info("entering " + getName());
- doTest("[::1]");
- log.info(getName() + " PASSES");
- }
-
-
- public void testIPv6Any() throws Throwable
- {
- log.info("entering " + getName());
- doTest("[::]");
- log.info(getName() + " PASSES");
- }
-
-
- public void testIPv4Mapped() throws Throwable
- {
- log.info("entering " + getName());
- doTest("[::ffff:127.0.0.1]");
- log.info(getName() + " PASSES");
- }
-
-
- protected void doTest(String host) throws Throwable
- {
- MBeanServer server = MBeanServerFactory.createMBeanServer();
-
- Connector connector = new Connector();
- port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
- serverLocator = new InvokerLocator(locatorURI);
- connector.setInvokerLocator(locatorURI);
- ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + getTransport());
- server.registerMBean(connector, obj);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("test", invocationHandler);
- connector.start();
-
- ServerInvoker serverInvoker = connector.getServerInvoker();
- ObjectName objectName = new ObjectName(serverInvoker.getMBeanObjectName());
- assertTrue(objectName.getCanonicalName().indexOf(host) >= 0);
- assertTrue(server.isRegistered(objectName));
- log.info(objectName + " is registered");
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- client.disconnect();
- shutdownServer();
- }
-
-
- protected String getTransport()
- {
- return "socket";
- }
-
-
- protected void addExtraClientConfig(Map config) {}
- protected void addExtraServerConfig(Map config) {}
-
-
- protected void setupServer() throws Exception
- {
- host = InetAddress.getLocalHost().getHostAddress();
- port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraServerConfig(config);
- connector = new Connector(serverLocator, config);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("test", invocationHandler);
- connector.start();
- }
-
-
- protected void shutdownServer() throws Exception
- {
- if (connector != null)
- connector.stop();
- }
-
-
- 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) {}
- }
-
-
- static class TestCallbackHandler implements InvokerCallbackHandler
- {
- public void handleCallback(Callback callback) throws HandleCallbackException
- {
- log.info("received callback");
- }
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ipv6;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.network.NetworkRegistry;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+public class ObjectNameWithIPv6AddressTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ObjectNameWithIPv6AddressTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testIPv6Loopback() throws Throwable
+ {
+ log.info("entering " + getName());
+ doTest("[::1]");
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testIPv6Any() throws Throwable
+ {
+ log.info("entering " + getName());
+ doTest("[::]");
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testIPv4Mapped() throws Throwable
+ {
+ log.info("entering " + getName());
+ doTest("[::ffff:127.0.0.1]");
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void doTest(String host) throws Throwable
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ Connector connector = new Connector();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ serverLocator = new InvokerLocator(locatorURI);
+ connector.setInvokerLocator(locatorURI);
+ ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + getTransport());
+ server.registerMBean(connector, obj);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+
+ ServerInvoker serverInvoker = connector.getServerInvoker();
+ ObjectName objectName = new ObjectName(serverInvoker.getMBeanObjectName());
+ assertTrue(objectName.getCanonicalName().indexOf(host) >= 0);
+ assertTrue(server.isRegistered(objectName));
+ log.info(objectName + " is registered");
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ client.disconnect();
+ shutdownServer();
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ 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) {}
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ log.info("received callback");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6AddressTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase.java 2010-08-05 01:10:03 UTC (rev 5986)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase.java 2010-08-05 01:11:08 UTC (rev 5987)
@@ -1,92 +1,92 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.ipv6;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.remoting.InvokerLocator;
-
-
-/**
- *
- * Unit test for JBREM-1003.
- *
- * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jan 23, 2008
- * </p>
- */
-public class PercentEncodingTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(PercentEncodingTestCase.class);
- private static boolean firstTime = true;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- log.info("java.version: " + System.getProperty("java.version"));
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testPercentEncoding() throws Throwable
- {
- log.info("entering " + getName());
-
- String version = System.getProperty("java.version");
- if (version.startsWith("1.4"))
- {
- log.info("java version is " + version + ". Skipping test");
- }
- else
- {
- String locatorURI = "socket://[fe80::205:9aff:fe3c:7800%7]:7777/";
- InvokerLocator locator = new InvokerLocator(locatorURI);
- assertEquals(locatorURI, locator.getLocatorURI());
-
- locatorURI = "socket://multihome/?homes=[fe80::205:9aff:fe3c:7800%7]:7777![fe80::214:22ff:feef:68bb%4]:8888";
- locator = new InvokerLocator(locatorURI);
- assertEquals(locatorURI, locator.getLocatorURI());
- }
- log.info(getName() + " PASSES");
-
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ipv6;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.InvokerLocator;
+
+
+/**
+ *
+ * Unit test for JBREM-1003.
+ *
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jan 23, 2008
+ * </p>
+ */
+public class PercentEncodingTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(PercentEncodingTestCase.class);
+ private static boolean firstTime = true;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ log.info("java.version: " + System.getProperty("java.version"));
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testPercentEncoding() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ String version = System.getProperty("java.version");
+ if (version.startsWith("1.4"))
+ {
+ log.info("java version is " + version + ". Skipping test");
+ }
+ else
+ {
+ String locatorURI = "socket://[fe80::205:9aff:fe3c:7800%7]:7777/";
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+ assertEquals(locatorURI, locator.getLocatorURI());
+
+ locatorURI = "socket://multihome/?homes=[fe80::205:9aff:fe3c:7800%7]:7777![fe80::214:22ff:feef:68bb%4]:8888";
+ locator = new InvokerLocator(locatorURI);
+ assertEquals(locatorURI, locator.getLocatorURI());
+ }
+ log.info(getName() + " PASSES");
+
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-remoting-commits
mailing list