Example usage for java.util.jar Manifest getAttributes

List of usage examples for java.util.jar Manifest getAttributes

Introduction

In this page you can find the example usage for java.util.jar Manifest getAttributes.

Prototype

public Attributes getAttributes(String name) 

Source Link

Document

Returns the Attributes for the specified entry name.

Usage

From source file:test.BuilderTest.java

/**
 * Test the name section/*from  w w  w . ja v a  2 s. com*/
 */

public static void testNamesection() throws Exception {
    Builder b = new Builder();
    try {
        b.addClasspath(IO.getFile("jar/osgi.jar"));
        b.setProperty(Constants.NAMESECTION,
                "org/osgi/service/event/*;MD5='${md5;${@}}';SHA1='${sha1;${@}}';MD5H='${md5;${@};hex}'");
        b.setProperty(Constants.PRIVATEPACKAGE, "org.osgi.service.event");
        Jar build = b.build();
        assertOk(b);
        build.calcChecksums(new String[] { "MD5", "SHA1" });
        assertTrue(b.check());
        Manifest m = build.getManifest();
        m.write(System.err);

        assertNotNull(m.getAttributes("org/osgi/service/event/EventAdmin.class").getValue("MD5"));
        assertNotNull(m.getAttributes("org/osgi/service/event/EventAdmin.class").getValue("SHA1"));
        assertEquals(m.getAttributes("org/osgi/service/event/EventAdmin.class").getValue("MD5-Digest"),
                m.getAttributes("org/osgi/service/event/EventAdmin.class").getValue("MD5"));
    } finally {
        b.close();
    }

}