#ODFTOOLKIT-462 - Adding manifest file to ODFDOM jar-with-dependencies JAR including regression integration tests
git-svn-id: https://svn.apache.org/repos/asf/incubator/odf/trunk@1802485 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/odfdom/pom.xml b/odfdom/pom.xml
index c114912..7580722 100644
--- a/odfdom/pom.xml
+++ b/odfdom/pom.xml
@@ -132,9 +132,8 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <!-- Explizit version required for fix on systemPropertyVariables -->
- <version>2.19.1</version>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.20</version>
<configuration>
<forkMode>pertest</forkMode>
<systemPropertyVariables>
@@ -173,7 +172,7 @@
<version>${project.version}</version>
</tagletArtifact>
</configuration>
- <executions>
+ <executions>
<execution>
<id>attach-javadocs</id>
<goals>
@@ -200,6 +199,27 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
+ <archive>
+ <index>true</index>
+ <manifest>
+ <mainClass>org.odftoolkit.odfdom.JarManifest</mainClass>
+ </manifest>
+ <manifestEntries>
+ <version>${project.version}</version>
+ </manifestEntries>
+ <manifestSections>
+ <manifestSection>
+ <name>ODFDOM</name>
+ <manifestEntries>
+ <ODFDOM-Name>odfdom</ODFDOM-Name>
+ <ODFDOM-Version>${project.version}</ODFDOM-Version>
+ <ODFDOM-Website>http://incubator.apache.org/odftoolkit/odfdom/index.html</ODFDOM-Website>
+ <ODFDOM-Built-Date>${build.timestamp}</ODFDOM-Built-Date>
+ <ODFDOM-Supported-Odf-Version>1.2</ODFDOM-Supported-Odf-Version>
+ </manifestEntries>
+ </manifestSection>
+ </manifestSections>
+ </archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
@@ -228,6 +248,29 @@
</excludes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.20</version>
+ <configuration>
+ <excludes>
+ <exclude>**/PerformanceIT.java</exclude>
+ </excludes>
+ <systemPropertyVariables>
+ <odfdom.version>${project.version}</odfdom.version>
+ <org.odftoolkit.odfdom.validation>org.odftoolkit.odfdom.pkg.DefaultErrorHandler</org.odftoolkit.odfdom.validation>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <id>failsafe-it</id>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<reporting>
@@ -265,7 +308,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>2.19.1</version>
+ <version>2.20</version>
<reportSets>
<reportSet>
<id>integration-tests</id>
@@ -446,8 +489,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>2.19.1</version>
- <executions>
+ <version>2.20</version>
+ <configuration>
+ <systemPropertyVariables>
+ <testresourcefolder>performance</testresourcefolder>
+ <executetimes>1</executetimes>
+ <testflag>test</testflag>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
<execution>
<id>failsafe-it</id>
<phase>integration-test</phase>
@@ -455,29 +505,21 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
- <configuration>
- <classesDirectory>${basedir}/target/odfdom*.jar</classesDirectory>
- <systemPropertyVariables>
- <testresourcefolder>performance</testresourcefolder>
- <executetimes>1</executetimes>
- <testflag>test</testflag>
- </systemPropertyVariables>
- </configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <!-- Explizit version required for fix on systemPropertyVariables -->
- <version>2.19.1</version>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.20</version>
<configuration>
<systemPropertyVariables>
<odfdom.version>${project.version}</odfdom.version>
<odfdom.timestamp>${build.timestamp}</odfdom.timestamp>
<org.odftoolkit.odfdom.validation>true</org.odftoolkit.odfdom.validation>
</systemPropertyVariables>
- <skip>true</skip> </configuration>
+ <skip>true</skip>
+ </configuration>
</plugin>
</plugins>
</build>
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java b/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java
index d2741cf..4546997 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java
@@ -1,20 +1,20 @@
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- *
+ *
* Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- *
+ *
* Use is subject to license terms.
- *
+ *
* Licensed 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. You can also
* obtain a copy of the License at http://odftoolkit.org/docs/license.txt
- *
+ *
* 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.
*
@@ -44,7 +44,7 @@
private static String ODFDOM_WEBSITE;
private static String ODFDOM_BUILD_DATE;
private static String ODFDOM_SUPPORTED_ODF_VERSION;
-
+
static {
try {
Manifest manifest = new Manifest(getManifestAsStream());
@@ -104,12 +104,12 @@
/**
* Returns the ODFDOM library title
- *
+ *
* @return A string containing both the name and the version of the ODFDOM library.
*/
public static String getOdfdomTitle() {
return getOdfdomName() + ' ' + getOdfdomVersion();
- }
+ }
/**
* Return the version of the ODFDOM library (ie. odfdom.jar)
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java b/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
index 1221378..d7d1eb6 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
@@ -1,81 +1,119 @@
-/************************************************************************
+/** **********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- *
+ *
* Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- *
+ *
* Use is subject to license terms.
- *
+ *
* Licensed 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. You can also
* obtain a copy of the License at http://odftoolkit.org/docs/license.txt
- *
+ *
* 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.odftoolkit.odfdom.integrationtest;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
-
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.junit.Test;
import org.odftoolkit.odfdom.JarManifest;
public class JarManifestIT {
- private static final Logger LOG = Logger.getLogger(JarManifestIT.class.getName());
+ private static final Logger LOG = Logger.getLogger(JarManifestIT.class.getName());
+ private static final String JAR_NAME_PREFIX = "odfdom-java-";
+ private static final String JAR_NAME_SUFFIX_1 = "-jar-with-dependencies.jar";
+ private static final String JAR_NAME_SUFFIX_2 = ".jar";
- @Test
- public void testJar() {
- try {
- String command = "java -jar target/odfdom.jar";
- Process process = Runtime.getRuntime().exec(command);
- process.waitFor();
- BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
- BufferedReader outputReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
- String line;
- while ((line = errorReader.readLine()) != null) {
- LOG.info(line);
- Assert.assertTrue(line.indexOf("Exception") == -1);
- }
- String firstOutputLine = outputReader.readLine();
- String secondOutputLine = outputReader.readLine();
- errorReader.close();
- outputReader.close();
- process.destroy();
- LOG.log(Level.INFO, "The version info from commandline given by {0} is:\n", command);
- LOG.log(Level.INFO, "\"{0}\"", firstOutputLine);
- LOG.log(Level.INFO, "\"{0}\"", secondOutputLine);
- Assert.assertEquals(firstOutputLine, JarManifest.getOdfdomTitle() + " (build " + JarManifest.getOdfdomBuildDate() + ')');
- Assert.assertEquals(secondOutputLine, "from " + JarManifest.getOdfdomWebsite() + " supporting ODF " + JarManifest.getOdfdomSupportedOdfVersion());
+ @Test
+ public void testOdfdomJar() {
+ testJar(JAR_NAME_SUFFIX_1);
+ }
- LOG.log(Level.INFO, "\nJarManifest.getName(): {0}", JarManifest.getOdfdomName());
- Assert.assertNotNull(JarManifest.getOdfdomName());
+ @Test
+ public void testOdfdomWithDependenciesJar() {
+ testJar(JAR_NAME_SUFFIX_2);
+ }
- LOG.log(Level.INFO, "\nJarManifest.getTitle(): {0}", JarManifest.getOdfdomTitle());
- Assert.assertNotNull(JarManifest.getOdfdomTitle());
- LOG.log(Level.INFO, "\nJarManifest.getVersion(): {0}", JarManifest.getOdfdomVersion());
- Assert.assertNotNull(JarManifest.getOdfdomVersion());
+ private void testJar(String commandSuffix) {
+ try {
+ // CREATING THE JAR PATH
+ String odfdomVersion = System.getProperty("odfdom.version");
+ String jarPath = "target" + File.separatorChar + JAR_NAME_PREFIX + odfdomVersion + commandSuffix;
- LOG.log(Level.INFO, "\nJarManifest.getBuildDate(): {0}", JarManifest.getOdfdomBuildDate());
- Assert.assertNotNull(JarManifest.getOdfdomBuildDate());
+ // TRIGGERING COMMAND LINE JAR EXECUTION
+ String firstOutputLine = null;
+ String secondOutputLine = null;
+ try {
+ ProcessBuilder builder = new ProcessBuilder("java", "-jar", jarPath);
+ builder.redirectErrorStream(true);
+ Process p = builder.start();
+ BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line;
+ while (true) {
+ line = r.readLine();
+ if (line == null) {
+ break;
+ }
+ if (line.contains("Exception")) {
+ throw new IOException(line);
+ }
+ if(firstOutputLine == null){
+ firstOutputLine = line;
+ }else{
+ secondOutputLine = line;
+ }
+ }
+ } catch (IOException t) {
+ StringWriter errors = new StringWriter();
+ t.printStackTrace(new PrintWriter(errors));
+ Assert.fail(t.toString() + "\n" + errors.toString());
+ }
- LOG.log(Level.INFO, "\nJarManifest.getSupportedOdfVersion(): {0}", JarManifest.getOdfdomSupportedOdfVersion());
- Assert.assertNotNull(JarManifest.getOdfdomSupportedOdfVersion());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, null, e);
- }
- }
+ // EVALUATING COMMAND LINE INFORMATION
+ LOG.log(Level.INFO, "The version info from commandline given by {0} is:\n", "java -jar" + jarPath);
+ LOG.log(Level.INFO, "\"{0}\"", firstOutputLine);
+ LOG.log(Level.INFO, "\"{0}\"", secondOutputLine);
+ Assert.assertEquals(JarManifest.getOdfdomTitle() + " (build " + JarManifest.getOdfdomBuildDate() + ')', firstOutputLine);
+ Assert.assertEquals("from " + JarManifest.getOdfdomWebsite() + " supporting ODF " + JarManifest.getOdfdomSupportedOdfVersion(), secondOutputLine);
+
+
+
+ // EVALUATING JAR MANIFEST INFORMATION
+ LOG.log(Level.INFO, "\nJarManifest.getName(): {0}", JarManifest.getOdfdomName());
+ Assert.assertNotNull(JarManifest.getOdfdomName());
+
+ LOG.log(Level.INFO, "\nJarManifest.getTitle(): {0}", JarManifest.getOdfdomTitle());
+ Assert.assertNotNull(JarManifest.getOdfdomTitle());
+
+ LOG.log(Level.INFO, "\nJarManifest.getVersion(): {0}", JarManifest.getOdfdomVersion());
+ Assert.assertNotNull(JarManifest.getOdfdomVersion());
+
+ LOG.log(Level.INFO, "\nJarManifest.getBuildDate(): {0}", JarManifest.getOdfdomBuildDate());
+ Assert.assertNotNull(JarManifest.getOdfdomBuildDate());
+
+ LOG.log(Level.INFO, "\nJarManifest.getSupportedOdfVersion(): {0}", JarManifest.getOdfdomSupportedOdfVersion());
+ Assert.assertNotNull(JarManifest.getOdfdomSupportedOdfVersion());
+
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, null, e);
+ }
+ }
}
diff --git a/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java b/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java
index e2bbcfd..d8e2ac6 100644
--- a/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java
+++ b/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java
@@ -2,7 +2,6 @@
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
- * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
*
* Use is subject to license terms.
*