aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2012-05-28 15:50:35 +0000
committerVincent Hennebert <vhennebert@apache.org>2012-05-28 15:50:35 +0000
commit340025483a07776d56b655bbee3b402ba589a5b4 (patch)
tree9c896cfa4c93bc9bc750602db505840a728c9585
parenta438a377ef974181a4b0a71f9d399e31f654588b (diff)
downloadxmlgraphics-fop-340025483a07776d56b655bbee3b402ba589a5b4.tar.gz
xmlgraphics-fop-340025483a07776d56b655bbee3b402ba589a5b4.zip
Bugzilla #53296: Updated TTFinPS specific test cases to JUnit 4
Patch by Robert Meyer, applied with minor modifications git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript@1343299 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--test/java/org/apache/fop/fonts/EncodingModeTest.java53
-rw-r--r--test/java/org/apache/fop/fonts/EncodingModeTestCase.java8
-rw-r--r--test/java/org/apache/fop/fonts/FOPFontsTestSuite.java40
-rw-r--r--test/java/org/apache/fop/fonts/truetype/FontFileReaderTestCase.java (renamed from test/java/org/apache/fop/fonts/truetype/FontFileReaderTest.java)27
-rw-r--r--test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java (renamed from test/java/org/apache/fop/fonts/truetype/TTFFileTest.java)38
-rw-r--r--test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java (renamed from test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTest.java)11
-rw-r--r--test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java (renamed from test/java/org/apache/fop/fonts/truetype/TTFTableNameTest.java)12
-rw-r--r--test/java/org/apache/fop/render/ps/RenderPSTestSuite.java40
-rw-r--r--test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java (renamed from test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTest.java)17
-rw-r--r--test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java (renamed from test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTest.java)20
-rw-r--r--test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java (renamed from test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTest.java)18
-rw-r--r--test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java (renamed from test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTest.java)15
-rw-r--r--test/java/org/apache/fop/util/HexEncoderTestCase.java37
-rw-r--r--test/resources/fonts/ttf/DroidSansMono.LICENSE (renamed from test/resources/fonts/DroidSansMono.LICENSE)0
-rw-r--r--test/resources/fonts/ttf/DroidSansMono.ttfbin0 -> 78296 bytes
15 files changed, 178 insertions, 158 deletions
diff --git a/test/java/org/apache/fop/fonts/EncodingModeTest.java b/test/java/org/apache/fop/fonts/EncodingModeTest.java
deleted file mode 100644
index e240aea30..000000000
--- a/test/java/org/apache/fop/fonts/EncodingModeTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/* $Id$ */
-
-package org.apache.fop.fonts;
-
-import junit.framework.TestCase;
-
-/**
- * Tests the enum org.apache.fop.fonts.EncodingMode.
- */
-public class EncodingModeTest extends TestCase {
- /**
- * Test getName() - tests the getName() method returns the expected String.
- */
- public void testGetName() {
- assertEquals("auto", EncodingMode.AUTO.getName());
- assertEquals("single-byte", EncodingMode.SINGLE_BYTE.getName());
- assertEquals("cid", EncodingMode.CID.getName());
- }
-
- /**
- * Test getValue() - test that getValue() method returns the expected enum value when given
- * an appropriate String.
- */
- public void testGetValue() {
- assertEquals(EncodingMode.AUTO, EncodingMode.getValue("auto"));
- assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getValue("single-byte"));
- assertEquals(EncodingMode.CID, EncodingMode.getValue("cid"));
- try {
- // We expect this to fail
- assertEquals(EncodingMode.AUTO, EncodingMode.getValue("fail"));
- fail("Encoding mode fails to throw an appropriate exception");
- } catch (IllegalArgumentException e) {
- // PASS
- }
- }
-}
diff --git a/test/java/org/apache/fop/fonts/EncodingModeTestCase.java b/test/java/org/apache/fop/fonts/EncodingModeTestCase.java
index 5fd9b4f37..8cab9eb8b 100644
--- a/test/java/org/apache/fop/fonts/EncodingModeTestCase.java
+++ b/test/java/org/apache/fop/fonts/EncodingModeTestCase.java
@@ -23,6 +23,9 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
+/**
+ * Tests {@link EncodingMode}.
+ */
public class EncodingModeTestCase {
@Test
@@ -38,4 +41,9 @@ public class EncodingModeTestCase {
assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getValue("single-byte"));
assertEquals(EncodingMode.CID, EncodingMode.getValue("cid"));
}
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getValueMustCheckForIllegalArguments() {
+ EncodingMode.getValue("fail");
+ }
}
diff --git a/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java b/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java
index 618bdde22..8e1a0040d 100644
--- a/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java
+++ b/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java
@@ -19,36 +19,24 @@
package org.apache.fop.fonts;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-import org.apache.fop.fonts.truetype.FontFileReaderTest;
-import org.apache.fop.fonts.truetype.TTFFileTest;
-import org.apache.fop.fonts.truetype.TTFSubSetFileTest;
-import org.apache.fop.fonts.truetype.TTFTableNameTest;
+import org.apache.fop.fonts.truetype.FontFileReaderTestCase;
+import org.apache.fop.fonts.truetype.TTFFileTestCase;
+import org.apache.fop.fonts.truetype.TTFSubSetFileTestCase;
+import org.apache.fop.fonts.truetype.TTFTableNameTestCase;
/**
* A test suite designed for org.apache.fop.fonts.*
*/
+@RunWith(Suite.class)
+@SuiteClasses({
+ EncodingModeTestCase.class,
+ FontFileReaderTestCase.class,
+ TTFFileTestCase.class,
+ TTFSubSetFileTestCase.class,
+ TTFTableNameTestCase.class })
public final class FOPFontsTestSuite {
- /**
- * Constructor
- */
- private FOPFontsTestSuite() {
- }
- /**
- * Testing org.apache.fop.fonts.*
- * @return test
- */
- public static Test suite() {
- TestSuite testSuite = new TestSuite("Test suite for FOPs fonts classes");
- //$JUnit-BEGIN$
- testSuite.addTest(new TestSuite(EncodingModeTest.class));
- testSuite.addTest(new TestSuite(FontFileReaderTest.class));
- testSuite.addTest(new TestSuite(TTFFileTest.class));
- testSuite.addTest(new TestSuite(TTFSubSetFileTest.class));
- testSuite.addTest(new TestSuite(TTFTableNameTest.class));
- //$JUnit-END$
- return testSuite;
- }
}
diff --git a/test/java/org/apache/fop/fonts/truetype/FontFileReaderTest.java b/test/java/org/apache/fop/fonts/truetype/FontFileReaderTestCase.java
index 25d5be735..5c1fec175 100644
--- a/test/java/org/apache/fop/fonts/truetype/FontFileReaderTest.java
+++ b/test/java/org/apache/fop/fonts/truetype/FontFileReaderTestCase.java
@@ -25,12 +25,17 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* A test class for org.apache.fop.truetype.FontFileReader
*/
-public class FontFileReaderTest extends TestCase {
+public class FontFileReaderTestCase {
private FontFileReader fontReader;
private final InputStream in;
private final byte[] byteArray;
@@ -39,7 +44,7 @@ public class FontFileReaderTest extends TestCase {
* Constructor - initialises an array that only needs to be created once. It creates a byte[]
* of form { 0x00, 0x01, 0x02, 0x03..., 0xff};
*/
- public FontFileReaderTest() {
+ public FontFileReaderTestCase() {
byteArray = new byte[256];
for (int i = 0; i < 256; i++) {
byteArray[i] = (byte) i;
@@ -50,6 +55,7 @@ public class FontFileReaderTest extends TestCase {
/**
* sets up the test subject object for testing.
*/
+ @Before
public void setUp() {
try {
fontReader = new FontFileReader(in);
@@ -70,6 +76,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFByte()
* @throws IOException exception
*/
+ @Test
public void testReadTTFByte() throws IOException {
for (int i = 0; i < 256; i++) {
assertEquals((byte) i, fontReader.readTTFByte());
@@ -80,6 +87,7 @@ public class FontFileReaderTest extends TestCase {
* Test seekSet() - check that it moves to the correct position and enforce a failure case.
* @throws IOException exception
*/
+ @Test
public void testSeekSet() throws IOException {
fontReader.seekSet(10);
assertEquals(10, fontReader.readTTFByte());
@@ -95,6 +103,7 @@ public class FontFileReaderTest extends TestCase {
* Test skip() - check that it moves to the correct position and enforce a failure case.
* @throws IOException exception
*/
+ @Test
public void testSkip() throws IOException {
fontReader.skip(100);
assertEquals(100, fontReader.readTTFByte());
@@ -114,6 +123,7 @@ public class FontFileReaderTest extends TestCase {
* 3) test with a readTTFByte() (this moves the position by the size of the data being read)
* @throws IOException exception
*/
+ @Test
public void testGetCurrentPos() throws IOException {
fontReader.seekSet(10);
fontReader.skip(100);
@@ -125,6 +135,7 @@ public class FontFileReaderTest extends TestCase {
/**
* Test getFileSize()
*/
+ @Test
public void testGetFileSize() {
assertEquals(256, fontReader.getFileSize());
}
@@ -133,6 +144,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFUByte()
* @throws IOException exception
*/
+ @Test
public void testReadTTFUByte() throws IOException {
for (int i = 0; i < 256; i++) {
assertEquals(i, fontReader.readTTFUByte());
@@ -143,6 +155,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFShort() - Test positive and negative numbers (two's compliment).
* @throws IOException exception
*/
+ @Test
public void testReadTTFShort() throws IOException {
// 0x0001 = 1
assertEquals("Should have been 1 (0x0001)", 1, fontReader.readTTFShort());
@@ -158,6 +171,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFUShort() - Test positive and potentially negative numbers (two's compliment).
* @throws IOException exception
*/
+ @Test
public void testReadTTFUShort() throws IOException {
// 0x0001
assertEquals(1, fontReader.readTTFUShort());
@@ -174,6 +188,7 @@ public class FontFileReaderTest extends TestCase {
* and in both cases ensure that our current position isn't changed.
* @throws IOException exception
*/
+ @Test
public void testReadTTFShortWithArg() throws IOException {
// 0x6465
assertEquals(25701, fontReader.readTTFShort(100));
@@ -190,6 +205,7 @@ public class FontFileReaderTest extends TestCase {
* position and in both cases ensure that our current position isn't changed.
* @throws IOException exception
*/
+ @Test
public void testReadTTFUShortWithArg() throws IOException {
// 0x6465
assertEquals(25701, fontReader.readTTFUShort(100));
@@ -205,6 +221,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFLong()
* @throws IOException exception
*/
+ @Test
public void testReadTTFLong() throws IOException {
// 0x00010203
assertEquals(66051, fontReader.readTTFLong());
@@ -218,6 +235,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFULong()
* @throws IOException exception
*/
+ @Test
public void testReadTTFULong() throws IOException {
// 0x00010203
assertEquals(66051, fontReader.readTTFULong());
@@ -233,6 +251,7 @@ public class FontFileReaderTest extends TestCase {
* 2) A string not terminated with a null (we expect this to throw an EOFException)
* @throws IOException exception
*/
+ @Test
public void testReadTTFString() throws IOException {
byte[] strByte = {(byte)'t', (byte)'e', (byte)'s', (byte)'t', 0x00};
fontReader = new FontFileReader(new ByteArrayInputStream(strByte));
@@ -252,6 +271,7 @@ public class FontFileReaderTest extends TestCase {
* Test readTTFString(int arg)
* @throws IOException exception
*/
+ @Test
public void testReadTTFStringIntArg() throws IOException {
byte[] strByte = {(byte)'t', (byte)'e', (byte)'s', (byte)'t'};
fontReader = new FontFileReader(new ByteArrayInputStream(strByte));
@@ -276,6 +296,7 @@ public class FontFileReaderTest extends TestCase {
* Test getBytes()
* @throws IOException exception
*/
+ @Test
public void testGetBytes() throws IOException {
byte[] retrievedBytes = fontReader.getBytes(0, 256);
assertTrue(Arrays.equals(byteArray, retrievedBytes));
diff --git a/test/java/org/apache/fop/fonts/truetype/TTFFileTest.java b/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
index ccc12d991..d490a3d5d 100644
--- a/test/java/org/apache/fop/fonts/truetype/TTFFileTest.java
+++ b/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
@@ -22,14 +22,18 @@ package org.apache.fop.fonts.truetype;
import java.io.IOException;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
/**
* Class for testing org.apache.fop.fonts.truetype.TTFFile
*/
-public class TTFFileTest extends TestCase {
+public class TTFFileTestCase {
// We only want to initialize the FontFileReader once (for performance reasons)
/** The truetype font file (DejaVuLGCSerif) */
protected final TTFFile dejavuTTFFile;
@@ -45,12 +49,12 @@ public class TTFFileTest extends TestCase {
* Constructor initialises FileFontReader to
* @throws IOException exception
*/
- public TTFFileTest() throws IOException {
+ public TTFFileTestCase() throws IOException {
dejavuTTFFile = new TTFFile();
- dejavuReader = new FontFileReader("test/resources/fonts/DejaVuLGCSerif.ttf");
+ dejavuReader = new FontFileReader("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
dejavuTTFFile.readFont(dejavuReader);
droidmonoTTFFile = new TTFFile();
- droidmonoReader = new FontFileReader("test/resources/fonts/DroidSansMono.ttf");
+ droidmonoReader = new FontFileReader("test/resources/fonts/ttf/DroidSansMono.ttf");
droidmonoTTFFile.readFont(droidmonoReader);
}
@@ -58,6 +62,7 @@ public class TTFFileTest extends TestCase {
* Test convertTTFUnit2PDFUnit() - The units per em retrieved reading the HEAD table from
* the font file. (DroidSansMono has the same units per em as DejaVu so no point testing it)
*/
+ @Test
public void testConvertTTFUnit2PDFUnit() {
// DejaVu has 2048 units per em (PDF works in millipts, thus the 1000)
// test rational number
@@ -77,6 +82,7 @@ public class TTFFileTest extends TestCase {
* Test checkTTC()
* @throws IOException exception
*/
+ @Test
public void testCheckTTC() throws IOException {
// DejaVu is not a TTC, thus this returns true
assertTrue(dejavuTTFFile.checkTTC(""));
@@ -90,6 +96,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getAnsiKerning() - Tests values retrieved from the kern table in the font file.
*/
+ @Test
public void testGetAnsiKerning() {
Map<Integer, Map<Integer, Integer>> ansiKerning = dejavuTTFFile.getKerning();
if (ansiKerning.isEmpty()) {
@@ -116,6 +123,7 @@ public class TTFFileTest extends TestCase {
* 3) The caps height in the OS/2 table
* Tests values retrieved from analysing the font file.
*/
+ @Test
public void testGetCapHeight() {
// DejaVu doesn't have the PCLT table and so these have to be guessed
// The height is approximated to be the height of the "H" which for
@@ -130,6 +138,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getCharSetName() - check that it returns "WinAnsiEncoding".
*/
+ @Test
public void testGetCharSetName() {
assertTrue("WinAnsiEncoding".equals(dejavuTTFFile.getCharSetName()));
assertTrue("WinAnsiEncoding".equals(droidmonoTTFFile.getCharSetName()));
@@ -139,6 +148,7 @@ public class TTFFileTest extends TestCase {
* Test getCharWidth() - Test values retrieved from the metrics in the glyf table in
* the font file.
*/
+ @Test
public void testGetCharWidth() {
// Arbitrarily test a few values:
// The width of "H" (Unicode index 0x0048) is 1786
@@ -164,6 +174,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getFamilyNames() - Test value retrieved from the name table in the font file.
*/
+ @Test
public void testGetFamilyNames() {
assertEquals(1, dejavuTTFFile.getFamilyNames().size());
for (String name : dejavuTTFFile.getFamilyNames()) {
@@ -178,6 +189,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getFirstChar() - TODO: implement a more intelligent test here.
*/
+ @Test
public void testGetFirstChar() {
// Not really sure how to test this intelligently
assertEquals(0, dejavuTTFFile.getFirstChar());
@@ -187,6 +199,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getFlags() - Test values retrieved from the POST table in the font file.
*/
+ @Test
public void testGetFlags() {
/* DejaVu flags are:
* italic angle = 0
@@ -214,6 +227,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getFontBBox() - Test values retrieved from values in the HEAD table in the font file.
*/
+ @Test
public void testGetFontBBox() {
int[] bBox = dejavuTTFFile.getFontBBox();
/*
@@ -238,6 +252,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getFullName() - Test value retrieved from the name table in the font file.
*/
+ @Test
public void testGetFullName() {
assertEquals("DejaVu LGC Serif", dejavuTTFFile.getFullName());
assertEquals("Droid Sans Mono", droidmonoTTFFile.getFullName());
@@ -246,6 +261,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getGlyphName - Test value retrieved from the POST table in the font file.
*/
+ @Test
public void testGetGlyphName() {
assertEquals("H", dejavuTTFFile.getGlyphName(43));
assertEquals("H", droidmonoTTFFile.getGlyphName(43));
@@ -254,6 +270,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getItalicAngle() - Test value retrieved from the POST table in the font file.
*/
+ @Test
public void testGetItalicAngle() {
assertEquals("0", dejavuTTFFile.getItalicAngle());
assertEquals("0", droidmonoTTFFile.getItalicAngle());
@@ -262,6 +279,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getKerning() - Test values retrieved from the kern table in the font file.
*/
+ @Test
public void testGetKerning() {
Map<Integer, Map<Integer, Integer>> kerning = dejavuTTFFile.getKerning();
if (kerning.isEmpty()) {
@@ -282,6 +300,7 @@ public class TTFFileTest extends TestCase {
/**
* Test lastChar() - TODO: implement a more intelligent test
*/
+ @Test
public void testLastChar() {
assertEquals(0xff, dejavuTTFFile.getLastChar());
assertEquals(0xff, droidmonoTTFFile.getLastChar());
@@ -293,6 +312,7 @@ public class TTFFileTest extends TestCase {
* 2) Fall back to values from the OS/2 table
* Test values retrieved from the font file.
*/
+ @Test
public void testGetLowerCaseAscent() {
assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1556),
dejavuTTFFile.getLowerCaseAscent());
@@ -304,6 +324,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getPostScriptName() - Test values retrieved from the post table in the font file.
*/
+ @Test
public void testGetPostScriptName() {
assertEquals(PostScriptVersion.V2, dejavuTTFFile.getPostScriptVersion());
assertEquals(PostScriptVersion.V2, droidmonoTTFFile.getPostScriptVersion());
@@ -312,6 +333,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getStemV() - Undefined.
*/
+ @Test
public void testGetStemV() {
// Undefined
assertEquals("0", dejavuTTFFile.getStemV());
@@ -321,6 +343,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getSubFamilyName() - Test values retrieved from the name table in the font file.
*/
+ @Test
public void testGetSubFamilyName() {
assertEquals("Book", dejavuTTFFile.getSubFamilyName());
assertEquals("Regular", droidmonoTTFFile.getSubFamilyName());
@@ -336,6 +359,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getWeightClass() - Test value retrieved from the OS/2 table in the font file.
*/
+ @Test
public void testGetWeightClass() {
// Retrieved from OS/2 table
assertEquals(400, dejavuTTFFile.getWeightClass());
@@ -345,6 +369,7 @@ public class TTFFileTest extends TestCase {
/**
* Test getWidths() - Test values retrieved from the hmtx table in the font file.
*/
+ @Test
public void testGetWidths() {
int[] widths = dejavuTTFFile.getWidths();
// using the width of 'A' index = 36
@@ -366,6 +391,7 @@ public class TTFFileTest extends TestCase {
* Fall back:
* 3) The xheight in the OS/2 table.
*/
+ @Test
public void testGetXHeight() {
// Since there's no PCLT table, the height of 'x' is used for both DejaVu and DroidSansMono
assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1064), dejavuTTFFile.getXHeight());
@@ -375,6 +401,7 @@ public class TTFFileTest extends TestCase {
/**
* Test isCFF() - TODO: add test for a CFF font.
*/
+ @Test
public void testIsCFF() {
// Neither DejaVu nor DroidSansMono are a compact format font
assertEquals(false, dejavuTTFFile.isCFF());
@@ -384,6 +411,7 @@ public class TTFFileTest extends TestCase {
/**
* Test isEmbeddable() - Test value retrieved from the OS/2 table in the font file.
*/
+ @Test
public void testIsEmbeddable() {
// Dejavu and DroidSansMono are both embeddable
assertEquals(true, dejavuTTFFile.isEmbeddable());
diff --git a/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTest.java b/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java
index b0ced70e8..16bedad8d 100644
--- a/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTest.java
+++ b/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java
@@ -24,18 +24,23 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
/**
* This class tests TTFSubSetFile
* TODO: Test with more than just a single font
*/
-public class TTFSubSetFileTest extends TTFFileTest {
+public class TTFSubSetFileTestCase extends TTFFileTestCase {
private TTFSubSetFile ttfSubset;
private byte[] subset;
/**
* Constructor
* @throws IOException exception
*/
- public TTFSubSetFileTest() throws IOException {
+ public TTFSubSetFileTestCase() throws IOException {
super();
}
@@ -43,6 +48,7 @@ public class TTFSubSetFileTest extends TTFFileTest {
* setUp()
* @exception IOException file read error
*/
+ @Before
public void setUp() throws IOException {
ttfSubset = new TTFSubSetFile();
Map<Integer, Integer> glyphs = new HashMap<Integer, Integer>();
@@ -58,6 +64,7 @@ public class TTFSubSetFileTest extends TTFFileTest {
* create a cmap table, and so the font doesn't contain ALL of the mandatory tables.
* @throws IOException exception
*/
+ @Test
public void testReadFont3Args() throws IOException {
ByteArrayInputStream byteArray = new ByteArrayInputStream(subset);
diff --git a/test/java/org/apache/fop/fonts/truetype/TTFTableNameTest.java b/test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java
index 224dad8a3..0a2eec544 100644
--- a/test/java/org/apache/fop/fonts/truetype/TTFTableNameTest.java
+++ b/test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java
@@ -19,18 +19,23 @@
package org.apache.fop.fonts.truetype;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* This class tests the enum org.apache.fop.fonts.truetype.TTFTableName
*
*/
-public class TTFTableNameTest extends TestCase {
+public class TTFTableNameTestCase {
/**
* Test getName() - tests that the getName() method returns the expected String as expected in
* the Directory Table.
* @exception IllegalAccessException error
*/
+ @Test
public void testGetName() throws IllegalAccessException {
assertEquals("dirTable", TTFTableName.DIRECTORY_TABLE.getName());
assertEquals("EBDT", TTFTableName.EBDT.getName());
@@ -71,6 +76,7 @@ public class TTFTableNameTest extends TestCase {
* TTFTableNames value when it is given a String (name of a table).
* @exception IllegalAccessException error
*/
+ @Test
public void testGetValue() throws IllegalAccessException {
assertEquals(TTFTableName.EBDT, TTFTableName.getValue("EBDT"));
assertEquals(TTFTableName.EBLC, TTFTableName.getValue("EBLC"));
@@ -107,6 +113,7 @@ public class TTFTableNameTest extends TestCase {
* objects and comparing their hash-codes.
* @exception IllegalAccessException error
*/
+ @Test
public void testHashCode() throws IllegalAccessException {
TTFTableName a = TTFTableName.getValue("testObject");
TTFTableName b = TTFTableName.getValue("testObject");
@@ -124,6 +131,7 @@ public class TTFTableNameTest extends TestCase {
* 5) check it fails if you put in a null value
* @throws IllegalAccessException error
*/
+ @Test
public void testEquals() throws IllegalAccessException {
// Reflexivity
TTFTableName a = TTFTableName.getValue("test");
diff --git a/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java b/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java
index 6052faeb5..2e15bf91f 100644
--- a/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java
+++ b/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java
@@ -19,37 +19,25 @@
package org.apache.fop.render.ps;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-import org.apache.fop.render.ps.fonts.PSTTFGeneratorTest;
-import org.apache.fop.render.ps.fonts.PSTTFGlyphOutputStreamTest;
-import org.apache.fop.render.ps.fonts.PSTTFOutputStreamTest;
-import org.apache.fop.render.ps.fonts.PSTTFTableOutputStreamTest;
+import org.apache.fop.render.ps.fonts.PSTTFGeneratorTestCase;
+import org.apache.fop.render.ps.fonts.PSTTFGlyphOutputStreamTestCase;
+import org.apache.fop.render.ps.fonts.PSTTFOutputStreamTestCase;
+import org.apache.fop.render.ps.fonts.PSTTFTableOutputStreamTestCase;
/**
* A test Suite for org.apache.fop.render.ps.*
*/
+@RunWith(Suite.class)
+@SuiteClasses({
+ PSTTFGeneratorTestCase.class,
+ PSTTFOutputStreamTestCase.class,
+ PSTTFGlyphOutputStreamTestCase.class,
+ PSTTFTableOutputStreamTestCase.class
+})
public final class RenderPSTestSuite {
- /**
- * Constructor.
- */
- private RenderPSTestSuite() {
- }
-
- /**
- * Testing org.apache.fop.render.ps.*
- * @return test
- */
- public static Test suite() {
- TestSuite suite = new TestSuite();
- //$JUnit-BEGIN$
- suite.addTest(new TestSuite(PSTTFGeneratorTest.class));
- suite.addTest(new TestSuite(PSTTFOutputStreamTest.class));
- suite.addTest(new TestSuite(PSTTFGlyphOutputStreamTest.class));
- suite.addTest(new TestSuite(PSTTFTableOutputStreamTest.class));
- //$JUnit-END$
- return suite;
- }
}
diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTest.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java
index fd3d98c98..f7f311ff8 100644
--- a/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTest.java
+++ b/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java
@@ -22,14 +22,19 @@ package org.apache.fop.render.ps.fonts;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.xmlgraphics.ps.PSGenerator;
/**
* The test class for org.apache.fop.render.ps.fonts.PSGenerator
*/
-public class PSTTFGeneratorTest extends TestCase {
+public class PSTTFGeneratorTestCase {
private PSTTFGenerator ttfGen;
private ByteArrayOutputStream out = new ByteArrayOutputStream();
private PSGenerator gen = new PSGenerator(out);
@@ -38,14 +43,14 @@ public class PSTTFGeneratorTest extends TestCase {
/**
* Constructor
*/
- public PSTTFGeneratorTest() {
+ public PSTTFGeneratorTestCase() {
byteArray = new byte[65536];
for (int i = 0; i < 65536; i++) {
byteArray[i] = (byte) i;
}
}
- @Override
+ @Before
public void setUp() {
ttfGen = new PSTTFGenerator(gen);
}
@@ -54,6 +59,7 @@ public class PSTTFGeneratorTest extends TestCase {
* Tests startString() - starts the string in an appropriate way for a PostScript file.
* @exception IOException write error
*/
+ @Test
public void testStartString() throws IOException {
ttfGen.startString();
assertEquals("<\n", out.toString());
@@ -63,6 +69,7 @@ public class PSTTFGeneratorTest extends TestCase {
* Test streamBytes() - tests that strings are written to file in the proper format.
* @throws IOException write error.
*/
+ @Test
public void testStreamBytes() throws IOException {
ttfGen.streamBytes(byteArray, 0, 16);
assertEquals("000102030405060708090A0B0C0D0E0F", out.toString());
@@ -86,6 +93,7 @@ public class PSTTFGeneratorTest extends TestCase {
* following string streamed to the PS document should be 80 chars long.
* @throws IOException file write error.
*/
+ @Test
public void testReset() throws IOException {
ttfGen.streamBytes(byteArray, 0, 40);
assertTrue(out.toString().matches("([0-9A-F]{80}\n)"));
@@ -99,6 +107,7 @@ public class PSTTFGeneratorTest extends TestCase {
* format, a "00" needs to be appended to the end of a string.
* @throws IOException file write error
*/
+ @Test
public void testEndString() throws IOException {
ttfGen.endString();
assertEquals("00\n> ", out.toString());
diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTest.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java
index 3bd93b1ba..82b4364c3 100644
--- a/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTest.java
+++ b/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java
@@ -19,25 +19,26 @@
package org.apache.fop.render.ps.fonts;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.mockito.InOrder;
-
/**
* Test class for PSTTFGlyphOutputStream
*/
-public class PSTTFGlyphOutputStreamTest extends TestCase {
+public class PSTTFGlyphOutputStreamTestCase {
private PSTTFGenerator mockGen;
private PSTTFGlyphOutputStream glyphOut;
- @Override
+ @Before
public void setUp() {
mockGen = mock(PSTTFGenerator.class);
glyphOut = new PSTTFGlyphOutputStream(mockGen);
@@ -48,6 +49,7 @@ public class PSTTFGlyphOutputStreamTest extends TestCase {
* PSTTFGenerator.
* @exception IOException file write error
*/
+ @Test
public void testStartGlyphStream() throws IOException {
glyphOut.startGlyphStream();
verify(mockGen).startString();
@@ -61,6 +63,7 @@ public class PSTTFGlyphOutputStreamTest extends TestCase {
* 3) if a glyph of size > PSTTFGenerator.MAX_BUFFER_SIZE is attempted, an exception is thrown.
* @throws IOException file write error.
*/
+ @Test
public void testStreamGlyph() throws IOException {
int byteArraySize = 10;
byte[] byteArray = new byte[byteArraySize];
@@ -98,6 +101,7 @@ public class PSTTFGlyphOutputStreamTest extends TestCase {
* is called.
* @throws IOException file write exception
*/
+ @Test
public void testEndGlyphStream() throws IOException {
glyphOut.endGlyphStream();
verify(mockGen).endString();
diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTest.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java
index f9b623f69..744f17f64 100644
--- a/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTest.java
+++ b/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java
@@ -19,27 +19,31 @@
package org.apache.fop.render.ps.fonts;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import java.io.IOException;
-
-import junit.framework.TestCase;
+import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.fonts.truetype.TTFGlyphOutputStream;
import org.apache.fop.fonts.truetype.TTFTableOutputStream;
-import org.apache.xmlgraphics.ps.PSGenerator;
/**
* Tests PSTTFOuputStream
*/
-public class PSTTFOutputStreamTest extends TestCase {
+public class PSTTFOutputStreamTestCase {
private PSGenerator gen;
private PSTTFOutputStream out;
/**
* Assigns an OutputStream to the PSGenerator.
*/
+ @Before
public void setUp() {
gen = mock(PSGenerator.class);
out = new PSTTFOutputStream(gen);
@@ -50,6 +54,7 @@ public class PSTTFOutputStreamTest extends TestCase {
* document (in this case with "/sfnts[")
* @throws IOException write exception.
*/
+ @Test
public void testStartFontStream() throws IOException {
out.startFontStream();
verify(gen).write("/sfnts[");
@@ -58,6 +63,7 @@ public class PSTTFOutputStreamTest extends TestCase {
/**
* Test getTableOutputStream() - we need to test that the inheritance model is properly obeyed.
*/
+ @Test
public void testGetTableOutputStream() {
TTFTableOutputStream tableOut = out.getTableOutputStream();
assertTrue(tableOut instanceof PSTTFTableOutputStream);
@@ -66,6 +72,7 @@ public class PSTTFOutputStreamTest extends TestCase {
/**
* Test getGlyphOutputStream() - we need to test that the inheritance model is properly obeyed.
*/
+ @Test
public void testGetGlyphOutputStream() {
TTFGlyphOutputStream glyphOut = out.getGlyphOutputStream();
assertTrue(glyphOut instanceof PSTTFGlyphOutputStream);
@@ -75,6 +82,7 @@ public class PSTTFOutputStreamTest extends TestCase {
* Test endFontStream()
* @exception IOException write error.
*/
+ @Test
public void testEndFontStream() throws IOException {
out.endFontStream();
verify(gen).writeln("] def");
diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTest.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java
index 41605ceb0..c20c3d8b1 100644
--- a/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTest.java
+++ b/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java
@@ -19,23 +19,23 @@
package org.apache.fop.render.ps.fonts;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-
import java.io.IOException;
-import junit.framework.TestCase;
-
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.InOrder;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+
/**
* Test class for unit testing PSTTFTableOutputStream
*/
-public class PSTTFTableOutputStreamTest extends TestCase {
+public class PSTTFTableOutputStreamTestCase {
private PSTTFGenerator mockGen;
private PSTTFTableOutputStream tableOut;
- @Override
+ @Before
public void setUp() {
mockGen = mock(PSTTFGenerator.class);
tableOut = new PSTTFTableOutputStream(mockGen);
@@ -53,6 +53,7 @@ public class PSTTFTableOutputStreamTest extends TestCase {
* are invoked.
* @throws IOException file write error.
*/
+ @Test
public void testStreamTable() throws IOException {
byte[] byteArray = new byte[PSTTFGenerator.MAX_BUFFER_SIZE * 3];
tableOut.streamTable(byteArray, 0, 10);
diff --git a/test/java/org/apache/fop/util/HexEncoderTestCase.java b/test/java/org/apache/fop/util/HexEncoderTestCase.java
index e6198e0ad..cb366abdf 100644
--- a/test/java/org/apache/fop/util/HexEncoderTestCase.java
+++ b/test/java/org/apache/fop/util/HexEncoderTestCase.java
@@ -19,20 +19,24 @@
package org.apache.fop.util;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
/**
* Test case for the conversion of characters into hex-encoded strings.
*/
-public class HexEncoderTestCase extends TestCase {
+public class HexEncoderTestCase {
- private static char successor(char d) {
- if (d == '9') {
- return 'A';
- } else if (d == 'F') {
- return '0';
- } else {
- return (char) (d + 1);
+ /**
+ * Tests that characters are properly encoded into hex strings.
+ */
+ @Test
+ public void testEncodeChar() {
+ char[] digits = new char[] {'0', '0', '0', '0'};
+ for (int c = 0; c <= 0xFFFF; c++) {
+ assertEquals(new String(digits), HexEncoder.encode((char) c));
+ increment(digits);
}
}
@@ -44,14 +48,13 @@ public class HexEncoderTestCase extends TestCase {
} while (digits[d] == '0' && d > 0);
}
- /**
- * Tests that characters are properly encoded into hex strings.
- */
- public void testEncodeChar() {
- char[] digits = new char[] {'0', '0', '0', '0'};
- for (int c = 0; c <= 0xFFFF; c++) {
- assertEquals(new String(digits), HexEncoder.encode((char) c));
- increment(digits);
+ private static char successor(char d) {
+ if (d == '9') {
+ return 'A';
+ } else if (d == 'F') {
+ return '0';
+ } else {
+ return (char) (d + 1);
}
}
diff --git a/test/resources/fonts/DroidSansMono.LICENSE b/test/resources/fonts/ttf/DroidSansMono.LICENSE
index 1a96dfde6..1a96dfde6 100644
--- a/test/resources/fonts/DroidSansMono.LICENSE
+++ b/test/resources/fonts/ttf/DroidSansMono.LICENSE
diff --git a/test/resources/fonts/ttf/DroidSansMono.ttf b/test/resources/fonts/ttf/DroidSansMono.ttf
new file mode 100644
index 000000000..4546611d4
--- /dev/null
+++ b/test/resources/fonts/ttf/DroidSansMono.ttf
Binary files differ