Author: dfabulich
Date: Fri Nov 23 16:00:54 2007
New Revision: 597766
URL: http://svn.apache.org/viewvc?rev=597766&view=rev
Log:
[SUREFIRE-313] Handle umlaut in dir name.
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirTest.java
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/pom.xml
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/java/umlautTest/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/java/umlautTest/BasicTest.java
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java?rev=597766&r1=597765&r2=597766&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
Fri Nov 23 16:00:54 2007
@@ -20,75 +20,22 @@
*/
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 = "US-ASCII";
-
- static
- {
- try
- {
- byte[] bytes =
-
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(
ENCODING );
- for ( int i = 0; i < bytes.length; i++ )
- {
- UNRESERVED.set( bytes[i] );
- }
- }
- catch ( UnsupportedEncodingException e )
- {
- // can't happen as US-ASCII must be present
- }
- }
public static URL getURL( File file )
throws MalformedURLException
{
- 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 );
- StringBuffer buf = new StringBuffer( bytes.length );
- for ( int i = 0; i < bytes.length; i++ )
- {
- byte b = bytes[i];
- if ( 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 US-ASCII must be present
- throw new NestedRuntimeException( e );
- }
+
+ return file.toURI().toURL();
}
}
Modified:
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java?rev=597766&r1=597765&r2=597766&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
(original)
+++
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
Fri Nov 23 16:00:54 2007
@@ -65,5 +65,12 @@
File f = new File( homeDir, "foo bar.txt" );
assertEquals( new URL( "file:" + homeDir + "/foo%20bar.txt" ),
UrlUtils.getURL( f ) );
}
+
+ public void testTestWithUmlaut()
+ throws IOException
+ {
+ File f = new File( homeDir, "foÜ.txt" );
+ assertEquals( new URL( "file:" + homeDir + "/foÜ.txt" ),
UrlUtils.getURL( f ) );
+ }
}
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirTest.java?rev=597766&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirTest.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UmlautDirTest.java
Fri Nov 23 16:00:54 2007
@@ -0,0 +1,32 @@
+package org.apache.maven.surefire.its;
+
+
+
+import java.io.File;
+
+import org.apache.maven.integrationtests.AbstractMavenIntegrationTestCase;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * Test a directory with an umlaut Ü
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Dan Fabulich</a>
+ *
+ */
+public class UmlautDirTest
+ extends AbstractMavenIntegrationTestCase
+{
+ public void testUmlaut ()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/junit-pathWithÜmlaut" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.executeGoal( "test" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, testDir );
+ }
+}
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/pom.xml
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWith%C3%9Cmlaut/pom.xml?rev=597766&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/pom.xml
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/pom.xml
Fri Nov 23 16:00:54 2007
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit-path-with-umlaut</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Test path with Ãmlaut</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/java/umlautTest/BasicTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWith%C3%9Cmlaut/src/test/java/umlautTest/BasicTest.java?rev=597766&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/java/umlautTest/BasicTest.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-pathWithÜmlaut/src/test/java/umlautTest/BasicTest.java
Fri Nov 23 16:00:54 2007
@@ -0,0 +1,68 @@
+package umlautTest;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class BasicTest
+ extends TestCase
+{
+
+ private boolean setUpCalled = false;
+
+ private static boolean tearDownCalled = false;
+
+ public BasicTest( String name, String extraName )
+ {
+ super( name );
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite();
+ Test test = new BasicTest( "testSetUp", "dummy" );
+ suite.addTest( test );
+ TestSetup setup = new TestSetup( suite )
+ {
+
+ protected void setUp()
+ {
+ //oneTimeSetUp();
+ }
+
+ protected void tearDown()
+ {
+ oneTimeTearDown();
+ }
+
+ };
+
+ return setup;
+ }
+
+ protected void setUp()
+ {
+ setUpCalled = true;
+ tearDownCalled = false;
+ System.out.println( "Called setUp" );
+ }
+
+ protected void tearDown()
+ {
+ setUpCalled = false;
+ tearDownCalled = true;
+ System.out.println( "Called tearDown" );
+ }
+
+ public void testSetUp()
+ {
+ assertTrue( "setUp was not called", setUpCalled );
+ }
+
+ public static void oneTimeTearDown()
+ {
+ assertTrue( "tearDown was not called", tearDownCalled );
+ }
+
+}