Search in sources :

Example 21 with InstallableResource

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InstallableResource(org.apache.sling.installer.api.InstallableResource) Test(org.junit.Test)

Example 22 with InstallableResource

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());
}
Also used : Hashtable(java.util.Hashtable) InstallableResource(org.apache.sling.installer.api.InstallableResource) Test(org.junit.Test)

Example 23 with InstallableResource

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());
}
Also used : TaskResource(org.apache.sling.installer.api.tasks.TaskResource) InstallableResource(org.apache.sling.installer.api.InstallableResource)

Example 24 with InstallableResource

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());
}
Also used : TaskResource(org.apache.sling.installer.api.tasks.TaskResource) InstallableResource(org.apache.sling.installer.api.InstallableResource) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 25 with InstallableResource

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);
}
Also used : Hashtable(java.util.Hashtable) InstallableResource(org.apache.sling.installer.api.InstallableResource) Test(org.junit.Test)

Aggregations

InstallableResource (org.apache.sling.installer.api.InstallableResource)47 Hashtable (java.util.Hashtable)23 Test (org.junit.Test)21 File (java.io.File)8 IOException (java.io.IOException)8 InputStream (java.io.InputStream)7 Configuration (org.osgi.service.cm.Configuration)6 FileInputStream (java.io.FileInputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 TaskResource (org.apache.sling.installer.api.tasks.TaskResource)3 TransformationResult (org.apache.sling.installer.api.tasks.TransformationResult)3 FileOutputStream (java.io.FileOutputStream)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 URL (java.net.URL)2 LinkedList (java.util.LinkedList)2 Node (javax.jcr.Node)2 OsgiInstaller (org.apache.sling.installer.api.OsgiInstaller)2 ModelArchiveReader (org.apache.sling.provisioning.model.io.ModelArchiveReader)2