maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apope...@apache.org
Subject svn commit: r537691 [8/11] - in /maven/sandbox/branches/surefire/surefire-collab2: ./ maven-surefire-plugin/ maven-surefire-plugin/src/ maven-surefire-plugin/src/it/ maven-surefire-plugin/src/it/test1/ maven-surefire-plugin/src/it/test1/src/ maven-sure...
Date Mon, 14 May 2007 01:34:18 GMT
Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/ComparisonToolTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/ComparisonToolTest.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/ComparisonToolTest.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/ComparisonToolTest.java Sun May 13 18:33:45 2007
@@ -0,0 +1,130 @@
+package org.apache.maven.surefire.assertion;
+
+/*
+ * 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 junit.framework.TestCase;
+
+/**
+ * Test the comparison tool string representations.
+ */
+public class ComparisonToolTest
+    extends TestCase
+{
+    public void testFormatMismatchNoMessage()
+    {
+        assertEquals( "expected:<foo> but was:<bar>", ComparisonTool.formatMismatch( null, "foo", "bar" ) );
+    }
+
+    public void testFormatMismatchWithMessage()
+    {
+        assertEquals( "msg expected:<foo> but was:<bar>", ComparisonTool.formatMismatch( "msg", "foo", "bar" ) );
+    }
+
+    public void testTrimComparisonActualNull()
+    {
+        assertEquals( "msg expected:<foo> but was:<null>", ComparisonTool.trimComparison( "msg", "foo", null ) );
+    }
+
+    public void testTrimComparisonExpectedNull()
+    {
+        assertEquals( "msg expected:<null> but was:<bar>", ComparisonTool.trimComparison( "msg", null, "bar" ) );
+    }
+
+    public void testTrimComparisonBothNull()
+    {
+        try
+        {
+            ComparisonTool.trimComparison( "msg", null, null );
+            fail( "Should fail to pass in equal values" );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            // correct
+        }
+    }
+
+    public void testTrimComparisonEqual()
+    {
+        try
+        {
+            ComparisonTool.trimComparison( "msg", "foo", "foo" );
+            fail( "Should fail to pass in equal values" );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            // correct
+        }
+    }
+
+    public void testTrimComparisonNoMatch()
+    {
+        assertEquals( "msg expected:<foo> but was:<bar>", ComparisonTool.trimComparison( "msg", "foo", "bar" ) );
+    }
+
+    public void testTrimComparisonMatchStart()
+    {
+        assertEquals( "msg expected:<...rah> but was:<...bar>",
+                      ComparisonTool.trimComparison( "msg", "foorah", "foobar" ) );
+    }
+
+    public void testTrimComparisonMatchStartWholeExpected()
+    {
+        assertEquals( "msg expected:<...> but was:<...bar>", ComparisonTool.trimComparison( "msg", "foo", "foobar" ) );
+    }
+
+    public void testTrimComparisonMatchStartWholeActual()
+    {
+        assertEquals( "msg expected:<...rah> but was:<...>", ComparisonTool.trimComparison( "msg", "foorah", "foo" ) );
+    }
+
+    public void testTrimComparisonMatchEnd()
+    {
+        assertEquals( "msg expected:<bop...> but was:<foo...>",
+                      ComparisonTool.trimComparison( "msg", "bopbar", "foobar" ) );
+    }
+
+    public void testTrimComparisonMatchEndWholeExpected()
+    {
+        assertEquals( "msg expected:<...> but was:<foo...>", ComparisonTool.trimComparison( "msg", "bar", "foobar" ) );
+    }
+
+    public void testTrimComparisonMatchEndWholeActual()
+    {
+        assertEquals( "msg expected:<foo...> but was:<...>", ComparisonTool.trimComparison( "msg", "foorah", "rah" ) );
+    }
+
+    public void testTrimComparisonMatchStartAndEnd()
+    {
+        assertEquals( "msg expected:<...bar...> but was:<...foo...>",
+                      ComparisonTool.trimComparison( "msg", "foobarbaz", "foofoobaz" ) );
+    }
+
+    public void testTrimComparisonMatchStartAndEndWholeExpected()
+    {
+        assertEquals( "msg expected:<......> but was:<...def...>",
+                      ComparisonTool.trimComparison( "msg", "abcghi", "abcdefghi" ) );
+    }
+
+    public void testTrimComparisonMatchStartAndEndWholeActual()
+    {
+        assertEquals( "msg expected:<...def...> but was:<......>",
+                      ComparisonTool.trimComparison( "msg", "abcdefghi", "abcghi" ) );
+    }
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/SurefireAssertTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/SurefireAssertTest.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/SurefireAssertTest.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/assertion/SurefireAssertTest.java Sun May 13 18:33:45 2007
@@ -0,0 +1,1068 @@
+package org.apache.maven.surefire.assertion;
+
+/*
+ * 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 junit.framework.TestCase;
+
+/**
+ * Test the surefire assertion class.
+ *
+ * @noinspection ProhibitedExceptionCaught
+ */
+public class SurefireAssertTest
+    extends TestCase
+{
+    public void testFailWithNoMessage()
+    {
+        try
+        {
+            SurefireAssert.fail( (String) null );
+            fail( "Should have thrown a NullPointerException" );
+        }
+        catch ( NullPointerException e )
+        {
+            // expected
+        }
+    }
+
+    public void testFailWithNoCause()
+    {
+        try
+        {
+            SurefireAssert.fail( (Throwable) null );
+            fail( "Should have thrown a NullPointerException" );
+        }
+        catch ( NullPointerException e )
+        {
+            // expected
+        }
+    }
+
+
+    public void testFailWithMessageButNoCause()
+    {
+        try
+        {
+            SurefireAssert.fail( "msg", null );
+            fail( "Should have thrown a NullPointerException" );
+        }
+        catch ( NullPointerException e )
+        {
+            // expected
+        }
+    }
+
+    public void testFailWithCauseButNoMessage()
+    {
+        try
+        {
+            SurefireAssert.fail( null, new Exception( "msg" ) );
+            fail( "Should have thrown a NullPointerException" );
+        }
+        catch ( NullPointerException e )
+        {
+            // expected
+        }
+    }
+
+    public void testFailWithNoMessageOrCause()
+    {
+        try
+        {
+            SurefireAssert.fail();
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertNull( e.getMessage() );
+        }
+    }
+
+    public void testFailWithMessage()
+    {
+        try
+        {
+            SurefireAssert.fail( "msg" );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg", e.getMessage() );
+        }
+    }
+
+    public void testFailWithCause()
+    {
+        try
+        {
+            SurefireAssert.fail( new Exception( "nestedMsg" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "null; nested exception is java.lang.Exception: nestedMsg", e.getMessage() );
+            assertEquals( "nestedMsg", e.getCause().getMessage() );
+        }
+    }
+
+    public void testFailWithMessageAndCause()
+    {
+        try
+        {
+            SurefireAssert.fail( "msg", new Exception( "nestedMsg" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg; nested exception is java.lang.Exception: nestedMsg", e.getMessage() );
+            assertEquals( "nestedMsg", e.getCause().getMessage() );
+        }
+    }
+
+    public void testFailAssertTrueWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertTrue( "msg", false );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertTrueWithMessage()
+    {
+        SurefireAssert.assertTrue( "msg", true );
+    }
+
+    public void testFailAssertTrueWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertTrue( false );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertNull( e.getMessage() );
+        }
+    }
+
+    public void testPassAssertTrueWithoutMessage()
+    {
+        SurefireAssert.assertTrue( true );
+    }
+
+    public void testFailAssertFalseWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertFalse( "msg", true );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertFalseWithMessage()
+    {
+        SurefireAssert.assertFalse( "msg", false );
+    }
+
+    public void testFailAssertFalseWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertFalse( true );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertNull( e.getMessage() );
+        }
+    }
+
+    public void testPassAssertFalseWithoutMessage()
+    {
+        SurefireAssert.assertFalse( false );
+    }
+
+    public void testFailAssertEqualsStringWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", "foo", "bar" );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<foo> but was:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsStringExpectedNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", null, "bar" );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<null> but was:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsStringActualNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", "foo", null );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<foo> but was:<null>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsStringWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", "foo", "foo" );
+    }
+
+    public void testPassAssertEqualsStringBothNullWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", null, null );
+    }
+
+    public void testPassAssertEqualsStringWithoutMessage()
+    {
+        SurefireAssert.assertEquals( "foo", "foo" );
+    }
+
+    public void testFailAssertEqualsStringWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "foo", "bar" );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<foo> but was:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsObjectWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", new DummyObject( "foo" ), new DummyObject( "bar" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<foo> but was:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsObjectDoesntTrim()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", new DummyObject( "foo" ), new DummyObject( "fobar" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<foo> but was:<fobar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsObjectExpectedNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", null, new DummyObject( "bar" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<null> but was:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsObjectActualNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", new DummyObject( "foo" ), null );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<foo> but was:<null>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsObjectWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", new DummyObject( "foo" ), new DummyObject( "foo" ) );
+    }
+
+    public void testPassAssertEqualsObjectBothNullWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", null, null );
+    }
+
+    public void testPassAssertEqualsObjectWithoutMessage()
+    {
+        SurefireAssert.assertEquals( new DummyObject( "foo" ), new DummyObject( "foo" ) );
+    }
+
+    public void testFailAssertEqualsObjectWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( new DummyObject( "foo" ), new DummyObject( "bar" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<foo> but was:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsIntWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", 1, 2 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsIntWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", 1, 1 );
+    }
+
+    public void testPassAssertEqualsIntWithoutMessage()
+    {
+        SurefireAssert.assertEquals( 1, 1 );
+    }
+
+    public void testFailAssertEqualsIntWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1, 2 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsLongWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", 1L, 2L );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsLongWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", 1L, 1L );
+    }
+
+    public void testPassAssertEqualsLongWithoutMessage()
+    {
+        SurefireAssert.assertEquals( 1L, 1L );
+    }
+
+    public void testFailAssertEqualsLongWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1L, 2L );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsFloatWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", 1.2f, 3.4f, 0.1f );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1.2> but was:<3.4>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsFloatWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", 1.2f, 1.2f, 0.1f );
+    }
+
+    public void testPassAssertEqualsFloatWithoutMessage()
+    {
+        SurefireAssert.assertEquals( 1.2f, 1.2f, 0.1f );
+    }
+
+    public void testFailAssertEqualsFloatWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1.2f, 3.4f, 0.1f );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1.2> but was:<3.4>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsFloatWithFudge()
+    {
+        SurefireAssert.assertEquals( 1.2f, 1.3f, 0.5f );
+    }
+
+    public void testFailAssertEqualsFloatWithoutFudge()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1.2f, 1.3f, 0.05f );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1.2> but was:<1.3>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsFloatExpectedIsInfinite()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( Float.POSITIVE_INFINITY, 1.3f, 0.05f );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<Infinity> but was:<1.3>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsFloatActualIsInfinite()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1.2f, Float.POSITIVE_INFINITY, 0.05f );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1.2> but was:<Infinity>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsFloatBothAreInfinite()
+    {
+        SurefireAssert.assertEquals( Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 0.05f );
+    }
+
+    public void testFailAssertEqualsDoubleWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", 1.2, 3.4, 0.1 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1.2> but was:<3.4>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsDoubleWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", 1.2, 1.2, 0.1 );
+    }
+
+    public void testPassAssertEqualsDoubleWithoutMessage()
+    {
+        SurefireAssert.assertEquals( 1.2, 1.2, 0.1 );
+    }
+
+    public void testFailAssertEqualsDoubleWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1.2, 3.4, 0.1 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1.2> but was:<3.4>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsDoubleWithFudge()
+    {
+        SurefireAssert.assertEquals( 1.2, 1.3, 0.5 );
+    }
+
+    public void testFailAssertEqualsDoubleWithoutFudge()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1.2, 1.3, 0.05 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1.2> but was:<1.3>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsDoubleExpectedIsInfinite()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( Double.POSITIVE_INFINITY, 1.3, 0.05 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<Infinity> but was:<1.3>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsDoubleActualIsInfinite()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( 1.2, Double.POSITIVE_INFINITY, 0.05 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1.2> but was:<Infinity>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsDoubleBothAreInfinite()
+    {
+        SurefireAssert.assertEquals( Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 0.05 );
+    }
+
+    public void testFailAssertEqualsByteWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", (byte) 1, (byte) 2 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsByteWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", (byte) 1, (byte) 1 );
+    }
+
+    public void testPassAssertEqualsByteWithoutMessage()
+    {
+        SurefireAssert.assertEquals( (byte) 1, (byte) 1 );
+    }
+
+    public void testFailAssertEqualsByteWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( (byte) 1, (byte) 2 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsBooleanWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", true, false );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<true> but was:<false>", e.getMessage() );
+        }
+        try
+        {
+            SurefireAssert.assertEquals( "msg", false, true );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<false> but was:<true>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsBooleanWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", true, true );
+        SurefireAssert.assertEquals( "msg", false, false );
+    }
+
+    public void testPassAssertEqualsBooleanWithoutMessage()
+    {
+        SurefireAssert.assertEquals( true, true );
+        SurefireAssert.assertEquals( false, false );
+    }
+
+    public void testFailAssertEqualsBooleanWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( true, false );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<true> but was:<false>", e.getMessage() );
+        }
+        try
+        {
+            SurefireAssert.assertEquals( false, true );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<false> but was:<true>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsCharWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", '1', '2' );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsCharWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", '1', '1' );
+    }
+
+    public void testPassAssertEqualsCharWithoutMessage()
+    {
+        SurefireAssert.assertEquals( '1', '1' );
+    }
+
+    public void testFailAssertEqualsCharWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( '1', '2' );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertEqualsShortWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( "msg", (short) 1, (short) 2 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertEqualsShortWithMessage()
+    {
+        SurefireAssert.assertEquals( "msg", (short) 1, (short) 1 );
+    }
+
+    public void testPassAssertEqualsShortWithoutMessage()
+    {
+        SurefireAssert.assertEquals( (short) 1, (short) 1 );
+    }
+
+    public void testFailAssertEqualsShortWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertEquals( (short) 1, (short) 2 );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected:<1> but was:<2>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertNull( "msg", new DummyObject( "foo" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertNullWithMessage()
+    {
+        SurefireAssert.assertNull( "msg", null );
+    }
+
+    public void testFailAssertNullWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertNull( new DummyObject( "foo" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertNull( e.getMessage() );
+        }
+    }
+
+    public void testPassAssertNullWithoutMessage()
+    {
+        SurefireAssert.assertNull( null );
+    }
+
+    public void testFailAssertNotNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertNotNull( "msg", null );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertNotNullWithMessage()
+    {
+        SurefireAssert.assertNotNull( "msg", new DummyObject( "foo" ) );
+    }
+
+    public void testFailAssertNotNullWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertNotNull( null );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertNull( e.getMessage() );
+        }
+    }
+
+    public void testPassAssertNotNullWithoutMessage()
+    {
+        SurefireAssert.assertNotNull( new DummyObject( "foo" ) );
+    }
+
+    public void testFailAssertSameWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertSame( "msg", new DummyObject( "foo" ), new DummyObject( "foo" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected same:<foo> was not:<foo>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertSameDoesntTrim()
+    {
+        try
+        {
+            SurefireAssert.assertSame( "msg", new DummyObject( "foo" ), new DummyObject( "fobar" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected same:<foo> was not:<fobar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertSameExpectedNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertSame( "msg", null, new DummyObject( "bar" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected same:<null> was not:<bar>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertSameActualNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertSame( "msg", new DummyObject( "foo" ), null );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected same:<foo> was not:<null>", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertSameWithMessage()
+    {
+        DummyObject value = new DummyObject( "foo" );
+        SurefireAssert.assertSame( "msg", value, value );
+    }
+
+    public void testPassAssertSameBothNullWithMessage()
+    {
+        SurefireAssert.assertSame( "msg", null, null );
+    }
+
+    public void testPassAssertSameWithoutMessage()
+    {
+        DummyObject value = new DummyObject( "foo" );
+        SurefireAssert.assertSame( value, value );
+    }
+
+    public void testFailAssertSameWithoutMessage()
+    {
+        try
+        {
+            SurefireAssert.assertSame( new DummyObject( "foo" ), new DummyObject( "foo" ) );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected same:<foo> was not:<foo>", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertNotSameWithMessage()
+    {
+        try
+        {
+            DummyObject value = new DummyObject( "foo" );
+            SurefireAssert.assertNotSame( "msg", value, value );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected not same", e.getMessage() );
+        }
+    }
+
+    public void testFailAssertNotSameExpectedNullWithMessage()
+    {
+        SurefireAssert.assertNotSame( "msg", null, new DummyObject( "bar" ) );
+    }
+
+    public void testFailAssertNotSameActualNullWithMessage()
+    {
+        SurefireAssert.assertNotSame( "msg", new DummyObject( "foo" ), null );
+    }
+
+    public void testPassAssertNotSameWithMessage()
+    {
+        SurefireAssert.assertNotSame( "msg", new DummyObject( "foo" ), new DummyObject( "foo" ) );
+    }
+
+    public void testPassAssertNotSameBothNullWithMessage()
+    {
+        try
+        {
+            SurefireAssert.assertNotSame( "msg", null, null );
+            fail( "Should not be the same" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "msg expected not same", e.getMessage() );
+        }
+    }
+
+    public void testPassAssertNotSameWithoutMessage()
+    {
+        SurefireAssert.assertNotSame( new DummyObject( "foo" ), new DummyObject( "foo" ) );
+    }
+
+    public void testFailAssertNotSameWithoutMessage()
+    {
+        try
+        {
+            DummyObject value = new DummyObject( "foo" );
+            SurefireAssert.assertNotSame( value, value );
+            fail( "Should have failed" );
+        }
+        catch ( SurefireAssertionFailedException e )
+        {
+            // expected
+            assertEquals( "expected not same", e.getMessage() );
+        }
+    }
+
+    private static class DummyObject
+    {
+        private final String value;
+
+        private DummyObject( String value )
+        {
+            this.value = value;
+        }
+
+        public boolean equals( Object obj )
+        {
+            if ( this == obj )
+            {
+                return true;
+            }
+            if ( obj == null || getClass() != obj.getClass() )
+            {
+                return false;
+            }
+
+            DummyObject that = (DummyObject) obj;
+
+            return !( value != null ? !value.equals( that.value ) : that.value != null );
+
+        }
+
+        public int hashCode()
+        {
+            return value != null ? value.hashCode() : 0;
+        }
+
+        public String toString()
+        {
+            return value;
+        }
+    }
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTestCase.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTestCase.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTestCase.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTestCase.java Sun May 13 18:33:45 2007
@@ -0,0 +1,100 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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 junit.framework.TestCase;
+
+/**
+ * Test for AbstractConsoleReporter
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id: AbstractConsoleReporterTestCase.java 513763 2007-03-02 13:51:08Z brett $
+ */
+public abstract class AbstractConsoleReporterTestCase
+    extends TestCase
+{
+
+    private AbstractConsoleReporter consoleReporter;
+
+    private ReportEntry report;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        report = new ReportEntry();
+        report.setGroup( "group" );
+        report.setName( "name" );
+    }
+
+    protected void setConsoleReporter( AbstractConsoleReporter consoleReporter )
+    {
+        this.consoleReporter = consoleReporter;
+    }
+
+    protected AbstractConsoleReporter getConsoleReporter()
+    {
+        return consoleReporter;
+    }
+
+    public void testTestSetStarting()
+        throws Exception
+    {
+        consoleReporter.testSetStarting( report );
+    }
+
+    public void testGetTestSetStartingMessage()
+        throws Exception
+    {
+        String message = AbstractConsoleReporter.getTestSetStartingMessage( report );
+        assertEquals( "Running name (of group)", message );
+
+        report.setGroup( null );
+        message = AbstractConsoleReporter.getTestSetStartingMessage( report );
+        assertEquals( "Running name", message );
+    }
+
+    public void testParseTestSetStartingMessage()
+        throws Exception
+    {
+        String message = "Running name (of group)";
+        ReportEntry actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message );
+        assertEquals( report, actualReport );
+
+        report.setGroup( null );
+        message = "Running name";
+        actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message );
+        assertEquals( report, actualReport );
+    }
+
+    public void testIsTestSetStartingMessage()
+        throws Exception
+    {
+        String message = "Running name (of group)";
+        assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
+
+        message = "Running name";
+        assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
+
+        message = "Xxxx";
+        assertFalse( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
+    }
+
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java Sun May 13 18:33:45 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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.
+ */
+
+/**
+ * Test for {@link ForkingConsoleReporter}
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id: ForkingConsoleReporterTest.java 513763 2007-03-02 13:51:08Z brett $
+ */
+public class ForkingConsoleReporterTest
+    extends AbstractConsoleReporterTestCase
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        ForkingConsoleReporter consoleReporter = new ForkingConsoleReporter( Boolean.TRUE );
+        setConsoleReporter( consoleReporter );
+    }
+
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java Sun May 13 18:33:45 2007
@@ -0,0 +1,71 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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 junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+public class XMLReporterTest
+    extends TestCase
+{
+
+    private XMLReporter reporter;
+
+    private ReportEntry reportEntry;
+
+    private String message;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        reporter = new XMLReporter( null, Boolean.TRUE );
+        message = "junit.framework.AssertionFailedError";
+        reportEntry = new ReportEntry( this, "XMLReporterTest", message,
+                                       new PojoStackTraceWriter( "", "", new AssertionFailedError() ) );
+    }
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.XMLReporter.testError(ReportEntry, String, String)'
+     */
+    public void testTestError()
+    {
+        reporter.testError( reportEntry, "", "" );
+        assertResult( reporter, message );
+    }
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.XMLReporter.testFailed(ReportEntry, String, String)'
+     */
+    public void testTestFailed()
+    {
+        reporter.testError( reportEntry, "", "" );
+        assertResult( reporter, message );
+    }
+
+    private void assertResult( XMLReporter reporter, String message )
+    {
+        Xpp3Dom result = (Xpp3Dom) reporter.getResults().next();
+        Xpp3Dom child = result.getChild( "error" );
+        assertEquals( message, child.getAttribute( "type" ) );
+    }
+
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java Sun May 13 18:33:45 2007
@@ -0,0 +1,69 @@
+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 junit.framework.TestCase;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * Test the URL utilities.
+ */
+public class UrlUtilsTest
+    extends TestCase
+{
+    private String homeDir;
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        homeDir = System.getProperty( "user.dir" );
+        if ( !homeDir.startsWith( "/" ) )
+        {
+            homeDir = "/" + homeDir;
+        }
+    }
+
+    public void testTestNoSpecialCharacters()
+        throws IOException
+    {
+        File f = new File( homeDir, "foo.txt" );
+        assertEquals( new URL( "file:" + homeDir + "/foo.txt" ), UrlUtils.getURL( f ) );
+        f = new File( homeDir, "qwertyuiopasdfghjklzxcvbnm.txt" );
+        assertEquals( new URL( "file:" + homeDir + "/qwertyuiopasdfghjklzxcvbnm.txt" ), UrlUtils.getURL( f ) );
+        f = new File( homeDir, "QWERTYUIOPASDFGHJKLZXCVBNM.txt" );
+        assertEquals( new URL( "file:" + homeDir + "/QWERTYUIOPASDFGHJKLZXCVBNM.txt" ), UrlUtils.getURL( f ) );
+        f = new File( homeDir, "1234567890.txt" );
+        assertEquals( new URL( "file:" + homeDir + "/1234567890.txt" ), UrlUtils.getURL( f ) );
+        f = new File( homeDir, ")('*~!._-.txt" );
+        assertEquals( new URL( "file:" + homeDir + "/)('*~!._-.txt" ), UrlUtils.getURL( f ) );
+    }
+
+    public void testTestWithSpaces()
+        throws IOException
+    {
+        File f = new File( homeDir, "foo bar.txt" );
+        assertEquals( new URL( "file:" + homeDir + "/foo%20bar.txt" ), UrlUtils.getURL( f ) );
+    }
+
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/name-output.txt
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/name-output.txt?view=auto&rev=537691
==============================================================================
    (empty)

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/pom.xml?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/pom.xml (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/pom.xml Sun May 13 18:33:45 2007
@@ -0,0 +1,24 @@
+<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">
+  <parent>
+    <artifactId>surefire</artifactId>
+    <groupId>org.apache.maven.surefire</groupId>
+    <version>2.4-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>surefire-booter</artifactId>
+  <name>SureFire Booter</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.surefire</groupId>
+      <artifactId>surefire-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-archiver</artifactId>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java Sun May 13 18:33:45 2007
@@ -0,0 +1,257 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * 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 org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.Manifest;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Configuration for forking tests.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ */
+public class ForkConfiguration
+{
+    public static final String FORK_ONCE = "once";
+
+    public static final String FORK_ALWAYS = "always";
+
+    public static final String FORK_NEVER = "never";
+
+    private String forkMode;
+
+    private Properties systemProperties;
+
+    private String jvmExecutable;
+
+    private String argLine;
+
+    private Map environmentVariables;
+
+    private File workingDirectory;
+
+    private boolean debug;
+
+    public void setForkMode( String forkMode )
+    {
+        if ( "pertest".equalsIgnoreCase( forkMode ) )
+        {
+            this.forkMode = FORK_ALWAYS;
+        }
+        else if ( "none".equalsIgnoreCase( forkMode ) )
+        {
+            this.forkMode = FORK_NEVER;
+        }
+        else if ( forkMode.equals( FORK_NEVER ) || forkMode.equals( FORK_ONCE ) || forkMode.equals( FORK_ALWAYS ) )
+        {
+            this.forkMode = forkMode;
+        }
+        else
+        {
+            throw new IllegalArgumentException( "Fork mode " + forkMode + " is not a legal value" );
+        }
+    }
+
+    public boolean isForking()
+    {
+        return !FORK_NEVER.equals( forkMode );
+    }
+
+    public void setSystemProperties( Properties systemProperties )
+    {
+        this.systemProperties = (Properties) systemProperties.clone();
+    }
+
+    public void setJvmExecutable( String jvmExecutable )
+    {
+        this.jvmExecutable = jvmExecutable;
+    }
+
+    public void setArgLine( String argLine )
+    {
+        this.argLine = argLine;
+    }
+
+    public void setEnvironmentVariables( Map environmentVariables )
+    {
+        this.environmentVariables = new HashMap( environmentVariables );
+    }
+
+    public void setWorkingDirectory( File workingDirectory )
+    {
+        this.workingDirectory = workingDirectory;
+    }
+
+    public String getForkMode()
+    {
+        return forkMode;
+    }
+
+    public Properties getSystemProperties()
+    {
+        return systemProperties;
+    }
+
+    /**
+     * @throws SurefireBooterForkException
+     * @deprecated use the 2-arg alternative.
+     */
+    public Commandline createCommandLine( List classPath )
+        throws SurefireBooterForkException
+    {
+        return createCommandLine( classPath, false );
+    }
+
+    public Commandline createCommandLine( List classPath, boolean useJar )
+        throws SurefireBooterForkException
+    {
+        Commandline cli = new Commandline();
+
+        cli.setExecutable( jvmExecutable );
+
+        if ( argLine != null )
+        {
+            cli.addArguments( StringUtils.split( argLine, " " ) );
+        }
+
+        if ( environmentVariables != null )
+        {
+            Iterator iter = environmentVariables.keySet().iterator();
+
+            while ( iter.hasNext() )
+            {
+                String key = (String) iter.next();
+
+                String value = (String) environmentVariables.get( key );
+
+                cli.addEnvironment( key, value );
+            }
+        }
+
+        if ( System.getProperty( "maven.surefire.debug" ) != null )
+        {
+            cli.createArgument().setLine(
+                "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" );
+        }
+
+        if ( useJar )
+        {
+            File jarFile;
+            try
+            {
+                jarFile = createJar( classPath );
+            }
+            catch ( IOException e )
+            {
+                throw new SurefireBooterForkException( "Error creating archive file", e );
+            }
+            catch ( ManifestException e )
+            {
+                throw new SurefireBooterForkException( "Error creating manifest", e );
+            }
+            catch ( ArchiverException e )
+            {
+                throw new SurefireBooterForkException( "Error creating archive", e );
+            }
+
+            cli.createArgument().setValue( "-jar" );
+
+            cli.createArgument().setValue( jarFile.getAbsolutePath() );
+        }
+        else
+        {
+            cli.createArgument().setValue( "-classpath" );
+
+            cli.createArgument().setValue( StringUtils.join( classPath.iterator(), File.pathSeparator ) );
+
+            cli.createArgument().setValue( SurefireBooter.class.getName() );
+        }
+
+        cli.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+
+        return cli;
+    }
+
+    /**
+     * Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry
+     * for all classpath elements.
+     *
+     * @param classPath List&lt;String> of all classpath elements.
+     * @return
+     * @throws IOException
+     * @throws ManifestException
+     * @throws ArchiverException
+     */
+    private static File createJar( List classPath )
+        throws IOException, ManifestException, ArchiverException
+    {
+        JarArchiver jar = new JarArchiver();
+        jar.setCompress( false ); // for speed
+        File file = File.createTempFile( "surefirebooter", ".jar" );
+        file.deleteOnExit();
+        jar.setDestFile( file );
+
+        Manifest manifest = new Manifest();
+
+        // we can't use StringUtils.join here since we need to add a '/' to
+        // the end of directory entries - otherwise the jvm will ignore them.
+        String cp = "";
+        for ( Iterator it = classPath.iterator(); it.hasNext(); )
+        {
+            String el = (String) it.next();
+            cp += " " + el + ( new File( el ).isDirectory() ? "/" : "" );
+        }
+
+        Manifest.Attribute attr = new Manifest.Attribute( "Class-Path", cp.trim() );
+        manifest.addConfiguredAttribute( attr );
+
+        attr = new Manifest.Attribute( "Main-Class", SurefireBooter.class.getName() );
+        manifest.addConfiguredAttribute( attr );
+
+        jar.addConfiguredManifest( manifest );
+
+        jar.createArchive();
+
+        return file;
+    }
+
+    public void setDebug( boolean debug )
+    {
+        this.debug = debug;
+    }
+
+    public boolean isDebug()
+    {
+        return debug;
+    }
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java Sun May 13 18:33:45 2007
@@ -0,0 +1,91 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * 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 org.apache.maven.surefire.booter.output.ForkingStreamConsumer;
+import org.apache.maven.surefire.report.ForkingConsoleReporter;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+import java.io.PrintWriter;
+import java.io.Writer;
+
+/**
+ * @author Jason van Zyl
+ * @version $Revision: 510866 $
+ * @deprecated use {@link ForkingStreamConsumer}
+ */
+public class ForkingWriterStreamConsumer
+    implements StreamConsumer
+{
+    private PrintWriter printWriter;
+
+    private int standardPrefixLength;
+
+    private int headingPrefixLength;
+
+    private boolean showHeading;
+
+    private int footerPrefixLength;
+
+    private boolean showFooter;
+
+    public ForkingWriterStreamConsumer( Writer writer, boolean showHeading, boolean showFooter )
+    {
+        this.showHeading = showHeading;
+
+        this.showFooter = showFooter;
+
+        printWriter = new PrintWriter( writer );
+
+        standardPrefixLength = ForkingConsoleReporter.FORKING_PREFIX_STANDARD.length();
+
+        headingPrefixLength = ForkingConsoleReporter.FORKING_PREFIX_HEADING.length();
+
+        footerPrefixLength = ForkingConsoleReporter.FORKING_PREFIX_FOOTER.length();
+    }
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_HEADING ) )
+        {
+            if ( showHeading )
+            {
+                printWriter.println( line.substring( headingPrefixLength ) );
+            }
+        }
+        else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_STANDARD ) )
+        {
+            printWriter.println( line.substring( standardPrefixLength ) );
+        }
+        else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_FOOTER ) )
+        {
+            if ( showFooter )
+            {
+                printWriter.println( line.substring( footerPrefixLength ) );
+            }
+        }
+        else
+        {
+            // stdout
+            printWriter.println( line );
+        }
+        printWriter.flush();
+    }
+}

Added: maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java?view=auto&rev=537691
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java (added)
+++ maven/sandbox/branches/surefire/surefire-collab2/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java Sun May 13 18:33:45 2007
@@ -0,0 +1,108 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * 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.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @noinspection CustomClassloader
+ */
+public class IsolatedClassLoader
+    extends URLClassLoader
+{
+    private ClassLoader parent = ClassLoader.getSystemClassLoader();
+
+    private Set urls = new HashSet();
+
+    private boolean childDelegation = true;
+
+    private static final URL[] EMPTY_URL_ARRAY = new URL[0];
+
+    public IsolatedClassLoader()
+    {
+        super( EMPTY_URL_ARRAY, null );
+    }
+
+    public IsolatedClassLoader( ClassLoader parent, boolean childDelegation )
+    {
+        super( EMPTY_URL_ARRAY, parent );
+
+        this.childDelegation = childDelegation;
+    }
+
+    public IsolatedClassLoader( ClassLoader parent )
+    {
+        super( EMPTY_URL_ARRAY, parent );
+    }
+
+    public void addURL( URL url )
+    {
+        // avoid duplicates
+        if ( !urls.contains( url ) )
+        {
+            super.addURL( url );
+            urls.add( url );
+        }
+    }
+
+    public synchronized Class loadClass( String name )
+        throws ClassNotFoundException
+    {
+        Class c;
+
+        if ( childDelegation )
+        {
+            c = findLoadedClass( name );
+
+            ClassNotFoundException ex = null;
+
+            if ( c == null )
+            {
+                try
+                {
+                    c = findClass( name );
+                }
+                catch ( ClassNotFoundException e )
+                {
+                    ex = e;
+
+                    if ( parent != null )
+                    {
+                        c = parent.loadClass( name );
+                    }
+                }
+            }
+
+            if ( c == null )
+            {
+                throw ex;
+            }
+        }
+        else
+        {
+            c = super.loadClass( name );
+        }
+
+        return c;
+    }
+}



Mime
View raw message