use of org.apache.aries.blueprint.reflect.BeanMetadataImpl in project geronimo-xbean by apache.
the class RestaurantUsingBlueprintTest method testPizza.
public void testPizza() throws Exception {
BeanMetadataImpl restaurant = (BeanMetadataImpl) reg.getComponentDefinition("restaurant");
BeanProperty prop = propertyByName("serviceName", restaurant);
BeanMetadataImpl qname = (BeanMetadataImpl) prop.getValue();
assertEquals(3, qname.getArguments().size());
assertEquals("http://acme.com", ((ValueMetadataImpl) qname.getArguments().get(0).getValue()).getStringValue());
assertEquals("xyz", ((ValueMetadataImpl) qname.getArguments().get(1).getValue()).getStringValue());
assertEquals("foo", ((ValueMetadataImpl) qname.getArguments().get(2).getValue()).getStringValue());
// dinners (1-many using list)
BeanProperty dinnerProp = propertyByName("dinnerMenu", restaurant);
List<Metadata> dinners = ((CollectionMetadata) dinnerProp.getValue()).getValues();
assertNotNull("dinners is null!", dinners);
assertEquals("dinners size: " + dinners, 2, dinners.size());
BeanMetadataImpl pizza = (BeanMetadataImpl) dinners.get(0);
checkPropertyValue("topping", "Ham", pizza);
checkPropertyValue("cheese", "Mozzarella", pizza);
// TODO blueprint int value
checkPropertyValue("size", "15", pizza);
pizza = (BeanMetadataImpl) dinners.get(1);
checkPropertyValue("topping", "Eggs", pizza);
checkPropertyValue("cheese", "Mozzarella", pizza);
// TODO blueprint int value
checkPropertyValue("size", "16", pizza);
// dinners (1-many using Set)
BeanProperty snackProp = propertyByName("snackMenu", restaurant);
List<Metadata> snacks = ((CollectionMetadata) snackProp.getValue()).getValues();
assertNotNull("dinners is null!", snacks);
assertEquals("dinners size: " + snacks, 2, snacks.size());
for (Metadata snackMeta : snacks) {
BeanMetadataImpl snack = (BeanMetadataImpl) snackMeta;
BeanProperty toppingProp = propertyByName("topping", snack);
String topping = ((ValueMetadataImpl) toppingProp.getValue()).getStringValue();
if ("Tofu".equals(topping)) {
checkPropertyValue("cheese", "Parmesan", snack);
checkPropertyValue("size", "6", snack);
} else if ("Prosciutto".equals(topping)) {
checkPropertyValue("cheese", "Blue", snack);
checkPropertyValue("size", "8", snack);
} else {
fail("wrong topping: " + snackMeta);
}
}
// lunches (1-many using array)
CollectionMetadataImpl lunches = (CollectionMetadataImpl) propertyByName("lunchMenu", restaurant).getValue();
assertNotNull("lunches is null!", lunches);
assertEquals("lunches size: " + lunches, 1, lunches.getValues().size());
pizza = (BeanMetadataImpl) lunches.getValues().get(0);
checkPropertyValue("topping", "Chicken", pizza);
checkPropertyValue("cheese", "Brie", pizza);
checkPropertyValue("size", "17", pizza);
// favourite (1-1)
BeanProperty favourite = propertyByName("favourite", restaurant);
pizza = (BeanMetadataImpl) favourite.getValue();
assertNotNull("Pizza is null!", pizza);
// pizza.makePizza();
//
checkPropertyValue("topping", "Salami", pizza);
checkPropertyValue("cheese", "Edam", pizza);
checkPropertyValue("size", "17", pizza);
}
use of org.apache.aries.blueprint.reflect.BeanMetadataImpl in project geronimo-xbean by apache.
the class QNameUsingBlueprintTest method testQName.
public void testQName() throws Exception {
BeanMetadataImpl svc = (BeanMetadataImpl) reg.getComponentDefinition("qnameService");
List<Metadata> services = ((CollectionMetadataImpl) propertyByName("services", svc).getValue()).getValues();
assertNotNull(services);
assertEquals(2, services.size());
checkQName("urn:foo", "test", services.get(0));
checkQName("urn:foo", "bar", services.get(1));
List<Metadata> list = ((CollectionMetadataImpl) propertyByName("list", svc).getValue()).getValues();
assertNotNull(list);
assertEquals(1, list.size());
checkQName("urn:foo", "list", list.get(0));
}
use of org.apache.aries.blueprint.reflect.BeanMetadataImpl in project geronimo-xbean by apache.
the class BeerNullTest method testBeer.
public void testBeer() throws Exception {
BeanMetadataImpl meta = (BeanMetadataImpl) reg.getComponentDefinition("beerService");
checkPropertyValue("name", "Stella", meta);
checkPropertyValue("id", "123", meta);
// no property set since this is the default
// checkPropertyValue("source", "tap", meta);
BeanMetadataImpl meta2 = (BeanMetadataImpl) reg.getComponentDefinition("beerService2");
checkPropertyValue("name", "Blue Moon", meta2);
checkPropertyValue("id", "123", meta2);
assertTrue(propertyByName("source", meta2).getValue() instanceof NullMetadata);
}
use of org.apache.aries.blueprint.reflect.BeanMetadataImpl in project geronimo-xbean by apache.
the class WineUsingBlueprintTest method testWine.
public void testWine() throws Exception {
BeanMetadataImpl meta = (BeanMetadataImpl) reg.getComponentDefinition("wineService");
checkArgumentValue(1, "Amarone", meta, false);
checkArgumentValue(0, "wineService", meta, false);
}
use of org.apache.aries.blueprint.reflect.BeanMetadataImpl in project geronimo-xbean by apache.
the class SocketAddressBlueprintTest method testSocketService.
public void testSocketService() throws Exception {
BeanMetadataImpl socketService = (BeanMetadataImpl) reg.getComponentDefinition("socketService");
// System.out.println();
// System.out.println("===========================");
// System.out.println(socketService.getAddresses());
// System.out.println("===========================");
// System.out.println();
// List<InetSocketAddress> expected = Arrays.asList(new InetSocketAddress("localhost", 42), new InetSocketAddress("localhost", 42));
assertEquals(1, socketService.getProperties().size());
CollectionMetadata collection = (CollectionMetadata) socketService.getProperties().get(0).getValue();
assertEquals(2, collection.getValues().size());
}
Aggregations