Return-Path: X-Original-To: apmail-creadur-commits-archive@www.apache.org Delivered-To: apmail-creadur-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 742741033D for ; Sat, 7 Dec 2013 11:09:14 +0000 (UTC) Received: (qmail 9560 invoked by uid 500); 7 Dec 2013 11:09:13 -0000 Delivered-To: apmail-creadur-commits-archive@creadur.apache.org Received: (qmail 9532 invoked by uid 500); 7 Dec 2013 11:09:13 -0000 Mailing-List: contact commits-help@creadur.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@creadur.apache.org Delivered-To: mailing list commits@creadur.apache.org Received: (qmail 9525 invoked by uid 99); 7 Dec 2013 11:09:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Dec 2013 11:09:12 +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; Sat, 07 Dec 2013 11:09:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1FB80238883D; Sat, 7 Dec 2013 11:08:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@creadur.apache.org From: rdonkin@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131207110851.1FB80238883D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);