You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by po...@apache.org on 2019/05/30 18:50:24 UTC

[creadur-rat] branch trunk updated: RAT-244: Update to non-deprecated ANT-Buildfilerule

This is an automated email from the ASF dual-hosted git repository.

pottlinger pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ce6d742  RAT-244: Update to non-deprecated ANT-Buildfilerule
ce6d742 is described below

commit ce6d74249e215d88568363e8cc24eef7dcd261cf
Author: Hugo Hirsch <gi...@hugo-hirsch.de>
AuthorDate: Thu May 30 20:50:18 2019 +0200

    RAT-244: Update to non-deprecated ANT-Buildfilerule
---
 .../claim/impl/xml/SimpleXmlClaimReporter.java     | 17 ++++++-------
 .../java/org/apache/rat/mp/RatCheckMojoTest.java   |  2 +-
 .../rat/anttasks/AbstractRatAntTaskTest.java       | 19 ++++++++-------
 .../java/org/apache/rat/anttasks/ReportTest.java   | 28 ++++++++++++----------
 4 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java b/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
index bcf5224..e4da2ee 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
@@ -29,16 +29,13 @@ import java.io.IOException;
 import java.util.Calendar;
 
 public class SimpleXmlClaimReporter extends AbstractReport {
-    public static final String RAT_REPORT = "rat-report";
-    public static final String TIMESTAMP = "timestamp";
-    public static final String LICENSE_APPROVAL_PREDICATE = "license-approval";
-    public static final String LICENSE_FAMILY_PREDICATE = "license-family";
-    public static final String HEADER_SAMPLE_PREDICATE = "header-sample";
-    public static final String HEADER_TYPE_PREDICATE = "header-type";
-    public static final String FILE_TYPE_PREDICATE = "type";
-    public static final String ARCHIVE_TYPE_PREDICATE = "archive-type";
-    public static final String ARCHIVE_TYPE_UNREADABLE = "unreadable";
-    public static final String ARCHIVE_TYPE_READABLE = "readable";
+    private static final String RAT_REPORT = "rat-report";
+    private static final String TIMESTAMP = "timestamp";
+    private static final String LICENSE_APPROVAL_PREDICATE = "license-approval";
+    private static final String LICENSE_FAMILY_PREDICATE = "license-family";
+    private static final String HEADER_SAMPLE_PREDICATE = "header-sample";
+    private static final String HEADER_TYPE_PREDICATE = "header-type";
+    private static final String FILE_TYPE_PREDICATE = "type";
 
     private final IXmlWriter writer;
     private static final String NAME = "name";
diff --git a/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java b/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
index 4259ab9..49fcb69 100644
--- a/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
+++ b/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
@@ -282,7 +282,7 @@ public class RatCheckMojoTest extends AbstractMojoTestCase {
             f.set(null, Charset.forName(charset));
         } catch (Exception ex) {
             // This is for unittesting - there is no good reason not to rethrow
-            // it. This could be happening in JDK 9, where the unittests need
+            // it. This could be happening in JDK 9, where the unittests need to
             // run with the java.base module opened
             throw new RuntimeException(ex);
         }
diff --git a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
index aa45b07..3601240 100644
--- a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
+++ b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
@@ -17,16 +17,20 @@
 package org.apache.rat.anttasks;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
 import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
 
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.regex.Pattern;
 
-public abstract class AbstractRatAntTaskTest extends BuildFileTest {
+public abstract class AbstractRatAntTaskTest {
     private static final File tempDir = new File("target/anttasks");
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
     protected abstract File getAntFile();
 
@@ -34,20 +38,19 @@ public abstract class AbstractRatAntTaskTest extends BuildFileTest {
         return tempDir;
     }
 
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        configureProject(getAntFile().getPath());
+    @Before
+    public void setUp() {
+        buildRule.configureProject(getAntFile().getPath());
     }
 
     protected void assertLogDoesNotMatch(String pPattern) {
-        final String log = super.getLog();
+        final String log = buildRule.getLog();
         Assert.assertFalse("Log matches the pattern: " + pPattern + ", got " + log,
                 isMatching(pPattern, log));
     }
 
     protected void assertLogMatches(String pPattern) {
-        final String log = super.getLog();
+        final String log = buildRule.getLog();
         Assert.assertTrue("Log doesn't match string: " + pPattern + ", got " + log,
                 isMatching(pPattern, log));
     }
diff --git a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java
index 3d6688b..325d179 100644
--- a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java
+++ b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java
@@ -32,6 +32,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import org.apache.rat.document.impl.guesser.BinaryGuesser;
 import org.w3c.dom.Document;
 
+import static org.junit.Assert.*;
+
 public class ReportTest extends AbstractRatAntTaskTest {
     private static final File antFile = new File("src/test/resources/antunit/report-junit.xml").getAbsoluteFile();
 
@@ -41,7 +43,7 @@ public class ReportTest extends AbstractRatAntTaskTest {
     }
 
     public void testWithReportSentToAnt() throws Exception {
-        executeTarget("testWithReportSentToAnt");
+        buildRule.executeTarget("testWithReportSentToAnt");
         assertLogMatches("AL +\\Q" + getAntFileName() + "\\E");
     }
 
@@ -54,27 +56,27 @@ public class ReportTest extends AbstractRatAntTaskTest {
         if (reportFile.isFile() && !reportFile.delete()) {
             throw new IOException("Unable to remove report file " + reportFile);
         }
-        executeTarget("testWithReportSentToFile");
+        buildRule.executeTarget("testWithReportSentToFile");
         assertLogDoesNotMatch(alLine);
-        Assert.assertTrue("Expected report file " + reportFile, reportFile.isFile());
+        assertTrue("Expected report file " + reportFile, reportFile.isFile());
         assertFileMatches(reportFile, alLine);
     }
 
     public void testWithALUnknown() throws Exception {
-        executeTarget("testWithALUnknown");
+        buildRule.executeTarget("testWithALUnknown");
         assertLogDoesNotMatch("AL +\\Q" + getAntFileName() + "\\E");
         assertLogMatches("\\!\\?\\?\\?\\?\\? +\\Q" + getAntFileName() + "\\E");
     }
 
     public void testCustomMatcher() throws Exception {
-        executeTarget("testCustomMatcher");
+        buildRule.executeTarget("testCustomMatcher");
         assertLogDoesNotMatch("AL +\\Q" + getAntFileName() + "\\E");
         assertLogMatches("EXMPL +\\Q" + getAntFileName() + "\\E");
     }
 
     public void testNoResources() throws Exception {
         try {
-            executeTarget("testNoResources");
+            buildRule.executeTarget("testNoResources");
             fail("Expected Exception");
         } catch (BuildException e) {
             final String expect = "You must specify at least one file";
@@ -85,7 +87,7 @@ public class ReportTest extends AbstractRatAntTaskTest {
 
     public void testNoLicenseMatchers() throws Exception {
         try {
-            executeTarget("testNoLicenseMatchers");
+            buildRule.executeTarget("testNoLicenseMatchers");
             fail("Expected Exception");
         } catch (BuildException e) {
             final String expect = "at least one license";
@@ -117,7 +119,7 @@ public class ReportTest extends AbstractRatAntTaskTest {
     }
 
     public void testAddLicenseHeaders() throws Exception {
-        executeTarget("testAddLicenseHeaders");
+        buildRule.executeTarget("testAddLicenseHeaders");
 
         final File origFile = new File("target/anttasks/it-sources/index.apt");
         final String origFirstLine = getFirstLine(origFile);
@@ -134,9 +136,9 @@ public class ReportTest extends AbstractRatAntTaskTest {
      */
     public void testISO88591() throws Exception {
         String origEncoding = overrideFileEncoding("ISO-8859-1");
-        executeTarget("testISO88591");
+        buildRule.executeTarget("testISO88591");
         overrideFileEncoding(origEncoding);
-        assertTrue("Log should contain the test umlauts", getLog().contains("\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF"));
+        assertTrue("Log should contain the test umlauts", buildRule.getLog().contains("\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF"));
     }
 
     /**
@@ -147,7 +149,7 @@ public class ReportTest extends AbstractRatAntTaskTest {
         String outputDir = System.getProperty("output.dir", "target/anttasks");
         String selftestOutput = System.getProperty("report.file", outputDir + "/selftest.report");
         String origEncoding = overrideFileEncoding("ISO-8859-1");
-        executeTarget("testISO88591WithReportFile");
+        buildRule.executeTarget("testISO88591WithReportFile");
         overrideFileEncoding(origEncoding);
         DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
         FileInputStream fis = new FileInputStream(selftestOutput);
@@ -183,7 +185,7 @@ public class ReportTest extends AbstractRatAntTaskTest {
             f.set(null, null);
         } catch (Exception ex) {
             // This is for unittesting - there is no good reason not to rethrow
-            // it. This could be happening in JDK 9, where the unittests need
+            // it. This could be happening in JDK 9, where the unittests need to
             // run with the java.base module opened
             throw new RuntimeException(ex);
         }
@@ -196,7 +198,7 @@ public class ReportTest extends AbstractRatAntTaskTest {
             f.set(null, Charset.forName(charset));
         } catch (Exception ex) {
             // This is for unittesting - there is no good reason not to rethrow
-            // it. This could be happening in JDK 9, where the unittests need
+            // it. This could be happening in JDK 9, where the unittests need to
             // run with the java.base module opened
             throw new RuntimeException(ex);
         }