]> source.dussan.org Git - poi.git/commitdiff
Try to make Sonar builds run again: add missing dependency, add ooxml-schema-security...
authorDominik Stadler <centic@apache.org>
Sun, 16 Aug 2015 20:51:40 +0000 (20:51 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 16 Aug 2015 20:51:40 +0000 (20:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696165 13f79535-47bb-0310-9956-ffa450edef68

sonar/ooxml-schema-security/pom.xml [new file with mode: 0644]
sonar/ooxml/pom.xml
sonar/pom.xml
src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
src/scratchpad/testcases/org/apache/poi/hdf/extractor/TestWordDocument.java
src/testcases/org/apache/poi/poifs/storage/TestRawDataBlock.java
src/testcases/org/apache/poi/poifs/storage/TestRawDataBlockList.java

diff --git a/sonar/ooxml-schema-security/pom.xml b/sonar/ooxml-schema-security/pom.xml
new file mode 100644 (file)
index 0000000..7debcf2
--- /dev/null
@@ -0,0 +1,84 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+                             http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.poi</groupId>
+        <artifactId>poi-parent</artifactId>
+        <version>3.12-SNAPSHOT</version>
+    </parent>
+    <artifactId>poi-ooxml-schema-security</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apach POI - Openxmlformats Security-Schema package</name>
+
+       <properties>
+               <!-- see http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus for details of this property -->
+               <sonar.exclusions>target/generated-sources/*</sonar.exclusions>
+       </properties>
+  
+    <build>
+               <plugins>
+                       <!-- reuse Ant build here instead of trying to tweak Maven to do this as we got stuck 
+                       because we cannot provide "-noupa -nopvr" using the xmlbeans-maven-plugin -->
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-antrun-plugin</artifactId>
+                               <version>1.6</version>
+                               <executions>
+                                       <execution>
+                                               <id>build-jar</id>
+                                               <phase>generate-sources</phase>
+                                               <configuration>
+                                                       <target>
+                                                               <echo message="build jar-file for ooxml-security" />
+                                                               <ant dir="../.." target="compile-ooxml-xsds" useNativeBasedir="true"/>
+                                                               <unzip src="../../ooxml-lib/ooxml-security-1.0.jar" dest="target/jar"/>
+                                                       </target>
+                                               </configuration>
+                                               <goals>
+                                                       <goal>run</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+                       <!-- copy resulting files from the jar-file as "resources" as otherwise Sonar does not pick them up -->
+                       <plugin>
+                               <artifactId>maven-resources-plugin</artifactId>
+                               <version>2.6</version>
+                               <executions>
+                                       <execution>
+                                               <id>copy-sources</id>
+                                               <phase>generate-sources</phase>
+                                               <goals>
+                                                       <goal>copy-resources</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <outputDirectory>${basedir}/src/main/resources</outputDirectory>
+                                                       <resources>          
+                                                               <resource>
+                                                                       <directory>target/jar</directory>
+                                                               </resource>
+                                                       </resources>              
+                                               </configuration>            
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>poi-main</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>poi-scratchpad</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>
index 994b232ea13887561cb1cdc5ecad2f7470f8e8ac..4df81fe121ca02d6e8f1f603e911d655551962e0 100644 (file)
@@ -22,7 +22,6 @@
                                <executions>
                                        <execution>
                                                <id>copy-sources</id>
-                                               <!-- here the phase you need -->
                                                <phase>generate-sources</phase>
                                                <goals>
                                                        <goal>copy-resources</goal>
@@ -38,7 +37,6 @@
                                        </execution>
                                        <execution>
                                                <id>copy-resources</id>
-                                               <!-- here the phase you need -->
                                                <phase>generate-resources</phase>
                                                <goals>
                                                        <goal>copy-resources</goal>
@@ -54,7 +52,6 @@
                                        </execution>
                                        <execution>
                                                <id>copy-tests</id>
-                                               <!-- here the phase you need -->
                                                <phase>generate-test-sources</phase>
                                                <goals>
                                                        <goal>copy-resources</goal>
             <artifactId>poi-ooxml-schema-encryption</artifactId>
                        <version>${project.version}</version>
         </dependency>
+        <dependency>
+                       <groupId>${project.groupId}</groupId>
+            <artifactId>poi-ooxml-schema-security</artifactId>
+                       <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>poi-main</artifactId>
                  <version>2.6.0</version>
                </dependency>
                
+               <dependency>
+                       <groupId>org.bouncycastle</groupId>
+                       <artifactId>bcpkix-jdk15on</artifactId>
+                       <version>1.51</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.bouncycastle</groupId>
+                       <artifactId>bcprov-jdk15on</artifactId>
+                       <version>1.51</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.santuario</groupId>
+                       <artifactId>xmlsec</artifactId>
+                       <version>2.0.1</version>
+               </dependency>
+  
                <!-- non-test dependency for OOXMLLite -->
         <dependency>
             <groupId>junit</groupId>
index 99796faaffba8974fdb2fc5fd623369f8e59fd72..6117e935554f834b4020bfaf743cd7914c778818 100644 (file)
@@ -56,6 +56,7 @@
                <module>main</module>
                <module>ooxml-schema</module>
                <module>ooxml-schema-encryption</module>
+               <module>ooxml-schema-security</module>
                <module>ooxml</module>
                <module>scratchpad</module>
                <module>excelant</module>
                                        <java.awt.headless>true</java.awt.headless>
                                        <org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
                                </systemPropertyVariables>
-                               <argLine>-Duser.language=en -Duser.country=US</argLine>
+                               <!-- use to following to analyze OOM issues:  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -->
+                               <argLine>-Duser.language=en -Duser.country=US -Xmx512m</argLine>
                                <excludes>
                                        <exclude>**/All*Tests.java</exclude>
                                        <exclude>**/TestUnfixedBugs.java</exclude>
index d0eeb3d4773b213bf3d85590a7d563b8d19cdac4..0835c566b810a31165cf4abdc339454c4c374c69 100644 (file)
@@ -33,6 +33,7 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.io.OutputStream;\r
 import java.lang.reflect.Method;\r
 import java.net.ConnectException;\r
 import java.net.HttpURLConnection;\r
@@ -632,13 +633,31 @@ public class TestSignatureInfo {
 \r
     private static File copy(File input) throws IOException {\r
         String extension = input.getName().replaceAll(".*?(\\.[^.]+)?$", "$1");\r
-        if (extension == null || "".equals(extension)) extension = ".zip";\r
-        File tmpFile = new File("build", "sigtest"+extension);\r
-        FileOutputStream fos = new FileOutputStream(tmpFile);\r
-        FileInputStream fis = new FileInputStream(input);\r
-        IOUtils.copy(fis, fos);\r
-        fis.close();\r
-        fos.close();\r
+        if (extension == null || "".equals(extension)) {\r
+            extension = ".zip";\r
+        }\r
+\r
+        // ensure that we create the "build" directory as it might not be existing\r
+        // in the Sonar Maven runs where we are at a different source directory\r
+        File buildDir = new File("build");\r
+        if(!buildDir.exists()) {\r
+            assertTrue("Failed to create " + buildDir.getAbsolutePath(), \r
+                    buildDir.mkdirs());\r
+        }\r
+        File tmpFile = new File(buildDir, "sigtest"+extension);\r
+\r
+        OutputStream fos = new FileOutputStream(tmpFile);\r
+        try {\r
+            InputStream fis = new FileInputStream(input);\r
+            try {\r
+                IOUtils.copy(fis, fos);\r
+            } finally {\r
+                fis.close();\r
+            }\r
+        } finally {\r
+            fos.close();\r
+        }\r
+\r
         return tmpFile;\r
     }\r
 \r
index 2a7752c525f3675bff99469c6390d0d4a5ffacf3..1409d422749d7e60dc0aa8c58d9e3c6d4d7d5147 100644 (file)
@@ -1923,6 +1923,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
 
     @Test
     public void test57196_WorkbookEvaluator() {
+        String previousLogger = System.getProperty("org.apache.poi.util.POILogger");
         //System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
         //System.setProperty("poi.log.level", "3");
         try {
@@ -1990,7 +1991,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
             workbookEvaluator.setDebugEvaluationOutputForNextEval(true);
             workbookEvaluator.evaluate(new XSSFEvaluationCell(cell));
         } finally {
-            System.clearProperty("org.apache.poi.util.POILogger");
+            if(previousLogger == null) {
+                System.clearProperty("org.apache.poi.util.POILogger");
+            } else {
+                System.setProperty("org.apache.poi.util.POILogger", previousLogger);
+            }
             System.clearProperty("poi.log.level");
         }
     }
index fbec25c670542b6c76ce775b3c7caca7e69f96c5..6f8c3f087c26af1afe1aedd1bde49dad78ec89cf 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import java.io.IOException;
+
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
 import org.apache.poi.ss.usermodel.BaseTestHyperlink;
@@ -32,15 +34,6 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
                super(XSSFITestDataProvider.instance);
        }
 
-       @Override
-       protected void setUp() {
-               // Use system out logger
-               System.setProperty(
-                               "org.apache.poi.util.POILogger",
-                               "org.apache.poi.util.SystemOutLogger"
-               );
-       }
-
        public void testLoadExisting() {
                XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx");
                assertEquals(3, workbook.getNumberOfSheets());
@@ -94,7 +87,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
         }
     }
 
-    public void testInvalidURLs() {
+    public void testInvalidURLs() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFCreationHelper createHelper = workbook.getCreationHelper();
 
@@ -111,6 +104,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
 
             }
         }
