You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2013/08/07 15:50:07 UTC
svn commit: r1511314 - in /commons/proper/compress/trunk/src/test:
java/org/apache/commons/compress/
java/org/apache/commons/compress/archivers/arj/ resources/
Author: ebourg
Date: Wed Aug 7 13:50:06 2013
New Revision: 1511314
URL: http://svn.apache.org/r1511314
Log:
Add some tests for ARJ archives
Added:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java (with props)
commons/proper/compress/trunk/src/test/resources/bla.arj (with props)
Modified:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java?rev=1511314&r1=1511313&r2=1511314&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java Wed Aug 7 13:50:06 2013
@@ -26,6 +26,7 @@ import java.io.IOException;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ar.ArArchiveInputStream;
+import org.apache.commons.compress.archivers.arj.ArjArchiveInputStream;
import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
@@ -73,6 +74,10 @@ public final class DetectArchiverTestCas
final ArchiveInputStream cpio = getStreamFor("bla.cpio");
assertNotNull(cpio);
assertTrue(cpio instanceof CpioArchiveInputStream);
+
+ final ArchiveInputStream arj = getStreamFor("bla.arj");
+ assertNotNull(arj);
+ assertTrue(arj instanceof ArjArchiveInputStream);
// Not yet implemented
// final ArchiveInputStream tgz = getStreamFor("bla.tgz");
Added: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java?rev=1511314&view=auto
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java (added)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java Wed Aug 7 13:50:06 2013
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.commons.compress.archivers.arj;
+
+import java.io.FileInputStream;
+
+import org.apache.commons.compress.AbstractTestCase;
+
+public class ArjArchiveInputStreamTest extends AbstractTestCase {
+
+ public void testArjUnarchive() throws Exception {
+ StringBuilder expected = new StringBuilder();
+ expected.append("test1.xml<?xml version=\"1.0\"?>\n");
+ expected.append("<empty/>test2.xml<?xml version=\"1.0\"?>\n");
+ expected.append("<empty/>\n");
+
+
+ ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.arj")));
+ ArjArchiveEntry entry;
+
+ StringBuilder result = new StringBuilder();
+ while ((entry = in.getNextEntry()) != null) {
+ result.append(entry.getName());
+ int tmp;
+ while ((tmp = in.read()) != -1) {
+ result.append((char) tmp);
+ }
+ }
+ in.close();
+ assertEquals(result.toString(), expected.toString());
+ }
+}
Propchange: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: commons/proper/compress/trunk/src/test/resources/bla.arj
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/bla.arj?rev=1511314&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/proper/compress/trunk/src/test/resources/bla.arj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream