Search in sources :

Example 61 with Element

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

the class ComponentVisitorTestCase method testNameAttribute.

public void testNameAttribute() throws Exception {
    Reporter reporter = mock(Reporter.class);
    ComponentWorkbench workbench = new ComponentWorkbench(null, clazz());
    ComponentVisitor visitor = new ComponentVisitor(workbench, reporter);
    visitor.visit("name", "changed");
    visitor.visitEnd();
    Element root = workbench.getRoot();
    assertNotNull(root);
    assertEquals("changed", root.getAttribute("name"));
}
Also used : Reporter(org.apache.felix.ipojo.manipulator.Reporter) Element(org.apache.felix.ipojo.metadata.Element) ComponentWorkbench(org.apache.felix.ipojo.manipulator.metadata.annotation.ComponentWorkbench)

Example 62 with Element

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

the class ComponentVisitorTestCase method testDefaultNameIsClassname.

public void testDefaultNameIsClassname() throws Exception {
    Reporter reporter = mock(Reporter.class);
    ComponentWorkbench workbench = new ComponentWorkbench(null, clazz());
    ComponentVisitor visitor = new ComponentVisitor(workbench, reporter);
    visitor.visitEnd();
    Element root = workbench.getRoot();
    assertNotNull(root);
    assertEquals("my.Component", root.getAttribute("name"));
}
Also used : Reporter(org.apache.felix.ipojo.manipulator.Reporter) Element(org.apache.felix.ipojo.metadata.Element) ComponentWorkbench(org.apache.felix.ipojo.manipulator.metadata.annotation.ComponentWorkbench)

Example 63 with Element

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

the class HandlerDeclarationVisitorTestCase method testAttributeConversionWithNoNamespace.

public void testAttributeConversionWithNoNamespace() throws Exception {
    visitor.visit(null, "<ns:testing xmlns:ns='org.apache.felix.ipojo.testing' name='Guillaume'/>");
    visitor.visitEnd();
    Element produced = workbench.build();
    Element testing = produced.getElements("testing", "org.apache.felix.ipojo.testing")[0];
    assertEquals(0, testing.getElements().length);
    assertEquals(1, testing.getAttributes().length);
    assertEquals("Guillaume", testing.getAttribute("name"));
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 64 with Element

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

the class HandlerDeclarationVisitorTestCase method testElementConversionWithNamespace.

public void testElementConversionWithNamespace() throws Exception {
    visitor.visit(null, "<ns:testing xmlns:ns='org.apache.felix.ipojo.testing'/>");
    visitor.visitEnd();
    Element produced = workbench.build();
    Element testing = produced.getElements("testing", "org.apache.felix.ipojo.testing")[0];
    assertEquals(0, testing.getElements().length);
    assertEquals(0, testing.getAttributes().length);
    assertNotNull(produced.getElements("org.apache.felix.ipojo.testing:testing"));
    assertNull(produced.getElements("testing"));
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 65 with Element

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

the class HandlerDeclarationVisitorTestCase method testAttributeConversionWithNamespace.

public void testAttributeConversionWithNamespace() throws Exception {
    visitor.visit(null, "<ns:testing xmlns:ns='org.apache.felix.ipojo.testing' ns:name='Guillaume'/>");
    visitor.visitEnd();
    Element produced = workbench.build();
    Element testing = produced.getElements("testing", "org.apache.felix.ipojo.testing")[0];
    assertEquals(0, testing.getElements().length);
    assertEquals(1, testing.getAttributes().length);
    assertEquals("Guillaume", testing.getAttribute("name", "org.apache.felix.ipojo.testing"));
    assertEquals("Guillaume", testing.getAttribute("org.apache.felix.ipojo.testing:name"));
}
Also used : 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