use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.
the class UtilTests method deleteAll.
@After
public void deleteAll() throws AmazonClientException {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB db = em.getSimpleDb();
String domainName = em.getDomainName(MyTestObject.class);
db.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
domainName = em.getDomainName(MyTestObject2.class);
db.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
domainName = em.getDomainName(MyInheritanceObject1.class);
db.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
em.close();
}
use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method selectItemsTests.
@Test
public void selectItemsTests() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
for (int i = 0; i < 10; i++) {
sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
}
SelectResult result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), null);
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
Assert.assertEquals(1, result.getItems().size());
Assert.assertNull(result.getNextToken());
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method selectItemsWithWhereTests.
@Test
public void selectItemsWithWhereTests() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
for (int i = 0; i < 10; i++) {
sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
}
SelectResult result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", null);
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
Assert.assertEquals(3, result.getItems().size());
Assert.assertNotNull(result.getNextToken());
result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
Assert.assertEquals(1, result.getItems().size());
Assert.assertNull(result.getNextToken());
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method listAllItemsTests.
@Test
public void listAllItemsTests() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
for (int i = 0; i < 3; i++) {
sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
}
List<Item> items = DomainHelper.listAllItems(sdbClient, domainName);
Assert.assertEquals(3, items.size());
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.
the class DomainHelperTests method findByIdTest.
@Test
public void findByIdTest() {
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
AmazonSimpleDB sdbClient = em.getSimpleDb();
String domainName = "simplejpa-domainhelper-tests";
sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
try {
Assert.assertNull(DomainHelper.findItemById(sdbClient, domainName, "noexist"));
sdbClient.putAttributes(new PutAttributesRequest().withItemName("exist").withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
Assert.assertNotNull(DomainHelper.findItemById(sdbClient, domainName, "exist"));
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
}
}
Aggregations