You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ni...@apache.org on 2011/05/24 15:57:36 UTC
svn commit: r1127056 - in /maven/sandbox/trunk/plexus-utils-commons-bridge:
./ plexus-utils-commons-bridge/
plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/
plexus-utils-tck/src/test/java/org/codehaus/plexus/util/
Author: nicolas
Date: Tue May 24 13:57:35 2011
New Revision: 1127056
URL: http://svn.apache.org/viewvc?rev=1127056&view=rev
Log:
TCK for Base64
Added:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.java
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java
Modified:
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml
maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml
Modified: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml?rev=1127056&r1=1127055&r2=1127056&view=diff
==============================================================================
--- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml (original)
+++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml Tue May 24 13:57:35 2011
@@ -21,6 +21,10 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Added: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.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/Base64.java?rev=1127056&view=auto
==============================================================================
--- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.java (added)
+++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.java Tue May 24 13:57:35 2011
@@ -0,0 +1,64 @@
+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.
+ */
+
+@Deprecated
+public class Base64
+{
+ public Base64()
+ {
+ super();
+ }
+
+ public static boolean isArrayByteBase64(byte[] arrayOctect)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public static byte[] encodeBase64(byte[] binaryData)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public static byte[] encodeBase64Chunked(byte[] binaryData)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public static byte[] decodeBase64(byte[] base64Data)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public byte[] encode(byte[] pArray)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+
+ public byte[] decode(byte[] pArray)
+ {
+ throw new UnsupportedOperationException( "Not implemented yet" );
+ }
+}
Added: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java?rev=1127056&view=auto
==============================================================================
--- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java (added)
+++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java Tue May 24 13:57:35 2011
@@ -0,0 +1,94 @@
+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 static org.apache.maven.tck.TckMatchers.hasDefaultConstructor;
+import static org.apache.maven.tck.TckMatchers.isFinalClass;
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Base64Test {
+
+
+ @Test
+ public void isNotUtilityClass()
+ throws Exception
+ {
+ assertThat( PropertyUtils.class, allOf( hasDefaultConstructor(), not( isFinalClass() ) ) );
+ }
+
+ @Test
+ public void encode()
+ throws Exception
+ {
+ assertEquals("dGVzdA==", new Base64().encode("test".getBytes()));
+ }
+
+ @Test
+ public void decode()
+ throws Exception
+ {
+ assertEquals( "test", new Base64().decode("dGVzdA==".getBytes()) );
+ }
+
+ @Test
+ public void encodeBase64()
+ throws Exception
+ {
+ assertEquals( "dGVzdA==", Base64.encodeBase64( "test".getBytes() ) );
+ assertEquals( "dGVzdA==", Base64.encodeBase64( "test".getBytes(), false ) );
+ }
+
+ @Test
+ public void encodeBase64Chunked()
+ throws Exception
+ {
+ assertEquals(
+ "c29tZSBsb25nIGxvbmcgbG9uZyBsb25nIGxvbmcgbG9uZyBsb25nIGxvbmcgbG9uZyBsb25nIGxv\r\n" +
+ "bmcgbG9uZyBsb25nIGxvbmcgdGV4dA==\r\n",
+ Base64.encodeBase64(
+ "some long long long long long long long long long long long long long long text"
+ .getBytes(), true ) );
+ }
+
+ @Test
+ public void decodeBase64()
+ throws Exception
+ {
+ assertEquals( "test", Base64.decodeBase64( "dGVzdA==".getBytes() ) );
+ }
+
+ @Test
+ public void isArrayByteBase64()
+ throws Exception
+ {
+ String valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ assertTrue( Base64.isArrayByteBase64( valid.getBytes() ) );
+ }
+
+ private static void assertEquals( String expected , byte[] actual )
+ {
+ Assert.assertEquals(expected, new String(actual));
+ }
+}
Modified: maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml?rev=1127056&r1=1127055&r2=1127056&view=diff
==============================================================================
--- maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml (original)
+++ maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml Tue May 24 13:57:35 2011
@@ -51,6 +51,11 @@ under the License.
<version>1.3.2</version>
</dependency>
<dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.0.7</version>
Re: svn commit: r1127056 - in /maven/sandbox/trunk/plexus-utils-commons-bridge:
./ plexus-utils-commons-bridge/ plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/
plexus-utils-tck/src/test/java/org/codehaus/plexus/util/
Posted by Stephen Connolly <st...@gmail.com>.
assertThat(new Base64().encode("test".getBytes()), is("dGVzdA=="));
will cover most of your needs...
it comes into it's own with arrays and collections
On 24 May 2011 16:12, nicolas de loof <ni...@gmail.com> wrote:
>> + assertEquals("dGVzdA==", new Base64().encode("test".getBytes()));
>>
>> assertThat with the matchers is far nicer, but if you like keeping it
>> old-style I'm fine with that!
>>
>>
> I'm not used with matchers (maybe I should be deprecated and replaced by
> some nicolas-update-bridge),
> can you please provide a sample in such case ?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r1127056 - in /maven/sandbox/trunk/plexus-utils-commons-bridge:
./ plexus-utils-commons-bridge/ plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/
plexus-utils-tck/src/test/java/org/codehaus/plexus/util/
Posted by nicolas de loof <ni...@gmail.com>.
> + assertEquals("dGVzdA==", new Base64().encode("test".getBytes()));
>
> assertThat with the matchers is far nicer, but if you like keeping it
> old-style I'm fine with that!
>
>
I'm not used with matchers (maybe I should be deprecated and replaced by
some nicolas-update-bridge),
can you please provide a sample in such case ?
Re: svn commit: r1127056 - in /maven/sandbox/trunk/plexus-utils-commons-bridge:
./ plexus-utils-commons-bridge/ plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/
plexus-utils-tck/src/test/java/org/codehaus/plexus/util/
Posted by Stephen Connolly <st...@gmail.com>.
On 24 May 2011 14:57, <ni...@apache.org> wrote:
> Author: nicolas
> Date: Tue May 24 13:57:35 2011
> New Revision: 1127056
>
> URL: http://svn.apache.org/viewvc?rev=1127056&view=rev
> Log:
> TCK for Base64
>
> Added:
> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.java
> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java
> Modified:
> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml
> maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml
>
> Modified: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml?rev=1127056&r1=1127055&r2=1127056&view=diff
> ==============================================================================
> --- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml (original)
> +++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml Tue May 24 13:57:35 2011
> @@ -21,6 +21,10 @@
> <artifactId>commons-io</artifactId>
> </dependency>
> <dependency>
> + <groupId>commons-codec</groupId>
> + <artifactId>commons-codec</artifactId>
> + </dependency>
> + <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <scope>test</scope>
>
> Added: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.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/Base64.java?rev=1127056&view=auto
> ==============================================================================
> --- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.java (added)
> +++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/Base64.java Tue May 24 13:57:35 2011
> @@ -0,0 +1,64 @@
> +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.
> + */
> +
> +@Deprecated
> +public class Base64
> +{
> + public Base64()
> + {
> + super();
Does it really need to call Object.super(). Can we not leave it with
the default constructor as Plexus' original has?
> + }
> +
> + public static boolean isArrayByteBase64(byte[] arrayOctect)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +
> + public static byte[] encodeBase64(byte[] binaryData)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +
> + public static byte[] encodeBase64Chunked(byte[] binaryData)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +
> + public static byte[] encodeBase64(byte[] binaryData, boolean isChunked)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +
> + public static byte[] decodeBase64(byte[] base64Data)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +
> + public byte[] encode(byte[] pArray)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +
> + public byte[] decode(byte[] pArray)
> + {
> + throw new UnsupportedOperationException( "Not implemented yet" );
> + }
> +}
>
> Added: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java?rev=1127056&view=auto
> ==============================================================================
> --- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java (added)
> +++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/Base64Test.java Tue May 24 13:57:35 2011
> @@ -0,0 +1,94 @@
> +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 static org.apache.maven.tck.TckMatchers.hasDefaultConstructor;
> +import static org.apache.maven.tck.TckMatchers.isFinalClass;
> +import static org.hamcrest.CoreMatchers.allOf;
> +import static org.hamcrest.CoreMatchers.not;
> +import static org.junit.Assert.*;
> +
> +import org.junit.Assert;
> +import org.junit.Test;
> +
> +public class Base64Test {
> +
> +
> + @Test
> + public void isNotUtilityClass()
> + throws Exception
> + {
> + assertThat( PropertyUtils.class, allOf( hasDefaultConstructor(), not( isFinalClass() ) ) );
I think you mean to be testing Base64.class and not PropertyUtils.class
> + }
> +
> + @Test
> + public void encode()
> + throws Exception
> + {
> + assertEquals("dGVzdA==", new Base64().encode("test".getBytes()));
assertThat with the matchers is far nicer, but if you like keeping it
old-style I'm fine with that!
> + }
> +
> + @Test
> + public void decode()
> + throws Exception
> + {
> + assertEquals( "test", new Base64().decode("dGVzdA==".getBytes()) );
> + }
> +
> + @Test
> + public void encodeBase64()
> + throws Exception
> + {
> + assertEquals( "dGVzdA==", Base64.encodeBase64( "test".getBytes() ) );
> + assertEquals( "dGVzdA==", Base64.encodeBase64( "test".getBytes(), false ) );
> + }
> +
> + @Test
> + public void encodeBase64Chunked()
> + throws Exception
> + {
> + assertEquals(
> + "c29tZSBsb25nIGxvbmcgbG9uZyBsb25nIGxvbmcgbG9uZyBsb25nIGxvbmcgbG9uZyBsb25nIGxv\r\n" +
> + "bmcgbG9uZyBsb25nIGxvbmcgdGV4dA==\r\n",
> + Base64.encodeBase64(
> + "some long long long long long long long long long long long long long long text"
> + .getBytes(), true ) );
> + }
> +
> + @Test
> + public void decodeBase64()
> + throws Exception
> + {
> + assertEquals( "test", Base64.decodeBase64( "dGVzdA==".getBytes() ) );
> + }
> +
> + @Test
> + public void isArrayByteBase64()
> + throws Exception
> + {
> + String valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
> + assertTrue( Base64.isArrayByteBase64( valid.getBytes() ) );
> + }
> +
> + private static void assertEquals( String expected , byte[] actual )
> + {
> + Assert.assertEquals(expected, new String(actual));
> + }
> +}
>
> Modified: maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml?rev=1127056&r1=1127055&r2=1127056&view=diff
> ==============================================================================
> --- maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml (original)
> +++ maven/sandbox/trunk/plexus-utils-commons-bridge/pom.xml Tue May 24 13:57:35 2011
> @@ -51,6 +51,11 @@ under the License.
> <version>1.3.2</version>
> </dependency>
> <dependency>
> + <groupId>commons-codec</groupId>
> + <artifactId>commons-codec</artifactId>
> + <version>1.4</version>
> + </dependency>
> + <dependency>
> <groupId>org.codehaus.plexus</groupId>
> <artifactId>plexus-utils</artifactId>
> <version>2.0.7</version>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org