in = new java.io.BufferedInputStream(in);
try {
DSCParser parser = new DSCParser(in);
//The first form is for arrow_down_small.png (to be reused)
PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1");
PSResource helvetica = new PSResource(PSResource.TYPE_FONT, "Helvetica");
PSResource helveticaBold = new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold");
PSResource res;
DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES);
assertEquals(2, pages.getPageCount());
DSCCommentDocumentSuppliedResources supplied
= (DSCCommentDocumentSuppliedResources)gotoDSCComment(parser,
DSCConstants.DOCUMENT_SUPPLIED_RESOURCES);
Set resources = supplied.getResources();
assertEquals(4, resources.size());
assertTrue(resources.contains(form1));
assertTrue("Expected barcode.eps as supplied resource",
resources.contains(new PSResource(PSResource.TYPE_FILE,
"test/resources/images/barcode.eps")));
DSCCommentDocumentNeededResources needed
= (DSCCommentDocumentNeededResources)gotoDSCComment(parser,
DSCConstants.DOCUMENT_NEEDED_RESOURCES);
resources = needed.getResources();
assertEquals(2, resources.size());
assertTrue("Expected Helvetica as needed resource",
resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica")));
assertTrue("Expected Helvetica-Bold as needed resource",
resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold")));
//Some document structure checking
assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_DEFAULTS));
assertNotNull(gotoDSCComment(parser, DSCConstants.END_DEFAULTS));
assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PROLOG));
assertNotNull(gotoDSCComment(parser, DSCConstants.END_PROLOG));
assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_SETUP));
//Check includes for the two referenced base 14 fonts
DSCCommentIncludeResource include;
Collection strings = new java.util.HashSet(
Arrays.asList(new String[] {"Helvetica", "Helvetica-Bold"}));
for (int i = 0; i < 2; i++) {
include = (DSCCommentIncludeResource)gotoDSCComment(
parser, DSCConstants.INCLUDE_RESOURCE);
res = include.getResource();
assertEquals(PSResource.TYPE_FONT, res.getType());
strings.remove(res.getName());
}
assertEquals(0, strings.size());
checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE,
new PSResource(PSResource.TYPE_ENCODING, "WinAnsiEncoding"));
//Here, we encounter form 1 again
checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1);
assertNotNull(gotoDSCComment(parser, DSCConstants.END_SETUP));
//Now the actual pages begin
//---=== Page 1 ===---
DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE);
assertEquals(1, page.getPagePosition());
assertEquals(DSCAtend.class,
gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass());
assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP));
assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP));
PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2");
checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2);
assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER));
AbstractResourcesDSCComment pageResources;
pageResources = (AbstractResourcesDSCComment)gotoDSCComment(