Try to make Sonar builds run again: add missing dependency, add ooxml-schema-security, don't depend on dir test-data and build-directory directly, don't override a POILogger that is set via System Properties

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696165 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-08-16 20:51:40 +00:00
parent d90309db4e
commit 0345110611
9 changed files with 148 additions and 43 deletions

View File

@ -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>

View File

@ -22,7 +22,6 @@
<executions> <executions>
<execution> <execution>
<id>copy-sources</id> <id>copy-sources</id>
<!-- here the phase you need -->
<phase>generate-sources</phase> <phase>generate-sources</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
@ -38,7 +37,6 @@
</execution> </execution>
<execution> <execution>
<id>copy-resources</id> <id>copy-resources</id>
<!-- here the phase you need -->
<phase>generate-resources</phase> <phase>generate-resources</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
@ -54,7 +52,6 @@
</execution> </execution>
<execution> <execution>
<id>copy-tests</id> <id>copy-tests</id>
<!-- here the phase you need -->
<phase>generate-test-sources</phase> <phase>generate-test-sources</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
@ -97,6 +94,11 @@
<artifactId>poi-ooxml-schema-encryption</artifactId> <artifactId>poi-ooxml-schema-encryption</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>poi-ooxml-schema-security</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>poi-main</artifactId> <artifactId>poi-main</artifactId>
@ -116,6 +118,22 @@
<version>2.6.0</version> <version>2.6.0</version>
</dependency> </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 --> <!-- non-test dependency for OOXMLLite -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -56,6 +56,7 @@
<module>main</module> <module>main</module>
<module>ooxml-schema</module> <module>ooxml-schema</module>
<module>ooxml-schema-encryption</module> <module>ooxml-schema-encryption</module>
<module>ooxml-schema-security</module>
<module>ooxml</module> <module>ooxml</module>
<module>scratchpad</module> <module>scratchpad</module>
<module>excelant</module> <module>excelant</module>
@ -100,7 +101,8 @@
<java.awt.headless>true</java.awt.headless> <java.awt.headless>true</java.awt.headless>
<org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger> <org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
</systemPropertyVariables> </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> <excludes>
<exclude>**/All*Tests.java</exclude> <exclude>**/All*Tests.java</exclude>
<exclude>**/TestUnfixedBugs.java</exclude> <exclude>**/TestUnfixedBugs.java</exclude>

View File

@ -33,6 +33,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -632,13 +633,31 @@ public class TestSignatureInfo {
private static File copy(File input) throws IOException { private static File copy(File input) throws IOException {
String extension = input.getName().replaceAll(".*?(\\.[^.]+)?$", "$1"); String extension = input.getName().replaceAll(".*?(\\.[^.]+)?$", "$1");
if (extension == null || "".equals(extension)) extension = ".zip"; if (extension == null || "".equals(extension)) {
File tmpFile = new File("build", "sigtest"+extension); extension = ".zip";
FileOutputStream fos = new FileOutputStream(tmpFile); }
FileInputStream fis = new FileInputStream(input);
// ensure that we create the "build" directory as it might not be existing
// in the Sonar Maven runs where we are at a different source directory
File buildDir = new File("build");
if(!buildDir.exists()) {
assertTrue("Failed to create " + buildDir.getAbsolutePath(),
buildDir.mkdirs());
}
File tmpFile = new File(buildDir, "sigtest"+extension);
OutputStream fos = new FileOutputStream(tmpFile);
try {
InputStream fis = new FileInputStream(input);
try {
IOUtils.copy(fis, fos); IOUtils.copy(fis, fos);
} finally {
fis.close(); fis.close();
}
} finally {
fos.close(); fos.close();
}
return tmpFile; return tmpFile;
} }

View File

@ -1923,6 +1923,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
@Test @Test
public void test57196_WorkbookEvaluator() { 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("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
//System.setProperty("poi.log.level", "3"); //System.setProperty("poi.log.level", "3");
try { try {
@ -1990,7 +1991,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
workbookEvaluator.setDebugEvaluationOutputForNextEval(true); workbookEvaluator.setDebugEvaluationOutputForNextEval(true);
workbookEvaluator.evaluate(new XSSFEvaluationCell(cell)); workbookEvaluator.evaluate(new XSSFEvaluationCell(cell));
} finally { } finally {
if(previousLogger == null) {
System.clearProperty("org.apache.poi.util.POILogger"); System.clearProperty("org.apache.poi.util.POILogger");
} else {
System.setProperty("org.apache.poi.util.POILogger", previousLogger);
}
System.clearProperty("poi.log.level"); System.clearProperty("poi.log.level");
} }
} }

View File

@ -17,6 +17,8 @@
package org.apache.poi.xssf.usermodel; package org.apache.poi.xssf.usermodel;
import java.io.IOException;
import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.ss.usermodel.BaseTestHyperlink; import org.apache.poi.ss.usermodel.BaseTestHyperlink;
@ -32,15 +34,6 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
super(XSSFITestDataProvider.instance); 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() { public void testLoadExisting() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx"); XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx");
assertEquals(3, workbook.getNumberOfSheets()); 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(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFCreationHelper createHelper = workbook.getCreationHelper(); XSSFCreationHelper createHelper = workbook.getCreationHelper();
@ -111,6 +104,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
} }
} }
workbook.close();
} }
public void testLoadSave() { public void testLoadSave() {

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFTestDataSamples; import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.hwpf.extractor.WordExtractor; 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/Word95.doc", "/tmp/test.doc"});
//WordDocument.main(new String[] {"test-data/document/Word6.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") @SuppressWarnings("deprecation")
@ -53,7 +54,7 @@ public class TestWordDocument {
assertTrue("Had: " + text, text.contains("Just a \u201Ctest\u201D")); assertTrue("Had: " + text, text.contains("Just a \u201Ctest\u201D"));
extractor.close(); 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(); StringWriter docTextWriter = new StringWriter();
PrintWriter out = new PrintWriter(docTextWriter); PrintWriter out = new PrintWriter(docTextWriter);

View File

@ -33,15 +33,6 @@ import org.apache.poi.util.DummyPOILogger;
* @author Marc Johnson * @author Marc Johnson
*/ */
public final class TestRawDataBlock extends TestCase { 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 * Test creating a normal RawDataBlock
*/ */
@ -130,7 +121,7 @@ public final class TestRawDataBlock extends TestCase {
assertEquals( 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!", "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 { } else {
assertEquals(0, logger.logged.size()); assertEquals(0, logger.logged.size());

View File

@ -32,15 +32,6 @@ import org.apache.poi.util.DummyPOILogger;
* @author Marc Johnson * @author Marc Johnson
*/ */
public final class TestRawDataBlockList extends TestCase { 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 * Test creating a normal RawDataBlockList
*/ */