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);
}
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");
}
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;
}
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");
}
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());
}
Aggregations