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 D7E231041C for ; Tue, 26 Nov 2013 19:52:57 +0000 (UTC) Received: (qmail 12903 invoked by uid 500); 26 Nov 2013 19:52:57 -0000 Delivered-To: apmail-creadur-commits-archive@creadur.apache.org Received: (qmail 12874 invoked by uid 500); 26 Nov 2013 19:52:57 -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 12867 invoked by uid 99); 26 Nov 2013 19:52:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Nov 2013 19:52:57 +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; Tue, 26 Nov 2013 19:52:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5F287238889B; Tue, 26 Nov 2013 19:52:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1545797 - /creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java Date: Tue, 26 Nov 2013 19:52:32 -0000 To: commits@creadur.apache.org From: dennisl@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131126195232.5F287238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dennisl Date: Tue Nov 26 19:52:31 2013 New Revision: 1545797 URL: http://svn.apache.org/r1545797 Log: [RAT-155][RAT-156] Fix tests Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java?rev=1545797&r1=1545796&r2=1545797&view=diff ============================================================================== --- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java (original) +++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java Tue Nov 26 19:52:31 2013 @@ -33,6 +33,8 @@ import static org.junit.Assert.assertEqu import static org.junit.Assert.assertFalse; public class TestLicenceAppender { + private static final String FIRST_LICENSE_LINE = " Licensed to the Apache Software Foundation (ASF) under one"; + /** Used to ensure that temporary files have unq */ private Random random = new Random(); @@ -112,6 +114,28 @@ public class TestLicenceAppender { }; } + private static NewFileReader checkLines(final String firstLine, + final String secondLine, + final String thirdLine) { + return new NewFileReader() { + public void readFile(BufferedReader r) throws IOException { + String line = r.readLine(); + assertEquals("First line is incorrect", + firstLine, line); + if (secondLine != null) { + line = r.readLine(); + assertEquals("Second line is incorrect", + secondLine, line); + } + if (thirdLine != null) { + line = r.readLine(); + assertEquals("Third line is incorrect", + thirdLine, line); + } + } + }; + } + @Test public void addLicenceToUnknownFile() throws IOException { String filename = qualify("tmp" + random.nextLong() @@ -144,7 +168,8 @@ public class TestLicenceAppender { public void addLicenceToJava() throws IOException { String filename = "tmp.java"; final String firstLine = "package foo;"; - String secondLine = "/*"; + final String secondLine = ""; + final String thirdLine = "/*"; commonTestTemplate(filename, new FileCreator() { public void createFile(Writer writer) throws IOException { @@ -154,7 +179,7 @@ public class TestLicenceAppender { writer.write("}\n"); } }, - checkLines(firstLine, secondLine)); + checkLines(firstLine, secondLine, thirdLine)); } @Test @@ -175,7 +200,8 @@ public class TestLicenceAppender { public void addLicenceToXML() throws IOException { String filename = "tmp.xml"; final String firstLine = ""; - final String secondLine = "