diff options
Diffstat (limited to 'fop-core/src/test/java')
4 files changed, 40 insertions, 8 deletions
diff --git a/fop-core/src/test/java/org/apache/fop/afp/DataStreamTestCase.java b/fop-core/src/test/java/org/apache/fop/afp/DataStreamTestCase.java index 702126989..f178a815e 100644 --- a/fop-core/src/test/java/org/apache/fop/afp/DataStreamTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/afp/DataStreamTestCase.java @@ -31,11 +31,14 @@ import org.junit.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import org.apache.fop.afp.fonts.CharacterSet; import org.apache.fop.afp.fonts.CharacterSetBuilder; import org.apache.fop.afp.modca.InterchangeSet; import org.apache.fop.afp.modca.InvokeMediumMap; import org.apache.fop.afp.modca.PageGroup; +import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; +import org.apache.fop.afp.util.BinaryUtils; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.Typeface; import org.apache.fop.util.CharUtilities; @@ -105,6 +108,7 @@ public class DataStreamTestCase { ds.endDocument(); ByteArrayInputStream data = new ByteArrayInputStream(outStream.toByteArray()); data.skip(21); + data.skip(8); Assert.assertEquals((byte)data.read(), InvokeMediumMap.Type.MAP); Assert.assertEquals((byte)data.read(), InvokeMediumMap.Category.MEDIUM_MAP); } @@ -121,7 +125,35 @@ public class DataStreamTestCase { ds.endDocument(); ByteArrayInputStream data = new ByteArrayInputStream(outStream.toByteArray()); data.skip(21); + data.skip(8); Assert.assertEquals((byte)data.read(), InvokeMediumMap.Type.MAP); Assert.assertEquals((byte)data.read(), InvokeMediumMap.Category.MEDIUM_MAP); } + + @Test + public void testMandatoryTripletIsAddedToAFP() throws Exception { + ds = new DataStream(new Factory(), paintState, outStream); + ds.startDocument(); + ds.startPageGroup(); + ds.startPage(1, 1, 0, 1, 1); + ds.endPage(); + ds.endPageGroup(); + ds.endDocument(); + ByteArrayInputStream data = new ByteArrayInputStream(outStream.toByteArray()); + data.skip(17); //skipping the begin document data + Assert.assertEquals("Separation byte", 0x00, (byte) data.read()); + Assert.assertEquals("Sum of the length of triplets", 0x06, (byte) data.read()); + Assert.assertEquals("Length of the current triplet", 0x06, (byte) data.read()); + Assert.assertEquals("Byte code of the mandatory triplet", + FullyQualifiedNameTriplet.CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER, + (byte) data.read()); + Assert.assertEquals("Part 1 of the 0xFFFF byte. Sets the character set to All", + -1, (byte) data.read()); + Assert.assertEquals("Part 2 of the 0xFFFF byte. Sets the character set to All", + -1, (byte) data.read()); //the 0xFF byte is converted to -1 + Assert.assertEquals("Part 1 of the default code page id", + BinaryUtils.convert(500, 2)[0], (byte) data.read()); + Assert.assertEquals("Part 2 of the default code page id", + BinaryUtils.convert(500, 2)[1], (byte) data.read()); + } } diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java index 92bf91edb..29c478cc2 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java @@ -161,7 +161,7 @@ public class AFPPainterTestCase { public void testPresentationText() throws Exception { List<String> strings = new ArrayList<String>(); strings.add("test"); - Assert.assertEquals(writeText(strings), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(writeText(strings), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + "DESCRIPTOR PAGE\n" @@ -176,7 +176,7 @@ public class AFPPainterTestCase { for (int i = 0; i < 5000; i++) { strings.add("test"); } - Assert.assertEquals(writeText(strings), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(writeText(strings), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + "DESCRIPTOR PAGE\n" @@ -198,7 +198,7 @@ public class AFPPainterTestCase { for (int i = 0; i < 5000; i++) { strings.add("tes"); } - Assert.assertEquals(writeText(strings), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(writeText(strings), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + "DESCRIPTOR PAGE\n" @@ -287,7 +287,7 @@ public class AFPPainterTestCase { InputStream bis = new ByteArrayInputStream(os.toByteArray()); StringBuilder sb = new StringBuilder(); new AFPParser(false).read(bis, sb); - Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + "DESCRIPTOR PAGE\n" @@ -325,7 +325,7 @@ public class AFPPainterTestCase { InputStream bis = new ByteArrayInputStream(os.toByteArray()); StringBuilder sb = new StringBuilder(); new AFPParser(false).read(bis, sb); - Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + "DESCRIPTOR PAGE\n" @@ -392,7 +392,7 @@ public class AFPPainterTestCase { InputStream bis = new ByteArrayInputStream(os.toByteArray()); StringBuilder sb = new StringBuilder(); new AFPParser(false).read(bis, sb); - Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + "MAP CODED_FONT Triplets: " diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java index f875d80d8..4407c2af2 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java @@ -111,7 +111,7 @@ public class AFPTrueTypeTestCase { format += "END OBJECT_CONTAINER OC000001\n" + "END NAME_RESOURCE RES00001\n" + "END RESOURCE_GROUP RG000001\n" - + "BEGIN DOCUMENT DOC00001\n" + + "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE_GROUP PGP00001\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java index dc908eb59..9f60fd476 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java @@ -40,7 +40,7 @@ import org.apache.fop.render.intermediate.IFContext; public class PageOverlayTestCase { @Test public void testPageOverlay() throws Exception { - Assert.assertEquals(getPageOverlay(), "BEGIN DOCUMENT DOC00001\n" + Assert.assertEquals(getPageOverlay(), "BEGIN DOCUMENT DOC00001 Triplets: 0x01,\n" + "BEGIN PAGE_GROUP PGP00001\n" + "END PAGE_GROUP PGP00001\n" + "BEGIN PAGE PGN00001\n" |