Author: bodewig
Date: Thu Oct 27 08:51:20 2011
New Revision: 1189680

URL: http://svn.apache.org/viewvc?rev=1189680&view=rev
Log:
Improve test-coverage for DumpArchiveEntry and fix a bug found by doing so

Added:
    
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
   (with props)
Modified:
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java?rev=1189680&r1=1189679&r2=1189680&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
 Thu Oct 27 08:51:20 2011
@@ -232,8 +232,9 @@ public class DumpArchiveEntry implements
      */
     protected DumpArchiveEntry(String name, String simpleName, int ino,
                                TYPE type) {
-        this(name, simpleName);
         setType(type);
+        setName(name);
+        this.simpleName = simpleName;
         this.ino = ino;
         this.offset = 0;
     }

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java?rev=1189680&view=auto
==============================================================================
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
 Thu Oct 27 08:51:20 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.dump;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class DumpArchiveEntryTest {
+    @Test
+    public void publicNameAddsTrailingSlashForDirectories() {
+        DumpArchiveEntry ent = new DumpArchiveEntry("foo", "bar", -1,
+                                                    DumpArchiveEntry.TYPE
+                                                    .DIRECTORY);
+        assertEquals("bar", ent.getSimpleName());
+        assertEquals("foo", ent.getOriginalName());
+        assertEquals("foo/", ent.getName());
+    }
+
+    @Test
+    public void publicNameRemovesLeadingDotSlash() {
+        DumpArchiveEntry ent = new DumpArchiveEntry("./foo", "bar");
+        assertEquals("bar", ent.getSimpleName());
+        assertEquals("./foo", ent.getOriginalName());
+        assertEquals("foo", ent.getName());
+    }
+
+}
\ No newline at end of file

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to