rpms/jakarta-commons-codec/devel commons-codec-base64-chunking-regression.patch, NONE, 1.1 .cvsignore, 1.5, 1.6 sources, 1.3, 1.4 jakarta-commons-codec.spec, 1.23, 1.24 jakarta-commons-codec-addosgimanifest.patch, 1.2, NONE jakarta-commons-codec-1.3-buildscript.patch, 1.3, NONE

mbooth mbooth at fedoraproject.org
Sat Nov 7 11:53:12 UTC 2009


Author: mbooth

Update of /cvs/pkgs/rpms/jakarta-commons-codec/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13267/jakarta-commons-codec/devel

Modified Files:
	.cvsignore sources jakarta-commons-codec.spec 
Added Files:
	commons-codec-base64-chunking-regression.patch 
Removed Files:
	jakarta-commons-codec-addosgimanifest.patch 
	jakarta-commons-codec-1.3-buildscript.patch 
Log Message:
* Sat Nov 7 2009 Mat Booth <fedora at matbooth.co.uk> - 1.4-1
- Update to 1.4
- Rewrite spec file to build using upstream-prefered maven instead of ant
- Drop patch to add OSGi manifest (done automatically in the maven build)
- Install pom and add to maven dep-map
- Re-enable all tests

commons-codec-base64-chunking-regression.patch:
 java/org/apache/commons/codec/binary/Base64.java             |   19 ++-
 java/org/apache/commons/codec/binary/Base64InputStream.java  |    2 
 java/org/apache/commons/codec/binary/Base64OutputStream.java |    2 
 test/org/apache/commons/codec/binary/Base64Test.java         |   56 +++++++++--
 4 files changed, 64 insertions(+), 15 deletions(-)

--- NEW FILE commons-codec-base64-chunking-regression.patch ---
Index: src/test/org/apache/commons/codec/binary/Base64Test.java
===================================================================
--- src/test/org/apache/commons/codec/binary/Base64Test.java	(revision 830665)
+++ src/test/org/apache/commons/codec/binary/Base64Test.java	(working copy)
@@ -191,6 +191,23 @@
         base64 = new Base64(64, new byte[]{' ', '$', '\n', '\r', '\t'}); // OK
     }
 
+    public void testConstructorEncode() {
+
+        // This unit test was introduced for https://issues.apache.org/jira/browse/CODEC-89
+        // BUG:  new Base64().encode() appends a CRLF, and chunks results into 76 character lines
+
+        Base64 b64 = new Base64();
+        String longString = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+        longString = (longString + longString + longString + longString + longString);
+
+        assertTrue("string is long enough to test for no-chunking", longString.length() > (2 * 76));
+        byte[] data = StringUtils.getBytesUtf8(longString);
+
+        String result = StringUtils.newStringUtf8(b64.encode(data));
+        assertTrue("No carriage returns in result", result.indexOf('\r') < 0);
+        assertTrue("No line feeds in result", result.indexOf('\n') < 0);
+    }
+
     public void testConstructor_Int_ByteArray_Boolean() {
         Base64 base64 = new Base64(65, new byte[]{'\t'}, false);
         byte[] encoded = base64.encode(Base64TestData.DECODED);
@@ -309,13 +326,33 @@
 
     // encode/decode a large random array
     public void testEncodeDecodeRandom() {
+        Base64 b64 = new Base64();
         for (int i = 1; i < 5; i++) {
-            byte[] data = new byte[this.getRandom().nextInt(10000) + 1];
-            this.getRandom().nextBytes(data);
-            byte[] enc = Base64.encodeBase64(data);
+            byte[] data, enc, roundTrip;
+            data = new byte[this.getRandom().nextInt(10000) + 1];
+            this.getRandom().nextBytes(data);            
+
+            // static encodeBase64()
+            enc = Base64.encodeBase64(data);
             assertTrue(Base64.isArrayByteBase64(enc));
-            byte[] data2 = Base64.decodeBase64(enc);
-            assertTrue(Arrays.equals(data, data2));
+            roundTrip = Base64.decodeBase64(enc);
+            assertTrue(Arrays.equals(data, roundTrip));
+
+            // instance encode()
+            // Need to make sure there is no chunking (bug: CODEC-89).            
+            enc = b64.encode(data);
+            boolean containsChunkSeparator = false;
+            for (int j = 0; j < enc.length; j++) {
+                byte b = enc[j];
+                if (b == '\n' || b == '\r') {
+                    containsChunkSeparator = true;
+                    break;
+                }
+            }
+            assertFalse("instance encode() shouldn't chunk", containsChunkSeparator);
+            assertTrue(Base64.isArrayByteBase64(enc));
+            roundTrip = b64.decode(enc);
+            assertTrue(Arrays.equals(data, roundTrip));
         }
     }
 
@@ -506,6 +543,11 @@
     }
 
     public void testSingletons() {
+        // Run one test against instance encode()
+        Base64 b64 = new Base64();
+        assertEquals("AA==", new String(b64.encode(new byte[]{(byte) 0})));
+
+        // The rest of the tests are against the static encodeBase64():
         assertEquals("AA==", new String(Base64.encodeBase64(new byte[]{(byte) 0})));
         assertEquals("AQ==", new String(Base64.encodeBase64(new byte[]{(byte) 1})));
         assertEquals("Ag==", new String(Base64.encodeBase64(new byte[]{(byte) 2})));
@@ -980,13 +1022,13 @@
         byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray());  // for url-safe tests
 
         assertEquals("byteToString Hello World", "SGVsbG8gV29ybGQ=", base64.encodeToString(b1));
