1 31 package test.pdfbox.pdfparser; 32 33 import java.io.ByteArrayInputStream ; 34 import java.io.IOException ; 35 import java.io.InputStream ; 36 37 import junit.framework.Test; 38 import junit.framework.TestCase; 39 import junit.framework.TestSuite; 40 41 import org.pdfbox.cos.COSName; 42 43 import org.pdfbox.pdfparser.BaseParser; 44 45 46 52 public class TestPDFParser extends TestCase 53 { 54 56 61 public TestPDFParser( String name ) 62 { 63 super( name ); 64 } 65 66 71 public static Test suite() 72 { 73 return new TestSuite( TestPDFParser.class ); 74 } 75 76 81 public static void main( String [] args ) 82 { 83 String [] arg = {TestPDFParser.class.getName() }; 84 junit.textui.TestRunner.main( arg ); 85 } 86 87 92 public void testCOSName() throws Exception 93 { 94 TestParser parser = new TestParser(new ByteArrayInputStream ( "/PANTONE#20116#20CV".getBytes() ) ); 95 COSName name = parser.parseCOSName(); 96 assertTrue("Failed to parse COSName",name.getName().equals( "PANTONE 116 CV" )); 97 98 } 99 100 103 private class TestParser extends BaseParser 104 { 105 110 public TestParser( InputStream input) throws IOException 111 { 112 super( input ); 113 } 114 115 121 public COSName parseCOSName() throws IOException 122 { 123 return super.parseCOSName(); 124 } 125 } 126 } | Popular Tags |