use of com.amazonaws.services.simpledb.model.Attribute in project camel by apache.
the class SdbComponentSpringTest method deleteAttributes.
@Test
public void deleteAttributes() {
final List<Attribute> attributes = Arrays.asList(new Attribute[] { new Attribute("NAME1", "VALUE1") });
final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
}
});
assertEquals("TestDomain", amazonSDBClient.deleteAttributesRequest.getDomainName());
assertEquals("ITEM1", amazonSDBClient.deleteAttributesRequest.getItemName());
assertEquals(condition, amazonSDBClient.deleteAttributesRequest.getExpected());
assertEquals(attributes, amazonSDBClient.deleteAttributesRequest.getAttributes());
}
use of com.amazonaws.services.simpledb.model.Attribute in project wildfly-camel by wildfly-extras.
the class SDBIntegrationTest method putAndGetAttributes.
@Test
@SuppressWarnings("unchecked")
public void putAndGetAttributes() throws Exception {
AmazonSimpleDBClient sdbClient = provider.getClient();
Assume.assumeNotNull("AWS client not null", sdbClient);
assertNoStaleDomain(sdbClient, "before");
try {
try {
SDBUtils.createDomain(sdbClient, domainName);
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("sdbClient", sdbClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to("aws-sdb://" + domainName + "?amazonSDBClient=#sdbClient");
}
});
camelctx.start();
try {
ReplaceableAttribute attr = new ReplaceableAttribute("SomeName", "SomeValue", true);
ProducerTemplate producer = camelctx.createProducerTemplate();
Exchange exchange = producer.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, itemName);
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, Collections.singletonList(attr));
}
});
Assert.assertNull(exchange.getException());
int retries = 10;
List<Attribute> result = Collections.emptyList();
while (result.isEmpty() && 0 < retries--) {
exchange = producer.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, itemName);
}
});
Assert.assertNull(exchange.getException());
result = exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class);
System.out.println(retries + ": " + result);
Thread.sleep(500);
}
Assert.assertEquals(1, result.size());
Assert.assertEquals(attr.getName(), result.get(0).getName());
Assert.assertEquals(attr.getValue(), result.get(0).getValue());
} finally {
camelctx.stop();
}
} finally {
sdbClient.deleteDomain(new DeleteDomainRequest(domainName));
}
} finally {
assertNoStaleDomain(sdbClient, "after");
}
}
use of com.amazonaws.services.simpledb.model.Attribute in project teiid by teiid.
the class TestSimpleDBExecution method mockResult.
private List<Item> mockResult() {
List<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute("a1", "a1"));
attributes.add(new Attribute("a2", "a2"));
attributes.add(new Attribute("a2", "a22"));
List<Item> items = new ArrayList<Item>();
items.add(new Item("one", attributes));
return items;
}
use of com.amazonaws.services.simpledb.model.Attribute in project teiid by teiid.
the class SimpleDbAPIClassTest method getAttributeNamesTest.
@Test
public void getAttributeNamesTest() throws Exception {
DomainMetadataResult metadataResult = mock(DomainMetadataResult.class);
SelectResult result = mock(SelectResult.class);
ArrayList<Item> items = new ArrayList<Item>();
items.add(new Item("1", Arrays.asList(new Attribute("c", "d"), new Attribute("a", "b"))));
stub(result.getItems()).toReturn(items);
when(metadataResult.getAttributeNameCount()).thenReturn(2);
when(client.select(any(SelectRequest.class))).thenReturn(result);
when(client.domainMetadata(any(DomainMetadataRequest.class))).thenReturn(metadataResult);
assertEquals("c", simpleDbApi.getAttributeNames("x").iterator().next().getName());
}
use of com.amazonaws.services.simpledb.model.Attribute in project siena by mandubian.
the class SdbMappingUtils method fillModel.
public static void fillModel(String itemName, List<Attribute> attrs, Class<?> clazz, Object obj) {
fillModelKeysOnly(itemName, clazz, obj);
Attribute theAttr;
for (Field field : ClassInfo.getClassInfo(clazz).updateFields) {
if (!ClassInfo.isEmbeddedNative(field)) {
theAttr = null;
String attrName = getAttributeName(field);
// searches attribute and if found, removes it from the list to reduce number of attributes
for (Attribute attr : attrs) {
if (attrName.equals(attr.getName())) {
theAttr = attr;
attrs.remove(attr);
break;
}
}
if (theAttr != null) {
setFromString(obj, field, theAttr.getValue());
}
} else {
Object value = SdbNativeSerializer.unembed(field.getType(), ClassInfo.getSingleColumnName(field), attrs);
Util.setField(obj, field, value);
}
}
}
Aggregations