-        assertEquals("byteToString static Hello World", "SGVsbG8gV29ybGQ=\r\n", Base64.encodeBase64String(b1));
+        assertEquals("byteToString static Hello World", "SGVsbG8gV29ybGQ=", Base64.encodeBase64String(b1));
         assertEquals("byteToString \"\"", "", base64.encodeToString(b2));
         assertEquals("byteToString static \"\"", "", Base64.encodeBase64String(b2));
         assertEquals("byteToString null", null, base64.encodeToString(b3));
         assertEquals("byteToString static null", null, Base64.encodeBase64String(b3));
         assertEquals("byteToString UUID", "K/fMJwH+Q5e0nr7tWsxwkA==", base64.encodeToString(b4));
-        assertEquals("byteToString static UUID", "K/fMJwH+Q5e0nr7tWsxwkA==\r\n", Base64.encodeBase64String(b4));
+        assertEquals("byteToString static UUID", "K/fMJwH+Q5e0nr7tWsxwkA==", Base64.encodeBase64String(b4));
         assertEquals("byteToString static-url-safe UUID", "K_fMJwH-Q5e0nr7tWsxwkA", Base64.encodeBase64URLSafeString(b4));
     }
 
Index: src/java/org/apache/commons/codec/binary/Base64InputStream.java
===================================================================
--- src/java/org/apache/commons/codec/binary/Base64InputStream.java	(revision 830665)
+++ src/java/org/apache/commons/codec/binary/Base64InputStream.java	(working copy)
@@ -73,7 +73,7 @@
     public Base64InputStream(InputStream in, boolean doEncode) {
         super(in);
         this.doEncode = doEncode;
-        this.base64 = new Base64();
+        this.base64 = new Base64(Base64.CHUNK_SIZE);
     }
 
     /**
Index: src/java/org/apache/commons/codec/binary/Base64OutputStream.java
===================================================================
--- src/java/org/apache/commons/codec/binary/Base64OutputStream.java	(revision 830665)
+++ src/java/org/apache/commons/codec/binary/Base64OutputStream.java	(working copy)
@@ -72,7 +72,7 @@
     public Base64OutputStream(OutputStream out, boolean doEncode) {
         super(out);
         this.doEncode = doEncode;
-        this.base64 = new Base64();
+        this.base64 = new Base64(Base64.CHUNK_SIZE);
     }
 
     /**
Index: src/java/org/apache/commons/codec/binary/Base64.java
===================================================================
--- src/java/org/apache/commons/codec/binary/Base64.java	(revision 830665)
+++ src/java/org/apache/commons/codec/binary/Base64.java	(working copy)
@@ -68,6 +68,12 @@
     static final int CHUNK_SIZE = 76;
 
     /**
+     * A string constant to improve code readability when we set our line-length to zero
+     * (NO_CHUNKING). 
+     */
+    static final int NO_CHUNKING = 0;
+
+    /**
      * Chunk separator per RFC 2045 section 2.1.
      *
      * <p>
@@ -214,7 +220,7 @@
     /**
      * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
      * <p>
-     * When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE.
+     * When encoding the line length is 0 (NO_CHUNKING), and the encoding table is STANDARD_ENCODE_TABLE.
      * </p>
      * 
      * <p>
@@ -228,7 +234,7 @@
     /**
      * Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode.
      * <p>
-     * When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE.
+     * When encoding the line length is zero (NO_CHUNKING) and the encoding table is STANDARD_ENCODE_TABLE.
      * </p>
      * 
      * <p>
@@ -241,7 +247,7 @@
      * @since 1.4
      */
     public Base64(boolean urlSafe) {
-        this(CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe);
+        this(NO_CHUNKING, CHUNK_SEPARATOR, urlSafe);
     }
 
     /**
@@ -643,7 +649,8 @@
     }
 
     /**
-     * Encodes binary data using the base64 algorithm into 76 character blocks separated by CRLF.
+     * Encodes binary data using the base64 algoritthm.  The string output is written to a single
+     * line (does not contain CRLF).
      *
      * @param binaryData
      *            binary data to encode
@@ -651,7 +658,7 @@
      * @since 1.4
      */    
     public static String encodeBase64String(byte[] binaryData) {
-        return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
+        return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
     }
     
     /**
@@ -814,7 +821,7 @@
                 maxResultSize);
         }
                 
-        Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe);
+        Base64 b64 = isChunked ? new Base64(CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe) : new Base64(urlSafe);
         return b64.encode(binaryData);
     }
 


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/jakarta-commons-codec/devel/.cvsignore,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -p -r1.5 -r1.6
--- .cvsignore	7 Sep 2007 17:34:34 -0000	1.5
+++ .cvsignore	7 Nov 2009 11:53:11 -0000	1.6
@@ -1,11 +1 @@
-.classpath
-.clover
-.project
-CODEC_1_*.xml
-HEAD.xml
-dist
-junit*.properties
-maven.log
-pub
-target
-velocity.log
\ No newline at end of file
+commons-codec-1.4-src.tar.gz


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/jakarta-commons-codec/devel/sources,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -r1.3 -r1.4
--- sources	26 Apr 2007 00:19:38 -0000	1.3
+++ sources	7 Nov 2009 11:53:11 -0000	1.4
@@ -1 +1 @@
-79e00c8738aa947f0c2a068301eda808  commons-codec-1.3-src.tar.gz
+6d96f8134e12cdab105d4934b90cb993  commons-codec-1.4-src.tar.gz


Index: jakarta-commons-codec.spec
===================================================================
RCS file: /cvs/pkgs/rpms/jakarta-commons-codec/devel/jakarta-commons-codec.spec,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -r1.23 -r1.24
--- jakarta-commons-codec.spec	25 Jul 2009 03:47:57 -0000	1.23
+++ jakarta-commons-codec.spec	7 Nov 2009 11:53:11 -0000	1.24
@@ -1,183 +1,101 @@
-# Copyright (c) 2000-2007, JPackage Project
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the
-#    distribution.
-# 3. Neither the name of the JPackage Project nor the names of its
-#    contributors may be used to endorse or promote products derived
-#    from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-%define _with_gcj_support 1
-
-%define gcj_support %{?_with_gcj_support:1}%{!?_with_gcj_support:%{?_without_gcj_support:0}%{!?_without_gcj_support:%{?_gcj_support:%{_gcj_support}}%{!?_gcj_support:0}}}
-
-%define base_name  codec
-%define short_name commons-%{base_name}
-%define section    free
-
-Name:           jakarta-commons-codec
-Version:        1.3
-Release:        11.4%{?dist}
-Summary:        Implementations of common encoders and decoders
-License:        ASL 2.0
-Group:          Development/Libraries/Java
-Epoch:          0
-URL:            http://jakarta.apache.org/commons/codec/
-Source0:        commons-codec-%{version}-src.tar.gz
-# svn export http://svn.apache.org/repos/asf/jakarta/commons/proper/codec/tags/CODEC_1_3/
-# cd CODEC_1_3
-# tar czvf commons-codec-1.3-src.tar.gz .
-
-Patch0:         jakarta-commons-codec-1.3-buildscript.patch
-# Add OSGi manifest
-Patch1:         %{name}-addosgimanifest.patch
-BuildRequires:  jpackage-utils >= 0:1.6
-BuildRequires:  ant >= 0:1.6.2
-BuildRequires:  ant-junit
-BuildRequires:  junit
-BuildRequires:  java-javadoc
-%if ! %{gcj_support}
-BuildArch:      noarch
-%endif
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Provides:       %{short_name} = %{epoch}:%{version}-%{release}
-Obsoletes:      %{short_name} <= %{epoch}:%{version}-%{release}
-
-%if %{gcj_support}
-BuildRequires:          java-gcj-compat-devel
-Requires(post):         java-gcj-compat
-Requires(postun):       java-gcj-compat
-%endif
+%global short_name commons-codec
+
+# TODO - Drop "jakarta-" from the package name
+Name:          jakarta-%{short_name}
+Version:       1.4
+Release:       1%{?dist}
+Summary:       Implementations of common encoders and decoders
+Group:         Development/Libraries/Java
+License:       ASL 2.0
+URL:           http://commons.apache.org/codec/
+
+Source0:       http://mirrors.dedipower.com/ftp.apache.org/commons/codec/source/%{short_name}-%{version}-src.tar.gz
+
+# Fix a regression in Base64 chunking behaviour, see upstream bug:
+# https://issues.apache.org/jira/browse/CODEC-89
+#Patch0:        %{short_name}-base64-chunking-regression.patch
+
+BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch:     noarch
+
+BuildRequires: java-devel
+BuildRequires: jpackage-utils
+Requires:      java
+Requires:      jpackage-utils
+
+Provides:      %{short_name} = %{version}-%{release}
+Obsoletes:     %{short_name} <= %{version}-%{release}
 
 %description
 Commons Codec is an attempt to provide definitive implementations of
 commonly used encoders and decoders. Examples include Base64, Hex,
 Phonetic and URLs.
 
-%package        javadoc
-Summary:        Javadoc for %{name}
-Group:          Development/Documentation
-Requires:       java-javadoc
+%package       javadoc
+Summary:       Javadocs for %{name}
+Group:         Development/Documentation
+Requires:      %{name}-%{version}-%{release}
 
 %description    javadoc
-Javadoc for %{name}.
-
-# -----------------------------------------------------------------------------
+API documentation for %{name}.
 
 %prep
-%setup -q -c
-
-# FIXME Remove SoundexTest which is failing
-# and thus preventing the build to proceed.
-# This problem has been communicated upstream Bug 31096
-%patch0 -p1
-
-# Add OSGi manifest
-pushd src/conf
-%patch1 -p0
-popd
-
-#fixes eof encoding
-%{__sed} -i 's/\r//' LICENSE.txt
-%{__sed} -i 's/\r//' RELEASE-NOTES.txt
-
-# -----------------------------------------------------------------------------
+%setup -q -n %{short_name}-%{version}-src
 
 %build
-export CLASSPATH=$(build-classpath junit)
-perl -p -i -e 's|../LICENSE|LICENSE.txt|g' build.xml
-ant -Dbuild.sysclasspath=first \
-  -Dconf.home=src/conf \
-  -Dbuild.home=build \
-  -Dsource.home=src/java \
-  -Dtest.home=src/test \
-  -Ddist.home=dist \
-  -Dcomponent.title=%{short_name} \
-  -Dcomponent.version=%{version} \
-  -Dfinal.name=%{name}-%{version} \
-  -Dextension.name=%{short_name} \
-  test jar javadoc
+export MAVEN_REPO_LOCAL=$(pwd)/.m2/repository
+mkdir -p $MAVEN_REPO_LOCAL
 
-# -----------------------------------------------------------------------------
+mvn-jpp -Dmaven.repo.local=$MAVEN_REPO_LOCAL install javadoc:javadoc
 
 %install
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
 # jars
-mkdir -p $RPM_BUILD_ROOT%{_javadir}
-cp -p dist/%{name}-%{version}.jar $RPM_BUILD_ROOT%{_javadir}
-(cd $RPM_BUILD_ROOT%{_javadir} && for jar in *-%{version}*; do ln -sf ${jar} `echo $jar| sed  "s|jakarta-||g"`; done)
-(cd $RPM_BUILD_ROOT%{_javadir} && for jar in *-%{version}*; do ln -sf ${jar} `echo $jar| sed  "s|-%{version}||g"`; done)
-
-# javadoc
-mkdir -p $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
-cp -pr dist/docs/api/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
-ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name}
-
-# -----------------------------------------------------------------------------
-
-%if %{gcj_support}
-%{_bindir}/aot-compile-rpm
-%endif
+install -pD -T target/%{short_name}-%{version}.jar \
+  %{buildroot}%{_javadir}/%{short_name}-%{version}.jar
+(cd %{buildroot}%{_javadir} && for jar in *-%{version}.jar; do ln -sf ${jar} `echo $jar| sed "s|%{short_name}|%{name}|g"`; done)
+(cd %{buildroot}%{_javadir} && for jar in *-%{version}.jar; do ln -sf ${jar} `echo $jar| sed "s|-%{version}||g"`; done)
+
+# javadocs
+mkdir -p %{buildroot}%{_javadocdir}/%{name}-%{version}
+cp -pr target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name}-%{version}
+(cd %{buildroot}%{_javadocdir} && ln -sf %{name}-%{version} %{name})
+
+# pom
+install -pD -T -m 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{short_name}.pom
+%add_to_maven_depmap %{short_name} %{short_name} %{version} JPP %{short_name}
 
 %clean
-rm -rf $RPM_BUILD_ROOT
-
-# -----------------------------------------------------------------------------
+rm -rf %{buildroot}
 
-%if %{gcj_support}
 %post
-if [ -x %{_bindir}/rebuild-gcj-db ]
-then
-  %{_bindir}/rebuild-gcj-db
-fi
-%endif
+%update_maven_depmap
 
-%if %{gcj_support}
 %postun
-if [ -x %{_bindir}/rebuild-gcj-db ]
-then
-  %{_bindir}/rebuild-gcj-db
-fi
-%endif
+%update_maven_depmap
 
 %files
-%defattr(0644,root,root,0755)
-%doc LICENSE.txt RELEASE-NOTES.txt
+%defattr(-,root,root,-)
+%doc LICENSE.txt NOTICE.txt RELEASE-NOTES*
+%{_mavendepmapfragdir}/*
+%{_mavenpomdir}/*
 %{_javadir}/*
 
-%if %{gcj_support}
-%attr(-,root,root) %{_libdir}/gcj/%{name}/jakarta-commons-codec-1.3.jar.*
-%endif
-
 %files javadoc
-%defattr(0644,root,root,0755)
-%doc %{_javadocdir}/%{name}-%{version}
-%doc %{_javadocdir}/%{name}
-# -----------------------------------------------------------------------------
+%defattr(-,root,root,-)
+%{_javadocdir}/%{name}-%{version}
+%{_javadocdir}/%{name}
 
 %changelog
+* Sat Nov 7 2009 Mat Booth <fedora at matbooth.co.uk> - 1.4-1
+- Update to 1.4
+- Rewrite spec file to build using upstream-prefered maven instead of ant
+- Drop patch to add OSGi manifest (done automatically in the maven build)
+- Install pom and add to maven dep-map
+- Re-enable all tests
+
 * Fri Jul 24 2009 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0:1.3-11.4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
 


--- jakarta-commons-codec-addosgimanifest.patch DELETED ---


--- jakarta-commons-codec-1.3-buildscript.patch DELETED ---




More information about the fedora-extras-commits mailing list