You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2012/08/29 21:40:45 UTC
svn commit: r1378692 - in /maven/shared/trunk/maven-shared-utils/src:
main/java/org/apache/maven/shared/utils/io/
main/java/org/apache/maven/shared/utils/reflection/
test/java/org/apache/maven/shared/utils/reflection/
test/java/org/apache/maven/shared/...
Author: struberg
Date: Wed Aug 29 19:40:44 2012
New Revision: 1378692
URL: http://svn.apache.org/viewvc?rev=1378692&view=rev
Log:
MSHARED-236 move Reflector from sandbox to proper
also fix a few license headers and improve unit test helpers
Added:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/
- copied from r1378653, maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/reflection/
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/
- copied from r1378653, maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/reflection/
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/ExceptionHelper.java (with props)
Modified:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/ScanConductor.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTest.java
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTestHelper.java
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/FileTestHelper.java
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/ScanConductor.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/ScanConductor.java?rev=1378692&r1=1378691&r2=1378692&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/ScanConductor.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/ScanConductor.java Wed Aug 29 19:40:44 2012
@@ -1,5 +1,25 @@
package org.apache.maven.shared.utils.io;
+/*
+ * 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;
/**
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java?rev=1378692&r1=1378653&r2=1378692&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java Wed Aug 29 19:40:44 2012
@@ -1,4 +1,4 @@
-package org.codehaus.plexus.util.reflection;
+package org.apache.maven.shared.utils.reflection;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -667,4 +667,4 @@ public final class Reflector
return methodMap;
}
-}
\ No newline at end of file
+}
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java?rev=1378692&r1=1378653&r2=1378692&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java Wed Aug 29 19:40:44 2012
@@ -1,4 +1,4 @@
-package org.codehaus.plexus.util.reflection;
+package org.apache.maven.shared.utils.reflection;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -71,4 +71,4 @@ public class ReflectorException
{
super( msg, root );
}
-}
\ No newline at end of file
+}
Modified: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTest.java?rev=1378692&r1=1378653&r2=1378692&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTest.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTest.java Wed Aug 29 19:40:44 2012
@@ -1,4 +1,4 @@
-package org.codehaus.plexus.util.reflection;
+package org.apache.maven.shared.utils.reflection;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,36 +19,23 @@ package org.codehaus.plexus.util.reflect
* under the License.
*/
-import org.apache.maven.tck.FixPlexusBugs;
-import org.apache.maven.tck.ReproducesPlexusBug;
-import org.junit.Rule;
import org.junit.Test;
import java.lang.reflect.Constructor;
-import static org.apache.maven.tck.TckMatchers.*;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.apache.maven.shared.utils.testhelpers.ExceptionHelper.*;
+
/**
* @author Stephen Connolly
*/
public class ReflectorTest
{
- @Rule
- public FixPlexusBugs fixPlexusBugs = new FixPlexusBugs();
-
private Reflector reflector = new Reflector();
- @Test
- @ReproducesPlexusBug( "Should actually be a utility class" )
- public void notUtilityClass()
- throws Exception
- {
- assertThat( Reflector.class, allOf( isFinalClass(), hasDefaultConstructor(), not( isUtilityClass() ) ) );
- }
-
//// newInstance( Class, Object[] )
@Test( expected = NullPointerException.class )
@@ -94,8 +81,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug(
- "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
+ // // @ReproducesPlexusBug( "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
public void newInstancePackageConstructor()
throws Exception
{
@@ -103,8 +89,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug(
- "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
+ // // @ReproducesPlexusBug( "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
public void newInstancePackageConstructorThrowsSomething()
throws Exception
{
@@ -112,8 +97,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug(
- "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
+ // // @ReproducesPlexusBug("Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
public void newInstanceProtectedConstructor()
throws Exception
{
@@ -121,8 +105,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug(
- "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
+ // // @ReproducesPlexusBug( "Looking up constructors by signature has an unlabelled continue, so finds the wrong constructor" )
public void newInstanceProtectedConstructorThrowsSomething()
throws Exception
{
@@ -204,7 +187,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void getSingletonPackageMethod()
throws Exception
{
@@ -212,7 +195,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void getSingletonPackageMethodThrowsSomething()
throws Exception
{
@@ -220,7 +203,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void getSingletonProtectedMethod()
throws Exception
{
@@ -228,7 +211,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void getSingletonProtectedMethodThrowsSomething()
throws Exception
{
@@ -833,7 +816,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void invokeStaticClassInvalidSignature()
throws Exception
{
@@ -848,7 +831,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void invokeStaticPackageMethod()
throws Exception
{
@@ -856,7 +839,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void invokeStaticPackageMethodThrowsSomething()
throws Exception
{
@@ -864,7 +847,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void invokeStaticProtectedMethod()
throws Exception
{
@@ -872,7 +855,7 @@ public class ReflectorTest
}
@Test( expected = IllegalArgumentException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void invokeStaticProtectedMethodThrowsSomething()
throws Exception
{
@@ -951,7 +934,7 @@ public class ReflectorTest
}
@Test( expected = ReflectorException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void getConstructorPrivate()
throws Exception
{
@@ -1014,7 +997,7 @@ public class ReflectorTest
}
@Test
- @ReproducesPlexusBug( "Should only access public properties" )
+ // @ReproducesPlexusBug( "Should only access public properties" )
public void getObjectPropertyViaPrivateField()
throws Exception
{
@@ -1026,7 +1009,7 @@ public class ReflectorTest
}
@Test
- @ReproducesPlexusBug( "Should only access public properties" )
+ // @ReproducesPlexusBug( "Should only access public properties" )
public void getObjectPropertyViaPackageField()
throws Exception
{
@@ -1038,7 +1021,7 @@ public class ReflectorTest
}
@Test
- @ReproducesPlexusBug( "Should only access public properties" )
+ // @ReproducesPlexusBug( "Should only access public properties" )
public void getObjectPropertyViaProtectedField()
throws Exception
{
@@ -1183,7 +1166,7 @@ public class ReflectorTest
}
@Test( expected = ReflectorException.class )
- @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
+ // @ReproducesPlexusBug( "Looking up methods by signature has an unlabelled continue, so finds the wrong method" )
public void getMethodPrivate()
throws Exception
{
Modified: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTestHelper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTestHelper.java?rev=1378692&r1=1378653&r2=1378692&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTestHelper.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/reflection/ReflectorTestHelper.java Wed Aug 29 19:40:44 2012
@@ -1,4 +1,4 @@
-package org.codehaus.plexus.util.reflection;
+package org.apache.maven.shared.utils.reflection;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,11 +21,8 @@ package org.codehaus.plexus.util.reflect
/**
- * Created by IntelliJ IDEA.
- * User: stephenc
- * Date: 03/08/2011
- * Time: 13:37
- * To change this template use File | Settings | File Templates.
+ *
+ * @author stephenc
*/
class ReflectorTestHelper
{
Added: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/ExceptionHelper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/ExceptionHelper.java?rev=1378692&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/ExceptionHelper.java (added)
+++ maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/ExceptionHelper.java Wed Aug 29 19:40:44 2012
@@ -0,0 +1,67 @@
+package org.apache.maven.shared.utils.testhelpers;
+
+/*
+ * 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.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+
+public class ExceptionHelper
+{
+
+ /**
+ * A matcher that verifies that the a root cause of an exception is of the specified type.
+ *
+ * @param cause the type of exception that caused this.
+ * @return A matcher that verifies that the a root cause of an exception is of the specified type.
+ */
+ public static Matcher<Throwable> hasCause( Class<? extends Throwable> cause )
+ {
+ return new HasCause( cause );
+ }
+
+ private static class HasCause
+ extends BaseMatcher<Throwable>
+ {
+ private final Class<? extends Throwable> cause;
+
+ public HasCause( Class<? extends Throwable> cause )
+ {
+ this.cause = cause;
+ }
+
+ public boolean matches( Object item )
+ {
+ Throwable throwable = (Throwable) item;
+ while ( throwable != null && !cause.isInstance( throwable ) )
+ {
+ throwable = throwable.getCause();
+ }
+ return cause.isInstance( throwable );
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "was caused by a " ).appendValue( cause ).appendText( " being thrown" );
+ }
+ }
+}
Propchange: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/ExceptionHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/FileTestHelper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/FileTestHelper.java?rev=1378692&r1=1378691&r2=1378692&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/FileTestHelper.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/testhelpers/FileTestHelper.java Wed Aug 29 19:40:44 2012
@@ -1,5 +1,25 @@
package org.apache.maven.shared.utils.testhelpers;
+/*
+ * 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.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.IOUtil;
import org.junit.rules.TemporaryFolder;