maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tibordig...@apache.org
Subject [1/2] maven-surefire git commit: [SUREFIRE] moved UrlUtils to internal package
Date Sat, 03 Dec 2016 21:17:37 GMT
Repository: maven-surefire
Updated Branches:
  refs/heads/master d9b577cdc -> ce6264f2d


[SUREFIRE] moved UrlUtils to internal package


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/569e7545
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/569e7545
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/569e7545

Branch: refs/heads/master
Commit: 569e75452b1180251190c34713714bb4ac515d0e
Parents: d9b577c
Author: Tibor17 <tibor17@lycos.com>
Authored: Sat Dec 3 20:57:21 2016 +0100
Committer: Tibor17 <tibor17@lycos.com>
Committed: Sat Dec 3 20:57:21 2016 +0100

----------------------------------------------------------------------
 .../booterclient/ForkConfiguration.java         |  5 +-
 .../apache/maven/surefire/util/UrlUtils.java    | 95 -------------------
 .../maven/surefire/util/internal/UrlUtils.java  | 96 ++++++++++++++++++++
 .../maven/surefire/util/UrlUtilsTest.java       |  6 +-
 .../apache/maven/surefire/booter/Classpath.java |  5 +-
 5 files changed, 105 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569e7545/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 036ec56..6d43bd2 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -27,7 +27,6 @@ import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ForkedBooter;
 import org.apache.maven.surefire.booter.StartupConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
-import org.apache.maven.surefire.util.UrlUtils;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -40,6 +39,8 @@ import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 
+import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
+
 /**
  * Configuration for forking tests.
  *
@@ -287,7 +288,7 @@ public class ForkConfiguration
             for ( String el : classPath )
             {
                 // NOTE: if File points to a directory, this entry MUST end in '/'.
-                cp.append( UrlUtils.getURL( new File( el ) ).toExternalForm() )
+                cp.append( toURL( new File( el ) ).toExternalForm() )
                         .append( " " );
             }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569e7545/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
deleted file mode 100644
index 34dfe3d..0000000
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.apache.maven.surefire.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.BitSet;
-
-/**
- * Utility for dealing with URLs in pre-JDK 1.4.
- */
-public class UrlUtils
-{
-    private static final BitSet UNRESERVED = new BitSet( Byte.MAX_VALUE - Byte.MIN_VALUE
+ 1 );
-
-    private static final int RADIX = 16;
-
-    private static final int MASK = 0xf;
-
-    private UrlUtils()
-    {
-    }
-
-    private static final String ENCODING = "UTF-8";
-
-    static
-    {
-        try
-        {
-            byte[] bytes =
-                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(
ENCODING );
-            for ( byte aByte : bytes )
-            {
-                UNRESERVED.set( aByte );
-            }
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            // can't happen as UTF-8 must be present
-        }
-    }
-
-    public static URL getURL( File file )
-        throws MalformedURLException
-    {
-        // with JDK 1.4+, code would be: return new URL( file.toURI().toASCIIString() );
-        //noinspection deprecation
-        URL url = file.toURL();
-        // encode any characters that do not comply with RFC 2396
-        // this is primarily to handle Windows where the user's home directory contains spaces
-        try
-        {
-            byte[] bytes = url.toString().getBytes( ENCODING );
-            StringBuilder buf = new StringBuilder( bytes.length );
-            for ( byte b : bytes )
-            {
-                if ( b > 0 && UNRESERVED.get( b ) )
-                {
-                    buf.append( (char) b );
-                }
-                else
-                {
-                    buf.append( '%' );
-                    buf.append( Character.forDigit( b >>> 4 & MASK, RADIX )
);
-                    buf.append( Character.forDigit( b & MASK, RADIX ) );
-                }
-            }
-            return new URL( buf.toString() );
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            // should not happen as UTF-8 must be present
-            throw new RuntimeException( e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569e7545/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
new file mode 100644
index 0000000..3a33b7f
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
@@ -0,0 +1,96 @@
+package org.apache.maven.surefire.util.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.BitSet;
+
+/**
+ * Utility for dealing with URLs in pre-JDK 1.4.
+ */
+public final class UrlUtils
+{
+    private static final BitSet UNRESERVED = new BitSet( Byte.MAX_VALUE - Byte.MIN_VALUE
+ 1 );
+
+    private static final int RADIX = 16;
+
+    private static final int MASK = 0xf;
+
+    private UrlUtils()
+    {
+        throw new IllegalStateException( "no instantiable constructor" );
+    }
+
+    private static final String ENCODING = "UTF-8";
+
+    static
+    {
+        try
+        {
+            byte[] bytes =
+                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(
ENCODING );
+            for ( byte aByte : bytes )
+            {
+                UNRESERVED.set( aByte );
+            }
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            // can't happen as UTF-8 must be present
+        }
+    }
+
+    public static URL toURL( File file )
+        throws MalformedURLException
+    {
+        // with JDK 1.4+, code would be: return new URL( file.toURI().toASCIIString() );
+        //noinspection deprecation
+        URL url = file.toURL();
+        // encode any characters that do not comply with RFC 2396
+        // this is primarily to handle Windows where the user's home directory contains spaces
+        try
+        {
+            byte[] bytes = url.toString().getBytes( ENCODING );
+            StringBuilder buf = new StringBuilder( bytes.length );
+            for ( byte b : bytes )
+            {
+                if ( b > 0 && UNRESERVED.get( b ) )
+                {
+                    buf.append( (char) b );
+                }
+                else
+                {
+                    buf.append( '%' );
+                    buf.append( Character.forDigit( b >>> 4 & MASK, RADIX )
);
+                    buf.append( Character.forDigit( b & MASK, RADIX ) );
+                }
+            }
+            return new URL( buf.toString() );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            // should not happen as UTF-8 must be present
+            throw new RuntimeException( e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569e7545/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
index a9d7df0..3d9a07f 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
@@ -19,12 +19,14 @@ package org.apache.maven.surefire.util;
  * under the License.
  */
 
+import junit.framework.TestCase;
+
 import java.io.File;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.net.URL;
 
-import junit.framework.TestCase;
+import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
 
 /**
  * Test the URL utilities.
@@ -55,7 +57,7 @@ public class UrlUtilsTest
         throws Exception
     {
         File f = new File( homeDir, fileName );
-        URL u = UrlUtils.getURL( f );
+        URL u = toURL( f );
         String url = u.toString();
         assertStartsWith( url, "file:" );
         assertEndsWith( url, expectedFileName );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569e7545/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index d03fed1..13388c5 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -19,8 +19,6 @@ package org.apache.maven.surefire.booter;
  * under the License.
  */
 
-import org.apache.maven.surefire.util.UrlUtils;
-
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -32,6 +30,7 @@ import java.util.LinkedHashSet;
 import java.util.List;
 
 import static java.io.File.pathSeparatorChar;
+import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
 
 /**
  * An ordered list of classpath elements with set behaviour
@@ -124,7 +123,7 @@ public class Classpath implements Iterable<String>
         for ( String url : unmodifiableElements )
         {
             File f = new File( url );
-            urls.add( UrlUtils.getURL( f ) );
+            urls.add( toURL( f ) );
         }
         return urls;
     }


Mime
View raw message