+        workbook.close();
     }
 
     public void testLoadSave() {
index f0941674ffe20ea597ad4b0429b42b29274290c8..e8c04a331ca6cee55b5e766fbc6ceba69830da5b 100644 (file)
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFTestDataSamples;
 import org.apache.poi.hwpf.extractor.WordExtractor;
@@ -38,7 +39,7 @@ public class TestWordDocument {
         
         //WordDocument.main(new String[] {"test-data/document/Word95.doc", "/tmp/test.doc"});
         //WordDocument.main(new String[] {"test-data/document/Word6.doc", "/tmp/test.doc"});
-        WordDocument.main(new String[] {"test-data/document/53446.doc", "/tmp/test.doc"});
+        WordDocument.main(new String[] {POIDataSamples.getDocumentInstance().getFile("53446.doc").getAbsolutePath(), "/tmp/test.doc"});
     }
 
     @SuppressWarnings("deprecation")
@@ -53,7 +54,7 @@ public class TestWordDocument {
         assertTrue("Had: " + text, text.contains("Just  a \u201Ctest\u201D"));
         extractor.close();
         
-               WordDocument wordDoc = new WordDocument("test-data/document/47304.doc");
+               WordDocument wordDoc = new WordDocument(POIDataSamples.getDocumentInstance().getFile("47304.doc").getAbsolutePath());
         
         StringWriter docTextWriter = new StringWriter();
         PrintWriter out = new PrintWriter(docTextWriter);
index 5b632ce833222c2fe503c8a7610cb6646dc68a33..f7be2acf71bcfb7232ac74bae61519134cbde061 100644 (file)
@@ -33,15 +33,6 @@ import org.apache.poi.util.DummyPOILogger;
  * @author Marc Johnson
  */
 public final class TestRawDataBlock extends TestCase {
-       static {
-               // We always want to use our own
-               //  logger
-               System.setProperty(
-                               "org.apache.poi.util.POILogger",
-                               "org.apache.poi.util.DummyPOILogger"
-               );
-       }
-
        /**
         * Test creating a normal RawDataBlock
         */
@@ -130,7 +121,7 @@ public final class TestRawDataBlock extends TestCase {
 
                                assertEquals(
                                                "7 - Unable to read entire block; "+bts+" read before EOF; expected 512 bytes. Your document was either written by software that ignores the spec, or has been truncated!",
-                                               (String)(logger.logged.get(0))
+                                               logger.logged.get(0)
                                );
                        } else {
                                assertEquals(0, logger.logged.size());
index 6dabfc0430b4a63999a1e28a60fb82d4b0637525..91be31e34d9eddb8b99ed3503ad21ddef4710075 100644 (file)
@@ -32,15 +32,6 @@ import org.apache.poi.util.DummyPOILogger;
  * @author Marc Johnson
  */
 public final class TestRawDataBlockList extends TestCase {
-       static {
-        // We always want to use our own
-        //  logger
-        System.setProperty(
-                       "org.apache.poi.util.POILogger",
-                       "org.apache.poi.util.DummyPOILogger"
-        );
-       }
-
     /**
      * Test creating a normal RawDataBlockList
      */