use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class DictionaryDigestTest method testDictionaryDigestSameData.
@org.junit.Test
public void testDictionaryDigestSameData() throws Exception {
final Hashtable<String, Object> d1 = new Hashtable<String, Object>();
final Hashtable<String, Object> d2 = new Hashtable<String, Object>();
setTestData(d1);
setTestData(d2);
assertEquals("Two dictionary with same values have the same key", create(new InstallableResource("a", null, d1, null, null, null)).getDigest(), create(new InstallableResource("a", null, d2, null, null, null)).getDigest());
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceComparatorTest method getConfig.
private RegisteredResourceImpl getConfig(String url, Dictionary<String, Object> data, int priority, String digest, ResourceState state) throws IOException {
if (data == null) {
data = new Hashtable<String, Object>();
data.put("foo", "bar");
}
new FileDataStore(new MockBundleContext());
final InstallableResource r = new InstallableResource(url, null, data, digest, null, priority);
final InternalResource internal = InternalResource.create("test", r);
final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
TransformationResult[] tr = new DefaultTransformer().transform(rr);
if (tr == null) {
final TransformationResult result = new TransformationResult();
result.setId(url);
result.setResourceType(InstallableResource.TYPE_CONFIG);
tr = new TransformationResult[] { result };
}
final RegisteredResourceImpl result = (RegisteredResourceImpl) rr.clone(tr[0]);
if (state != null) {
result.setState(state, null);
}
return result;
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class TaskOrderingTest method getRegisteredResource.
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);
result.setResourceType(InstallableResource.TYPE_CONFIG);
tr = new TransformationResult[] { result };
}
rr = (RegisteredResourceImpl) rr.clone(tr[0]);
final EntityResourceList erl = new EntityResourceList("test", new MockInstallationListener());
erl.addOrUpdate(rr);
return erl;
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceComparatorTest method untransformedResource.
private RegisteredResource untransformedResource(String id, int prio) throws IOException {
final ByteArrayInputStream is = new ByteArrayInputStream(id.getBytes("UTF-8"));
final InstallableResource r = new InstallableResource(id, is, null, id, id, prio);
final InternalResource internal = InternalResource.create("test", r);
return RegisteredResourceImpl.create(internal);
}
use of org.apache.sling.installer.api.InstallableResource in project sling by apache.
the class RegisteredResourceTest method testDictionaryDigestFromDictionaries.
@org.junit.Test
public void testDictionaryDigestFromDictionaries() throws Exception {
final Hashtable<String, Object> d1 = new Hashtable<String, Object>();
final Hashtable<String, Object> d2 = new Hashtable<String, Object>();
final String[] keys = { "foo", "bar", "something" };
for (int i = 0; i < keys.length; i++) {
d1.put(keys[i], keys[i] + "." + keys[i]);
}
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());
}
Aggregations