Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.Segment$SegmentMethodVisitor


* @author Alex Blewitt
* @version $Revision: $
*/
public class CodecEncodingTest extends TestCase {
  public void testCanonicalEncodings() throws IOException, Pack200Exception {
    Codec defaultCodec = new BHSDCodec(2,16,0,0);
    assertEquals(defaultCodec,CodecEncoding.getCodec(0,null, defaultCodec));
    Map map = new HashMap();
    // These are the canonical encodings specified by the Pack200 spec
    map.put(new Integer(1), "(1,256)");
    map.put(new Integer(2), "(1,256,1)");
View Full Code Here


           
        }
    };
   
    public void testDecodeBandInt() throws IOException, Pack200Exception {
        BHSDCodec codec = Codec.BYTE1;
        byte[] bytes = new byte[]{(byte)3,(byte)56,(byte)122,(byte)78};
        InputStream in = new ByteArrayInputStream(bytes);
        int[] ints = bandSet.decodeBandInt("Test Band", in, codec, 4);
        for (int i = 0; i < ints.length; i++) {
            assertEquals("Wrong value in position " + i, ints[i], bytes[i]);
View Full Code Here

            assertEquals("Wrong value in position " + i, ints[i], bytes[i]);
        }
    }
   
    public void testDecodeBandLong() throws IOException, Pack200Exception {
        BHSDCodec codec = Codec.BYTE1;
        byte[] bytes = new byte[]{(byte)3,(byte)56,(byte)122,(byte)78, Byte.MAX_VALUE, Byte.MIN_VALUE};
        InputStream in = new ByteArrayInputStream(bytes);
        long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 4);
        for (int i = 0; i < longs.length; i++) {
            assertEquals("Wrong value in position " + i, longs[i], bytes[i]);
View Full Code Here

        for (int i = 0; i < 255; i++)
            decode(Codec.BYTE1, new byte[] { (byte) i }, i, 0);
    }

    public void testByte1Delta() throws Exception {
        Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
        long last = 0;
        for (int i = 1; i < 255; i++)
            last = decode(BYTE1D, new byte[] { (byte) 1 }, i, last);
    }
View Full Code Here

        for (int i = 1; i < 255; i++)
            last = decode(BYTE1D, new byte[] { (byte) 1 }, i, last);
    }

    public void testByte1DeltaException() throws Exception {
        Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
        try {
            BYTE1D.decode(new ByteArrayInputStream(new byte[] { (byte) 1 }));
            fail("Decoding with a delta stream and not passing a last value should throw exception");
        } catch (Pack200Exception e) {
            assertTrue(true);
        }
    }
View Full Code Here

            assertTrue(true);
        }
    }

    public void testByte1Signed() throws Exception {
        Codec BYTE1S2 = new BHSDCodec(1, 256, 2);
        decode(BYTE1S2, new byte[] { 0 }, 0, 0);
        decode(BYTE1S2, new byte[] { 1 }, 1, 0);
        decode(BYTE1S2, new byte[] { 2 }, 2, 0);
        decode(BYTE1S2, new byte[] { 3 }, -1, 0);
        decode(BYTE1S2, new byte[] { 4 }, 3, 0);
View Full Code Here

* @author Alex Blewitt
* @version $Revision: $
*/
public class CodecEncodingTest extends TestCase {
  public void testCanonicalEncodings() throws IOException, Pack200Exception {
    Codec defaultCodec = new BHSDCodec(2,16,0,0);
    assertEquals(defaultCodec,CodecEncoding.getCodec(0,null, defaultCodec));
    Map map = new HashMap();
    // These are the canonical encodings specified by the Pack200 spec
    map.put(new Integer(1), "(1,256)");
    map.put(new Integer(2), "(1,256,1)");
View Full Code Here

    public void testSQL() throws IOException, Pack200Exception, URISyntaxException {
        in = new JarFile(new File(Archive.class.getResource(
                "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
        file = File.createTempFile("sql", ".pack");
        out = new FileOutputStream(file);
        PackingOptions options = new PackingOptions();
        options.setGzip(false);
        Archive ar = new Archive(in, out, options);
        ar.pack();
        in.close();
        out.close();
View Full Code Here

        in = new JarFile(new File(Archive.class.getResource(
                "/org/apache/harmony/pack200/tests/largeClassUnpacked.jar")
                .toURI()));
        file = File.createTempFile("largeClass", ".pack");
        out = new FileOutputStream(file);
        PackingOptions options = new PackingOptions();
        options.setGzip(false);
        new Archive(in, out, options).pack();
        in.close();
        out.close();

        // now unpack
View Full Code Here

    public void testJNDI() throws IOException, Pack200Exception, URISyntaxException {
        in = new JarFile(new File(Archive.class.getResource(
                "/org/apache/harmony/pack200/tests/jndi.jar").toURI()));
        file = File.createTempFile("jndi", ".pack");
        out = new FileOutputStream(file);
        PackingOptions options = new PackingOptions();
        options.setGzip(false);
        new Archive(in, out, options).pack();
        in.close();
        out.close();

        // now unpack
View Full Code Here

TOP

Related Classes of org.apache.harmony.pack200.Segment$SegmentMethodVisitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.