maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r686736 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src: main/java/org/apache/maven/scm/provider/bazaar/repository/ test/java/org/apache/maven/scm/provider/bazaar/repository/
Date Mon, 18 Aug 2008 12:30:18 GMT
Author: vsiveton
Date: Mon Aug 18 05:30:16 2008
New Revision: 686736

URL: http://svn.apache.org/viewvc?rev=686736&view=rev
Log:
SCM-401: Fix parseHostAndPort() for Bazaar too

o same logic that r686735

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepositoryTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java?rev=686736&r1=686735&r2=686736&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
Mon Aug 18 05:30:16 2008
@@ -167,35 +167,29 @@
     {
         if ( !FILE.equals( protocol ) )
         {
-            String[] split = url.split( ":" );
-            if ( split.length == 2 )
+            int indexSlash = url.indexOf( "/" );
+
+            String hostPort = url;
+            if ( indexSlash > 0 )
             {
-                setHost( split[0] );
-                url = url.substring( split[0].length() + 1 );
-                split = split[1].split( "/" );
-                if ( split.length == 2 )
-                {
-                    url = url.substring( split[0].length() );
-                    try
-                    {
-                        setPort( Integer.valueOf( split[0] ).intValue() );
-                    }
-                    catch ( NumberFormatException e )
-                    {
-                        //Ignore - error will manifest itself later.
-                    }
-                }
+                hostPort = url.substring( 0, indexSlash );
+            }
+
+            int indexColon = hostPort.indexOf( ":" );
+            if ( indexColon > 0 )
+            {
+                setHost( hostPort.substring( 0, indexColon ) );
+                url = StringUtils.replace( url, getHost(), "" );
+                setPort( Integer.parseInt( hostPort.substring( indexColon + 1 ) ) );
+                url = StringUtils.replace( url, ":" + getPort(), "" );
             }
             else
             {
-                split = url.split( "/" );
-                if ( split.length > 1 )
-                {
-                    url = url.substring( split[0].length() );
-                    setHost( split[0] );
-                }
+                setHost( hostPort );
+                url = StringUtils.replace( url, getHost(), "" );
             }
         }
+
         return url;
     }
 

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepositoryTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepositoryTest.java?rev=686736&r1=686735&r2=686736&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepositoryTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepositoryTest.java
Mon Aug 18 05:30:16 2008
@@ -115,4 +115,24 @@
         assertEquals( "http://www.myhost.com:81/dev/maven", repo.getURI() );
         assertNull( repo.validateURI() );
     }
+
+    /**
+     * @throws Exception
+     */
+    public void testParseHostAndPort()
+        throws Exception
+    {
+        String url = "http://localhost:8000/";
+        BazaarScmProviderRepository repo = new BazaarScmProviderRepository( url );
+        System.out.println(repo.getURI());
+        assertEquals( repo.getURI(), url );
+
+        url = "http://localhost/";
+        repo = new BazaarScmProviderRepository( url );
+        assertEquals( repo.getURI(), url );
+
+        url = "http://www.myhost.com:81/dev/maven";
+        repo = new BazaarScmProviderRepository( url );
+        assertEquals( repo.getURI(), url );
+    }
 }
\ No newline at end of file



Mime
View raw message