Search in sources :

Example 1 with MyBean1

use of org.apache.aries.blueprint.plugin.test.MyBean1 in project aries by apache.

the class BlueprintFileWriterTest method testGenerateBeanWithInitDestroyAndfieldInjection.

@Test
public void testGenerateBeanWithInitDestroyAndfieldInjection() throws Exception {
    Node bean1 = getBeanById("myBean1");
    assertXpathEquals(bean1, "@class", MyBean1.class.getName());
    assertXpathEquals(bean1, "@init-method", "init");
    assertXpathEquals(bean1, "@destroy-method", "destroy");
    assertXpathEquals(bean1, "@field-injection", "true");
    assertXpathDoesNotExist(bean1, "@scope");
}
Also used : Node(org.w3c.dom.Node) MyBean1(org.apache.aries.blueprint.plugin.test.MyBean1) Test(org.junit.Test)

Example 2 with MyBean1

use of org.apache.aries.blueprint.plugin.test.MyBean1 in project aries by apache.

the class BlueprintFileWriterTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    ClassFinder classFinder = new ClassFinder(BlueprintFileWriterTest.class.getClassLoader());
    long start = System.currentTimeMillis();
    Set<Class<?>> beanClasses = findClasses(classFinder, Arrays.asList(MyBean1.class.getPackage().getName(), ReferenceListenerToProduceWithoutAnnotation.class.getPackage().getName()));
    Set<String> namespaces = new HashSet<>(Arrays.asList(NS_JPA, NS_TX1));
    Map<String, String> customParameters = new HashMap<>();
    customParameters.put("ex.t", "1");
    customParameters.put("example.p1", "v1");
    customParameters.put("example.p2", "v2");
    BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null, customParameters);
    Blueprint blueprint = new Blueprint(blueprintConfiguration, beanClasses);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    new BlueprintFileWriter(os).write(blueprint);
    xmlAsBytes = os.toByteArray();
    System.out.println("Generation took " + (System.currentTimeMillis() - start) + " millis");
    System.out.println(new String(xmlAsBytes, "UTF-8"));
    document = readToDocument(xmlAsBytes, false);
    xpath = XPathFactory.newInstance().newXPath();
}
Also used : HashMap(java.util.HashMap) Blueprint(org.apache.aries.blueprint.plugin.model.Blueprint) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) ReferenceListenerToProduceWithoutAnnotation(org.apache.aries.blueprint.plugin.test.referencelistener.ReferenceListenerToProduceWithoutAnnotation) ClassFinder(org.apache.xbean.finder.ClassFinder) BeforeClass(org.junit.BeforeClass) MyBean1(org.apache.aries.blueprint.plugin.test.MyBean1) HashSet(java.util.HashSet) BeforeClass(org.junit.BeforeClass)

Aggregations

MyBean1 (org.apache.aries.blueprint.plugin.test.MyBean1)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Blueprint (org.apache.aries.blueprint.plugin.model.Blueprint)1 ReferenceListenerToProduceWithoutAnnotation (org.apache.aries.blueprint.plugin.test.referencelistener.ReferenceListenerToProduceWithoutAnnotation)1 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)1 ClassFinder (org.apache.xbean.finder.ClassFinder)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1