assertEquals(DSCAtend.class,
gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass());
assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP));
assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP));
DSCCommentBeginDocument beginDocument;
beginDocument = (DSCCommentBeginDocument)gotoDSCComment(
parser, DSCConstants.BEGIN_DOCUMENT);
assertEquals("test/resources/images/barcode.eps",
beginDocument.getResource().getName());
DSCListener listener = new DefaultNestedDocumentHandler(null);
listener.processEvent(beginDocument, parser);
//And again (the barcode is generated twice)
beginDocument = (DSCCommentBeginDocument)gotoDSCComment(
parser, DSCConstants.BEGIN_DOCUMENT);
assertEquals("test/resources/images/barcode.eps",
beginDocument.getResource().getName());
listener.processEvent(beginDocument, parser);
assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER));
pageResources = (AbstractResourcesDSCComment)gotoDSCComment(
parser, DSCConstants.PAGE_RESOURCES);
resources = pageResources.getResources();
assertEquals(6, resources.size());
assertTrue(resources.contains(form1));
assertFalse(resources.contains(form2));
assertTrue(resources.contains(helvetica));
assertTrue(resources.contains(helveticaBold));
assertTrue(resources.contains(beginDocument.getResource()));
assertNotNull(gotoDSCComment(parser, DSCConstants.TRAILER));
//No headers in between, as they should have been put at the beginning of the file
assertEquals(DSCCommentEndOfFile.class, parser.nextEvent().asDSCComment().getClass());