Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.NewAttribute$ErrorAttribute


        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

*
*/
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)");
View Full Code Here

        CPUTF8 name = new CPUTF8("TestAttribute");
        CPUTF8 layout = new CPUTF8("B");
        MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
                null, null, new AttributeDefinition(35,
                        AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[] {27}, null, 0, null));
        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[] {56}, null, 0, null));
        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[] {3}, null, 0, null));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        newAttributeBands.pack(out);
        // BYTE1 is used for B layouts so we don't need to unpack to test the results
        byte[] bytes = out.toByteArray();
        assertEquals(3, bytes.length);
View Full Code Here

        CPUTF8 name = new CPUTF8("TestAttribute");
        CPUTF8 layout = new CPUTF8("NB[SH]");
        MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
                null, null, new AttributeDefinition(35,
                        AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[] {1, 0, 100}, null, 0, null));
        short s = -50;
        byte b1 = (byte)(s>>>8);
        byte b2 = (byte)s;
        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[] {3, 0, 5, 0, 25, b1, b2}, null, 0, null));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        newAttributeBands.pack(out);
        byte[] bytes = out.toByteArray();
        assertEquals(1, bytes[0]);
        assertEquals(3, bytes[1]);
View Full Code Here

     * @throws Pack200Exception
     *             if the minor version is not 7
     */
    private void setArchiveMinorVersion(int version) throws Pack200Exception {
        if (version != 7)
            throw new Pack200Exception("Invalid segment minor version");
        archiveMinor = version;
    }
View Full Code Here

     * @throws Pack200Exception
     *             if the major version is not 150
     */
    private void setArchiveMajorVersion(int version) throws Pack200Exception {
        if (version != 150)
            throw new Pack200Exception("Invalid segment major version: "
                    + version);
        archiveMajor = version;
    }
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.NewAttribute$ErrorAttribute

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.