use of org.apache.sling.cassandra.resource.provider.CassandraResourceResolver in project sling by apache.
the class CassandraDataParentNodeTest method getParentData.
private void getParentData(CassandraResourceProvider cassandraResourceProvider, String cf) {
Resource resource = cassandraResourceProvider.getResource(new CassandraResourceResolver(), "/content/cassandra/" + cf + "/c1/c2");
Assert.assertNotNull(resource);
Resource parent = resource.getParent();
Assert.assertNotNull(parent);
Assert.assertEquals("/content/cassandra/" + cf + "/c1", parent.getPath());
}
use of org.apache.sling.cassandra.resource.provider.CassandraResourceResolver in project sling by apache.
the class CassandraDataReadTest method readData.
private void readData(CassandraResourceProvider cassandraResourceProvider, String cf) {
Resource resource = cassandraResourceProvider.getResource(new CassandraResourceResolver(), "/content/cassandra/" + cf + "/c1/c2");
Assert.assertNotNull(resource);
}
use of org.apache.sling.cassandra.resource.provider.CassandraResourceResolver in project sling by apache.
the class CassandraModifyResourceProviderDeleteTest method testDeleteData.
@Test
public void testDeleteData() {
String cf = "p3";
try {
String path1 = "/content/cassandra/" + cf + "/c1";
CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
cassandraResourceProvider.setColumnFamily(cf);
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("metadata", "resolutionPathInfo=json");
map1.put("resourceType", "nt:cassandra0");
map1.put("resourceSuperType", "nt:supercass1");
CassandraResourceResolver resolver = new CassandraResourceResolver();
cassandraResourceProvider.create(resolver, path1, map1);
Assert.assertNull("Before Commiting Resource should be null", cassandraResourceProvider.getResource(resolver, path1));
cassandraResourceProvider.commit(resolver);
Assert.assertNotNull("Commited Resource cannot be null", cassandraResourceProvider.getResource(resolver, path1));
cassandraResourceProvider.delete(resolver, path1);
Assert.assertNotNull("Uncommited deleted resource cannot be null", cassandraResourceProvider.getResource(resolver, path1));
cassandraResourceProvider.commit(resolver);
Assert.assertNull("Deleted resource should be null", cassandraResourceProvider.getResource(resolver, path1));
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
Assert.fail("Failed to add data to cassandra");
}
}
use of org.apache.sling.cassandra.resource.provider.CassandraResourceResolver in project sling by apache.
the class CassandraModifyResourceProviderRevertTest method testRevertData.
@Test
public void testRevertData() {
String cf = "p4";
try {
String path1 = "/content/cassandra/" + cf + "/c1";
CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
cassandraResourceProvider.setColumnFamily(cf);
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("metadata", "resolutionPathInfo=json");
map1.put("resourceType", "nt:cassandra0");
map1.put("resourceSuperType", "nt:supercass1");
CassandraResourceResolver resolver = new CassandraResourceResolver();
cassandraResourceProvider.create(resolver, path1, map1);
Assert.assertNull("Before Commiting resource should be null", cassandraResourceProvider.getResource(resolver, path1));
cassandraResourceProvider.revert(resolver);
Assert.assertNull("Reverted resource should be null", cassandraResourceProvider.getResource(resolver, path1));
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
Assert.fail("Failed to add data to cassandra");
}
}
use of org.apache.sling.cassandra.resource.provider.CassandraResourceResolver in project sling by apache.
the class CassandraDataAddLoadTest method testAddLoadTestData.
public void testAddLoadTestData() {
try {
for (int k = 0; k < sizes.length; k++) {
CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
createColumnFamily(cfs[k], cassandraResourceProvider.getKeyspace(), new StringSerializer());
cassandraResourceProvider.setColumnFamily(cfs[k]);
CassandraResourceResolver resolver = new CassandraResourceResolver();
for (int i = 0; i < sizes[k]; i++) {
String path = parentPath + cfs[k] + "/" + i;
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("metadata", "resolutionPathInfo=json");
map1.put("resourceType", "nt:cassandra0");
map1.put("resourceSuperType", "nt:supercass1");
cassandraResourceProvider.create(resolver, path, map1);
cassandraResourceProvider.commit(resolver);
System.out.println(">>" + path);
}
}
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
Assert.fail("Failed to add data to cassandra");
}
}
Aggregations