incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svanteschub...@apache.org
Subject svn commit: r1802485 - in /incubator/odf/trunk: odfdom/ odfdom/src/main/java/org/odftoolkit/odfdom/ odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/ validator/src/test/java/org/odftoolkit/odfvalidator/jar/
Date Thu, 20 Jul 2017 13:42:53 GMT
Author: svanteschubert
Date: Thu Jul 20 13:42:53 2017
New Revision: 1802485

URL: http://svn.apache.org/viewvc?rev=1802485&view=rev
Log:
#ODFTOOLKIT-462 - Adding manifest file to ODFDOM jar-with-dependencies JAR including regression
integration tests

Modified:
    incubator/odf/trunk/odfdom/pom.xml
    incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java
    incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
    incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java

Modified: incubator/odf/trunk/odfdom/pom.xml
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/pom.xml?rev=1802485&r1=1802484&r2=1802485&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/pom.xml (original)
+++ incubator/odf/trunk/odfdom/pom.xml Thu Jul 20 13:42:53 2017
@@ -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>

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java?rev=1802485&r1=1802484&r2=1802485&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/JarManifest.java Thu Jul
20 13:42:53 2017
@@ -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 @@ public class JarManifest {
     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 @@ public class JarManifest {
 
     /**
      * 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)

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java?rev=1802485&r1=1802484&r2=1802485&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
(original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/integrationtest/JarManifestIT.java
Thu Jul 20 13:42:53 2017
@@ -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());
-
-	@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());
-
-			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);
-		}
-	}
+    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 testOdfdomJar() {
+        testJar(JAR_NAME_SUFFIX_1);
+    }
+
+    @Test
+    public void testOdfdomWithDependenciesJar() {
+        testJar(JAR_NAME_SUFFIX_2);
+    }
+
+
+    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;
+
+            // 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());
+            }
+
+
+            // 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);
+        }
+    }
 }

Modified: incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java?rev=1802485&r1=1802484&r2=1802485&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java
(original)
+++ incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/jar/ITJarTest.java
Thu Jul 20 13:42:53 2017
@@ -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.
  *



Mime
View raw message