Search in sources :

Example 51 with Element

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

the class AnnotationMetadataProviderTestCase method testGetMetadatas.

public void testGetMetadatas() throws Exception {
    MiniStore store = new MiniStore(AnnotatedComponent.class, FakeAnnotation.class);
    Reporter reporter = mock(Reporter.class);
    AnnotationMetadataProvider provider = new AnnotationMetadataProvider(store, reporter);
    List<Element> meta = provider.getMetadatas();
    assertEquals(1, meta.size());
}
Also used : Reporter(org.apache.felix.ipojo.manipulator.Reporter) Element(org.apache.felix.ipojo.metadata.Element)

Example 52 with Element

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

the class CompositeMetadataProviderTestCase method newComponentElement.

private Element newComponentElement(String type) {
    Element main = new Element("component", null);
    main.addAttribute(new Attribute("name", type));
    return main;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 53 with Element

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

the class CompositeMetadataProviderTestCase method newInstanceElement.

private Element newInstanceElement(String type, String name) {
    Element main = new Element("instance", null);
    main.addAttribute(new Attribute("component", type));
    main.addAttribute(new Attribute("name", name));
    return main;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 54 with Element

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

the class CompositeMetadataProviderTestCase method testGetMetadatasWithInstances.

public void testGetMetadatasWithInstances() throws Exception {
    CompositeMetadataProvider provider = new CompositeMetadataProvider(reporter);
    provider.addMetadataProvider(delegate1);
    provider.addMetadataProvider(delegate2);
    Element returned = newInstanceElement("type1", "name1");
    when(delegate1.getMetadatas()).thenReturn(Collections.singletonList(returned));
    // Try with a duplicate instance name
    Element returned2 = newInstanceElement("type1", "name2");
    when(delegate2.getMetadatas()).thenReturn(Collections.singletonList(returned2));
    List<Element> meta = provider.getMetadatas();
    assertEquals(2, meta.size());
}
Also used : Element(org.apache.felix.ipojo.metadata.Element)

Example 55 with Element

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

the class FileMetadataProviderTestCase method testGetMetadatasFromFile.

public void testGetMetadatasFromFile() throws Exception {
    File metadata = new File(new File("target", "test-classes"), "metadata.xml");
    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)

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