From jboss-remoting-commits at lists.jboss.org Thu May 22 20:05:14 2008 Content-Type: multipart/mixed; boundary="===============3364149644249438742==" MIME-Version: 1.0 From: jboss-remoting-commits at lists.jboss.org To: jboss-remoting-commits at lists.jboss.org Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4233 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/multihome. Date: Thu, 22 May 2008 20:05:13 -0400 Message-ID: --===============3364149644249438742== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ron.sigal(a)jboss.com Date: 2008-05-22 20:05:13 -0400 (Thu, 22 May 2008) New Revision: 4233 Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/multihome/XmlMu= ltihomeConfigTestCase.java Log: JBREM-983: New unit tests. Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/multihome/X= mlMultihomeConfigTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/multihome/XmlM= ultihomeConfigTestCase.java (rev 0) +++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/multihome/XmlM= ultihomeConfigTestCase.java 2008-05-23 00:05:13 UTC (rev 4233) @@ -0,0 +1,288 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, 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.multihome; + +import java.io.ByteArrayInputStream; + +import javax.xml.parsers.DocumentBuilderFactory; + +import junit.framework.TestCase; + +import org.jboss.logging.Logger; +import org.jboss.remoting.transport.Connector; +import org.w3c.dom.Document; + +/** + * = + * @author Ron Sigal + * @version $Revision: 3873 $ + *

+ * Copyright (c) Jun 13, 2006 + *

+ */ +public class XmlMultihomeConfigTestCase extends TestCase +{ + protected static Logger log =3D Logger.getLogger(XmlMultihomeConfigTest= Case.class); + protected static boolean firstTime =3D true; + = + = + protected String getTransport() + { + return "socket"; + } + = + = + public void setUp() + { + } + = + + public void testXmlConfigOneHome() throws Throwable + { + Connector connector =3D new Connector(); + + // Create and set xml configuration document. + StringBuffer buf =3D new StringBuffer(); + buf.append("\n"); + buf.append(""); + buf.append(" "); + buf.append(" "); + buf.append(" host2:2222"); + buf.append(" "); + buf.append(" a/b"); + buf.append(" 1= 000"); + buf.append(" "); + buf.append(""); + ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(= ).getBytes()); + Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui= lder().parse(bais); + connector.setConfiguration(xml.getDocumentElement()); + connector.create(); + = + String createdURI =3D connector.getInvokerLocator(); + log.info("created InvokerLocator: " + createdURI); + String expectedURI =3D "socket://multihome/a/b/?"; + expectedURI +=3D "homes=3Dhost2:2222&"; + expectedURI +=3D "timeout=3D1000"; + log.info("expected InvokerLocator: " + expectedURI); + assertEquals(expectedURI, createdURI); + = + log.info(getName() + " PASSES"); + } + = + = + public void testXmlConfigThreeHomes() throws Throwable + { + Connector connector =3D new Connector(); + + // Create and set xml configuration document. + StringBuffer buf =3D new StringBuffer(); + buf.append("\n"); + buf.append(""); + buf.append(" "); + buf.append(" "); + buf.append(" host2:2222"); + buf.append(" host3:3333"); + buf.append(" host4:4444"); + buf.append(" "); + buf.append(" a/b"); + buf.append(" 1= 000"); + buf.append(" "); + buf.append(""); + ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(= ).getBytes()); + Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui= lder().parse(bais); + connector.setConfiguration(xml.getDocumentElement()); + connector.create(); + = + String createdURI =3D connector.getInvokerLocator(); + log.info("created InvokerLocator: " + createdURI); + String expectedURI =3D "socket://multihome/a/b/?"; + expectedURI +=3D "homes=3Dhost2:2222!host3:3333!host4:4444&"; + expectedURI +=3D "timeout=3D1000"; + log.info("expected InvokerLocator: " + expectedURI); + assertEquals(expectedURI, createdURI); + = + log.info(getName() + " PASSES"); + } + = + = + public void testXmlConfigWithConnectHomes() throws Throwable + { + Connector connector =3D new Connector(); + + // Create and set xml configuration document. + StringBuffer buf =3D new StringBuffer(); + buf.append("\n"); + buf.append(""); + buf.append(" "); + buf.append(" "); + buf.append(" host2:2222"); + buf.append(" host3:3333"); + buf.append(" "); + buf.append(" "); + buf.append(" host4:4444"); + buf.append(" host5:5555"); + buf.append(" "); + buf.append(" a/b"); + buf.append(" 1= 000"); + buf.append(" "); + buf.append(""); + ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(= ).getBytes()); + Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui= lder().parse(bais); + connector.setConfiguration(xml.getDocumentElement()); + connector.create(); + = + String createdURI =3D connector.getInvokerLocator(); + log.info("created InvokerLocator: " + createdURI); + String expectedURI =3D "socket://multihome/a/b/?"; + expectedURI +=3D "connecthomes=3Dhost4:4444!host5:5555&"; + expectedURI +=3D "homes=3Dhost2:2222!host3:3333&"; + expectedURI +=3D "timeout=3D1000"; + log.info("expected InvokerLocator: " + expectedURI); + assertEquals(expectedURI, createdURI); + = + log.info(getName() + " PASSES"); + } + = + = + public void testXmlConfigWithServerBindPort() throws Throwable + { + Connector connector =3D new Connector(); + + // Create and set xml configuration document. + StringBuffer buf =3D new StringBuffer(); + buf.append("\n"); + buf.append(""); + buf.append(" "); + buf.append(" host1"); + buf.append(" 1111"); + buf.append(" "); + buf.append(" host2:2222"); + buf.append(" host3"); + buf.append(" "); + buf.append(" "); + buf.append(" host4"); + buf.append(" host5:5555"); + buf.append(" "); + buf.append(" a/b"); + buf.append(" 1= 000"); + buf.append(" "); + buf.append(""); + ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(= ).getBytes()); + Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui= lder().parse(bais); + connector.setConfiguration(xml.getDocumentElement()); + connector.create(); + = + String createdURI =3D connector.getInvokerLocator(); + log.info("created InvokerLocator: " + createdURI); + String expectedURI =3D "socket://multihome:1111/a/b/?"; + expectedURI +=3D "connecthomes=3Dhost4:1111!host5:5555&"; + expectedURI +=3D "homes=3Dhost2:2222!host3:1111&"; + expectedURI +=3D "timeout=3D1000"; + log.info("expected InvokerLocator: " + expectedURI); + assertEquals(expectedURI, createdURI); + = + log.info(getName() + " PASSES"); + } + = + = + public void testXmlConfigWithClientConnectPort() throws Throwable + { + Connector connector =3D new Connector(); + + // Create and set xml configuration document. + StringBuffer buf =3D new StringBuffer(); + buf.append("\n"); + buf.append(""); + buf.append(" "); + buf.append(" host1"); + buf.append(" 1111"); + buf.append(" host2"); + buf.append(" 2222"); + buf.append(" "); + buf.append(" host3:3333"); + buf.append(" host4"); + buf.append(" "); + buf.append(" "); + buf.append(" host5"); + buf.append(" host6:6666"); + buf.append(" "); + buf.append(" a/b"); + buf.append(" 1= 000"); + buf.append(" "); + buf.append(""); + ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(= ).getBytes()); + Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui= lder().parse(bais); + connector.setConfiguration(xml.getDocumentElement()); + connector.create(); + = + String createdURI =3D connector.getInvokerLocator(); + log.info("created InvokerLocator: " + createdURI); + String expectedURI =3D "socket://multihome:2222/a/b/?"; + expectedURI +=3D "connecthomes=3Dhost5:2222!host6:6666&"; + expectedURI +=3D "homes=3Dhost3:3333!host4:2222&"; + expectedURI +=3D "timeout=3D1000"; + log.info("expected InvokerLocator: " + expectedURI); + assertEquals(expectedURI, createdURI); + = + log.info(getName() + " PASSES"); + } + = + = + public void testXmlConfigWithConnectHomesAndNoHomes() throws Throwable + { + Connector connector =3D new Connector(); + + // Create and set xml configuration document. + StringBuffer buf =3D new StringBuffer(); + buf.append("\n"); + buf.append(""); + buf.append(" "); + buf.append(" "); + buf.append(" host5"); + buf.append(" host6:6666"); + buf.append(" "); + buf.append(" a/b"); + buf.append(" 1= 000"); + buf.append(" "); + buf.append(""); + ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(= ).getBytes()); + Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui= lder().parse(bais); + connector.setConfiguration(xml.getDocumentElement()); + + try + { + log.info("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D EX= CEPTION EXPECTED =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"); + connector.create(); + fail("Should have gotten IllegalStateException"); + } + catch (IllegalStateException e) + { + String msg =3D "Error configuring invoker for connector. Can not= continue without invoker."; + assertEquals("unexpected message", msg, e.getMessage()); + log.info("got expected IllegalStateException"); + log.info("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"); + } + = + log.info(getName() + " PASSES"); + } +} \ No newline at end of file --===============3364149644249438742==--