Search in sources :

Example 21 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class ProvidedServiceHandlerTest method testServiceDetectionSuperSuperClass.

public void testServiceDetectionSuperSuperClass() throws ConfigurationException {
    String classname = "org.apache.felix.ipojo.handlers.providedservice.ComponentTestWithAnotherSuperClass";
    Element metadata = new Element("component", "");
    Element manipulation = new Element("manipulation", "");
    metadata.addAttribute(new Attribute("classname", classname));
    Element provides = new Element("provides", "");
    provides.addAttribute(new Attribute("specifications", "java.beans.FeatureDescriptor"));
    metadata.addElement(provides);
    metadata.addElement(manipulation);
    manipulation.addAttribute(new Attribute("classname", classname));
    manipulation.addAttribute(new Attribute("super", "java.beans.MethodDescriptor"));
    Mockito.when(factory.getPojoMetadata()).thenReturn(new PojoMetadata(metadata));
    Mockito.when(factory.getClassName()).thenReturn(classname);
    handler.initializeComponentFactory(desc, metadata);
    System.out.println(metadata);
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element) PojoMetadata(org.apache.felix.ipojo.parser.PojoMetadata)

Example 22 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class ManipulationMetadataTest method testTwoArgsMethod.

public void testTwoArgsMethod() {
    String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
    Element manip = getManipulationForComponent(comp_name);
    Element method = getMethodFromName(manip, "doNothing");
    assertEquals("Check args", method.getAttribute("arguments"), "{java.lang.Object,java.lang.String}");
    assertEquals("Check args count", 2, ParseUtils.parseArrays("{java.lang.Object,java.lang.String}").length);
    assertEquals("Check return", method.getAttribute("return"), "java.lang.Object");
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 23 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class ManipulationMetadataTest method getManipulationForComponent.

private Element getManipulationForComponent(String comp_name) {
    Element elem = null;
    try {
        elem = ManifestMetadataParser.parseHeaderMetadata(header);
    } catch (ParseException e) {
        fail("Parse Exception when parsing iPOJO-Component");
    }
    assertNotNull("Check elem not null", elem);
    Element manip = getManipulationForComponent(elem, comp_name);
    assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
    return manip;
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 24 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class ManipulationMetadataTest method testInterfaces.

public void testInterfaces() {
    String comp_name = "ManipulationMetadata-FooBarProviderType-1";
    Element manip = getManipulationForComponent(comp_name);
    Element[] itf = manip.getElements("Interface");
    assertEquals("Check interfaces number", itf.length, 2);
    assertEquals("Check itf name", itf[0].getAttribute("name"), "org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService");
    assertEquals("Check itf name", itf[1].getAttribute("name"), "org.apache.felix.ipojo.test.scenarios.manipulation.service.BarService");
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 25 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class MethodMetadataTest method testComputationForArraysUsingPrimitiveFromElement.

public void testComputationForArraysUsingPrimitiveFromElement() {
    Element metadata1 = new Element("method", null);
    metadata1.addAttribute(new Attribute("name", "withOneArray"));
    metadata1.addAttribute(new Attribute("arguments", "{int[]}"));
    Element metadata2 = new Element("method", null);
    metadata2.addAttribute(new Attribute("name", "withOneArray"));
    metadata2.addAttribute(new Attribute("arguments", "{int[][]}"));
    Element metadata3 = new Element("method", null);
    metadata3.addAttribute(new Attribute("name", "withOneArray"));
    metadata3.addAttribute(new Attribute("arguments", "{int[][][]}"));
    MethodMetadata methodMetadata1 = new MethodMetadata(metadata1);
    Assert.assertEquals("withOneArray$int__", methodMetadata1.getMethodIdentifier());
    MethodMetadata methodMetadata2 = new MethodMetadata(metadata2);
    Assert.assertEquals("withOneArray$int____", methodMetadata2.getMethodIdentifier());
    MethodMetadata methodMetadata3 = new MethodMetadata(metadata3);
    Assert.assertEquals("withOneArray$int______", methodMetadata3.getMethodIdentifier());
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Aggregations

Element (org.apache.felix.ipojo.metadata.Element)400 Test (org.junit.Test)126 Attribute (org.apache.felix.ipojo.metadata.Attribute)109 ConfigurationException (org.apache.felix.ipojo.ConfigurationException)22 ParseException (org.apache.felix.ipojo.parser.ParseException)14 PojoMetadata (org.apache.felix.ipojo.parser.PojoMetadata)14 ArrayList (java.util.ArrayList)13 Reporter (org.apache.felix.ipojo.manipulator.Reporter)12 FieldMetadata (org.apache.felix.ipojo.parser.FieldMetadata)12 Dictionary (java.util.Dictionary)10 Properties (java.util.Properties)10 MethodMetadata (org.apache.felix.ipojo.parser.MethodMetadata)10 BaseTest (org.ow2.chameleon.testing.helpers.BaseTest)10 PropertyDescription (org.apache.felix.ipojo.architecture.PropertyDescription)9 IOException (java.io.IOException)8 List (java.util.List)8 Before (org.junit.Before)7 Enumeration (java.util.Enumeration)6 ComponentWorkbench (org.apache.felix.ipojo.manipulator.metadata.annotation.ComponentWorkbench)6 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)6