felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1159173 [5/5] - in /felix/trunk/ipojo: ant/ ant/src/main/java/org/apache/felix/ipojo/task/ manipulator/ manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ manipulato...
Date Thu, 18 Aug 2011 11:32:22 GMT
Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/StreamMetadataProviderTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/StreamMetadataProviderTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/StreamMetadataProviderTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/StreamMetadataProviderTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.metadata;
+
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.Reporter;
+import org.apache.felix.ipojo.metadata.Element;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class StreamMetadataProviderTestCase extends TestCase {
+
+    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());
+    }
+
+    public void testWithEmptyMetadataXml() throws Exception {
+        File metadata = new File(new File("target", "test-classes"), "empty-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(0, meta.size());
+        verify(reporter).warn(anyString());
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/ManipulatedMetadataFilterTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/ManipulatedMetadataFilterTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/ManipulatedMetadataFilterTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/ManipulatedMetadataFilterTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.render;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.manipulation.MethodCreator;
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+
+public class ManipulatedMetadataFilterTestCase extends TestCase {
+
+    private ManipulatedMetadataFilter filter;
+
+    @Override
+    public void setUp() throws Exception {
+        filter = new ManipulatedMetadataFilter();
+    }
+
+    public void testFilterPrefixedMethod() throws Exception {
+        Element main = new Element("test", null);
+        main.addAttribute(new Attribute("name", MethodCreator.PREFIX + "PropertyName"));
+
+        Assert.assertTrue(filter.accept(main));
+    }
+
+    public void testFilterInstanceManagerValue() throws Exception {
+        Element main = new Element("test", null);
+        main.addAttribute(new Attribute("name", InstanceManager.class.getName()));
+
+        Assert.assertTrue(filter.accept(main));
+    }
+
+    public void testFilterInstanceManagerSetter() throws Exception {
+        Element main = new Element("test", null);
+        main.addAttribute(new Attribute("name", "_setInstanceManager"));
+
+        Assert.assertTrue(filter.accept(main));
+    }
+
+    public void testDoNotFilterOthers() throws Exception {
+        Element main = new Element("test", null);
+        main.addAttribute(new Attribute("name", "setPropertyName"));
+
+        Assert.assertFalse(filter.accept(main));
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/MetadataRendererTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/MetadataRendererTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/MetadataRendererTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/MetadataRendererTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.render;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+
+public class MetadataRendererTestCase extends TestCase {
+
+    private MetadataRenderer renderer;
+
+    @Override
+    public void setUp() throws Exception {
+        renderer = new MetadataRenderer();
+    }
+
+    public void testAddMetadataFilter() throws Exception {
+
+        // Auto remove all elements with a namespace
+        renderer.addMetadataFilter(new MetadataFilter() {
+            public boolean accept(Element element) {
+                return element.getNameSpace() != null;
+            }
+        });
+
+        Element main = new Element("test", null);
+        Element child = new Element("child", "uri");
+        main.addElement(child);
+        String rendered = renderer.render(main);
+        Assert.assertEquals("test { }", rendered);
+
+    }
+
+    public void testRenderElementWithNoNamespace() throws Exception {
+        Element main = new Element("test", null);
+        String rendered = renderer.render(main);
+        Assert.assertEquals("test { }", rendered);
+    }
+
+    public void testRenderElementWithEmptyNamespace() throws Exception {
+        Element main = new Element("test", "");
+        String rendered = renderer.render(main);
+        Assert.assertEquals("test { }", rendered);
+    }
+
+    public void testRenderElementWithDefaultNamespace() throws Exception {
+        // TODO Do we need to strip off default namespace ?
+        Element main = new Element("test", "org.apache.felix.ipojo");
+        String rendered = renderer.render(main);
+        Assert.assertEquals("org.apache.felix.ipojo:test { }", rendered);
+    }
+
+    public void testRenderElementWithNamespace() throws Exception {
+        Element main = new Element("test", "http://felix.apache.org/ipojo/testing");
+        String rendered = renderer.render(main);
+        Assert.assertEquals("http://felix.apache.org/ipojo/testing:test { }", rendered);
+    }
+
+    public void testRenderElementWithNoNamespaceAttribute() throws Exception {
+        Element main = new Element("test", null);
+        main.addAttribute(new Attribute("name", "attribute"));
+        String rendered = renderer.render(main);
+        Assert.assertEquals("test { $name=\"attribute\" }", rendered);
+    }
+
+    public void testRenderElementWithNamespaceAttribute() throws Exception {
+        Element main = new Element("test", null);
+        main.addAttribute(new Attribute("name", "ns-uri", "attribute"));
+        String rendered = renderer.render(main);
+        Assert.assertEquals("test { $ns-uri:name=\"attribute\" }", rendered);
+    }
+
+    public void testRenderElementWithChildren() throws Exception {
+        Element main = new Element("test", null);
+        Element child = new Element("child", null);
+        main.addElement(child);
+        String rendered = renderer.render(main);
+        Assert.assertEquals("test { child { }}", rendered);
+    }
+
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStoreTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStoreTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStoreTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStoreTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.manipulator.store;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.Pojoization;
+import org.apache.felix.ipojo.manipulator.ResourceVisitor;
+import org.apache.felix.ipojo.manipulator.util.Streams;
+import org.apache.felix.ipojo.manipulator.util.Strings;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+/**
+ * A {@code DirectoryBytecodeStoreTestCase} is ...
+ *
+ */
+public class DirectoryResourceStoreTestCase extends TestCase {
+
+    private DirectoryResourceStore store;
+    private File classes;
+    private File out;
+
+    public void setUp() throws Exception {
+        classes = new File("target", "classes");
+        out = new File(classes, "test.txt");
+        store = new DirectoryResourceStore(classes);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        out.delete();
+    }
+
+    public void testAccessibleResources() throws Exception {
+        byte[] data = store.read(Streams.class.getName().replace('.', '/').concat(".class"));
+        assertNotNull("Data cannot be null", data);
+    }
+
+    public void testInaccessibleResources() throws Exception {
+        try {
+            store.read("something/that/do/not/exists.txt");
+            fail();
+        } catch (IOException ioe) {
+            // Expected
+        }
+    }
+
+    public void testResourceWriting() throws Exception {
+        store.write("test.txt", "Hello World".getBytes());
+        Assert.assertTrue(out.isFile());
+    }
+
+    public void testResourceVisitor() throws Exception {
+
+        // final String expectedPath = Strings.asResourcePath(Pojoization.class.getName());
+        ResourceVisitor visitor = mock(ResourceVisitor.class);
+        store.accept(visitor);
+
+        verify(visitor, atLeastOnce()).visit(anyString());
+
+        // TODO try to check that Pojoization class resource was called
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/JarFileResourceStoreTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/JarFileResourceStoreTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/JarFileResourceStoreTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/JarFileResourceStoreTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.store;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.ResourceVisitor;
+import org.apache.felix.ipojo.manipulator.util.Streams;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
+
+public class JarFileResourceStoreTestCase extends TestCase {
+    public static final String RESOURCE_PATH = "org/apache/felix/ipojo/test/scenarios/component/Annotation.class";
+    private JarFileResourceStore store;
+    private File out;
+
+    public void setUp() throws Exception {
+        File classes = new File("target", "test-classes");
+        out = new File(classes, "test-store.jar");
+        JarFile jar = new JarFile(new File(classes, "tests.manipulation.java5.jar"));
+        store = new JarFileResourceStore(jar, out);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        out.delete();
+    }
+
+    public void testRead() throws Exception {
+        byte[] bytes = store.read(RESOURCE_PATH);
+        Assert.assertNotNull(bytes);
+    }
+
+    public void testAccept() throws Exception {
+        ResourceVisitor visitor = mock(ResourceVisitor.class);
+        store.accept(visitor);
+
+        verify(visitor, atLeastOnce()).visit(anyString());
+
+    }
+
+    public void testWrite() throws Exception {
+
+        ManifestBuilder builder = mock(ManifestBuilder.class);
+        Manifest manifest = new Manifest();
+        when(builder.build(any(Manifest.class))).thenReturn(manifest);
+        store.setManifestBuilder(builder);
+
+        store.write(RESOURCE_PATH, "Hello World".getBytes());
+
+        store.close();
+
+        JarFile outJar = new JarFile(out);
+        Assert.assertNotNull(outJar.getEntry(RESOURCE_PATH));
+        byte[] bytes = Streams.readBytes(outJar.getInputStream(outJar.getEntry(RESOURCE_PATH)));
+
+        Assert.assertEquals("Hello World", new String(bytes));
+
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilderTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilderTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilderTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilderTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.manipulator.store.builder;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.Pojoization;
+import org.apache.felix.ipojo.manipulator.store.ManifestBuilder;
+import org.apache.felix.ipojo.manipulator.store.builder.DefaultManifestBuilder;
+
+public class DefaultManifestBuilderTestCase extends TestCase {
+
+    private static final String ORG_OSGI_FRAMEWORK_VERSION_1_5 = "org.osgi.framework;version=1.5";
+    private Manifest manifest;
+    private ManifestBuilder builder;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        manifest = new Manifest();
+        Attributes attributes = manifest.getMainAttributes();
+        attributes.putValue("Import-Package", ORG_OSGI_FRAMEWORK_VERSION_1_5);
+        attributes.putValue("Created-By", "TestCase");
+
+        builder = new DefaultManifestBuilder();
+        builder.addReferredPackage(Collections.singleton("org.osgi.service.http"));
+    }
+
+    public void testManifestIsModified() throws Exception {
+        Manifest modified = builder.build(manifest);
+
+        // Created by header was properly modified
+        Assert.assertEquals("TestCase & iPOJO " + Pojoization.IPOJO_PACKAGE_VERSION,
+                            modified.getMainAttributes().getValue("Created-By"));
+
+        // As there was no metadata provided, no iPOJO-Components header should be present
+        Assert.assertNull(modified.getMainAttributes().getValue("iPOJO-Components"));
+
+        // Check that default manipulation introduced packages are present
+        String imported = modified.getMainAttributes().getValue("Import-Package");
+        Assert.assertTrue(imported.contains(ORG_OSGI_FRAMEWORK_VERSION_1_5));
+        Assert.assertTrue(imported.contains("org.apache.felix.ipojo"));
+        Assert.assertTrue(imported.contains("org.apache.felix.ipojo.architecture"));
+        Assert.assertTrue(imported.contains("org.osgi.service.cm"));
+        Assert.assertTrue(imported.contains("org.osgi.service.log"));
+    }
+
+
+    public void testCreatedByHeaderDoesNotContainIPojoTwice() throws Exception {
+
+        manifest.getMainAttributes().putValue("Created-By", "TestCase for iPOJO");
+
+        Manifest modified = builder.build(manifest);
+
+        // Created by header was properly not changed
+        Assert.assertEquals("TestCase for iPOJO",
+                            modified.getMainAttributes().getValue("Created-By"));
+    }
+
+    public void testReferredPackagesAreProperlyAdded() throws Exception {
+
+        List<String> p = Arrays.asList("org.apache.felix.ipojo.test", "org.apache.felix.ipojo.log");
+        builder.addReferredPackage(new HashSet<String>(p));
+
+        Manifest modified = builder.build(manifest);
+
+        // Check that referred packages are present
+        String imported = modified.getMainAttributes().getValue("Import-Package");
+        Assert.assertTrue(imported.contains("org.apache.felix.ipojo.test"));
+        Assert.assertTrue(imported.contains("org.apache.felix.ipojo.log"));
+    }
+
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapperTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapperTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapperTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapperTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.store.mapper;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.store.ResourceMapper;
+
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class FileSystemResourceMapperTestCase extends TestCase {
+
+    public void testUnixInternalize() throws Exception {
+
+        ResourceMapper delegate = mock(ResourceMapper.class);
+        FileSystemResourceMapper mapper = new FileSystemResourceMapper(delegate);
+
+        String path = "this/is/a/unix/like/path.extension";
+        when(delegate.internalize(eq(path))).thenReturn(path);
+
+        String result = mapper.internalize(path);
+
+        Assert.assertEquals(path, result);
+
+    }
+
+    public void testUnixExternalize() throws Exception {
+
+        ResourceMapper delegate = mock(ResourceMapper.class);
+        FileSystemResourceMapper mapper = new FileSystemResourceMapper(delegate);
+
+        String path = "this/is/a/unix/like/path.extension";
+        when(delegate.externalize(eq(path))).thenReturn(path);
+
+        String result = mapper.externalize(path);
+
+        // unix path is already normalized
+        Assert.assertEquals(path, result);
+    }
+
+    public void ignoreWindowsExternalize() throws Exception {
+        // As Java doesn't like '\' alone in Strings I have to replace them on the fly :'(
+        // Grrr doesn't work as expected
+        ResourceMapper delegate = mock(ResourceMapper.class);
+        FileSystemResourceMapper mapper = new FileSystemResourceMapper(delegate);
+
+        String path = "c:\\this\\is\\a\\windows\\like\\path.extension";
+        when(delegate.externalize(eq(path))).thenReturn(path);
+
+        String expected = "c:/this/is/a/windows/like/path.extension";
+        String result = mapper.externalize(path);
+
+        // unix path is already normalized
+        Assert.assertEquals(expected, result);
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/IdentityResourceMapperTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/IdentityResourceMapperTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/IdentityResourceMapperTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/IdentityResourceMapperTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.store.mapper;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class IdentityResourceMapperTestCase extends TestCase {
+    public void testInternalize() throws Exception {
+        IdentityResourceMapper mapper = new IdentityResourceMapper();
+        String path = "must/not/change";
+        Assert.assertEquals(path, mapper.internalize(path));
+    }
+
+    public void testExternalize() throws Exception {
+        IdentityResourceMapper mapper = new IdentityResourceMapper();
+        String path = "must/not/change";
+        Assert.assertEquals(path, mapper.externalize(path));
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/WABResourceMapperTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/WABResourceMapperTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/WABResourceMapperTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/WABResourceMapperTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.store.mapper;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.store.ResourceMapper;
+
+public class WABResourceMapperTestCase extends TestCase {
+    public void testSimpleInternalize() throws Exception {
+        ResourceMapper mapper = new WABResourceMapper();
+        String path = "jndi.properties";
+        Assert.assertEquals("WEB-INF/classes/" + path, mapper.internalize(path));
+    }
+
+    public void testSimpleExternalize() throws Exception {
+        ResourceMapper mapper = new WABResourceMapper();
+        String path = "WEB-INF/classes/jndi.properties";
+        Assert.assertEquals("jndi.properties", mapper.externalize(path));
+    }
+
+    public void testExternalizeError() throws Exception {
+        ResourceMapper mapper = new WABResourceMapper();
+        String path = "jndi.properties";
+
+        try {
+            mapper.externalize(path);
+            fail("Should have thrown an IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // ok
+        }
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StreamsTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StreamsTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StreamsTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StreamsTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.util;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class StreamsTestCase extends TestCase {
+    public void testSimpleClose() throws Exception {
+        Closeable closeable = mock(Closeable.class);
+        Streams.close(closeable);
+        verify(closeable).close();
+    }
+
+    public void testCloseWithNullParameter() throws Exception {
+        Closeable closeable = mock(Closeable.class);
+        Streams.close(closeable, null);
+        verify(closeable).close();
+    }
+
+    public void testTransfer() throws Exception {
+        String toBeRead = "Tadam";
+        ByteArrayInputStream bais = new ByteArrayInputStream(toBeRead.getBytes());
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        Streams.transfer(bais, baos);
+        Assert.assertEquals(toBeRead, new String(baos.toByteArray()));
+    }
+
+    public void testReadBytes() throws Exception {
+        String toBeRead = "Tadam";
+        ByteArrayInputStream bais = new ByteArrayInputStream(toBeRead.getBytes());
+        byte[] bytes = Streams.readBytes(bais);
+        Assert.assertEquals(toBeRead, new String(bytes));
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StringsTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StringsTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StringsTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StringsTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.manipulator.util;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class StringsTestCase extends TestCase {
+
+    private static final String CLASSNAME = StringsTestCase.class.getName();
+    private static final String PATH = "org/apache/felix/ipojo/manipulator/util/StringsTestCase.class";
+
+    public void testClassnameIsTransformedIntoNormalizedResourcePath() throws Exception {
+        Assert.assertEquals(PATH, Strings.asResourcePath(CLASSNAME));
+    }
+
+    public void testNormalizedResourcePathIsTransformedIntoClassname() throws Exception {
+        Assert.assertEquals(CLASSNAME, Strings.asClassName(PATH));
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyResultVisitorTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyResultVisitorTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyResultVisitorTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyResultVisitorTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.visitor.check;
+
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.ManipulationResultVisitor;
+import org.apache.felix.ipojo.manipulator.Reporter;
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.mockito.Mockito.*;
+
+
+public class CheckFieldConsistencyResultVisitorTestCase extends TestCase {
+
+    @Mock
+    private Reporter reporter;
+
+    @Mock
+    private ManipulationResultVisitor delegate;
+
+    @Override
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    public void testVisitClassStructureOK() throws Exception {
+        Element component = newComponentElement();
+        CheckFieldConsistencyResultVisitor visitor = new CheckFieldConsistencyResultVisitor(delegate);
+        visitor.setReporter(reporter);
+        visitor.setMetadata(component);
+
+        Element manipulation = newManipulationElement(true);
+        visitor.visitClassStructure(manipulation);
+
+        verifyZeroInteractions(reporter);
+
+    }
+
+    public void testVisitClassStructureWithMissingFields() throws Exception {
+        Element component = newComponentElement();
+        CheckFieldConsistencyResultVisitor visitor = new CheckFieldConsistencyResultVisitor(delegate);
+        visitor.setReporter(reporter);
+        visitor.setMetadata(component);
+
+        Element manipulation = newManipulationElement(false);
+        visitor.visitClassStructure(manipulation);
+
+        verify(reporter).error(anyString());
+
+    }
+
+    private Element newManipulationElement(boolean complete) {
+        Element manipulation = new Element("manipulation", null);
+        if (complete) {
+            Element field = new Element("field", null);
+            field.addAttribute(new Attribute("name", "property"));
+            manipulation.addElement(field);
+        }
+
+        return manipulation;
+    }
+
+    private Element newComponentElement() {
+        Element component = new Element("component", null);
+        Element requires = new Element("requires", null);
+        requires.addAttribute(new Attribute("field", "property"));
+        component.addElement(requires);
+
+        return component;
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResourcesWriterTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResourcesWriterTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResourcesWriterTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResourcesWriterTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.visitor.writer;
+
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.manipulator.Reporter;
+import org.apache.felix.ipojo.manipulator.ResourceStore;
+import org.apache.felix.ipojo.metadata.Element;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.mockito.Mockito.*;
+
+
+public class ManipulatedResourcesWriterTestCase extends TestCase {
+
+    @Mock
+    private Reporter reporter;
+
+    @Mock
+    private ResourceStore store;
+
+    @Override
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    public void testVisitManipulationResult() throws Exception {
+        ManipulatedResourcesWriter writer = new ManipulatedResourcesWriter();
+        writer.setReporter(reporter);
+        writer.setResourceStore(store);
+
+        Element component = new Element("component", null);
+        assertNotNull(writer.visitManipulationResult(component));
+        verify(store).writeMetadata(same(component));
+    }
+
+    public void testVisitMetadata() throws Exception {
+        ManipulatedResourcesWriter writer = new ManipulatedResourcesWriter();
+        writer.setReporter(reporter);
+        writer.setResourceStore(store);
+
+        Element instance = new Element("instance", null);
+        writer.visitMetadata(instance);
+        verify(store).writeMetadata(same(instance));
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResultWriterTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResultWriterTestCase.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResultWriterTestCase.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResultWriterTestCase.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.manipulator.visitor.writer;
+
+import junit.framework.TestCase;
+import org.apache.felix.ipojo.metadata.Element;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+
+import static org.mockito.Mockito.*;
+
+
+public class ManipulatedResultWriterTestCase extends TestCase {
+
+    @Spy
+    private Element element = new Element("component", null);
+
+    @Override
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    public void testVisitClassStructure() throws Exception {
+        ManipulatedResultWriter writer = new ManipulatedResultWriter(element);
+
+        Element manipulation = new Element("manipulation", null);
+        writer.visitClassStructure(manipulation);
+        verify(element).addElement(same(manipulation));
+    }
+
+    public void testVisitManipulatedResource() throws Exception {
+        ManipulatedResultWriter writer = new ManipulatedResultWriter(element);
+
+        writer.visitManipulatedResource("test.class", "Hello".getBytes());
+
+        assertNotNull(writer.getResources().get("test.class"));
+        assertEquals("Hello", new String(writer.getResources().get("test.class")));
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/test/java/test/AnnotatedComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/java/test/AnnotatedComponent.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/java/test/AnnotatedComponent.java (added)
+++ felix/trunk/ipojo/manipulator/src/test/java/test/AnnotatedComponent.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,18 @@
+package test;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: guillaume
+ * Date: 10/08/11
+ * Time: 21:56
+ * To change this template use File | Settings | File Templates.
+ */
+@Component
+public class AnnotatedComponent {
+
+    @Property
+    private String prop;
+}

Added: felix/trunk/ipojo/manipulator/src/test/resources/MANIFEST.MF
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/resources/MANIFEST.MF?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/resources/MANIFEST.MF (added)
+++ felix/trunk/ipojo/manipulator/src/test/resources/MANIFEST.MF Thu Aug 18 11:32:19 2011
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.felix.ipojo.test.scenarios.manipulation.ser
+ vice
+Test-Suite: org.apache.felix.ipojo.test.scenarios.manipulation.Manipul
+ ationTestSuite
+Built-By: clement
+Tool: Bnd-0.0.357
+Bundle-Name: iPOJO Manipulation Test Suite For Java 5
+Created-By: Apache Maven Bundle Plugin
+Build-Jdk: 1.6.0_22
+Bundle-Version: 1.5.0.SNAPSHOT
+Bnd-LastModified: 1292008458378
+Bundle-ManifestVersion: 2
+Import-Package: junit.framework,org.apache.felix.ipojo;version="1.6",o
+ rg.apache.felix.ipojo.junit4osgi,org.apache.felix.ipojo.junit4osgi.he
+ lpers,org.apache.felix.ipojo.test.scenarios.manipulation.service,org.
+ osgi.framework;version="1.5"
+Bundle-SymbolicName: tests.manipulation.java5
+

Added: felix/trunk/ipojo/manipulator/src/test/resources/empty-metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/test/resources/empty-metadata.xml?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/test/resources/empty-metadata.xml (added)
+++ felix/trunk/ipojo/manipulator/src/test/resources/empty-metadata.xml Thu Aug 18 11:32:19 2011
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+       xmlns="org.apache.felix.ipojo" />

Modified: felix/trunk/ipojo/plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/pom.xml?rev=1159173&r1=1159172&r2=1159173&view=diff
==============================================================================
--- felix/trunk/ipojo/plugin/pom.xml (original)
+++ felix/trunk/ipojo/plugin/pom.xml Thu Aug 18 11:32:19 2011
@@ -118,6 +118,14 @@
           <configLocation>http://felix.apache.org/ipojo/dev/checkstyle_ipojo.xml</configLocation>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java?rev=1159173&r1=1159172&r2=1159173&view=diff
==============================================================================
--- felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java (original)
+++ felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java Thu Aug 18 11:32:19 2011
@@ -25,6 +25,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.felix.ipojo.manipulator.Pojoization;
+import org.apache.felix.ipojo.manipulator.Reporter;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -222,7 +223,8 @@ public class ManipulatorMojo extends Abs
 
         File out = new File(m_buildDirectory + File.separator + "_out.jar");
 
-        Pojoization pojo = new Pojoization();
+        Reporter reporter = new MavenReporter(getLog());
+        Pojoization pojo = new Pojoization(reporter);
         if (m_ignoreAnnotations) { pojo.disableAnnotationProcessing(); }
         if (!m_ignoreEmbeddedXSD) { pojo.setUseLocalXSD(); }
 
@@ -237,10 +239,12 @@ public class ManipulatorMojo extends Abs
             pojo.pojoization(in, out, is);
         }
 
-        for (int i = 0; i < pojo.getWarnings().size(); i++) {
-            getLog().warn((String) pojo.getWarnings().get(i));
+        for (int i = 0; i < reporter.getWarnings().size(); i++) {
+            getLog().warn((String) reporter.getWarnings().get(i));
+        }
+        if (reporter.getErrors().size() > 0) {
+            throw new MojoExecutionException((String) reporter.getErrors().get(0));
         }
-        if (pojo.getErrors().size() > 0) { throw new MojoExecutionException((String) pojo.getErrors().get(0)); }
 
         if (m_classifier != null) {
             // The user want to attach the resulting jar

Added: felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/MavenReporter.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/MavenReporter.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/MavenReporter.java (added)
+++ felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/MavenReporter.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.plugin;
+
+import org.apache.felix.ipojo.manipulator.reporter.EmptyReporter;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * A {@code MavenReporter} wraps a maven logging system into an iPOJO Reporter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class MavenReporter extends EmptyReporter {
+
+    /**
+     * Maven logger.
+     */
+    private Log log;
+
+    public MavenReporter(Log log) {
+        this.log = log;
+    }
+
+    @Override
+    public void trace(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        Throwable t = getThrowable(args);
+        if (t != null) {
+            log.debug(formatted, t);
+        } else {
+            log.debug(formatted);
+        }
+    }
+
+    @Override
+    public void info(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        Throwable t = getThrowable(args);
+        if (t != null) {
+            log.info(formatted, t);
+        } else {
+            log.info(formatted);
+        }
+    }
+
+    @Override
+    public void warn(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        Throwable t = getThrowable(args);
+        if (t != null) {
+            log.warn(formatted, t);
+        } else {
+            log.warn(formatted);
+        }
+        getWarnings().add(formatted);
+    }
+
+    @Override
+    public void error(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        Throwable t = getThrowable(args);
+        if (t != null) {
+            log.error(formatted, t);
+        } else {
+            log.error(formatted);
+        }
+        getErrors().add(formatted);
+    }
+}



Mime
View raw message