[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/locator ...

Ron Sigal ron_sigal at yahoo.com
Tue May 22 03:42:45 EDT 2007


  User: rsigal  
  Date: 07/05/22 03:42:45

  Modified:    src/tests/org/jboss/test/remoting/locator  Tag: remoting_2_x
                        InvokerLocatorTestCase.java
  Log:
  JBREM-645:  Added test method for new URI based parsing.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.4.1   +107 -1    JBossRemoting/src/tests/org/jboss/test/remoting/locator/InvokerLocatorTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InvokerLocatorTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/locator/InvokerLocatorTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.7.4.1
  diff -u -b -r1.7 -r1.7.4.1
  --- InvokerLocatorTestCase.java	17 Jul 2006 21:21:28 -0000	1.7
  +++ InvokerLocatorTestCase.java	22 May 2007 07:42:45 -0000	1.7.4.1
  @@ -22,6 +22,8 @@
   
   package org.jboss.test.remoting.locator;
   
  +import java.net.MalformedURLException;
  +
   import junit.framework.TestCase;
   import org.jboss.remoting.InvokerLocator;
   
  @@ -30,14 +32,109 @@
    */
   public class InvokerLocatorTestCase extends TestCase
   {
  -   public void testLocatorConfig() throws Exception
  +   /**
  +    *  testLegacyLocatorConfig tests the original version of InvokerLocator parsing.
  +    */
  +   public void testLegacyLocatorConfig() throws Exception
  +   {
  +      System.setProperty(InvokerLocator.LEGACY_PARSING, "true");
  +      InvokerLocator locator = new InvokerLocator("http://localhost:1234/services/uri:Test");
  +      InvokerLocator locator2 = new InvokerLocator("http://localhost:1234");
  +      InvokerLocator locator3 = new InvokerLocator("http://127.0.0.1:1234");
  +      InvokerLocator locator4 = new InvokerLocator("http://1.2.3.4/aaa");
  +      InvokerLocator locator5 = new InvokerLocator("http://1.2.3.4/abB");
  +
  +      assertFalse(locator.equals(null));
  +      assertFalse(locator.equals(locator2));
  +      assertFalse(locator.isSameEndpoint(null));
  +      assertTrue(locator.isSameEndpoint(locator2));
  +      assertFalse(locator.equals(locator3));
  +      assertFalse(locator.isSameEndpoint(locator3));
  +
  +      assertTrue(locator4.equals(locator4));
  +      assertFalse(locator4.equals(locator5));
  +      assertTrue(locator5.equals(locator5));
  +      assertFalse(locator5.equals(locator4));
  +
  +      String url = locator.getLocatorURI();
  +      String origUrl = locator.getOriginalURI();
  +
  +//      assertEquals("http://127.0.0.1:1234/services/uri:Test", url);
  +      assertEquals("http://localhost:1234/services/uri:Test", url);
  +      assertEquals("http://localhost:1234/services/uri:Test", origUrl);
  +
  +      locator = new InvokerLocator("http://localhost/services/uri:Test");
  +
  +      url = locator.getLocatorURI();
  +      origUrl = locator.getOriginalURI();
  +
  +//      assertEquals("http://127.0.0.1/services/uri:Test", url);
  +      assertEquals("http://localhost/services/uri:Test", url);
  +      assertEquals("http://localhost/services/uri:Test", origUrl);
  +
  +      locator = new InvokerLocator("socket://localhost:1234");
  +
  +      url = locator.getLocatorURI();
  +      origUrl = locator.getOriginalURI();
  +
  +//      assertEquals("socket://127.0.0.1:1234/", url);
  +      assertEquals("socket://localhost:1234/", url);
  +      assertEquals("socket://localhost:1234", origUrl);
  +
  +      locator = new InvokerLocator("socket://localhost:1234/some/path");
  +
  +      url = locator.getLocatorURI();
  +      origUrl = locator.getOriginalURI();
  +
  +//      assertEquals("socket://127.0.0.1:1234/some/path", url);
  +      assertEquals("socket://localhost:1234/some/path", url);
  +      assertEquals("socket://localhost:1234/some/path", origUrl);
  +
  +      locator = new InvokerLocator("socket://myhost:1234");
  +
  +      url = locator.getLocatorURI();
  +      origUrl = locator.getOriginalURI();
  +
  +      assertEquals("socket://myhost:1234/", url);
  +      assertEquals("socket://myhost:1234", origUrl);
  +
  +      locator = new InvokerLocator("socket://myhost");
  +
  +      url = locator.getLocatorURI();
  +      origUrl = locator.getOriginalURI();
  +
  +      assertEquals("socket://myhost/", url);
  +      assertEquals("socket://myhost", origUrl);
  +
  +      locator = new InvokerLocator("socket://myhost");
  +
  +      url = locator.getLocatorURI();
  +      origUrl = locator.getOriginalURI();
  +
  +      assertEquals("socket://myhost/", url);
  +      assertEquals("socket://myhost", origUrl);
  +
  +   }
  +   
  +   /**
  +    * testURILocatorConfig() tests the new version of InvokerLocator parsing.
  +    */
  +   public void testURILocatorConfig() throws Exception
      {
  +      System.setProperty(InvokerLocator.LEGACY_PARSING, "false");
         InvokerLocator locator = new InvokerLocator("http://localhost:1234/services/uri:Test");
         InvokerLocator locator2 = new InvokerLocator("http://localhost:1234");
         InvokerLocator locator3 = new InvokerLocator("http://127.0.0.1:1234");
         InvokerLocator locator4 = new InvokerLocator("http://1.2.3.4/aaa");
         InvokerLocator locator5 = new InvokerLocator("http://1.2.3.4/abB");
   
  +      // Test that path starts with '/', in accordance with
  +      // RFC 2396 "Uniform Resource Identifiers (URI): Generic Syntax" 
  +      assertEquals("/services/uri:Test", locator.getPath());
  +      assertEquals("", locator2.getPath());
  +      assertEquals("/aaa", locator4.getPath());
  +      assertEquals("/abB", locator5.getPath());
  +
         assertFalse(locator.equals(null));
         assertFalse(locator.equals(locator2));
         assertFalse(locator.isSameEndpoint(null));
  @@ -110,4 +207,13 @@
   
      }
   
  +   public void testJBREM645() throws MalformedURLException
  +   {
  +      System.setProperty(InvokerLocator.LEGACY_PARSING, "false");
  +      String locatorURI ="socket://succubus.starkinternational.com:4446?datatype=invocation";
  +      InvokerLocator locator = new InvokerLocator(locatorURI);
  +      int port = locator.getPort();
  +      assertEquals(4446, port);
  +   }
  +
   }
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list