Author: stephenc
Date: Tue May 24 08:48:01 2011
New Revision: 1126934
URL: http://svn.apache.org/viewvc?rev=1126934&view=rev
Log:
got these working
Added:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java
- copied, changed from r1126920,
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/TckMatchers.java
Modified:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/IOUtil.java
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
Modified:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/IOUtil.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/IOUtil.java?rev=1126934&r1=1126933&r2=1126934&view=diff
==============================================================================
---
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/IOUtil.java
(original)
+++
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/IOUtil.java
Tue May 24 08:48:01 2011
@@ -1,5 +1,24 @@
package org.codehaus.plexus.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.
+ */
+
public final class IOUtil
{
private static final int DEFAULT_BUFFER_SIZE = 4096;
Added:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java?rev=1126934&view=auto
==============================================================================
---
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
(added)
+++
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
Tue May 24 08:48:01 2011
@@ -0,0 +1,45 @@
+package org.codehaus.plexus.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.
+ */
+
+public class PropertyUtils
+{
+
+ public PropertyUtils()
+ {
+ // should throw new IllegalAccessError( "Utility class" );
+ }
+
+ public static java.util.Properties loadProperties( java.net.URL url )
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public static java.util.Properties loadProperties( java.io.File file )
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public static java.util.Properties loadProperties( java.io.InputStream is )
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+}
\ No newline at end of file
Modified:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java?rev=1126934&r1=1126933&r2=1126934&view=diff
==============================================================================
---
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
(original)
+++
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
Tue May 24 08:48:01 2011
@@ -1,24 +1,37 @@
package org.codehaus.plexus.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 org.junit.Test;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
-
-import static org.hamcrest.CoreMatchers.is;
+import static org.codehaus.plexus.util.TckMatchers.isUtilityClass;
import static org.junit.Assert.assertThat;
public class IOUtilTest
{
@Test
- public void isUtilityClass()
+ public void isAUtilityClass()
throws Exception
{
- for ( Constructor c : IOUtil.class.getConstructors() )
- {
- assertThat( Modifier.isPrivate( c.getModifiers() ), is( true ) );
- }
+ assertThat( IOUtil.class, isUtilityClass() );
}
+
}
Copied:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java
(from r1126920,
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java)
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java?p2=maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java&p1=maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java&r1=1126920&r2=1126934&rev=1126934&view=diff
==============================================================================
---
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
(original)
+++
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java
Tue May 24 08:48:01 2011
@@ -1,24 +1,40 @@
package org.codehaus.plexus.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 org.junit.Test;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
-
-import static org.hamcrest.CoreMatchers.is;
+import static org.codehaus.plexus.util.TckMatchers.hasDefaultConstructor;
+import static org.codehaus.plexus.util.TckMatchers.isFinalClass;
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
-public class IOUtilTest
+public class PropertyUtilsTest
{
@Test
- public void isUtilityClass()
+ public void isNotUtilityClass()
throws Exception
{
- for ( Constructor c : IOUtil.class.getConstructors() )
- {
- assertThat( Modifier.isPrivate( c.getModifiers() ), is( true ) );
- }
+ assertThat( PropertyUtils.class, allOf( hasDefaultConstructor(), not(
isFinalClass() ) ) );
}
+
}
Added:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/TckMatchers.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/TckMatchers.java?rev=1126934&view=auto
==============================================================================
---
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/TckMatchers.java
(added)
+++
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/TckMatchers.java
Tue May 24 08:48:01 2011
@@ -0,0 +1,135 @@
+package org.codehaus.plexus.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 org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import static org.hamcrest.CoreMatchers.allOf;
+
+/**
+ * Common {@link Matcher}s used in the TCK.
+ */
+public class TckMatchers
+{
+ /**
+ * A matcher which checks that the class is a Utility class (i.e. is final
and has only private constructors).
+ *
+ * @return A matcher which checks that the class is a Utility class (i.e.
is final and has only private constructors).
+ */
+ public static Matcher<Class<?>> isUtilityClass()
+ {
+ return allOf( isFinalClass(), isClassWithOnlyPrivateConstructors() );
+ }
+
+ /**
+ * A matcher which checks that the class has only private constructors.
+ *
+ * @return A matcher which checks that the class has only private
constructors.
+ */
+ public static Matcher<Class<?>> isClassWithOnlyPrivateConstructors()
+ {
+ return new IsClassWithOnlyPrivateConstructors();
+ }
+
+ /**
+ * A matcher which checks that the class is final.
+ *
+ * @return A matcher which checks that the class is final.
+ */
+ public static Matcher<Class<?>> isFinalClass()
+ {
+ return new IsFinalClass();
+ }
+
+ /**
+ * A matcher which checks that the class has the default constructor.
+ *
+ * @return A matcher which checks that the class has the default
constructor.
+ */
+ public static Matcher<Class<?>> hasDefaultConstructor()
+ {
+ return new HasDefaultConstructor();
+ }
+
+ private static class HasDefaultConstructor
+ extends BaseMatcher<Class<?>>
+ {
+ public boolean matches( Object item )
+ {
+ Class<?> clazz = (Class<?>) item;
+ try
+ {
+ Constructor<?> constructor = clazz.getConstructor();
+ return Modifier.isPublic( constructor.getModifiers() );
+ }
+ catch ( NoSuchMethodException e )
+ {
+ return false;
+ }
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "a class with the default constructor" );
+ }
+ }
+
+ private static class IsClassWithOnlyPrivateConstructors
+ extends BaseMatcher<Class<?>>
+ {
+ public boolean matches( Object item )
+ {
+ Class<?> clazz = (Class<?>) item;
+ for ( Constructor c : clazz.getConstructors() )
+ {
+ if ( !Modifier.isPrivate( c.getModifiers() ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "a class with only private constructors" );
+ }
+ }
+
+ private static class IsFinalClass
+ extends BaseMatcher<Class<?>>
+ {
+ public boolean matches( Object item )
+ {
+ Class<?> clazz = (Class<?>) item;
+ return Modifier.isFinal( clazz.getModifiers() );
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "a final class" );
+ }
+ }
+}