Package org.apache.sling.installer.api

Examples of org.apache.sling.installer.api.InstallableResource


    b.put("two", "B");
    b.put("one", "A");
    b.put("three", "C");

    assertEquals("Same data in different order must have same digest",
                create(new InstallableResource("a", null, a, null, null, null)).getDigest(),
                create(new InstallableResource("a", null, b, null, null, null)).getDigest()
    );
  }
View Full Code Here


    }

    @org.junit.Test public void testResourceType() throws Exception {
        {
            final InputStream s = new FileInputStream(getTestBundle("testbundle-1.0.jar"));
            final RegisteredResource r = create(new InstallableResource("test:1.jar", s, null, "some digest", null, null));

            assertEquals(".jar URL creates a BUNDLE resource",
                    InstallableResource.TYPE_BUNDLE, r.getType());
            final InputStream rs = r.getInputStream();
            assertNotNull("BUNDLE resource provides an InputStream", rs);
            rs.close();
            assertNull("BUNDLE resource does not provide a Dictionary", r.getDictionary());
            assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
        }

        {
            final Hashtable<String, Object> data = new Hashtable<String, Object>();
            data.put("foo", "bar");
            data.put("other", 2);
            final TaskResource r = create(new InstallableResource("configuration:1", null, data, null, null, null));
            assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
                    InstallableResource.TYPE_CONFIG, r.getType());
            final InputStream rs = r.getInputStream();
            assertNull("CONFIG resource does not provide an InputStream", rs);
            final Dictionary<String, Object> d = r.getDictionary();
View Full Code Here

                return localFile;
            }

        };

    InternalResource.create("test", new InstallableResource("test:1.jar", s, null, "somedigest", null, null));
    assertTrue("Local file exists", localFile.exists());

    assertEquals("Local file length matches our data", f.length(), localFile.length());
  }
View Full Code Here

    @org.junit.Test public void testMissingDigest() throws Exception {
        final String data = "This is some data";
        final InputStream in = new ByteArrayInputStream(data.getBytes());

        create(new InstallableResource("test:1.jar", in, null, null, null, null));
        assertNotNull(create(new InstallableResource("test:1.jar", in, null, null, null, null)).getDigest());
    }
View Full Code Here

        assertNotNull(create(new InstallableResource("test:1.jar", in, null, null, null, null)).getDigest());
    }

    @org.junit.Test public void testBundleManifest() throws Exception {
        final File f = getTestBundle("testbundle-1.0.jar");
        final InstallableResource i = new InstallableResource("test:" + f.getAbsolutePath(), new FileInputStream(f), null, f.getName(), null, null);
        final TaskResource r = create(i);
        assertNotNull("RegisteredResource must have bundle symbolic name", r.getAttribute(Constants.BUNDLE_SYMBOLICNAME));
        assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
    }
View Full Code Here

        assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
    }

//    @org.junit.Test
    public void testConfigEntity() throws Exception {
        final InstallableResource i = new InstallableResource("test:/foo/someconfig", null, new Hashtable<String, Object>(), null, null, null);
        final TaskResource r = create(i);
        assertNull("RegisteredResource must not have bundle symbolic name", r.getAttribute(Constants.BUNDLE_SYMBOLICNAME));
        assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId());
    }
View Full Code Here

        assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId());
    }

    @org.junit.Test public void testConfigDigestIncludesUrl() throws Exception {
        final Dictionary<String, Object> data = new Hashtable<String, Object>();
        final InstallableResource rA = new InstallableResource("test:urlA", null, data, null, null, null);
        final InstallableResource rB = new InstallableResource("test:urlB", null, data, null, null, null);
        assertTrue(
                "Expecting configs with same data but different URLs to have same digests",
                create(rA).getDigest().equals(create(rB).getDigest()));
    }
View Full Code Here

    }

    @Test
    public void testDictionaryDigest() throws IOException {
        final Dictionary<String, Object> d = new Hashtable<String, Object>();
        final InstallableResource r = new InstallableResource("x:url", null, d, null, null, null);
        assertNotNull("Expected RegisteredResource to compute its own digest", create(r).getDigest());
    }
View Full Code Here

        }
        for(int i=keys.length - 1 ; i >= 0; i--) {
            d2.put(keys[i], keys[i] + "." + keys[i]);
        }

        final InstallableResource r1 = new InstallableResource("test:url1", null, d1, null, null, null);
        final InstallableResource r2 = new InstallableResource("test:url1", null, d2, null, null, null);

        assertEquals(
                "Two InstallableResource (Dictionary) with same values but different key orderings must have the same key",
                create(r1).getDigest(),
                create(r2).getDigest()
View Full Code Here

  }

  private static EntityResourceList getRegisteredResource(String url) throws IOException {
        new FileDataStore(new MockBundleContext());
        final InternalResource internal = InternalResource.create("test",
                new InstallableResource(url, null, new Hashtable<String, Object>(), null, null, null));
        RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
        TransformationResult[] tr = new DefaultTransformer().transform(rr);
        if ( tr == null ) {
            final TransformationResult result = new TransformationResult();
            result.setId(url);
View Full Code Here

TOP

Related Classes of org.apache.sling.installer.api.InstallableResource

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.