creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1549417 - /creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java
Date Mon, 09 Dec 2013 05:45:39 GMT
Author: rdonkin
Date: Mon Dec  9 05:45:39 2013
New Revision: 1549417

URL: http://svn.apache.org/r1549417
Log:
Format Code.

Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java?rev=1549417&r1=1549416&r2=1549417&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java
Mon Dec  9 05:45:39 2013
@@ -32,85 +32,82 @@ import org.junit.Test;
 
 public class BinaryGuesserTest {
 
-    @Test
-    public void testMatches() {
-        assertThatDocumentIsBinary("image.png");
-        assertThatDocumentIsBinary("image.pdf");
-        assertThatDocumentIsBinary("image.gif");
-        assertThatDocumentIsBinary("image.giff");
-        assertThatDocumentIsBinary("image.tif");
-        assertThatDocumentIsBinary("image.tiff");
-        assertThatDocumentIsBinary("image.jpg");
-        assertThatDocumentIsBinary("image.jpeg");
-        assertThatDocumentIsBinary("image.exe");
-        assertThatDocumentIsBinary("Whatever.class");
-        assertThatDocumentIsBinary("data.dat");
-        assertThatDocumentIsBinary("libicudata.so.34.");
-    }
-
-    private void assertThatDocumentIsBinary(final String name) {
-        assertTrue(new BinaryGuesser().matches(new MockDocument(name)));
-    }
-
-    /**
-     * Used to swallow a MalformedInputException and return false because the
-     * encoding of the stream was different from the platform's default
-     * encoding.
-     * 
-     * @see "RAT-81"
-     */
-    @Test
-    public void binaryWithMalformedInputRAT81() throws Throwable {
-        Document doc =
-                new FileDocument(new File(
-                        "src/test/resources/binaries/UTF16_with_signature.xml"));
-        Reader r = null;
-        try {
-            final char[] dummy = new char[100];
-            r = doc.reader();
-            r.read(dummy);
-            // if we get here, the UTF-16 encoded file didn't throw
-            // any exception, try the UTF-8 encoded one
-            r.close();
-            doc =
-                    new FileDocument(
-                            new File(
-                                    "src/test/resources/binaries/UTF8_with_signature.xml"));
-            r = doc.reader();
-            r.read(dummy);
-            // still here? can't test on this platform
-            System.err.println("Skipping testBinaryWithMalformedInput");
-        } catch (final IOException e) {
-            if (r != null) {
-                r.close();
-            }
-            r = null;
-            assertTrue(new BinaryGuesser().matches(doc));
-        } finally {
-            if (r != null) {
-                r.close();
-            }
-        }
-    }
-
-    @Test
-    public void realBinaryContent() {
-        // This test is not accurate on all platforms
-        if (System.getProperty("file.encoding").startsWith("ANSI")) {
-            assertTrue(new BinaryGuesser().matches(new FileDocument(new File(
-            "src/test/resources/binaries/Image-png.not"))));
-        }
-    }
-
-    @Test
-    public void textualContent() {
-        assertFalse(new BinaryGuesser().matches(new FileDocument(new File(
-        "src/test/resources/elements/Text.txt"))));
-    }
-
-    @Test
-    public void emptyFile() {
-        assertFalse(new BinaryGuesser().matches(new FileDocument(new File(
-        "src/test/resources/elements/sub/Empty.txt"))));
-    }
+	@Test
+	public void testMatches() {
+		assertThatDocumentIsBinary("image.png");
+		assertThatDocumentIsBinary("image.pdf");
+		assertThatDocumentIsBinary("image.gif");
+		assertThatDocumentIsBinary("image.giff");
+		assertThatDocumentIsBinary("image.tif");
+		assertThatDocumentIsBinary("image.tiff");
+		assertThatDocumentIsBinary("image.jpg");
+		assertThatDocumentIsBinary("image.jpeg");
+		assertThatDocumentIsBinary("image.exe");
+		assertThatDocumentIsBinary("Whatever.class");
+		assertThatDocumentIsBinary("data.dat");
+		assertThatDocumentIsBinary("libicudata.so.34.");
+	}
+
+	private void assertThatDocumentIsBinary(final String name) {
+		assertTrue(new BinaryGuesser().matches(new MockDocument(name)));
+	}
+
+	/**
+	 * Used to swallow a MalformedInputException and return false because the
+	 * encoding of the stream was different from the platform's default
+	 * encoding.
+	 * 
+	 * @see "RAT-81"
+	 */
+	@Test
+	public void binaryWithMalformedInputRAT81() throws Throwable {
+		Document doc = new FileDocument(new File(
+				"src/test/resources/binaries/UTF16_with_signature.xml"));
+		Reader r = null;
+		try {
+			final char[] dummy = new char[100];
+			r = doc.reader();
+			r.read(dummy);
+			// if we get here, the UTF-16 encoded file didn't throw
+			// any exception, try the UTF-8 encoded one
+			r.close();
+			doc = new FileDocument(new File(
+					"src/test/resources/binaries/UTF8_with_signature.xml"));
+			r = doc.reader();
+			r.read(dummy);
+			// still here? can't test on this platform
+			System.err.println("Skipping testBinaryWithMalformedInput");
+		} catch (final IOException e) {
+			if (r != null) {
+				r.close();
+			}
+			r = null;
+			assertTrue(new BinaryGuesser().matches(doc));
+		} finally {
+			if (r != null) {
+				r.close();
+			}
+		}
+	}
+
+	@Test
+	public void realBinaryContent() {
+		// This test is not accurate on all platforms
+		if (System.getProperty("file.encoding").startsWith("ANSI")) {
+			assertTrue(new BinaryGuesser().matches(new FileDocument(new File(
+					"src/test/resources/binaries/Image-png.not"))));
+		}
+	}
+
+	@Test
+	public void textualContent() {
+		assertFalse(new BinaryGuesser().matches(new FileDocument(new File(
+				"src/test/resources/elements/Text.txt"))));
+	}
+
+	@Test
+	public void emptyFile() {
+		assertFalse(new BinaryGuesser().matches(new FileDocument(new File(
+				"src/test/resources/elements/sub/Empty.txt"))));
+	}
 }



Mime
View raw message