Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6FC5D48F for ; Fri, 26 Oct 2012 02:53:48 +0000 (UTC) Received: (qmail 22460 invoked by uid 500); 26 Oct 2012 02:53:48 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 22417 invoked by uid 500); 26 Oct 2012 02:53:47 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 22391 invoked by uid 99); 26 Oct 2012 02:53:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2012 02:53:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2012 02:53:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 274E723888E3; Fri, 26 Oct 2012 02:53:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@sling.apache.org From: ieb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121026025300.274E723888E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. }