http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticDecoderTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticDecoderTest.java b/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticDecoderTest.java index b29d03c..d45d674 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticDecoderTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticDecoderTest.java @@ -25,553 +25,172 @@ import org.apache.pdfbox.jbig2.decoder.arithmetic.CX; import org.apache.pdfbox.jbig2.io.DefaultInputStreamFactory; import org.junit.*; -public class ArithmeticDecoderTest { +public class ArithmeticDecoderTest +{ - long[][] tracedata = { // - { - 0L, 0x8000L, 0x42638000L, 0x3D9C0000L - }, { - 0L, 0xAC02L, 0x84C70000L, 0x273A0000L - }, { - 0L, 0xF002L, 0xA18C7600L, 0x4E758800L - }, { - 0L, 0xD801L, 0x898B7600L, 0x4E758800L - }, { - 0L, 0xC000L, 0x718A7600L, 0x4E758800L - }, { - 0L, 0xA7FFL, 0x59897600L, 0x4E758800L - }, { - 0L, 0x8FFEL, 0x41887600L, 0x4E758800L - }, { - 0L, 0xEFFAL, 0x530EEC00L, 0x9CEB1000L - }, { - 0L, 0xE539L, 0x484DEC00L, 0x9CEB1000L - }, { - 0L, 0xDA78L, 0x3D8CEC00L, 0x9CEB1000L - }, { - 0L, 0xCFB7L, 0x32CBEC00L, 0x9CEB1000L - }, { - 0L, 0xC4F6L, 0x280AEC00L, 0x9CEB1000L - }, { - 0L, 0xBA35L, 0x1D49EC00L, 0x9CEB1000L - }, { - 0L, 0xAF74L, 0x1288EC00L, 0x9CEB1000L - }, { - 1L, 0xA4B3L, 0x07C7EC00L, 0x9CEB1000L - }, { - 0L, 0xAC10L, 0x7C7EC000L, 0x2F910000L - }, { - 0L, 0x900FL, 0x607DC000L, 0x2F910000L - }, { - 0L, 0xE81CL, 0x88F98000L, 0x5F220000L - }, { - 0L, 0xD21BL, 0x72F88000L, 0x5F220000L - }, { - 0L, 0xBC1AL, 0x5CF78000L, 0x5F220000L - }, { - 0L, 0xA619L, 0x46F68000L, 0x5F220000L - }, { - 0L, 0x9018L, 0x30F58000L, 0x5F220000L - }, { - 0L, 0xF42EL, 0x35E90000L, 0xBE440000L - }, { - 0L, 0xE32DL, 0x24E80000L, 0xBE440000L - }, { - 0L, 0xD22CL, 0x13E70000L, 0xBE440000L - }, { - 1L, 0xC12BL, 0x02E60000L, 0xBE440000L - }, { - 0L, 0x8808L, 0x1737E000L, 0x70D01800L - }, { - 1L, 0xE80EL, 0x066DC000L, 0xE1A03000L - }, { - 0L, 0x9008L, 0x336E0000L, 0x5C998000L - }, { - 0L, 0xF40EL, 0x3ADA0000L, 0xB9330000L - }, { - 0L, 0xE00DL, 0x26D90000L, 0xB9330000L - }, { - 1L, 0xCC0CL, 0x12D80000L, 0xB9330000L - }, { - 0L, 0xA008L, 0x96C70800L, 0x0940F000L - }, { - 0L, 0x8807L, 0x7EC60800L, 0x0940F000L - }, { - 0L, 0xE00CL, 0xCD8A1000L, 0x1281E000L - }, { - 0L, 0xCA0BL, 0xB7891000L, 0x1281E000L - }, { - 0L, 0xB40AL, 0xA1881000L, 0x1281E000L - }, { - 0L, 0x9E09L, 0x8B871000L, 0x1281E000L - }, { - 0L, 0x8808L, 0x75861000L, 0x1281E000L - }, { - 0L, 0xE40EL, 0xBF0A2000L, 0x2503C000L - }, { - 0L, 0xD00DL, 0xAB092000L, 0x2503C000L - }, { - 0L, 0xBC0CL, 0x97082000L, 0x2503C000L - }, { - 0L, 0xA80BL, 0x83072000L, 0x2503C000L - }, { - 0L, 0x940AL, 0x6F062000L, 0x2503C000L - }, { - 0L, 0x8009L, 0x5B052000L, 0x2503C000L - }, { - 0L, 0xD810L, 0x8E084000L, 0x4A078000L - }, { - 0L, 0xC60FL, 0x7C074000L, 0x4A078000L - }, { - 0L, 0xB40EL, 0x6A064000L, 0x4A078000L - }, { - 0L, 0xA20DL, 0x58054000L, 0x4A078000L - }, { - 0L, 0x900CL, 0x46044000L, 0x4A078000L - }, { - 0L, 0xFC16L, 0x68068000L, 0x940F0000L - }, { - 0L, 0xEB15L, 0x57058000L, 0x940F0000L - }, { - 0L, 0xDA14L, 0x46048000L, 0x940F0000L - }, { - 0L, 0xC913L, 0x35038000L, 0x940F0000L - }, { - 0L, 0xB812L, 0x24028000L, 0x940F0000L - }, { - 0L, 0xA711L, 0x13018000L, 0x940F0000L - }, { - 1L, 0x9610L, 0x02008000L, 0x940F0000L - }, { - 1L, 0x8808L, 0x10068400L, 0x78017800L - }, { - 0L, 0xA008L, 0x80342000L, 0x1FD3C000L - }, { - 0L, 0x8807L, 0x68332000L, 0x1FD3C000L - }, { - 0L, 0xE00CL, 0xA0644000L, 0x3FA78000L - }, { - 0L, 0xCA0BL, 0x8A634000L, 0x3FA78000L - }, { - 0L, 0xB40AL, 0x74624000L, 0x3FA78000L - }, { - 0L, 0x9E09L, 0x5E614000L, 0x3FA78000L - }, { - 0L, 0x8808L, 0x48604000L, 0x3FA78000L - }, { - 0L, 0xE40EL, 0x64BE8000L, 0x7F4F0000L - }, { - 0L, 0xD00DL, 0x50BD8000L, 0x7F4F0000L - }, { - 0L, 0xBC0CL, 0x3CBC8000L, 0x7F4F0000L - }, { - 0L, 0xA80BL, 0x28BB8000L, 0x7F4F0000L - }, { - 0L, 0x940AL, 0x14BA8000L, 0x7F4F0000L - }, { - 1L, 0x8009L, 0x00B98000L, 0x7F4F0000L - }, { - 1L, 0xA008L, 0x05CD0C00L, 0x9A3AF000L - }, { - 0L, 0xC008L, 0x2E686000L, 0x919F8000L - }, { - 1L, 0x9E07L, 0x0C676000L, 0x919F8000L - }, { - 0L, 0x8804L, 0x319D8000L, 0x56660000L - }, { - 1L, 0xC006L, 0x13390000L, 0xACCC0000L - }, { - 0L, 0x9004L, 0x4CE41000L, 0x431FEC00L - }, { - 0L, 0xC006L, 0x39C62000L, 0x863FD800L - }, { - 1L, 0x9805L, 0x11C52000L, 0x863FD800L - }, { - 0L, 0xA004L, 0x47148000L, 0x58EF6000L - }, { - 1L, 0xD806L, 0x26270000L, 0xB1DEC000L - }, { - 0L, 0xC004L, 0x989C0000L, 0x27670000L - }, { - 0L, 0x8C03L, 0x649B0000L, 0x27670000L - }, { - 0L, 0xB004L, 0x61340400L, 0x4ECFFA00L - }, { - 0L, 0x8003L, 0x31330400L, 0x4ECFFA00L - }, { - 1L, 0xA004L, 0x02640800L, 0x9D9FF400L - }, { - 1L, 0xA004L, 0x09902000L, 0x9673D000L - }, { - 1L, 0xD004L, 0x26408000L, 0xA9C34000L - }, { - 0L, 0xE004L, 0x99020000L, 0x47010000L - }, { - 0L, 0x9803L, 0x51010000L, 0x47010000L - }, { - 1L, 0xA004L, 0x12004000L, 0x8E03BE00L - }, { - 0L, 0xE004L, 0x48010000L, 0x9802F800L - }, { - 1L, 0x9803L, 0x00000000L, 0x9802F800L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001F000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201E000L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001C000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA2018000L - }, { - 0L, 0x9002L, 0x00000000L, 0x90010000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201FE00L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001FC00L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201F800L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001F000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201E000L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001C000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA2018000L - }, { - 0L, 0x9002L, 0x00000000L, 0x90010000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201FE00L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001FC00L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201F800L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001F000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA201E000L - }, { - 0L, 0x9002L, 0x00000000L, 0x9001C000L - }, { - 1L, 0xA202L, 0x00000000L, 0xA2018000L - }, { - 0L, 0x9002L, 0x00000000L, 0x90010000L - }, { - 1L, 0xA202L, 0x00008200L, 0xA2017C00L - }, { - 0L, 0x9002L, 0x00010400L, 0x9000F800L - }, { - 1L, 0xA202L, 0x00020800L, 0xA1FFF000L - }, { - 0L, 0x9002L, 0x00041000L, 0x8FFDE000L - }, { - 1L, 0xA202L, 0x00082000L, 0xA1F9C000L - }, { - 0L, 0x9002L, 0x00104000L, 0x8FF18000L - }, { - 1L, 0xA202L, 0x00208000L, 0xA1E10000L - }, { - 0L, 0x9002L, 0x00410000L, 0x8FC00000L - }, { - 1L, 0xA202L, 0x00821A00L, 0xA17FE400L - }, { - 0L, 0x9002L, 0x01043400L, 0x8EFDC800L - }, { - 1L, 0xA202L, 0x02086800L, 0x9FF99000L - }, { - 0L, 0x9002L, 0x0410D000L, 0x8BF12000L - }, { - 1L, 0xA202L, 0x0821A000L, 0x99E04000L - }, { - 0L, 0x9002L, 0x10434000L, 0x7FBE8000L - }, { - 1L, 0xA202L, 0x20868000L, 0x817B0000L - }, { - 0L, 0x9002L, 0x410D0000L, 0x4EF40000L - }, { - 0L, 0xA202L, 0x821B7600L, 0x1FE68800L - }, { - 0L, 0xB402L, 0x7434EC00L, 0x3FCD1000L - }, { - 0L, 0xF802L, 0x7867D800L, 0x7F9A2000L - }, { - 0L, 0xC401L, 0x4466D800L, 0x7F9A2000L - }, { - 1L, 0x9000L, 0x1065D800L, 0x7F9A2000L - }, { - 0L, 0xD004L, 0x41976000L, 0x8E6C8000L - }, { - 1L, 0x9803L, 0x09966000L, 0x8E6C8000L - }, { - 1L, 0xE004L, 0x26598000L, 0xB9AA0000L - }, { - 0L, 0x9002L, 0x4CB30000L, 0x434E0000L - }, { - 0L, 0xA202L, 0x99670C00L, 0x089AF200L - }, { - 0L, 0xB402L, 0xA2CC1800L, 0x1135E400L - }, { - 0L, 0xF802L, 0xD5963000L, 0x226BC800L - }, { - 0L, 0xC401L, 0xA1953000L, 0x226BC800L - }, { - 0L, 0x9000L, 0x6D943000L, 0x226BC800L - }, { - 0L, 0xB7FEL, 0x73266000L, 0x44D79000L - }, { - 0L, 0x87FDL, 0x43256000L, 0x44D79000L - }, { - 1L, 0xAFF8L, 0x2648C000L, 0x89AF2000L - }, { - 0L, 0xA004L, 0x99230000L, 0x06E08000L - }, { - 0L, 0xD806L, 0xCA440000L, 0x0DC10000L - }, { - 0L, 0xA805L, 0x9A430000L, 0x0DC10000L - }, { - 0L, 0xF008L, 0xD485E800L, 0x1B821600L - }, { - 0L, 0xC807L, 0xAC84E800L, 0x1B821600L - }, { - 0L, 0xA006L, 0x8483E800L, 0x1B821600L - }, { - 0L, 0xF00AL, 0xB905D000L, 0x37042C00L - }, { - 0L, 0xCC09L, 0x9504D000L, 0x37042C00L - }, { - 0L, 0xA808L, 0x7103D000L, 0x37042C00L - }, { - 0L, 0x8407L, 0x4D02D000L, 0x37042C00L - }, { - 0L, 0xC00CL, 0x5203A000L, 0x6E085800L - }, { - 0L, 0x9E0BL, 0x3002A000L, 0x6E085800L - }, { - 0L, 0xF814L, 0x1C034000L, 0xDC10B000L - }, { - 1L, 0xDC13L, 0x00024000L, 0xDC10B000L - }, { - 1L, 0xE008L, 0x00120000L, 0xDFF58000L - }, { - 1L, 0x9004L, 0x00486200L, 0x8FBB9C00L - }, { - 1L, 0xC004L, 0x01218800L, 0xBEE27000L - }, { - 1L, 0xD004L, 0x04862000L, 0xCB7DC000L - }, { - 1L, 0xE004L, 0x12188000L, 0xCDEB0000L - }, { - 0L, 0x9002L, 0x24310000L, 0x6BD00000L - }, { - 0L, 0xA202L, 0x4862FE00L, 0x599F0000L - }, { - 1L, 0xB402L, 0x00C3FC00L, 0xB33E0000L - }, { - 1L, 0xE004L, 0x030FF000L, 0xDCF40000L - }, { - 0L, 0x9002L, 0x061FE000L, 0x89E20000L - }, { - 1L, 0xA202L, 0x0C3FC000L, 0x95C20000L - }, { - 0L, 0x9002L, 0x187F8000L, 0x77820000L - }, { - 1L, 0xA202L, 0x30FF0000L, 0x71020000L - }, { - 1L, 0x9002L, 0x61FFFE00L, 0x2E020000L - }, { - 1L, 0xFC04L, 0x43FBF800L, 0xB8080000L - }, { - 1L, 0xA802L, 0x87F7F000L, 0x200A0000L - }, { - 0L, 0xA402L, 0x63EDE000L, 0x40140000L - }, { - 0L, 0x9C02L, 0x1BD9C000L, 0x80280000L - }, { - 1L, 0xAC02L, 0x37B38000L, 0x744E0000L - }, { - 1L, 0xA802L, 0x6F670000L, 0x389A0000L - }, { - 1L, 0xA402L, 0x32CE2000L, 0x7133DC00L - }, { - 1L, 0xAC02L, 0x659C4000L, 0x4665B800L - }, { - 0L, 0xB002L, 0x23368000L, 0x8CCB7000L - }, { - 1L, 0xA202L, 0x466D0000L, 0x5B94E000L - }, { - 1L, 0xA802L, 0x8CDA0000L, 0x1B27C000L - }, { - 1L, 0xAE02L, 0x77B20000L, 0x364F8000L - }, { - 1L, 0xCC02L, 0x5F620000L, 0x6C9F0000L - }, { - 0L, 0x9401L, 0x27610000L, 0x6C9F0000L - }, { - 1L, 0xE004L, 0x9D87FC00L, 0x427C0000L - }, { - 1L, 0x9803L, 0x5586FC00L, 0x427C0000L - }, { - 0L, 0xA004L, 0x1B0BF800L, 0x84F80000L - }, { - 1L, 0xE004L, 0x6C2FE000L, 0x73D40000L - }, { - 0L, 0x9803L, 0x242EE000L, 0x73D40000L - }, { - 1L, 0x9002L, 0x485DC000L, 0x47A40000L - }, { - 1L, 0xA202L, 0x90BB8000L, 0x11460000L - }, { - 1L, 0xB402L, 0x91750000L, 0x228C0000L - }, { - 1L, 0xF802L, 0xB2E8DC00L, 0x45192000L - }, { - 1L, 0xC401L, 0x7EE7DC00L, 0x45192000L - }, { - 1L, 0x9000L, 0x4AE6DC00L, 0x45192000L - }, { - 0L, 0xB7FEL, 0x2DCBB800L, 0x8A324000L - }, { - 1L, 0xC004L, 0xB72EE000L, 0x08D50000L - }, { - 1L, 0x8C03L, 0x832DE000L, 0x08D50000L - }, { - 1L, 0xB004L, 0x9E59C000L, 0x11AA0000L - }, { - 1L, 0x8003L, 0x6E58C000L, 0x11AA0000L - }, { - 1L, 0xA004L, 0x7CAF8000L, 0x23540000L - }, { - 1L, 0xF006L, 0xA95D0000L, 0x46A80000L - }, { - 1L, 0xCC05L, 0x855C0000L, 0x46A80000L - }, { - 1L, 0xA804L, 0x615B0000L, 0x46A80000L - }, { - 1L, 0x8403L, 0x3D5A0000L, 0x46A80000L - }, { - 1L, 0xC004L, 0x32B28E00L, 0x8D517000L - }, { - 0L, 0x9E03L, 0x10B18E00L, 0x8D517000L - }, { - 1L, 0x8804L, 0x42C63800L, 0x453DC000L - }, { - 1L, 0xC006L, 0x358A7000L, 0x8A7B8000L - }, { - 0L, 0x9C05L, 0x11897000L, 0x8A7B8000L - }, { - 1L, 0x9004L, 0x4625C000L, 0x49DE0000L - }, { - 1L, 0xC006L, 0x2C498000L, 0x93BC0000L - }, { - 0L, 0x9805L, 0x04488000L, 0x93BC0000L - }, { - 0L, 0xA004L, 0x11223400L, 0x8EE1CA00L - }, { - 1L, 0xD004L, 0x4488D000L, 0x8B7B2800L - }, { - 0L, 0x9803L, 0x0C87D000L, 0x8B7B2800L - }, { - 0L, 0xE004L, 0x321F4000L, 0xADE4A000L - }, { - 0L, 0x9002L, 0x643E8000L, 0x2BC34000L - }, { - 0L, 0xFC04L, 0x4CF60000L, 0xAF0D0000L - }, { - 0L, 0xA802L, 0x99EDB600L, 0x0E144800L - }, { - 1L, 0xA402L, 0x87D96C00L, 0x1C289000L - }, { - 0L, 0x9C02L, 0x63B0D800L, 0x38512000L - }, { - 0L, 0x8C02L, 0x1B5FB000L, 0x70A24000L - }, { - 1L, 0xAC02L, 0x36BF6000L, 0x75428000L - }, { - 1L, 0xA802L, 0x6D7EC000L, 0x3A830000L - }, { - 1L, 0xA402L, 0x2EFB8000L, 0x75060000L - }, { - 1L, 0xAC02L, 0x5DF70000L, 0x4E0A0000L - }, { - 0L, 0xB002L, 0x13ECD400L, 0x9C152A00L - }, { - 1L, 0xA202L, 0x27D9A800L, 0x7A285400L - }, { - 0L, 0xA802L, 0x4FB35000L, 0x584EA800L - }, { - 0L, 0xA202L, 0x9F66A000L, 0x029B5000L - }, { - 0L, 0x9C02L, 0x96CB4000L, 0x0536A000L - }, { - 1L, 0x8C02L, 0x81948000L, 0x0A6D4000L - }, { - 1L, 0xD804L, 0xAE4E0000L, 0x29B50000L - }, { - 0L, 0x8203L, 0x584D0000L, 0x29B50000L - }, { - 1L, 0xB008L, 0x09337C00L, 0xA6D48000L - }, { - 0L, 0xAC02L, 0x1266F800L, 0x999B0000L - }, { - 1L, 0xAC02L, 0x24CDF000L, 0x87340000L - }, { - 0L, 0xAC02L, 0x499BE000L, 0x62660000L - }, { - 0L, 0xAC02L, 0x9337C000L, 0x18CA0000L - }, { - 0L, 0xAC02L, 0x7A6D8000L, 0x31940000L - }, { - 1L, 0xB002L, 0x4CD90000L, 0x63280000L - }, { - 1L, 0xA202L, 0x99B3FE00L, 0x084E0000L - }, { - 1L, 0x9C02L, 0x8B65FC00L, 0x109C0000L - }, { - 0L, 0x8C02L, 0x6AC9F800L, 0x21380000L - }, { - 1L, 0xD804L, 0x5323E000L, 0x84E00000L - }, { - 1L, 0xAC02L, 0xA647C000L, 0x05BA0000L - }, { - 1L, 0xAC02L, 0xA08D8000L, 0x0B740000L - }, { - 1L, 0xB002L, 0x99190000L, 0x16E80000L - }, { - 1L, 0xBE02L, 0x9031FE00L, 0x2DD00000L - }, { - 1L, 0xEC02L, 0x9061FC00L, 0x5BA00000L - }, - }; + long[][] tracedata = { // + { 0L, 0x8000L, 0x42638000L, 0x3D9C0000L }, { 0L, 0xAC02L, 0x84C70000L, 0x273A0000L }, + { 0L, 0xF002L, 0xA18C7600L, 0x4E758800L }, { 0L, 0xD801L, 0x898B7600L, 0x4E758800L }, + { 0L, 0xC000L, 0x718A7600L, 0x4E758800L }, { 0L, 0xA7FFL, 0x59897600L, 0x4E758800L }, + { 0L, 0x8FFEL, 0x41887600L, 0x4E758800L }, { 0L, 0xEFFAL, 0x530EEC00L, 0x9CEB1000L }, + { 0L, 0xE539L, 0x484DEC00L, 0x9CEB1000L }, { 0L, 0xDA78L, 0x3D8CEC00L, 0x9CEB1000L }, + { 0L, 0xCFB7L, 0x32CBEC00L, 0x9CEB1000L }, { 0L, 0xC4F6L, 0x280AEC00L, 0x9CEB1000L }, + { 0L, 0xBA35L, 0x1D49EC00L, 0x9CEB1000L }, { 0L, 0xAF74L, 0x1288EC00L, 0x9CEB1000L }, + { 1L, 0xA4B3L, 0x07C7EC00L, 0x9CEB1000L }, { 0L, 0xAC10L, 0x7C7EC000L, 0x2F910000L }, + { 0L, 0x900FL, 0x607DC000L, 0x2F910000L }, { 0L, 0xE81CL, 0x88F98000L, 0x5F220000L }, + { 0L, 0xD21BL, 0x72F88000L, 0x5F220000L }, { 0L, 0xBC1AL, 0x5CF78000L, 0x5F220000L }, + { 0L, 0xA619L, 0x46F68000L, 0x5F220000L }, { 0L, 0x9018L, 0x30F58000L, 0x5F220000L }, + { 0L, 0xF42EL, 0x35E90000L, 0xBE440000L }, { 0L, 0xE32DL, 0x24E80000L, 0xBE440000L }, + { 0L, 0xD22CL, 0x13E70000L, 0xBE440000L }, { 1L, 0xC12BL, 0x02E60000L, 0xBE440000L }, + { 0L, 0x8808L, 0x1737E000L, 0x70D01800L }, { 1L, 0xE80EL, 0x066DC000L, 0xE1A03000L }, + { 0L, 0x9008L, 0x336E0000L, 0x5C998000L }, { 0L, 0xF40EL, 0x3ADA0000L, 0xB9330000L }, + { 0L, 0xE00DL, 0x26D90000L, 0xB9330000L }, { 1L, 0xCC0CL, 0x12D80000L, 0xB9330000L }, + { 0L, 0xA008L, 0x96C70800L, 0x0940F000L }, { 0L, 0x8807L, 0x7EC60800L, 0x0940F000L }, + { 0L, 0xE00CL, 0xCD8A1000L, 0x1281E000L }, { 0L, 0xCA0BL, 0xB7891000L, 0x1281E000L }, + { 0L, 0xB40AL, 0xA1881000L, 0x1281E000L }, { 0L, 0x9E09L, 0x8B871000L, 0x1281E000L }, + { 0L, 0x8808L, 0x75861000L, 0x1281E000L }, { 0L, 0xE40EL, 0xBF0A2000L, 0x2503C000L }, + { 0L, 0xD00DL, 0xAB092000L, 0x2503C000L }, { 0L, 0xBC0CL, 0x97082000L, 0x2503C000L }, + { 0L, 0xA80BL, 0x83072000L, 0x2503C000L }, { 0L, 0x940AL, 0x6F062000L, 0x2503C000L }, + { 0L, 0x8009L, 0x5B052000L, 0x2503C000L }, { 0L, 0xD810L, 0x8E084000L, 0x4A078000L }, + { 0L, 0xC60FL, 0x7C074000L, 0x4A078000L }, { 0L, 0xB40EL, 0x6A064000L, 0x4A078000L }, + { 0L, 0xA20DL, 0x58054000L, 0x4A078000L }, { 0L, 0x900CL, 0x46044000L, 0x4A078000L }, + { 0L, 0xFC16L, 0x68068000L, 0x940F0000L }, { 0L, 0xEB15L, 0x57058000L, 0x940F0000L }, + { 0L, 0xDA14L, 0x46048000L, 0x940F0000L }, { 0L, 0xC913L, 0x35038000L, 0x940F0000L }, + { 0L, 0xB812L, 0x24028000L, 0x940F0000L }, { 0L, 0xA711L, 0x13018000L, 0x940F0000L }, + { 1L, 0x9610L, 0x02008000L, 0x940F0000L }, { 1L, 0x8808L, 0x10068400L, 0x78017800L }, + { 0L, 0xA008L, 0x80342000L, 0x1FD3C000L }, { 0L, 0x8807L, 0x68332000L, 0x1FD3C000L }, + { 0L, 0xE00CL, 0xA0644000L, 0x3FA78000L }, { 0L, 0xCA0BL, 0x8A634000L, 0x3FA78000L }, + { 0L, 0xB40AL, 0x74624000L, 0x3FA78000L }, { 0L, 0x9E09L, 0x5E614000L, 0x3FA78000L }, + { 0L, 0x8808L, 0x48604000L, 0x3FA78000L }, { 0L, 0xE40EL, 0x64BE8000L, 0x7F4F0000L }, + { 0L, 0xD00DL, 0x50BD8000L, 0x7F4F0000L }, { 0L, 0xBC0CL, 0x3CBC8000L, 0x7F4F0000L }, + { 0L, 0xA80BL, 0x28BB8000L, 0x7F4F0000L }, { 0L, 0x940AL, 0x14BA8000L, 0x7F4F0000L }, + { 1L, 0x8009L, 0x00B98000L, 0x7F4F0000L }, { 1L, 0xA008L, 0x05CD0C00L, 0x9A3AF000L }, + { 0L, 0xC008L, 0x2E686000L, 0x919F8000L }, { 1L, 0x9E07L, 0x0C676000L, 0x919F8000L }, + { 0L, 0x8804L, 0x319D8000L, 0x56660000L }, { 1L, 0xC006L, 0x13390000L, 0xACCC0000L }, + { 0L, 0x9004L, 0x4CE41000L, 0x431FEC00L }, { 0L, 0xC006L, 0x39C62000L, 0x863FD800L }, + { 1L, 0x9805L, 0x11C52000L, 0x863FD800L }, { 0L, 0xA004L, 0x47148000L, 0x58EF6000L }, + { 1L, 0xD806L, 0x26270000L, 0xB1DEC000L }, { 0L, 0xC004L, 0x989C0000L, 0x27670000L }, + { 0L, 0x8C03L, 0x649B0000L, 0x27670000L }, { 0L, 0xB004L, 0x61340400L, 0x4ECFFA00L }, + { 0L, 0x8003L, 0x31330400L, 0x4ECFFA00L }, { 1L, 0xA004L, 0x02640800L, 0x9D9FF400L }, + { 1L, 0xA004L, 0x09902000L, 0x9673D000L }, { 1L, 0xD004L, 0x26408000L, 0xA9C34000L }, + { 0L, 0xE004L, 0x99020000L, 0x47010000L }, { 0L, 0x9803L, 0x51010000L, 0x47010000L }, + { 1L, 0xA004L, 0x12004000L, 0x8E03BE00L }, { 0L, 0xE004L, 0x48010000L, 0x9802F800L }, + { 1L, 0x9803L, 0x00000000L, 0x9802F800L }, { 0L, 0x9002L, 0x00000000L, 0x9001F000L }, + { 1L, 0xA202L, 0x00000000L, 0xA201E000L }, { 0L, 0x9002L, 0x00000000L, 0x9001C000L }, + { 1L, 0xA202L, 0x00000000L, 0xA2018000L }, { 0L, 0x9002L, 0x00000000L, 0x90010000L }, + { 1L, 0xA202L, 0x00000000L, 0xA201FE00L }, { 0L, 0x9002L, 0x00000000L, 0x9001FC00L }, + { 1L, 0xA202L, 0x00000000L, 0xA201F800L }, { 0L, 0x9002L, 0x00000000L, 0x9001F000L }, + { 1L, 0xA202L, 0x00000000L, 0xA201E000L }, { 0L, 0x9002L, 0x00000000L, 0x9001C000L }, + { 1L, 0xA202L, 0x00000000L, 0xA2018000L }, { 0L, 0x9002L, 0x00000000L, 0x90010000L }, + { 1L, 0xA202L, 0x00000000L, 0xA201FE00L }, { 0L, 0x9002L, 0x00000000L, 0x9001FC00L }, + { 1L, 0xA202L, 0x00000000L, 0xA201F800L }, { 0L, 0x9002L, 0x00000000L, 0x9001F000L }, + { 1L, 0xA202L, 0x00000000L, 0xA201E000L }, { 0L, 0x9002L, 0x00000000L, 0x9001C000L }, + { 1L, 0xA202L, 0x00000000L, 0xA2018000L }, { 0L, 0x9002L, 0x00000000L, 0x90010000L }, + { 1L, 0xA202L, 0x00008200L, 0xA2017C00L }, { 0L, 0x9002L, 0x00010400L, 0x9000F800L }, + { 1L, 0xA202L, 0x00020800L, 0xA1FFF000L }, { 0L, 0x9002L, 0x00041000L, 0x8FFDE000L }, + { 1L, 0xA202L, 0x00082000L, 0xA1F9C000L }, { 0L, 0x9002L, 0x00104000L, 0x8FF18000L }, + { 1L, 0xA202L, 0x00208000L, 0xA1E10000L }, { 0L, 0x9002L, 0x00410000L, 0x8FC00000L }, + { 1L, 0xA202L, 0x00821A00L, 0xA17FE400L }, { 0L, 0x9002L, 0x01043400L, 0x8EFDC800L }, + { 1L, 0xA202L, 0x02086800L, 0x9FF99000L }, { 0L, 0x9002L, 0x0410D000L, 0x8BF12000L }, + { 1L, 0xA202L, 0x0821A000L, 0x99E04000L }, { 0L, 0x9002L, 0x10434000L, 0x7FBE8000L }, + { 1L, 0xA202L, 0x20868000L, 0x817B0000L }, { 0L, 0x9002L, 0x410D0000L, 0x4EF40000L }, + { 0L, 0xA202L, 0x821B7600L, 0x1FE68800L }, { 0L, 0xB402L, 0x7434EC00L, 0x3FCD1000L }, + { 0L, 0xF802L, 0x7867D800L, 0x7F9A2000L }, { 0L, 0xC401L, 0x4466D800L, 0x7F9A2000L }, + { 1L, 0x9000L, 0x1065D800L, 0x7F9A2000L }, { 0L, 0xD004L, 0x41976000L, 0x8E6C8000L }, + { 1L, 0x9803L, 0x09966000L, 0x8E6C8000L }, { 1L, 0xE004L, 0x26598000L, 0xB9AA0000L }, + { 0L, 0x9002L, 0x4CB30000L, 0x434E0000L }, { 0L, 0xA202L, 0x99670C00L, 0x089AF200L }, + { 0L, 0xB402L, 0xA2CC1800L, 0x1135E400L }, { 0L, 0xF802L, 0xD5963000L, 0x226BC800L }, + { 0L, 0xC401L, 0xA1953000L, 0x226BC800L }, { 0L, 0x9000L, 0x6D943000L, 0x226BC800L }, + { 0L, 0xB7FEL, 0x73266000L, 0x44D79000L }, { 0L, 0x87FDL, 0x43256000L, 0x44D79000L }, + { 1L, 0xAFF8L, 0x2648C000L, 0x89AF2000L }, { 0L, 0xA004L, 0x99230000L, 0x06E08000L }, + { 0L, 0xD806L, 0xCA440000L, 0x0DC10000L }, { 0L, 0xA805L, 0x9A430000L, 0x0DC10000L }, + { 0L, 0xF008L, 0xD485E800L, 0x1B821600L }, { 0L, 0xC807L, 0xAC84E800L, 0x1B821600L }, + { 0L, 0xA006L, 0x8483E800L, 0x1B821600L }, { 0L, 0xF00AL, 0xB905D000L, 0x37042C00L }, + { 0L, 0xCC09L, 0x9504D000L, 0x37042C00L }, { 0L, 0xA808L, 0x7103D000L, 0x37042C00L }, + { 0L, 0x8407L, 0x4D02D000L, 0x37042C00L }, { 0L, 0xC00CL, 0x5203A000L, 0x6E085800L }, + { 0L, 0x9E0BL, 0x3002A000L, 0x6E085800L }, { 0L, 0xF814L, 0x1C034000L, 0xDC10B000L }, + { 1L, 0xDC13L, 0x00024000L, 0xDC10B000L }, { 1L, 0xE008L, 0x00120000L, 0xDFF58000L }, + { 1L, 0x9004L, 0x00486200L, 0x8FBB9C00L }, { 1L, 0xC004L, 0x01218800L, 0xBEE27000L }, + { 1L, 0xD004L, 0x04862000L, 0xCB7DC000L }, { 1L, 0xE004L, 0x12188000L, 0xCDEB0000L }, + { 0L, 0x9002L, 0x24310000L, 0x6BD00000L }, { 0L, 0xA202L, 0x4862FE00L, 0x599F0000L }, + { 1L, 0xB402L, 0x00C3FC00L, 0xB33E0000L }, { 1L, 0xE004L, 0x030FF000L, 0xDCF40000L }, + { 0L, 0x9002L, 0x061FE000L, 0x89E20000L }, { 1L, 0xA202L, 0x0C3FC000L, 0x95C20000L }, + { 0L, 0x9002L, 0x187F8000L, 0x77820000L }, { 1L, 0xA202L, 0x30FF0000L, 0x71020000L }, + { 1L, 0x9002L, 0x61FFFE00L, 0x2E020000L }, { 1L, 0xFC04L, 0x43FBF800L, 0xB8080000L }, + { 1L, 0xA802L, 0x87F7F000L, 0x200A0000L }, { 0L, 0xA402L, 0x63EDE000L, 0x40140000L }, + { 0L, 0x9C02L, 0x1BD9C000L, 0x80280000L }, { 1L, 0xAC02L, 0x37B38000L, 0x744E0000L }, + { 1L, 0xA802L, 0x6F670000L, 0x389A0000L }, { 1L, 0xA402L, 0x32CE2000L, 0x7133DC00L }, + { 1L, 0xAC02L, 0x659C4000L, 0x4665B800L }, { 0L, 0xB002L, 0x23368000L, 0x8CCB7000L }, + { 1L, 0xA202L, 0x466D0000L, 0x5B94E000L }, { 1L, 0xA802L, 0x8CDA0000L, 0x1B27C000L }, + { 1L, 0xAE02L, 0x77B20000L, 0x364F8000L }, { 1L, 0xCC02L, 0x5F620000L, 0x6C9F0000L }, + { 0L, 0x9401L, 0x27610000L, 0x6C9F0000L }, { 1L, 0xE004L, 0x9D87FC00L, 0x427C0000L }, + { 1L, 0x9803L, 0x5586FC00L, 0x427C0000L }, { 0L, 0xA004L, 0x1B0BF800L, 0x84F80000L }, + { 1L, 0xE004L, 0x6C2FE000L, 0x73D40000L }, { 0L, 0x9803L, 0x242EE000L, 0x73D40000L }, + { 1L, 0x9002L, 0x485DC000L, 0x47A40000L }, { 1L, 0xA202L, 0x90BB8000L, 0x11460000L }, + { 1L, 0xB402L, 0x91750000L, 0x228C0000L }, { 1L, 0xF802L, 0xB2E8DC00L, 0x45192000L }, + { 1L, 0xC401L, 0x7EE7DC00L, 0x45192000L }, { 1L, 0x9000L, 0x4AE6DC00L, 0x45192000L }, + { 0L, 0xB7FEL, 0x2DCBB800L, 0x8A324000L }, { 1L, 0xC004L, 0xB72EE000L, 0x08D50000L }, + { 1L, 0x8C03L, 0x832DE000L, 0x08D50000L }, { 1L, 0xB004L, 0x9E59C000L, 0x11AA0000L }, + { 1L, 0x8003L, 0x6E58C000L, 0x11AA0000L }, { 1L, 0xA004L, 0x7CAF8000L, 0x23540000L }, + { 1L, 0xF006L, 0xA95D0000L, 0x46A80000L }, { 1L, 0xCC05L, 0x855C0000L, 0x46A80000L }, + { 1L, 0xA804L, 0x615B0000L, 0x46A80000L }, { 1L, 0x8403L, 0x3D5A0000L, 0x46A80000L }, + { 1L, 0xC004L, 0x32B28E00L, 0x8D517000L }, { 0L, 0x9E03L, 0x10B18E00L, 0x8D517000L }, + { 1L, 0x8804L, 0x42C63800L, 0x453DC000L }, { 1L, 0xC006L, 0x358A7000L, 0x8A7B8000L }, + { 0L, 0x9C05L, 0x11897000L, 0x8A7B8000L }, { 1L, 0x9004L, 0x4625C000L, 0x49DE0000L }, + { 1L, 0xC006L, 0x2C498000L, 0x93BC0000L }, { 0L, 0x9805L, 0x04488000L, 0x93BC0000L }, + { 0L, 0xA004L, 0x11223400L, 0x8EE1CA00L }, { 1L, 0xD004L, 0x4488D000L, 0x8B7B2800L }, + { 0L, 0x9803L, 0x0C87D000L, 0x8B7B2800L }, { 0L, 0xE004L, 0x321F4000L, 0xADE4A000L }, + { 0L, 0x9002L, 0x643E8000L, 0x2BC34000L }, { 0L, 0xFC04L, 0x4CF60000L, 0xAF0D0000L }, + { 0L, 0xA802L, 0x99EDB600L, 0x0E144800L }, { 1L, 0xA402L, 0x87D96C00L, 0x1C289000L }, + { 0L, 0x9C02L, 0x63B0D800L, 0x38512000L }, { 0L, 0x8C02L, 0x1B5FB000L, 0x70A24000L }, + { 1L, 0xAC02L, 0x36BF6000L, 0x75428000L }, { 1L, 0xA802L, 0x6D7EC000L, 0x3A830000L }, + { 1L, 0xA402L, 0x2EFB8000L, 0x75060000L }, { 1L, 0xAC02L, 0x5DF70000L, 0x4E0A0000L }, + { 0L, 0xB002L, 0x13ECD400L, 0x9C152A00L }, { 1L, 0xA202L, 0x27D9A800L, 0x7A285400L }, + { 0L, 0xA802L, 0x4FB35000L, 0x584EA800L }, { 0L, 0xA202L, 0x9F66A000L, 0x029B5000L }, + { 0L, 0x9C02L, 0x96CB4000L, 0x0536A000L }, { 1L, 0x8C02L, 0x81948000L, 0x0A6D4000L }, + { 1L, 0xD804L, 0xAE4E0000L, 0x29B50000L }, { 0L, 0x8203L, 0x584D0000L, 0x29B50000L }, + { 1L, 0xB008L, 0x09337C00L, 0xA6D48000L }, { 0L, 0xAC02L, 0x1266F800L, 0x999B0000L }, + { 1L, 0xAC02L, 0x24CDF000L, 0x87340000L }, { 0L, 0xAC02L, 0x499BE000L, 0x62660000L }, + { 0L, 0xAC02L, 0x9337C000L, 0x18CA0000L }, { 0L, 0xAC02L, 0x7A6D8000L, 0x31940000L }, + { 1L, 0xB002L, 0x4CD90000L, 0x63280000L }, { 1L, 0xA202L, 0x99B3FE00L, 0x084E0000L }, + { 1L, 0x9C02L, 0x8B65FC00L, 0x109C0000L }, { 0L, 0x8C02L, 0x6AC9F800L, 0x21380000L }, + { 1L, 0xD804L, 0x5323E000L, 0x84E00000L }, { 1L, 0xAC02L, 0xA647C000L, 0x05BA0000L }, + { 1L, 0xAC02L, 0xA08D8000L, 0x0B740000L }, { 1L, 0xB002L, 0x99190000L, 0x16E80000L }, + { 1L, 0xBE02L, 0x9031FE00L, 0x2DD00000L }, { 1L, 0xEC02L, 0x9061FC00L, 0x5BA00000L }, }; - @Test - public void decodeTest() throws Throwable { - InputStream is = getClass().getResourceAsStream("/images/arith/encoded testsequence"); - DefaultInputStreamFactory factory = new DefaultInputStreamFactory(); - ImageInputStream iis = factory.getInputStream(is); + @Test + public void decodeTest() throws Throwable + { + InputStream is = getClass().getResourceAsStream("/images/arith/encoded testsequence"); + DefaultInputStreamFactory factory = new DefaultInputStreamFactory(); + ImageInputStream iis = factory.getInputStream(is); - ArithmeticDecoder decoder = new ArithmeticDecoder(iis); + ArithmeticDecoder decoder = new ArithmeticDecoder(iis); - CX cx = new CX(1, 0); - for (int i = 0; i < 257; i++) { - decoder.decode(cx); - } + CX cx = new CX(1, 0); + for (int i = 0; i < 257; i++) + { + decoder.decode(cx); + } - } + } - @Test - public void decodeTestWithTracadataComparison() throws Throwable { - InputStream is = getClass().getResourceAsStream("/images/arith/encoded testsequence"); - DefaultInputStreamFactory factory = new DefaultInputStreamFactory(); - ImageInputStream iis = factory.getInputStream(is); + @Test + public void decodeTestWithTracadataComparison() throws Throwable + { + InputStream is = getClass().getResourceAsStream("/images/arith/encoded testsequence"); + DefaultInputStreamFactory factory = new DefaultInputStreamFactory(); + ImageInputStream iis = factory.getInputStream(is); - ArithmeticDecoder decoder = new ArithmeticDecoder(iis); - CX cx = new CX(1, 0); + ArithmeticDecoder decoder = new ArithmeticDecoder(iis); + CX cx = new CX(1, 0); - for (int i = 0; i < 255; i++) { - Assert.assertEquals(tracedata[i][0], decoder.decode(cx)); - Assert.assertEquals(tracedata[i + 1][1], (long) decoder.getA()); - Assert.assertEquals(tracedata[i + 1][2], decoder.getC()); + for (int i = 0; i < 255; i++) + { + Assert.assertEquals(tracedata[i][0], decoder.decode(cx)); + Assert.assertEquals(tracedata[i + 1][1], (long) decoder.getA()); + Assert.assertEquals(tracedata[i + 1][2], decoder.getC()); + } } - } }
http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticIntegerDecoderTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticIntegerDecoderTest.java b/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticIntegerDecoderTest.java index a17b8c6..2448cbd 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticIntegerDecoderTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/decoder/arithmetic/ArithmeticIntegerDecoderTest.java @@ -28,19 +28,21 @@ import org.apache.pdfbox.jbig2.decoder.arithmetic.ArithmeticIntegerDecoder; import org.apache.pdfbox.jbig2.io.DefaultInputStreamFactory; import org.junit.Test; -public class ArithmeticIntegerDecoderTest { +public class ArithmeticIntegerDecoderTest +{ - @Test - public void decodeTest() throws Throwable { - InputStream is = getClass().getResourceAsStream("/images/arith/encoded testsequence"); - DefaultInputStreamFactory isFactory = new DefaultInputStreamFactory(); - ImageInputStream iis = isFactory.getInputStream(is); + @Test + public void decodeTest() throws Throwable + { + InputStream is = getClass().getResourceAsStream("/images/arith/encoded testsequence"); + DefaultInputStreamFactory isFactory = new DefaultInputStreamFactory(); + ImageInputStream iis = isFactory.getInputStream(is); - ArithmeticDecoder ad = new ArithmeticDecoder(iis); - ArithmeticIntegerDecoder aid = new ArithmeticIntegerDecoder(ad); + ArithmeticDecoder ad = new ArithmeticDecoder(iis); + ArithmeticIntegerDecoder aid = new ArithmeticIntegerDecoder(ad); - long result = aid.decode(null); + long result = aid.decode(null); - Assert.assertEquals(1, result); - } + Assert.assertEquals(1, result); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressorTest.java b/src/test/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressorTest.java index f8da8de..e64ee22 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressorTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressorTest.java @@ -33,7 +33,8 @@ import org.apache.pdfbox.jbig2.io.DefaultInputStreamFactory; import org.apache.pdfbox.jbig2.io.SubInputStream; import org.junit.Test; -public class MMRDecompressorTest { +public class MMRDecompressorTest +{ @Test public void mmrDecodingTest() throws IOException, InvalidHeaderValueException @@ -47,7 +48,7 @@ public class MMRDecompressorTest { assumeTrue(inputFile.exists()); final InputStream inputStream = new FileInputStream(inputFile); - + final DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); final ImageInputStream iis = disf.getInputStream(inputStream); @@ -58,7 +59,7 @@ public class MMRDecompressorTest { final Bitmap b = mmrd.uncompress(); final byte[] actual = b.getByteArray(); - + assertArrayEquals(expected, actual); } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsBlitTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsBlitTest.java b/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsBlitTest.java index 8e074fe..fb63dac 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsBlitTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsBlitTest.java @@ -36,58 +36,61 @@ import org.apache.pdfbox.jbig2.io.DefaultInputStreamFactory; import org.apache.pdfbox.jbig2.util.CombinationOperator; import org.junit.Test; -public class BitmapsBlitTest { +public class BitmapsBlitTest +{ - @Test - public void testCompleteBitmapTransfer() throws IOException, JBIG2Exception { + @Test + public void testCompleteBitmapTransfer() throws IOException, JBIG2Exception + { - final File inputFile = new File("target/images/042_1.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); + final File inputFile = new File("target/images/042_1.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); - final InputStream inputStream = new FileInputStream(inputFile); - - final DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - final ImageInputStream iis = disf.getInputStream(inputStream); + final InputStream inputStream = new FileInputStream(inputFile); - final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); + final DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + final ImageInputStream iis = disf.getInputStream(inputStream); - final Bitmap src = doc.getPageBitmap(1); - final Bitmap dst = new Bitmap(src.getWidth(), src.getHeight()); - Bitmaps.blit(src, dst, 0, 0, CombinationOperator.REPLACE); + final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); - final byte[] srcData = src.getByteArray(); - final byte[] dstData = dst.getByteArray(); + final Bitmap src = doc.getPageBitmap(1); + final Bitmap dst = new Bitmap(src.getWidth(), src.getHeight()); + Bitmaps.blit(src, dst, 0, 0, CombinationOperator.REPLACE); - assertArrayEquals(srcData, dstData); - } + final byte[] srcData = src.getByteArray(); + final byte[] dstData = dst.getByteArray(); - @Test - public void test() throws IOException, JBIG2Exception { + assertArrayEquals(srcData, dstData); + } - final File inputFile = new File("target/images/042_1.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); + @Test + public void test() throws IOException, JBIG2Exception + { - final InputStream inputStream = new FileInputStream(inputFile); + final File inputFile = new File("target/images/042_1.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); - final DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - final ImageInputStream iis = disf.getInputStream(inputStream); + final InputStream inputStream = new FileInputStream(inputFile); - final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); + final DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + final ImageInputStream iis = disf.getInputStream(inputStream); - final Bitmap dst = doc.getPageBitmap(1); + final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); - final Rectangle roi = new Rectangle(100, 100, 100, 100); - final Bitmap src = new Bitmap(roi.width, roi.height); - Bitmaps.blit(src, dst, roi.x, roi.y, CombinationOperator.REPLACE); + final Bitmap dst = doc.getPageBitmap(1); - final Bitmap dstRegionBitmap = Bitmaps.extract(roi, dst); + final Rectangle roi = new Rectangle(100, 100, 100, 100); + final Bitmap src = new Bitmap(roi.width, roi.height); + Bitmaps.blit(src, dst, roi.x, roi.y, CombinationOperator.REPLACE); - final byte[] srcData = src.getByteArray(); - final byte[] dstRegionData = dstRegionBitmap.getByteArray(); + final Bitmap dstRegionBitmap = Bitmaps.extract(roi, dst); - assertArrayEquals(srcData, dstRegionData); - } + final byte[] srcData = src.getByteArray(); + final byte[] dstRegionData = dstRegionBitmap.getByteArray(); + + assertArrayEquals(srcData, dstRegionData); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsByteCombinationTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsByteCombinationTest.java b/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsByteCombinationTest.java index b1baed5..7fd5fd2 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsByteCombinationTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsByteCombinationTest.java @@ -30,40 +30,33 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) -public class BitmapsByteCombinationTest { - - private static final byte value1 = 0xA; - private static final byte value2 = 0xD; - - private final int expected; - private final CombinationOperator operator; - - @Parameters - public static Collection<Object[]> data() { - return Arrays.asList(new Object[][]{ - { - 0xF, CombinationOperator.OR - }, { - 0x8, CombinationOperator.AND - }, { - 0x7, CombinationOperator.XOR - }, { - -8, CombinationOperator.XNOR - }, { - value2, CombinationOperator.REPLACE - } - }); - } - - public BitmapsByteCombinationTest(final int expected, final CombinationOperator operator) { - this.expected = expected; - this.operator = operator; - } - - - @Test - public void test() { - assertEquals(expected, Bitmaps.combineBytes(value1, value2, operator)); - } +public class BitmapsByteCombinationTest +{ + + private static final byte value1 = 0xA; + private static final byte value2 = 0xD; + + private final int expected; + private final CombinationOperator operator; + + @Parameters + public static Collection<Object[]> data() + { + return Arrays.asList(new Object[][] { { 0xF, CombinationOperator.OR }, + { 0x8, CombinationOperator.AND }, { 0x7, CombinationOperator.XOR }, + { -8, CombinationOperator.XNOR }, { value2, CombinationOperator.REPLACE } }); + } + + public BitmapsByteCombinationTest(final int expected, final CombinationOperator operator) + { + this.expected = expected; + this.operator = operator; + } + + @Test + public void test() + { + assertEquals(expected, Bitmaps.combineBytes(value1, value2, operator)); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsChecksumTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsChecksumTest.java b/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsChecksumTest.java index 1752341..b7e5aee 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsChecksumTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/image/BitmapsChecksumTest.java @@ -49,136 +49,130 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @RunWith(Parameterized.class) -public class BitmapsChecksumTest { +public class BitmapsChecksumTest +{ + + private String resourcePath; + private ImageReadParam param; + private FilterType filterType; + private String checksum; + private int pageNumber; + + @Parameters + public static Collection<Object[]> data() + { + return Arrays.asList(new Object[][] { + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Dimension(500, 500)), FilterType.Bessel, + "101-6467-126-3534108-8927-58-26-37248672" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Dimension(500, 800)), FilterType.Box, + "-748135-126-6412111-11925-1038826-95-32-6-104" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Dimension(4000, 5500)), FilterType.Box, + "-646510160-466410970-77-1031184396-8-23-18" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Dimension(600, 300)), FilterType.Bessel, + "-69-11478-721003586-100-72-85-1559101-118-24-94" }, + { "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(2, 2, 0, 0), + FilterType.Bessel, "-4979-94-68-125645751-2111712617-59-295" }, + { "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(2, 2, 0, 0), + FilterType.Lanczos, "-4979-94-68-125645751-2111712617-59-295" }, + { "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(3, 3, 1, 1), + FilterType.Lanczos, "84-1069410599-9575-7934-1279-80-85127-18-128" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Rectangle(100, 100, 500, 500)), + FilterType.Lanczos, "1245-23-127954634-1232173-109-5739-303-48" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Rectangle(500, 500, 2000, 2000)), + FilterType.Lanczos, "-60-45-117-90-6596-11556-47-30-112-741138412082" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Rectangle(500, 500, 2000, 2000), + new Dimension(678, 931)), + FilterType.Lanczos, "-17-95-5543-12062-625054-94-88-31-4-120-1971" }, + { "target/images/042_1.jb2", 1, + new PreconfiguredImageReadParam(new Rectangle(500, 500, 2000, 2000), + new Dimension(678, 931), 3, 3, 1, 1), + FilterType.Lanczos, "-109-60118-41999255-94113-5019-2818-10-39-71" } }); + } - private String resourcePath; - private ImageReadParam param; - private FilterType filterType; - private String checksum; - private int pageNumber; + public BitmapsChecksumTest(String resourcePath, int pageNumber, ImageReadParam param, + FilterType filterType, String checksum) + { + this.resourcePath = resourcePath; + this.pageNumber = pageNumber; + this.param = param; + this.filterType = filterType; + this.checksum = checksum; + } - @Parameters - public static Collection<Object[]> data() { - return Arrays.asList(new Object[][]{ - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(new Dimension(500, 500)), FilterType.Bessel, - "101-6467-126-3534108-8927-58-26-37248672" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(new Dimension(500, 800)), FilterType.Box, - "-748135-126-6412111-11925-1038826-95-32-6-104" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(new Dimension(4000, 5500)), FilterType.Box, - "-646510160-466410970-77-1031184396-8-23-18" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(new Dimension(600, 300)), FilterType.Bessel, - "-69-11478-721003586-100-72-85-1559101-118-24-94" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(2, 2, 0, 0), FilterType.Bessel, - "-4979-94-68-125645751-2111712617-59-295" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(2, 2, 0, 0), FilterType.Lanczos, - "-4979-94-68-125645751-2111712617-59-295" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(3, 3, 1, 1), FilterType.Lanczos, - "84-1069410599-9575-7934-1279-80-85127-18-128" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(new Rectangle(100, 100, 500, 500)), - FilterType.Lanczos, "1245-23-127954634-1232173-109-5739-303-48" - }, - { - "target/images/042_1.jb2", 1, new PreconfiguredImageReadParam(new Rectangle(500, 500, 2000, 2000)), - FilterType.Lanczos, "-60-45-117-90-6596-11556-47-30-112-741138412082" - }, + @Test + public void test() throws IOException, JBIG2Exception, NoSuchAlgorithmException + { + + final File inputFile = new File(resourcePath); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + final InputStreamFactory disf = new DefaultInputStreamFactory(); + final ImageInputStream iis = disf.getInputStream(inputStream); + + final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); + final Bitmap b = doc.getPageBitmap(pageNumber); + final WritableRaster raster = Bitmaps.asRaster(b, param, filterType); + + final DataBufferByte dataBufferByte = (DataBufferByte) raster.getDataBuffer(); + final byte[] bytes = dataBufferByte.getData(); + + final MessageDigest md = MessageDigest.getInstance("MD5"); + + final byte[] digest = md.digest(bytes); + final StringBuilder sb = new StringBuilder(); + for (byte toAppend : digest) { - "target/images/042_1.jb2", 1, - new PreconfiguredImageReadParam(new Rectangle(500, 500, 2000, 2000), new Dimension(678, 931)), - FilterType.Lanczos, "-17-95-5543-12062-625054-94-88-31-4-120-1971" - }, + sb.append(toAppend); + } + + assertArrayEquals(checksum.getBytes(), sb.toString().getBytes()); + } + + static class RasterChecksumCalculator + { + public static void main(String[] args) + throws IOException, JBIG2Exception, NoSuchAlgorithmException { - "target/images/042_1.jb2", 1, - new PreconfiguredImageReadParam(new Rectangle(500, 500, 2000, 2000), new Dimension(678, 931), 3, 3, 1, 1), - FilterType.Lanczos, "-109-60118-41999255-94113-5019-2818-10-39-71" + + final File inputFile = new File("target/images/042_1.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final int pageNumber = 1; + + final InputStream inputStream = new FileInputStream(inputFile); + + final InputStreamFactory disf = new DefaultInputStreamFactory(); + final ImageInputStream iis = disf.getInputStream(inputStream); + + final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); + final Bitmap b = doc.getPageBitmap(pageNumber); + + final ImageReadParam param = new PreconfiguredImageReadParam( + new Rectangle(100, 100, 500, 500)); + + final WritableRaster raster = Bitmaps.asRaster(b, param, FilterType.Lanczos); + final DataBufferByte dataBufferByte = (DataBufferByte) raster.getDataBuffer(); + final byte[] bytes = dataBufferByte.getData(); + + final MessageDigest md = MessageDigest.getInstance("MD5"); + + final byte[] digest = md.digest(bytes); + for (byte d : digest) + { + System.out.print(d); + } } - }); - } - - public BitmapsChecksumTest(String resourcePath, int pageNumber, ImageReadParam param, FilterType filterType, - String checksum) { - this.resourcePath = resourcePath; - this.pageNumber = pageNumber; - this.param = param; - this.filterType = filterType; - this.checksum = checksum; - } - - @Test - public void test() throws IOException, JBIG2Exception, NoSuchAlgorithmException { - - final File inputFile = new File(resourcePath); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - final InputStreamFactory disf = new DefaultInputStreamFactory(); - final ImageInputStream iis = disf.getInputStream(inputStream); - - final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); - final Bitmap b = doc.getPageBitmap(pageNumber); - final WritableRaster raster = Bitmaps.asRaster(b, param, filterType); - - final DataBufferByte dataBufferByte = (DataBufferByte) raster.getDataBuffer(); - final byte[] bytes = dataBufferByte.getData(); - - final MessageDigest md = MessageDigest.getInstance("MD5"); - - final byte[] digest = md.digest(bytes); - final StringBuilder sb = new StringBuilder(); - for (byte toAppend : digest) { - sb.append(toAppend); - } - - assertArrayEquals(checksum.getBytes(), sb.toString().getBytes()); - } - - static class RasterChecksumCalculator { - public static void main(String[] args) throws IOException, JBIG2Exception, NoSuchAlgorithmException { - - final File inputFile = new File("target/images/042_1.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final int pageNumber = 1; - - final InputStream inputStream = new FileInputStream(inputFile); - - final InputStreamFactory disf = new DefaultInputStreamFactory(); - final ImageInputStream iis = disf.getInputStream(inputStream); - - final JBIG2DocumentFacade doc = new JBIG2DocumentFacade(iis); - final Bitmap b = doc.getPageBitmap(pageNumber); - - final ImageReadParam param = new PreconfiguredImageReadParam(new Rectangle(100, 100, 500, 500)); - - final WritableRaster raster = Bitmaps.asRaster(b, param, FilterType.Lanczos); - final DataBufferByte dataBufferByte = (DataBufferByte) raster.getDataBuffer(); - final byte[] bytes = dataBufferByte.getData(); - - final MessageDigest md = MessageDigest.getInstance("MD5"); - - final byte[] digest = md.digest(bytes); - for (byte d : digest) { - System.out.print(d); - } } - } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/GenericRegionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/GenericRegionTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/GenericRegionTest.java index ade800f..ad29882 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/GenericRegionTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/GenericRegionTest.java @@ -38,105 +38,110 @@ import org.apache.pdfbox.jbig2.util.CombinationOperator; import org.junit.Ignore; import org.junit.Test; -public class GenericRegionTest { - - @Test - public void parseHeaderTest() throws IOException, InvalidHeaderValueException { - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - - // Twelfth Segment (number 11) - SubInputStream sis = new SubInputStream(iis, 523, 35); - GenericRegion gr = new GenericRegion(); - gr.init(null, sis); - - Assert.assertEquals(54, gr.getRegionInfo().getBitmapWidth()); - Assert.assertEquals(44, gr.getRegionInfo().getBitmapHeight()); - Assert.assertEquals(4, gr.getRegionInfo().getXLocation()); - Assert.assertEquals(11, gr.getRegionInfo().getYLocation()); - Assert.assertEquals(CombinationOperator.OR, gr.getRegionInfo().getCombinationOperator()); - - Assert.assertFalse(gr.useExtTemplates()); - Assert.assertFalse(gr.isMMREncoded()); - Assert.assertEquals(0, gr.getGbTemplate()); - Assert.assertTrue(gr.isTPGDon()); - - short[] gbAtX = gr.getGbAtX(); - short[] gbAtY = gr.getGbAtY(); - Assert.assertEquals(3, gbAtX[0]); - Assert.assertEquals(-1, gbAtY[0]); - Assert.assertEquals(-3, gbAtX[1]); - Assert.assertEquals(-1, gbAtY[1]); - Assert.assertEquals(2, gbAtX[2]); - Assert.assertEquals(-2, gbAtY[2]); - Assert.assertEquals(-2, gbAtX[3]); - Assert.assertEquals(-2, gbAtY[3]); - } - - // TESTS WITH TESTOUTPUT - // Ignore in build process - - @Ignore - @Test - public void decodeTemplate0Test() throws Throwable { - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Twelfth Segment (number 11) - SubInputStream sis = new SubInputStream(iis, 523, 35); - GenericRegion gr = new GenericRegion(); - - gr.init(null, sis); - new TestImage(Bitmaps.asBufferedImage(gr.getRegionBitmap())); - } - - @Ignore - @Test - public void decodeWithArithmetichCoding() throws Throwable { - - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Twelfth Segment (number 11) - SubInputStream sis = new SubInputStream(iis, 523, 35); - GenericRegion gr = new GenericRegion(sis); - - gr.init(null, sis); - new TestImage(Bitmaps.asBufferedImage(gr.getRegionBitmap())); - } - - @Ignore - @Test - public void decodeWithMMR() throws Throwable { - - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Fifth Segment (number 4) - SubInputStream sis = new SubInputStream(iis, 190, 59); - GenericRegion gr = new GenericRegion(sis); - gr.init(null, sis); - new TestImage(Bitmaps.asBufferedImage(gr.getRegionBitmap())); - } +public class GenericRegionTest +{ + + @Test + public void parseHeaderTest() throws IOException, InvalidHeaderValueException + { + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + + // Twelfth Segment (number 11) + SubInputStream sis = new SubInputStream(iis, 523, 35); + GenericRegion gr = new GenericRegion(); + gr.init(null, sis); + + Assert.assertEquals(54, gr.getRegionInfo().getBitmapWidth()); + Assert.assertEquals(44, gr.getRegionInfo().getBitmapHeight()); + Assert.assertEquals(4, gr.getRegionInfo().getXLocation()); + Assert.assertEquals(11, gr.getRegionInfo().getYLocation()); + Assert.assertEquals(CombinationOperator.OR, gr.getRegionInfo().getCombinationOperator()); + + Assert.assertFalse(gr.useExtTemplates()); + Assert.assertFalse(gr.isMMREncoded()); + Assert.assertEquals(0, gr.getGbTemplate()); + Assert.assertTrue(gr.isTPGDon()); + + short[] gbAtX = gr.getGbAtX(); + short[] gbAtY = gr.getGbAtY(); + Assert.assertEquals(3, gbAtX[0]); + Assert.assertEquals(-1, gbAtY[0]); + Assert.assertEquals(-3, gbAtX[1]); + Assert.assertEquals(-1, gbAtY[1]); + Assert.assertEquals(2, gbAtX[2]); + Assert.assertEquals(-2, gbAtY[2]); + Assert.assertEquals(-2, gbAtX[3]); + Assert.assertEquals(-2, gbAtY[3]); + } + + // TESTS WITH TESTOUTPUT + // Ignore in build process + + @Ignore + @Test + public void decodeTemplate0Test() throws Throwable + { + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Twelfth Segment (number 11) + SubInputStream sis = new SubInputStream(iis, 523, 35); + GenericRegion gr = new GenericRegion(); + + gr.init(null, sis); + new TestImage(Bitmaps.asBufferedImage(gr.getRegionBitmap())); + } + + @Ignore + @Test + public void decodeWithArithmetichCoding() throws Throwable + { + + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Twelfth Segment (number 11) + SubInputStream sis = new SubInputStream(iis, 523, 35); + GenericRegion gr = new GenericRegion(sis); + + gr.init(null, sis); + new TestImage(Bitmaps.asBufferedImage(gr.getRegionBitmap())); + } + + @Ignore + @Test + public void decodeWithMMR() throws Throwable + { + + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Fifth Segment (number 4) + SubInputStream sis = new SubInputStream(iis, 190, 59); + GenericRegion gr = new GenericRegion(sis); + gr.init(null, sis); + new TestImage(Bitmaps.asBufferedImage(gr.getRegionBitmap())); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/HalftoneRegionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/HalftoneRegionTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/HalftoneRegionTest.java index 7559259..7457220 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/HalftoneRegionTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/HalftoneRegionTest.java @@ -35,37 +35,39 @@ import org.apache.pdfbox.jbig2.segments.HalftoneRegion; import org.apache.pdfbox.jbig2.util.CombinationOperator; import org.junit.Test; -public class HalftoneRegionTest { +public class HalftoneRegionTest +{ - @Test - public void parseHeaderTest() throws IOException, InvalidHeaderValueException { + @Test + public void parseHeaderTest() throws IOException, InvalidHeaderValueException + { - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); - final InputStream inputStream = new FileInputStream(inputFile); + final InputStream inputStream = new FileInputStream(inputFile); - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Seventh Segment (number 6) - SubInputStream sis = new SubInputStream(iis, 302, 87); - HalftoneRegion hr = new HalftoneRegion(sis); - hr.init(null, sis); + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Seventh Segment (number 6) + SubInputStream sis = new SubInputStream(iis, 302, 87); + HalftoneRegion hr = new HalftoneRegion(sis); + hr.init(null, sis); - Assert.assertEquals(true, hr.isMMREncoded()); - Assert.assertEquals(0, hr.getHTemplate()); - Assert.assertEquals(false, hr.isHSkipEnabled()); - Assert.assertEquals(CombinationOperator.OR, hr.getCombinationOperator()); - Assert.assertEquals(0, hr.getHDefaultPixel()); + Assert.assertEquals(true, hr.isMMREncoded()); + Assert.assertEquals(0, hr.getHTemplate()); + Assert.assertEquals(false, hr.isHSkipEnabled()); + Assert.assertEquals(CombinationOperator.OR, hr.getCombinationOperator()); + Assert.assertEquals(0, hr.getHDefaultPixel()); - Assert.assertEquals(8, hr.getHGridWidth()); - Assert.assertEquals(9, hr.getHGridHeight()); - Assert.assertEquals(0, hr.getHGridX()); - Assert.assertEquals(0, hr.getHGridY()); - Assert.assertEquals(1024, hr.getHRegionX()); - Assert.assertEquals(0, hr.getHRegionY()); + Assert.assertEquals(8, hr.getHGridWidth()); + Assert.assertEquals(9, hr.getHGridHeight()); + Assert.assertEquals(0, hr.getHGridX()); + Assert.assertEquals(0, hr.getHGridY()); + Assert.assertEquals(1024, hr.getHRegionX()); + Assert.assertEquals(0, hr.getHRegionY()); - } + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/PageInformationTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/PageInformationTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/PageInformationTest.java index 700a6ad..d8b2a9a 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/PageInformationTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/PageInformationTest.java @@ -34,74 +34,75 @@ import org.apache.pdfbox.jbig2.util.CombinationOperator; import org.junit.Ignore; import org.junit.Test; -public class PageInformationTest { +public class PageInformationTest +{ - @Test - public void parseHeaderCompleteTest() throws IOException, - InvalidHeaderValueException { + @Test + public void parseHeaderCompleteTest() throws IOException, InvalidHeaderValueException + { - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); - final InputStream inputStream = new FileInputStream(inputFile); + final InputStream inputStream = new FileInputStream(inputFile); - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Second Segment (number 1) - SubInputStream sis = new SubInputStream(iis, 59, 19); - PageInformation pi = new PageInformation(); - pi.init(null, sis); - Assert.assertEquals(64, pi.getBitmapWidth()); - Assert.assertEquals(56, pi.getBitmapHeight()); - Assert.assertEquals(0, pi.getResolutionX()); - Assert.assertEquals(0, pi.getResolutionY()); - Assert.assertEquals(true, pi.isLossless()); - Assert.assertEquals(false, pi.mightContainRefinements()); - Assert.assertEquals(0, pi.getDefaultPixelValue()); - Assert.assertEquals(CombinationOperator.OR, pi.getCombinationOperator()); - Assert.assertEquals(false, pi.isAuxiliaryBufferRequired()); - Assert.assertEquals(false, pi.isCombinationOperatorOverrideAllowed()); - Assert.assertEquals(false, pi.isStriped()); - Assert.assertEquals(0, pi.getMaxStripeSize()); - } + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Second Segment (number 1) + SubInputStream sis = new SubInputStream(iis, 59, 19); + PageInformation pi = new PageInformation(); + pi.init(null, sis); + Assert.assertEquals(64, pi.getBitmapWidth()); + Assert.assertEquals(56, pi.getBitmapHeight()); + Assert.assertEquals(0, pi.getResolutionX()); + Assert.assertEquals(0, pi.getResolutionY()); + Assert.assertEquals(true, pi.isLossless()); + Assert.assertEquals(false, pi.mightContainRefinements()); + Assert.assertEquals(0, pi.getDefaultPixelValue()); + Assert.assertEquals(CombinationOperator.OR, pi.getCombinationOperator()); + Assert.assertEquals(false, pi.isAuxiliaryBufferRequired()); + Assert.assertEquals(false, pi.isCombinationOperatorOverrideAllowed()); + Assert.assertEquals(false, pi.isStriped()); + Assert.assertEquals(0, pi.getMaxStripeSize()); + } - @Ignore - @Test - public void parseHeaderXOROperatorTest() throws IOException, - InvalidHeaderValueException { - InputStream inputStream = getClass().getResourceAsStream( - "/sampledata_pageinformation_with_xor-opartor.jb2"); - // skip test if input stream isn't available - assumeTrue(inputStream != null && inputStream.available() > 0); + @Ignore + @Test + public void parseHeaderXOROperatorTest() throws IOException, InvalidHeaderValueException + { + InputStream inputStream = getClass() + .getResourceAsStream("/sampledata_pageinformation_with_xor-opartor.jb2"); + // skip test if input stream isn't available + assumeTrue(inputStream != null && inputStream.available() > 0); - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Second Segment (number 1) - SubInputStream sis = new SubInputStream(iis, 59, 19); - PageInformation pi = new PageInformation(); - pi.init(null, sis); - // XOR (2) als Operator erwartet - Assert.assertEquals(2, pi.getCombinationOperator()); - } + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Second Segment (number 1) + SubInputStream sis = new SubInputStream(iis, 59, 19); + PageInformation pi = new PageInformation(); + pi.init(null, sis); + // XOR (2) als Operator erwartet + Assert.assertEquals(2, pi.getCombinationOperator()); + } - @Ignore - @Test - public void parseHeaderANDOperatorTest() throws IOException, - InvalidHeaderValueException { - InputStream inputStream = getClass().getResourceAsStream( - "/sampledata_pageinformation_with_and-opartor.jb2"); - // skip test if input stream isn't available - assumeTrue(inputStream != null && inputStream.available() > 0); + @Ignore + @Test + public void parseHeaderANDOperatorTest() throws IOException, InvalidHeaderValueException + { + InputStream inputStream = getClass() + .getResourceAsStream("/sampledata_pageinformation_with_and-opartor.jb2"); + // skip test if input stream isn't available + assumeTrue(inputStream != null && inputStream.available() > 0); - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Second Segment (number 1) - SubInputStream sis = new SubInputStream(iis, 59, 19); - PageInformation pi = new PageInformation(); - pi.init(null, sis); - Assert.assertEquals(true, pi.isLossless()); - // AND (1) als Operator erwartet - Assert.assertEquals(1, pi.getCombinationOperator()); - } + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Second Segment (number 1) + SubInputStream sis = new SubInputStream(iis, 59, 19); + PageInformation pi = new PageInformation(); + pi.init(null, sis); + Assert.assertEquals(true, pi.isLossless()); + // AND (1) als Operator erwartet + Assert.assertEquals(1, pi.getCombinationOperator()); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/PatternDictionaryTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/PatternDictionaryTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/PatternDictionaryTest.java index 63b333c..43c5c56 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/PatternDictionaryTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/PatternDictionaryTest.java @@ -35,83 +35,87 @@ import org.apache.pdfbox.jbig2.io.*; import org.junit.Ignore; import org.junit.Test; -public class PatternDictionaryTest { - @Test - public void parseHeaderTest() throws IOException, InvalidHeaderValueException { - - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Sixth Segment (number 5) - SubInputStream sis = new SubInputStream(iis, 245, 45); - PatternDictionary pd = new PatternDictionary(); - pd.init(null, sis); - Assert.assertEquals(true, pd.isMMREncoded()); - Assert.assertEquals(0, pd.getHdTemplate()); - Assert.assertEquals(4, pd.getHdpWidth()); - Assert.assertEquals(4, pd.getHdpHeight()); - Assert.assertEquals(15, pd.getGrayMax()); - } - - // TESTS WITH TESTOUTPUT - // Ignore in build process - - @Ignore - @Test - public void decodeTestWithOutput() throws Throwable { - - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Sixth Segment (number 5) - SubInputStream sis = new SubInputStream(iis, 245, 45); - - PatternDictionary pd = new PatternDictionary(); - pd.init(null, sis); - - ArrayList<Bitmap> b = pd.getDictionary(); - - int i = 5; - // for (int i = 0; i < 8; i++) { - new TestImage(b.get(i).getByteArray(), (int) b.get(i).getWidth(), (int) b.get(i).getHeight(), - b.get(i).getRowStride()); - // } - } - - @Ignore - @Test - public void decodeTestWithOutput2() throws Throwable { - - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - final InputStream inputStream = new FileInputStream(inputFile); - - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - // Twelfth Segment (number 12) - SubInputStream sis = new SubInputStream(iis, 569, 28); - - PatternDictionary pd = new PatternDictionary(); - pd.init(null, sis); - - ArrayList<Bitmap> b = pd.getDictionary(); - - int i = 2; - // for (int i = 0; i < 8; i++) { - new TestImage(b.get(i).getByteArray(), (int) b.get(i).getWidth(), (int) b.get(i).getHeight(), - b.get(i).getRowStride()); - // } - } +public class PatternDictionaryTest +{ + @Test + public void parseHeaderTest() throws IOException, InvalidHeaderValueException + { + + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Sixth Segment (number 5) + SubInputStream sis = new SubInputStream(iis, 245, 45); + PatternDictionary pd = new PatternDictionary(); + pd.init(null, sis); + Assert.assertEquals(true, pd.isMMREncoded()); + Assert.assertEquals(0, pd.getHdTemplate()); + Assert.assertEquals(4, pd.getHdpWidth()); + Assert.assertEquals(4, pd.getHdpHeight()); + Assert.assertEquals(15, pd.getGrayMax()); + } + + // TESTS WITH TESTOUTPUT + // Ignore in build process + + @Ignore + @Test + public void decodeTestWithOutput() throws Throwable + { + + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Sixth Segment (number 5) + SubInputStream sis = new SubInputStream(iis, 245, 45); + + PatternDictionary pd = new PatternDictionary(); + pd.init(null, sis); + + ArrayList<Bitmap> b = pd.getDictionary(); + + int i = 5; + // for (int i = 0; i < 8; i++) { + new TestImage(b.get(i).getByteArray(), (int) b.get(i).getWidth(), + (int) b.get(i).getHeight(), b.get(i).getRowStride()); + // } + } + + @Ignore + @Test + public void decodeTestWithOutput2() throws Throwable + { + + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + final InputStream inputStream = new FileInputStream(inputFile); + + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + // Twelfth Segment (number 12) + SubInputStream sis = new SubInputStream(iis, 569, 28); + + PatternDictionary pd = new PatternDictionary(); + pd.init(null, sis); + + ArrayList<Bitmap> b = pd.getDictionary(); + + int i = 2; + // for (int i = 0; i < 8; i++) { + new TestImage(b.get(i).getByteArray(), (int) b.get(i).getWidth(), + (int) b.get(i).getHeight(), b.get(i).getRowStride()); + // } + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/RegionSegmentInformationTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/RegionSegmentInformationTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/RegionSegmentInformationTest.java index 89f86ec..bfc3089 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/RegionSegmentInformationTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/RegionSegmentInformationTest.java @@ -32,25 +32,27 @@ import org.apache.pdfbox.jbig2.util.CombinationOperator; import org.junit.Test; import org.junit.Assert; -public class RegionSegmentInformationTest { - - @Test - public void parseHeaderTest() throws IOException { - - final File inputFile = new File("target/images/sampledata.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); - - InputStream inputStream = new FileInputStream(inputFile); - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - SubInputStream sis = new SubInputStream(iis, 130, 49); - RegionSegmentInformation rsi = new RegionSegmentInformation(sis); - rsi.parseHeader(); - Assert.assertEquals(37, rsi.getBitmapWidth()); - Assert.assertEquals(8, rsi.getBitmapHeight()); - Assert.assertEquals(4, rsi.getXLocation()); - Assert.assertEquals(1, rsi.getYLocation()); - Assert.assertEquals(CombinationOperator.OR, rsi.getCombinationOperator()); - } +public class RegionSegmentInformationTest +{ + + @Test + public void parseHeaderTest() throws IOException + { + + final File inputFile = new File("target/images/sampledata.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); + + InputStream inputStream = new FileInputStream(inputFile); + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + SubInputStream sis = new SubInputStream(iis, 130, 49); + RegionSegmentInformation rsi = new RegionSegmentInformation(sis); + rsi.parseHeader(); + Assert.assertEquals(37, rsi.getBitmapWidth()); + Assert.assertEquals(8, rsi.getBitmapHeight()); + Assert.assertEquals(4, rsi.getXLocation()); + Assert.assertEquals(1, rsi.getYLocation()); + Assert.assertEquals(CombinationOperator.OR, rsi.getCombinationOperator()); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/SymbolDictionaryTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/SymbolDictionaryTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/SymbolDictionaryTest.java index 8babe4b..be49c41 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/SymbolDictionaryTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/SymbolDictionaryTest.java @@ -20,5 +20,6 @@ package org.apache.pdfbox.jbig2.segments; import org.junit.Ignore; @Ignore -public class SymbolDictionaryTest { -} \ No newline at end of file +public class SymbolDictionaryTest +{ +} http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/segments/TextRegionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/segments/TextRegionTest.java b/src/test/java/org/apache/pdfbox/jbig2/segments/TextRegionTest.java index 3aefea4..ad5421b 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/segments/TextRegionTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/segments/TextRegionTest.java @@ -36,27 +36,30 @@ import org.apache.pdfbox.jbig2.io.DefaultInputStreamFactory; import org.junit.Ignore; import org.junit.Test; -public class TextRegionTest { +public class TextRegionTest +{ - // TESTS WITH TESTOUTPUT - // Ignore for in build process + // TESTS WITH TESTOUTPUT + // Ignore for in build process - @Ignore - @Test - public void textRegionWith() throws IOException, InvalidHeaderValueException, IntegerMaxValueException { + @Ignore + @Test + public void textRegionWith() + throws IOException, InvalidHeaderValueException, IntegerMaxValueException + { - int pageNumber = 1; + int pageNumber = 1; - final File inputFile = new File("target/images/042_11.jb2"); - // skip test if input stream isn't available - assumeTrue(inputFile.exists()); + final File inputFile = new File("target/images/042_11.jb2"); + // skip test if input stream isn't available + assumeTrue(inputFile.exists()); - InputStream inputStream = new FileInputStream(inputFile); - DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); - ImageInputStream iis = disf.getInputStream(inputStream); - JBIG2ImageReader jb2 = new JBIG2ImageReader(new JBIG2ImageReaderSpi()); - jb2.setInput(iis); - BufferedImage b = jb2.read(pageNumber); - new TestImage(b); - } + InputStream inputStream = new FileInputStream(inputFile); + DefaultInputStreamFactory disf = new DefaultInputStreamFactory(); + ImageInputStream iis = disf.getInputStream(inputStream); + JBIG2ImageReader jb2 = new JBIG2ImageReader(new JBIG2ImageReaderSpi()); + jb2.setInput(iis); + BufferedImage b = jb2.read(pageNumber); + new TestImage(b); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/util/CacheFactoryTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/util/CacheFactoryTest.java b/src/test/java/org/apache/pdfbox/jbig2/util/CacheFactoryTest.java index 0f15338..0a9e980 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/util/CacheFactoryTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/util/CacheFactoryTest.java @@ -23,19 +23,21 @@ import org.apache.pdfbox.jbig2.util.cache.CacheBridge; import org.apache.pdfbox.jbig2.util.cache.CacheFactory; import org.junit.Test; -public class CacheFactoryTest { - - @Test - public void testWithDefaultClassLoader() { - CacheFactory.setClassLoader(CacheBridge.class.getClassLoader()); - assertNotNull(CacheFactory.getCache()); - } - - @Test - public void testWithContextClassLoader() { - CacheFactory.setClassLoader(Thread.currentThread().getContextClassLoader()); - assertNotNull(CacheFactory.getCache()); - } - +public class CacheFactoryTest +{ + + @Test + public void testWithDefaultClassLoader() + { + CacheFactory.setClassLoader(CacheBridge.class.getClassLoader()); + assertNotNull(CacheFactory.getCache()); + } + + @Test + public void testWithContextClassLoader() + { + CacheFactory.setClassLoader(Thread.currentThread().getContextClassLoader()); + assertNotNull(CacheFactory.getCache()); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/util/LoggerFactoryTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/util/LoggerFactoryTest.java b/src/test/java/org/apache/pdfbox/jbig2/util/LoggerFactoryTest.java index 0fc89b6..6f40baf 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/util/LoggerFactoryTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/util/LoggerFactoryTest.java @@ -23,19 +23,21 @@ import org.apache.pdfbox.jbig2.util.log.LoggerBridge; import org.apache.pdfbox.jbig2.util.log.LoggerFactory; import org.junit.Test; -public class LoggerFactoryTest { +public class LoggerFactoryTest +{ - @Test - public void testWithDefaultClassLoader() { - LoggerFactory.setClassLoader(LoggerBridge.class.getClassLoader()); - assertNotNull(LoggerFactory.getLogger(LoggerFactoryTest.class)); - } - - @Test - public void testWithContextClassLoader() { - LoggerFactory.setClassLoader(Thread.currentThread().getContextClassLoader()); - assertNotNull(LoggerFactory.getLogger(LoggerFactoryTest.class)); - } - + @Test + public void testWithDefaultClassLoader() + { + LoggerFactory.setClassLoader(LoggerBridge.class.getClassLoader()); + assertNotNull(LoggerFactory.getLogger(LoggerFactoryTest.class)); + } + + @Test + public void testWithContextClassLoader() + { + LoggerFactory.setClassLoader(Thread.currentThread().getContextClassLoader()); + assertNotNull(LoggerFactory.getLogger(LoggerFactoryTest.class)); + } } http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/30839c32/src/test/java/org/apache/pdfbox/jbig2/util/ServiceLookupTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/pdfbox/jbig2/util/ServiceLookupTest.java b/src/test/java/org/apache/pdfbox/jbig2/util/ServiceLookupTest.java index 72c86ef..0e85f1f 100644 --- a/src/test/java/org/apache/pdfbox/jbig2/util/ServiceLookupTest.java +++ b/src/test/java/org/apache/pdfbox/jbig2/util/ServiceLookupTest.java @@ -25,32 +25,37 @@ import java.util.Iterator; import org.apache.pdfbox.jbig2.util.ServiceLookup; import org.junit.Test; -public class ServiceLookupTest { - - @Test - public void withDefaultClassLoader() { - runTest(null); - } - - @Test - public void withContextClassLoader() { - runTest(Thread.currentThread().getContextClassLoader()); - } - - @Test - public void withClassLoaderFromClass() { - runTest(TestService.class.getClassLoader()); - } - - private void runTest(ClassLoader clsLoader) { - ServiceLookup<TestService> serviceLookup = new ServiceLookup<TestService>(); - - Iterator<TestService> services = clsLoader != null - ? serviceLookup.getServices(TestService.class, clsLoader) - : serviceLookup.getServices(TestService.class); - - assertTrue(services.hasNext()); - assertEquals(TestServiceImpl.class, services.next().getClass()); - } +public class ServiceLookupTest +{ + + @Test + public void withDefaultClassLoader() + { + runTest(null); + } + + @Test + public void withContextClassLoader() + { + runTest(Thread.currentThread().getContextClassLoader()); + } + + @Test + public void withClassLoaderFromClass() + { + runTest(TestService.class.getClassLoader()); + } + + private void runTest(ClassLoader clsLoader) + { + ServiceLookup<TestService> serviceLookup = new ServiceLookup<TestService>(); + + Iterator<TestService> services = clsLoader != null + ? serviceLookup.getServices(TestService.class, clsLoader) + : serviceLookup.getServices(TestService.class); + + assertTrue(services.hasNext()); + assertEquals(TestServiceImpl.class, services.next().getClass()); + } }