creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1548858 - in /creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks: AbstractRatAntTaskTest.java ReportTest.java
Date Sat, 07 Dec 2013 11:08:51 GMT
Author: rdonkin
Date: Sat Dec  7 11:08:50 2013
New Revision: 1548858

URL: http://svn.apache.org/r1548858
Log:
Switch to org.junit; tidy up and reformat

Modified:
    creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
    creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java

Modified: creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java?rev=1548858&r1=1548857&r2=1548858&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/AbstractRatAntTaskTest.java
Sat Dec  7 11:08:50 2013
@@ -13,18 +13,17 @@
  * 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.rat.anttasks;
 
-import junit.framework.Assert;
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.util.FileUtils;
-
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.regex.Pattern;
 
+import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.util.FileUtils;
+
 public abstract class AbstractRatAntTaskTest extends BuildFileTest {
     private static final File tempDir = new File("target/anttasks");
 
@@ -39,15 +38,15 @@ public abstract class AbstractRatAntTask
         configureProject(getAntFile().getPath());
     }
 
-    protected void assertLogDoesntMatch(String pPattern) {
+    protected void assertLogDoesntMatch(final String pPattern) {
         final String log = super.getLog();
-        Assert.assertFalse("Log matches the pattern: " + pPattern + ", got " + log,
+        assertFalse("Log matches the pattern: " + pPattern + ", got " + log,
                 isMatching(pPattern, log));
     }
 
-    protected void assertLogMatches(String pPattern) {
+    protected void assertLogMatches(final String pPattern) {
         final String log = super.getLog();
-        Assert.assertTrue("Log doesn't match string: " + pPattern + ", got " + log,
+        assertTrue("Log doesn't match string: " + pPattern + ", got " + log,
                 isMatching(pPattern, log));
     }
 
@@ -55,13 +54,13 @@ public abstract class AbstractRatAntTask
         return Pattern.compile(pPattern).matcher(pValue).find();
     }
 
-    private String load(File pFile) throws IOException {
+    private String load(final File pFile) throws IOException {
         FileReader fr = new FileReader(pFile);
         try {
             final StringBuilder sb = new StringBuilder();
-            char[] buffer = new char[1024];
+            final char[] buffer = new char[1024];
             for (;;) {
-                int res = fr.read(buffer);
+                final int res = fr.read(buffer);
                 if (res == -1) {
                     fr.close();
                     fr = null;
@@ -76,12 +75,10 @@ public abstract class AbstractRatAntTask
         }
     }
 
-    protected void assertFileMatches(File pFile, String pPattern)
+    protected void assertFileMatches(final File pFile, final String pPattern)
             throws IOException {
         final String content = load(pFile);
-        Assert.assertTrue("File " + pFile
-                + " doesn't match the pattern " + pPattern
-                + ", got " + content,
-                isMatching(pPattern, content));
+        assertTrue("File " + pFile + " doesn't match the pattern " + pPattern
+                + ", got " + content, isMatching(pPattern, content));
     }
 }

Modified: creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java?rev=1548858&r1=1548857&r2=1548858&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java
Sat Dec  7 11:08:50 2013
@@ -24,10 +24,9 @@ import java.io.InputStreamReader;
 
 import org.apache.tools.ant.BuildException;
 
-import junit.framework.Assert;
-
 public class ReportTest extends AbstractRatAntTaskTest {
-    private static final File antFile = new File("src/test/resources/antunit/report-junit.xml").getAbsoluteFile();
+    private static final File antFile = new File(
+            "src/test/resources/antunit/report-junit.xml").getAbsoluteFile();
 
     @Override
     protected File getAntFile() {
@@ -41,16 +40,17 @@ public class ReportTest extends Abstract
 
     public void testWithReportSentToFile() throws Exception {
         final File reportFile = new File(getTempDir(), "selftest.report");
-        if(!getTempDir().mkdirs() && !getTempDir().isDirectory()) {
-            throw new IOException("Could not create temporary directory " + getTempDir());
+        if (!getTempDir().mkdirs() && !getTempDir().isDirectory()) {
+            throw new IOException("Could not create temporary directory "
+                    + getTempDir());
         }
         final String alLine = "AL +\\Q" + getAntFileName() + "\\E";
-        if (reportFile.isFile()  &&  !reportFile.delete()) {
+        if (reportFile.isFile() && !reportFile.delete()) {
             throw new IOException("Unable to remove report file " + reportFile);
         }
         executeTarget("testWithReportSentToFile");
         assertLogDoesntMatch(alLine);
-        Assert.assertTrue("Expected report file " + reportFile, reportFile.isFile());
+        assertTrue("Expected report file " + reportFile, reportFile.isFile());
         assertFileMatches(reportFile, alLine);
     }
 
@@ -70,10 +70,10 @@ public class ReportTest extends Abstract
         try {
             executeTarget("testNoResources");
             fail("Expected Exception");
-        } catch (BuildException e) {
+        } catch (final BuildException e) {
             final String expect = "You must specify at least one file";
-            assertTrue("Expected " + expect + ", got " + e.getMessage(),
-                       e.getMessage().indexOf(expect) != -1);
+            assertTrue("Expected " + expect + ", got " + e.getMessage(), e
+                    .getMessage().indexOf(expect) != -1);
         }
     }
 
@@ -81,10 +81,10 @@ public class ReportTest extends Abstract
         try {
             executeTarget("testNoLicenseMatchers");
             fail("Expected Exception");
-        } catch (BuildException e) {
+        } catch (final BuildException e) {
             final String expect = "at least one license";
-            assertTrue("Expected " + expect + ", got " + e.getMessage(),
-                       e.getMessage().indexOf(expect) != -1);
+            assertTrue("Expected " + expect + ", got " + e.getMessage(), e
+                    .getMessage().indexOf(expect) != -1);
         }
     }
 
@@ -92,7 +92,7 @@ public class ReportTest extends Abstract
         return getAntFile().getPath().replace('\\', '/');
     }
 
-    private String getFirstLine(File pFile) throws IOException {
+    private String getFirstLine(final File pFile) throws IOException {
         final FileInputStream fis = new FileInputStream(pFile);
         final InputStreamReader reader = new InputStreamReader(fis, "UTF8");
         final BufferedReader breader = new BufferedReader(reader);
@@ -108,7 +108,8 @@ public class ReportTest extends Abstract
         final String origFirstLine = getFirstLine(origFile);
         assertTrue(origFirstLine.indexOf("--") != -1);
         assertTrue(origFirstLine.indexOf("~~") == -1);
-        final File modifiedFile = new File("target/anttasks/it-sources/index.apt.new");
+        final File modifiedFile =
+                new File("target/anttasks/it-sources/index.apt.new");
         final String modifiedFirstLine = getFirstLine(modifiedFile);
         assertTrue(modifiedFirstLine.indexOf("--") == -1);
         assertTrue(modifiedFirstLine.indexOf("~~") != -1);



Mime
View raw message