incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r1402380 - /sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java
Date Fri, 26 Oct 2012 02:53:00 GMT
Author: ieb
Date: Fri Oct 26 02:52:59 2012
New Revision: 1402380

URL: http://svn.apache.org/viewvc?rev=1402380&view=rev
Log:
SLING-2149 Attempt to make the test classes build on JDK1.5 even if they dont run.

Modified:
    sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java

Modified: sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java?rev=1402380&r1=1402379&r2=1402380&view=diff
==============================================================================
--- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java
(original)
+++ sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java
Fri Oct 26 02:52:59 2012
@@ -235,8 +235,16 @@ public class SlingLogWriterTest extends 
         File protectedParent = new File(baseFile,"protected");
         protectedParent.mkdirs();
         File loggingParent = new File(protectedParent,"logging");
-        protectedParent.setExecutable(false);
-        protectedParent.setWritable(false);
+        try {
+            // these methods are JDK 1.6 and later so we have introspect to invoke
+            File.class.getMethod("setWritable", boolean.class).invoke(protectedParent, false);
+            File.class.getMethod("setExecutable", boolean.class).invoke(protectedParent,
false);
+        } catch ( Exception e ) {
+            e.printStackTrace();
+            if ( System.getProperty("java.version").startsWith("1.5") ) {
+                return; // cant perform this test on JDKs before 1.5
+            }
+        }
         try{
             assertFalse(protectedParent.canWrite());
             SlingLoggerWriter writer = createLogWriter(loggingParent.getAbsolutePath(), -1,
10);
@@ -246,8 +254,9 @@ public class SlingLogWriterTest extends 
             writer.append("Testing Stdout");
         } finally {
             try {
-                protectedParent.setExecutable(true);
-                protectedParent.setWritable(true);
+                // these methods are JDK 1.6 and later so we have introspect to invoke
+                File.class.getMethod("setWritable", boolean.class).invoke(loggingParent,
true);
+                File.class.getMethod("setExecutable", boolean.class).invoke(protectedParent,
true);
             } catch ( Exception e ) {
                 // no need.
             }
@@ -259,8 +268,16 @@ public class SlingLogWriterTest extends 
         File protectedParent = new File(baseFile,"protected");
         File loggingParent = new File(protectedParent,"logging");
         loggingParent.mkdirs();
-        loggingParent.setWritable(false);
-        protectedParent.setExecutable(false);
+        try {
+            // these methods are JDK 1.6 and later so we have introspect to invoke
+            File.class.getMethod("setWritable", boolean.class).invoke(loggingParent, false);
+            File.class.getMethod("setExecutable", boolean.class).invoke(protectedParent,
false);
+        } catch ( Exception e ) {
+            e.printStackTrace();
+            if ( System.getProperty("java.version").startsWith("1.5") ) {
+                return; // cant perform this test on JDKs before 1.5
+            }
+        }
         try {
             assertFalse(loggingParent.canWrite());
             SlingLoggerWriter writer = createLogWriter(loggingParent.getAbsolutePath(), -1,
10);
@@ -270,8 +287,9 @@ public class SlingLogWriterTest extends 
             writer.append("Testing Stdout");
         } finally {
             try {
-                protectedParent.setExecutable(true);
-                protectedParent.setWritable(true);
+                // these methods are JDK 1.6 and later so we have introspect to invoke
+                File.class.getMethod("setWritable", boolean.class).invoke(loggingParent,
true);
+                File.class.getMethod("setExecutable", boolean.class).invoke(protectedParent,
true);
             } catch ( Exception e ) {
                 // no need.
             }



Mime
View raw message