use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class TestManipulationMetadata method testInterface.
@Test
public void testInterface() {
String comp_name = "ManipulationMetadata-FooProviderType-1";
Element manip = getManipulationForComponent(comp_name);
Element[] itf = manip.getElements("Interface");
assertEquals("Check interfaces number", itf.length, 1);
assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class TestManipulationMetadata method testPrimitivesFields.
@Test
public void testPrimitivesFields() {
String comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
Element manip = getManipulationForComponent(comp_name);
Element[] fields = manip.getElements("Field");
assertEquals("Check field count", fields.length, 16);
/*
byte b = 1;
short s = 1;
int i = 1;
long l = 1;
double d = 1.1;
float f = 1.1f;
char c = 'a';
boolean bool = false;
byte[] bs = new byte[] {0,1,2};
short[] ss = new short[] {0,1,2};
int[] is = new int[] {0,1,2};
long[] ls = new long[] {0,1,2};
double[] ds = new double[] {0.0, 1.1, 2.2};
float[] fs = new float[] {0.0f, 1.1f, 2.2f};
char[] cs = new char[] {'a', 'b', 'c'};
boolean[] bools = new boolean[] {false, true, false};
*/
Element field;
field = getFieldFromName(manip, "b");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte");
field = getFieldFromName(manip, "s");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short");
field = getFieldFromName(manip, "i");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
field = getFieldFromName(manip, "l");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long");
field = getFieldFromName(manip, "d");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double");
field = getFieldFromName(manip, "f");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float");
field = getFieldFromName(manip, "c");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char");
field = getFieldFromName(manip, "bool");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
field = getFieldFromName(manip, "bs");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte[]");
field = getFieldFromName(manip, "ss");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short[]");
field = getFieldFromName(manip, "is");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
field = getFieldFromName(manip, "ls");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long[]");
field = getFieldFromName(manip, "ds");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double[]");
field = getFieldFromName(manip, "fs");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float[]");
field = getFieldFromName(manip, "cs");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char[]");
field = getFieldFromName(manip, "bools");
assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean[]");
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class TestManipulationMetadata method testTwoArgsMethod.
@Test
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 TestManipulationMetadata method testInnerClasses.
@Test
public void testInnerClasses() {
String comp_name = "org.apache.felix.ipojo.runtime.core.components.ComponentWithInnerClasses";
Element manipulation = getManipulationForComponent(comp_name);
Element[] inners = manipulation.getElements("inner");
assertEquals(inners.length, 3);
Element inner = getInnerClassMetadataByName(inners, "MyInnerWithANativeMethod");
Assert.assertNotNull(inner);
Assert.assertNotNull(getMethodByName(inner.getElements("method"), "foo"));
inner = getInnerClassMetadataByName(inners, "MyInnerClass");
assertNotNull(inner);
assertNotNull(getMethodByName(inner.getElements("method"), "foo"));
inner = getInnerClassMetadataByName(inners, "1");
assertNotNull(inner);
assertNotNull(getMethodByName(inner.getElements("method"), "run"));
}
use of org.apache.felix.ipojo.metadata.Element in project felix by apache.
the class PrimitiveInstanceDescription method getDescription.
/**
* Gets the instance description.
* Overridden to add created objects.
* @return the instance description
*/
public Element getDescription() {
Element elem = super.getDescription();
// Created Object (empty is composite)
String[] objs = getCreatedObjects();
for (int i = 0; objs != null && i < objs.length; i++) {
Element obj = new Element("Object", "");
obj.addAttribute(new Attribute("name", ((Object) objs[i]).toString()));
elem.addElement(obj);
}
return elem;
}
Aggregations