use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceTest method testMissingDigest.
@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());
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceTest method testDictionaryDigest.
@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());
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceTest method testConfigEntity.
// @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());
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceTest method testBundleManifest.
@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());
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class ConfigPrioritiesTest method testOverrideConfig.
@Test
public void testOverrideConfig() throws Exception {
final String pid = getClass().getSimpleName() + "." + System.currentTimeMillis();
final Dictionary<String, Object> data = new Hashtable<String, Object>();
data.put("foo", "a");
final InstallableResource a = getInstallableResource("a/" + pid, data, InstallableResource.DEFAULT_PRIORITY - 1)[0];
data.put("foo", "b");
final InstallableResource b = getInstallableResource("b/" + pid, data, InstallableResource.DEFAULT_PRIORITY)[0];
data.put("foo", "c");
final InstallableResource c = getInstallableResource("c/" + pid, data, InstallableResource.DEFAULT_PRIORITY + 1)[0];
// c has more priority than b which has more than a
installer.updateResources(URL_SCHEME, new InstallableResource[] { b }, null);
waitForConfigValue(null, pid, "foo", "b");
installer.updateResources(URL_SCHEME, new InstallableResource[] { c }, null);
waitForConfigValue(null, pid, "foo", "c");
installer.updateResources(URL_SCHEME, new InstallableResource[] { a }, null);
// highest prio should be active (c)
waitForConfigValue(null, pid, "foo", "c");
// removing c, second highest prio should be active (b)
installer.updateResources(URL_SCHEME, null, new String[] { c.getId() });
waitForConfigValue(null, pid, "foo", "b");
// removing b, a should be active
installer.updateResources(URL_SCHEME, null, new String[] { b.getId() });
waitForConfigValue(null, pid, "foo", "a");
// and config should be gone only after removing everything
installer.updateResources(URL_SCHEME, null, new String[] { a.getId() });
waitForConfiguration("After removing all resources", pid, false);
}
Aggregations