--- /dev/null
+<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>
<executions>
<execution>
<id>copy-sources</id>
- <!-- here the phase you need -->
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</execution>
<execution>
<id>copy-resources</id>
- <!-- here the phase you need -->
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</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>
<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>
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
\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
@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 {
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");
}
}
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;
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());
}
}
- public void testInvalidURLs() {
+ public void testInvalidURLs() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFCreationHelper createHelper = workbook.getCreationHelper();
}
}
+ workbook.close();
}
public void testLoadSave() {
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;
//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")
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);
* @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
*/
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());
* @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
*/