creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1549173 - /creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
Date Sun, 08 Dec 2013 19:57:29 GMT
Author: rdonkin
Date: Sun Dec  8 19:57:29 2013
New Revision: 1549173

URL: http://svn.apache.org/r1549173
Log:
Add test: testAddLicenceToJavaForced()

Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java?rev=1549173&r1=1549172&r2=1549173&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
Sun Dec  8 19:57:29 2013
@@ -874,4 +874,64 @@ public class LicenceAppenderTest {
 			}
 		});
 	}
+
+	/**
+	 * Test add licence to java forced.
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	@Test
+	public void testAddLicenceToJavaForced() throws IOException {
+		String filename = "tmp.java";
+		final String firstLine = "package foo;";
+		String secondLine = "/*";
+		commonTestTemplateForced(filename, new FileCreator() {
+			public void createFile(final Writer writer) throws IOException {
+				writer.write(firstLine + "\n");
+				writer.write("\n");
+				writer.write("public class test {\n");
+				writer.write(END_BRACKET);
+			}
+		}, checkLines(firstLine, secondLine));
+	}
+
+	/**
+	 * Common test template forced.
+	 * 
+	 * @param relativeName
+	 *            the relative name
+	 * @param creator
+	 *            the creator
+	 * @param reader
+	 *            the reader
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private static void commonTestTemplateForced(final String relativeName,
+			final FileCreator creator, final NewFileReader reader)
+			throws IOException {
+		String name = qualify(relativeName);
+		try {
+			createTestFile(name, creator);
+
+			ApacheV2LicenceAppender appender = new ApacheV2LicenceAppender();
+			appender.setForce(true);
+			appender.append(new File(name));
+
+			BufferedReader bufferedReader = null;
+			try {
+				bufferedReader = new BufferedReader(new FileReader(name
+						+ DOT_NEW));
+				reader.readFile(bufferedReader);
+			} finally {
+				if (bufferedReader != null) {
+					bufferedReader.close();
+				}
+			}
+		} finally {
+			tryToDelete(new File(name));
+			tryToDelete(new File(name + DOT_NEW));
+		}
+	}
 }



Mime
View raw message