Search in sources :

Example 56 with Element

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

the class FileMetadataProviderTestCase method testGetMetadatasFromDirectory.

public void testGetMetadatasFromDirectory() throws Exception {
    File metadata = new File("target", "test-classes");
    Reporter reporter = mock(Reporter.class);
    FileMetadataProvider provider = new FileMetadataProvider(metadata, reporter);
    provider.setValidateUsingLocalSchemas(true);
    List<Element> meta = provider.getMetadatas();
    assertEquals(3, meta.size());
}
Also used : Reporter(org.apache.felix.ipojo.manipulator.Reporter) Element(org.apache.felix.ipojo.metadata.Element) File(java.io.File)

Example 57 with Element

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

the class StreamMetadataProviderTestCase method testGetMetadatas.

public void testGetMetadatas() throws Exception {
    File metadata = new File(new File("target", "test-classes"), "metadata.xml");
    FileInputStream fis = new FileInputStream(metadata);
    Reporter reporter = mock(Reporter.class);
    StreamMetadataProvider provider = new StreamMetadataProvider(fis, reporter);
    provider.setValidateUsingLocalSchemas(true);
    List<Element> meta = provider.getMetadatas();
    assertEquals(3, meta.size());
}
Also used : Reporter(org.apache.felix.ipojo.manipulator.Reporter) Element(org.apache.felix.ipojo.metadata.Element) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 58 with Element

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

the class ComponentWorkbenchTestCase method testBuildWithNoTopLevelElements.

public void testBuildWithNoTopLevelElements() throws Exception {
    ComponentWorkbench workbench = new ComponentWorkbench(null, node());
    Element built = workbench.build();
    assertNull(built);
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 59 with Element

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

the class ComponentWorkbenchTestCase method testElementsAreHierarchicallyPlaced.

public void testElementsAreHierarchicallyPlaced() throws Exception {
    Element root = new Element("root", null);
    Element child = new Element("child", null);
    ComponentWorkbench workbench = new ComponentWorkbench(null, node());
    workbench.setRoot(root);
    workbench.getElements().put(child, null);
    Element built = workbench.build();
    assertEquals("root", built.getName());
    assertNull(built.getNameSpace());
    assertEquals(0, built.getAttributes().length);
    assertEquals(1, built.getElements().length);
    Element builtChild = built.getElements("child")[0];
    assertEquals("child", builtChild.getName());
    assertNull(builtChild.getNameSpace());
    assertEquals(0, builtChild.getAttributes().length);
    assertEquals(0, builtChild.getElements().length);
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 60 with Element

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

the class ComponentVisitorTestCase method testFactoryMethodDeprecationSupport.

public void testFactoryMethodDeprecationSupport() throws Exception {
    Reporter reporter = mock(Reporter.class);
    ComponentWorkbench workbench = new ComponentWorkbench(null, clazz());
    ComponentVisitor visitor = new ComponentVisitor(workbench, reporter);
    visitor.visit("factory_method", "create");
    visitor.visitEnd();
    Element root = workbench.getRoot();
    assertNotNull(root);
    assertEquals("create", root.getAttribute("factory-method"));
}
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)

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