protected void testBMD(BeanMetaData bmd) throws Throwable { assertNotNull(bmd); assertEquals(Collections.singleton((Object) "alias"), bmd.getAliases()); assertEquals( Collections.singleton((SupplyMetaData) new AbstractSupplyMetaData("supply")), bmd.getSupplies()); assertEquals( Collections.singleton((DemandMetaData) new AbstractDemandMetaData("demand")), bmd.getDemands()); assertEquals( Collections.singleton((DependencyMetaData) new AbstractDependencyMetaData("depend")), bmd.getDepends()); ConstructorMetaData cmd = bmd.getConstructor(); assertNotNull(cmd); assertEquals(AnnotationTester.class.getName(), cmd.getFactoryClass()); assertEquals("factoryMethod", cmd.getFactoryMethod()); testInstalls(bmd.getInstalls()); testInstalls(bmd.getUninstalls()); List<CallbackMetaData> callbacks = bmd.getInstallCallbacks(); assertNotNull(callbacks); assertEquals(1, callbacks.size()); CallbackMetaData callback = callbacks.get(0); assertTrue(callback.getMethodName().contains("Something")); callbacks = bmd.getUninstallCallbacks(); assertNotNull(callbacks); assertEquals(1, callbacks.size()); callback = callbacks.get(0); assertTrue(callback.getMethodName().contains("Something")); BeanAccessMode mode = bmd.getAccessMode(); if (mode == BeanAccessMode.ALL) { Set<PropertyMetaData> propertys = bmd.getProperties(); assertNotNull(propertys); assertEquals(2, propertys.size()); } else { Set<PropertyMetaData> propertys = bmd.getProperties(); assertNotNull(propertys); assertEquals(1, propertys.size()); PropertyMetaData pmd = propertys.iterator().next(); assertEquals("number", pmd.getName()); assertInstanceOf(pmd.getValue(), AbstractDependencyValueMetaData.class); } testLifecycle(bmd.getCreate(), "myCreate"); testLifecycle(bmd.getStart(), "myStart"); testLifecycle(bmd.getStop(), "myStop"); testLifecycle(bmd.getDestroy(), "myDestroy"); }
public void testDefaultAnnotation2BMDFactory() throws Throwable { BeanMetaData bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(AllIoCAnnotations.class); testBMD(bmd1); bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData( AllIoCAnnotations.class, BeanAccessMode.ALL); testBMD(bmd1); bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(ConstructorAnnotationTester.class); ConstructorMetaData cmd = bmd1.getConstructor(); assertNotNull(cmd); List<ParameterMetaData> parameters = cmd.getParameters(); assertNotNull(parameters); assertEquals(1, parameters.size()); }