* Forgot to add ASF License Header to DirManipulationTest in last commit, and some cosmetic changes.
* Added missing license header to RemanipulationTest.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1346941 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/DirManipulationTest.java b/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/DirManipulationTest.java
index e8bd6fe..52f0112 100644
--- a/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/DirManipulationTest.java
+++ b/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/DirManipulationTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.manipulation;
import java.io.BufferedReader;
@@ -16,68 +34,70 @@
import junit.framework.TestCase;
+/**
+ * Test cases for Pojoization.directoryManipulation()
+ *
+ */
public class DirManipulationTest extends TestCase {
+ /**
+ * Test case for FELIX-3466.
+ *
+ * Checks if directory manipulation, uses the supplied manifest file as
+ * output.
+ *
+ * @throws IOException
+ */
@Test
- public void testManifestLocationKept() {
-
+ public void testManifestLocationKept() throws IOException {
Pojoization pojoizator = new Pojoization();
File tmpDir = null, manifestFile = null, testClass = null;
- try {
- // To obtain OS's temp directory.
- File tmpFile = File.createTempFile("pojodir", ".dir");
- String tmpPath = tmpFile.getAbsolutePath();
- tmpFile.delete();
- // Creating directory on temp location
- tmpDir = new File(tmpPath);
- tmpDir.mkdir();
- tmpDir.deleteOnExit();
+ // To obtain OS's temp directory.
+ File tmpFile = File.createTempFile("pojodir", ".dir");
+ String tmpPath = tmpFile.getAbsolutePath();
+ tmpFile.delete();
- // Create manifest file under temp directory
- manifestFile = new File(tmpDir, "MANIFEST.MF");
- new FileOutputStream(manifestFile)
- .write("Manifest-Version: 1.0\r\n".getBytes());
- manifestFile.deleteOnExit();
+ // Creating directory on temp location
+ tmpDir = new File(tmpPath);
+ tmpDir.mkdir();
+ tmpDir.deleteOnExit();
- // Just to ensure it is not deleted later from test classes.
- AnnotatedComponent safe;
+ // Create manifest file under temp directory
+ manifestFile = new File(tmpDir, "MANIFEST.MF");
+ new FileOutputStream(manifestFile).write("Manifest-Version: 1.0\r\n"
+ .getBytes());
+ manifestFile.deleteOnExit();
- // Annotated Class File
- File annotedClassPackage = new File(tmpDir, "test");
- annotedClassPackage.deleteOnExit();
- annotedClassPackage.mkdir();
- testClass = new File(annotedClassPackage,
- "AnnotatedComponent.class");
- testClass.deleteOnExit();
- FileOutputStream os = new FileOutputStream(testClass);
- os.write(ManipulatorTest.getBytesFromFile(new File(
- "target/test-classes/test/AnnotatedComponent.class")));
- os.close();
+ // Just to ensure it is not deleted later from test classes.
+ AnnotatedComponent safe;
- // Issue directory manipulation
- pojoizator.directoryPojoization(tmpDir, null, manifestFile);
+ // Annotated Class File
+ File annotedClassPackage = new File(tmpDir, "test");
+ annotedClassPackage.deleteOnExit();
+ annotedClassPackage.mkdir();
+ testClass = new File(annotedClassPackage, "AnnotatedComponent.class");
+ testClass.deleteOnExit();
+ FileOutputStream os = new FileOutputStream(testClass);
+ os.write(ManipulatorTest.getBytesFromFile(new File(
+ "target/test-classes/test/AnnotatedComponent.class")));
+ os.close();
- // Check if supplied manifest file is altered in place
- BufferedReader fi = new BufferedReader(new FileReader(manifestFile));
- String manifestLine;
- while ((manifestLine = fi.readLine()) != null) {
- if (manifestLine.contains("iPOJO-Components")) {
- assertTrue(true);
- return;
- }
+ // Issue directory manipulation
+ pojoizator.directoryPojoization(tmpDir, null, manifestFile);
+
+ // Check if supplied manifest file is altered in place
+ BufferedReader fi = new BufferedReader(new FileReader(manifestFile));
+ String manifestLine;
+ while ((manifestLine = fi.readLine()) != null) {
+ if (manifestLine.contains("iPOJO-Components")) {
+ assertTrue(true);
+ return;
}
-
- assertTrue(
- "Directory Manipulation didn't use supplied manifest file as output",
- false);
-
- } catch (IOException e) {
- assertTrue(
- "File system error occured while testing directory manipulation",
- false);
}
+ assertTrue(
+ "Directory Manipulation didn't use supplied manifest file as output",
+ false);
}
-
}
diff --git a/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/RemanipulationTest.java b/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/RemanipulationTest.java
index 1b8945c..76df283 100644
--- a/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/RemanipulationTest.java
+++ b/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/RemanipulationTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.manipulation;
import junit.framework.Assert;