commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1617967 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/compressors/xz/ test/java/org/apache/commons/compress/compressors/ test/java/org/apache/commons/compress/compressors/xz/
Date Thu, 14 Aug 2014 15:07:19 GMT
Author: bodewig
Date: Thu Aug 14 15:07:18 2014
New Revision: 1617967

URL: http://svn.apache.org/r1617967
Log:
COMPRESS-285 add some tests that can only test the XZ is there case - wouldn't know how to
get rid of it during tests

Added:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
      - copied, changed from r1617881, commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java
Removed:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java
Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java?rev=1617967&r1=1617966&r2=1617967&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
Thu Aug 14 15:07:18 2014
@@ -171,4 +171,9 @@ public class XZUtils {
             cachedXZAvailability.set(hasXz ? CACHED_AVAILABLE : CACHED_UNAVAILABLE);
         }
     }
+
+    // only exists to support unit tests
+    static int getCachedXZAvailability() {
+        return cachedXZAvailability.get();
+    }
 }

Copied: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
(from r1617881, commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java)
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java?p2=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java&p1=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java&r1=1617881&r2=1617967&rev=1617967&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
Thu Aug 14 15:07:18 2014
@@ -16,12 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.compress.compressors;
+package org.apache.commons.compress.compressors.xz;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.compress.compressors.xz.XZUtils;
-
 public class XZUtilsTestCase extends TestCase {
 
     public void testIsCompressedFilename() {
@@ -76,4 +74,30 @@ public class XZUtilsTestCase extends Tes
         assertFalse(XZUtils.matches(data, 6));
     }
 
+    public void testCachingIsEnabledByDefaultAndXZIsPresent() {
+        assertEquals(1, XZUtils.getCachedXZAvailability());
+        assertTrue(XZUtils.isXZCompressionAvailable());
+    }
+
+    public void testCanTurnOffCaching() {
+        try {
+            XZUtils.setCacheXZAvailablity(false);
+            assertEquals(2, XZUtils.getCachedXZAvailability());
+            assertTrue(XZUtils.isXZCompressionAvailable());
+        } finally {
+            XZUtils.setCacheXZAvailablity(true);
+        }
+    }
+
+    public void testTurningOnCachingReEvaluatesAvailability() {
+        try {
+            XZUtils.setCacheXZAvailablity(false);
+            assertEquals(2, XZUtils.getCachedXZAvailability());
+            XZUtils.setCacheXZAvailablity(true);
+            assertEquals(1, XZUtils.getCachedXZAvailability());
+        } finally {
+            XZUtils.setCacheXZAvailablity(true);
+        }
+    }
+
 }



Mime
View raw message