Search in sources :

Example 11 with Element

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());
}
Also used : FooService(org.apache.felix.ipojo.runtime.core.services.FooService) Element(org.apache.felix.ipojo.metadata.Element) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Example 12 with Element

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[]");
}
Also used : Element(org.apache.felix.ipojo.metadata.Element) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Example 13 with Element

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");
}
Also used : Element(org.apache.felix.ipojo.metadata.Element) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Example 14 with Element

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"));
}
Also used : Element(org.apache.felix.ipojo.metadata.Element) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Example 15 with Element

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;
}
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