#ODFTOOLKIT-453# Temporary test files moved into build directory. Patched by Ian Cunningham
git-svn-id: https://svn.apache.org/repos/asf/incubator/odf/trunk@1795827 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/ChartTemplateTest.java b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/ChartTemplateTest.java
index 8610ad3..56653a8 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/ChartTemplateTest.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/ChartTemplateTest.java
@@ -1,5 +1,5 @@
/************************************************************************
-*
+*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -21,7 +21,6 @@
package org.odftoolkit.odfdom.doc;
import java.io.File;
-
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -45,7 +44,7 @@
@Test
public void testSavingAChartTemplate() throws Exception {
OdfDocument document = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(TEST_CHART_TEMPLATE));
- File destination = File.createTempFile("odfdom-test", ".otc");
+ File destination = File.createTempFile("odfdom-test", ".otc", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -62,7 +61,7 @@
Assert.assertEquals(OdfDocument.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".otc");
+ File destination = File.createTempFile("odfdom-test", ".otc", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/GraphicsTemplateTest.java b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/GraphicsTemplateTest.java
index 7723126..b1b7e78 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/GraphicsTemplateTest.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/GraphicsTemplateTest.java
@@ -21,9 +21,9 @@
package org.odftoolkit.odfdom.doc;
import java.io.File;
-
import org.junit.Assert;
import org.junit.Test;
+import org.odftoolkit.odfdom.utils.ResourceUtilities;
/**
* Test class for template aspects of graphics.
@@ -42,7 +42,7 @@
@Test
public void testSavingAGraphicsTemplate() throws Exception {
OdfDocument document = OdfDocument.loadDocument(this.getClass().getResourceAsStream(TEST_GRAPHICS_TEMPLATE));
- File destination = File.createTempFile("odfdom-test", ".otg");
+ File destination = File.createTempFile("odfdom-test", ".otg", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -55,7 +55,7 @@
OdfDocument document = OdfGraphicsDocument.newGraphicsTemplateDocument();
Assert.assertEquals(OdfDocument.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
Assert.assertEquals(OdfDocument.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".otg");
+ File destination = File.createTempFile("odfdom-test", ".otg", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/PresentationTemplateTest.java b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/PresentationTemplateTest.java
index e315fcf..881048c 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/PresentationTemplateTest.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/PresentationTemplateTest.java
@@ -21,9 +21,9 @@
package org.odftoolkit.odfdom.doc;
import java.io.File;
-
import org.junit.Assert;
import org.junit.Test;
+import org.odftoolkit.odfdom.utils.ResourceUtilities;
/**
* Test class for template aspects of presentations.
@@ -42,7 +42,7 @@
@Test
public void testSavingAPresentationTemplate() throws Exception {
OdfDocument document = OdfDocument.loadDocument(this.getClass().getResourceAsStream(TEST_PRESENTATION));
- File destination = File.createTempFile("odfdom-test", ".otp");
+ File destination = File.createTempFile("odfdom-test", ".otp", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -56,7 +56,7 @@
Assert.assertEquals(OdfDocument.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
Assert.assertEquals(OdfDocument.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".otp");
+ File destination = File.createTempFile("odfdom-test", ".otp", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/SpreadsheetTemplateTest.java b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/SpreadsheetTemplateTest.java
index dd49f88..e933ee9 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/SpreadsheetTemplateTest.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/SpreadsheetTemplateTest.java
@@ -21,9 +21,9 @@
package org.odftoolkit.odfdom.doc;
import java.io.File;
-
import org.junit.Assert;
import org.junit.Test;
+import org.odftoolkit.odfdom.utils.ResourceUtilities;
/**
* Test class for template aspects of calc documents.
@@ -42,7 +42,7 @@
@Test
public void testSavingASpreadsheetTemplate() throws Exception {
OdfDocument document = OdfDocument.loadDocument(this.getClass().getResourceAsStream(TEST_SPREADSHEET_TEMPLATE));
- File destination = File.createTempFile("odfdom-test", ".ots");
+ File destination = File.createTempFile("odfdom-test", ".ots", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -55,7 +55,7 @@
OdfDocument document = OdfSpreadsheetDocument.newSpreadsheetTemplateDocument();
Assert.assertEquals(OdfDocument.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
Assert.assertEquals(OdfDocument.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".ots");
+ File destination = File.createTempFile("odfdom-test", ".ots", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/TextTemplateTest.java b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/TextTemplateTest.java
index 1039f02..424506b 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/TextTemplateTest.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/TextTemplateTest.java
@@ -21,13 +21,13 @@
package org.odftoolkit.odfdom.doc;
import java.io.File;
-
import org.junit.Assert;
import org.junit.Test;
+import org.odftoolkit.odfdom.utils.ResourceUtilities;
/**
* Test class for template aspects of calc documents.
- *
+ *
* @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
*/
public class TextTemplateTest {
@@ -44,7 +44,7 @@
@Test
public void testSavingATextTemplate() throws Exception {
OdfDocument document = OdfDocument.loadDocument(this.getClass().getResourceAsStream(TEST_TEXT_TEMPLATE));
- File destination = File.createTempFile("odfdom-test", ".ott");
+ File destination = File.createTempFile("odfdom-test", ".ott", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -60,7 +60,7 @@
document.getMediaTypeString());
Assert.assertEquals(OdfDocument.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".ott");
+ File destination = File.createTempFile("odfdom-test", ".ott", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -77,7 +77,7 @@
document.getMediaTypeString());
Assert.assertEquals(OdfDocument.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".ott");
+ File destination = File.createTempFile("odfdom-test", ".ott", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
@@ -94,7 +94,7 @@
document.getMediaTypeString());
Assert.assertEquals(OdfDocument.OdfMediaType.TEXT_WEB.getMediaTypeString(),
document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("odfdom-test", ".ott");
+ File destination = File.createTempFile("odfdom-test", ".ott", ResourceUtilities.getTempTestDirectory());
document.save(destination);
// load again
diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java b/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java
index a5bf621..aa0c6a3 100644
--- a/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java
+++ b/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java
@@ -27,11 +27,11 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.odftoolkit.odfdom.pkg.rdfa.Util;
+
/** Test utility class providing resources for the test in- and output */
public final class ResourceUtilities {
@@ -65,7 +65,7 @@
public static URI getURI(String relativeFilePath) throws URISyntaxException {
String filePath = "file:" + ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).getPath();
filePath = Util.toExternalForm(new URI(filePath));
- return new URI(filePath);
+ return new URI(filePath);
}
/** The relative path of the test file will be used to determine an absolute
@@ -100,7 +100,7 @@
return new File(filepath);
}
- /**
+ /**
* @return the absolute path of the test output folder, which is usually <code>target/test-classes/</code>.
*/
public static String getTestOutputFolder() {
@@ -110,6 +110,12 @@
} catch (URISyntaxException ex) {
Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
}
- return testFolder;
+ return testFolder;
+ }
+
+ public static File getTempTestDirectory() {
+ File tempDir = new File(ResourceUtilities.getTestOutputFolder() + "temp");
+ tempDir.mkdir(); //if it already exist no problem
+ return tempDir;
}
}
diff --git a/simple/src/test/java/org/odftoolkit/simple/ChartTemplateTest.java b/simple/src/test/java/org/odftoolkit/simple/ChartTemplateTest.java
index a7c3c7b..d6f29f5 100644
--- a/simple/src/test/java/org/odftoolkit/simple/ChartTemplateTest.java
+++ b/simple/src/test/java/org/odftoolkit/simple/ChartTemplateTest.java
@@ -1,155 +1,157 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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
-
-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.simple;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test class for template aspects of chart.
- */
-public class ChartTemplateTest {
-
- private static final Logger LOG = Logger.getLogger(ChartTemplateTest.class.getName());
- private static final String TEST_CHART_TEMPLATE = "/chartTestTemplate.otc";
-
- @Test
- public void testLoadingAChartTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_CHART_TEMPLATE));
- Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
- document.getMediaTypeString());
- }
-
- @Test
- public void testSavingAChartTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_CHART_TEMPLATE));
- File destination = File.createTempFile("simple-test", ".otc");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- }
-
- @Test
- public void testNewChartTemplate() throws Exception {
- Document document = ChartDocument.newChartTemplateDocument();
- Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
- document.getMediaTypeString());
-
- Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("simple-test", ".otc");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof ChartDocument);
- }
-
- @Test
- public void testSwitchingOdfChartDocument() throws Exception {
- ChartDocument document = ChartDocument.newChartDocument();
- document.changeMode(ChartDocument.OdfMediaType.CHART_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
-
- document = ChartDocument.newChartTemplateDocument();
- document.changeMode(ChartDocument.OdfMediaType.CHART);
- Assert.assertEquals(Document.OdfMediaType.CHART.getMediaTypeString(), document.getPackage().getMediaTypeString());
- }
-
- @Test
- public void testGetOdfMediaType() throws Exception {
-
- try {
- Document.OdfMediaType chartType = ChartDocument.OdfMediaType.getOdfMediaType("CHART");
- Assert.assertEquals("CHART", chartType.name());
- Assert.assertEquals("application/vnd.oasis.opendocument.chart", chartType.getMediaTypeString());
- Assert.assertEquals("odc", chartType.getSuffix());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage(), e);
- Assert.fail(e.getMessage());
- }
-
- }
-
- @Test
- public void testGetMediaTypeString() throws Exception {
- try {
- ChartDocument.OdfMediaType odfMediaTypeChart = ChartDocument.OdfMediaType.valueOf(ChartDocument.OdfMediaType.class, ChartDocument.OdfMediaType.CHART.name());
- String MediaType = odfMediaTypeChart.getMediaTypeString();
- Assert.assertEquals("application/vnd.oasis.opendocument.chart", MediaType);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage(), e);
- Assert.fail(e.getMessage());
- }
-
- }
-
- @Test
- public void testLoadDocumentInputStream() throws Exception {
- try {
- InputStream inStream = this.getClass().getResourceAsStream(TEST_CHART_TEMPLATE);
- ChartDocument chardoc = ChartDocument.loadDocument(inStream);
- Assert.assertNotNull(chardoc);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage(), e);
- Assert.fail(e.getMessage());
- }
-
- }
-
- @Test
- public void testLoadDocumentFilePath() throws Exception {
- try {
- String filePath = this.getClass().getResource(TEST_CHART_TEMPLATE).getPath();
- ChartDocument chardoc = ChartDocument.loadDocument(filePath);
- Assert.assertNotNull(chardoc);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage(), e);
- Assert.fail(e.getMessage());
- }
-
- }
-
- @Test
- public void testLoadDocumentFile() throws Exception {
- try {
- String filePath = this.getClass().getResource(TEST_CHART_TEMPLATE).getPath();
- File filedoc = new File(filePath);
- Assert.assertNotNull(filedoc);
- ChartDocument chardoc = ChartDocument.loadDocument(filedoc);
- Assert.assertNotNull(chardoc);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage(), e);
- Assert.fail(e.getMessage());
- }
-
- }
-}
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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
+
+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.simple;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.odftoolkit.simple.utils.ResourceUtilities;
+
+
+/**
+ * Test class for template aspects of chart.
+ */
+public class ChartTemplateTest {
+
+ private static final Logger LOG = Logger.getLogger(ChartTemplateTest.class.getName());
+ private static final String TEST_CHART_TEMPLATE = "/chartTestTemplate.otc";
+
+ @Test
+ public void testLoadingAChartTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_CHART_TEMPLATE));
+ Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
+ document.getMediaTypeString());
+ }
+
+ @Test
+ public void testSavingAChartTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_CHART_TEMPLATE));
+ File destination = File.createTempFile("simple-test", ".otc", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ }
+
+ @Test
+ public void testNewChartTemplate() throws Exception {
+ Document document = ChartDocument.newChartTemplateDocument();
+ Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
+ document.getMediaTypeString());
+
+ Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ File destination = File.createTempFile("simple-test", ".otc", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof ChartDocument);
+ }
+
+ @Test
+ public void testSwitchingOdfChartDocument() throws Exception {
+ ChartDocument document = ChartDocument.newChartDocument();
+ document.changeMode(ChartDocument.OdfMediaType.CHART_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.CHART_TEMPLATE.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+
+ document = ChartDocument.newChartTemplateDocument();
+ document.changeMode(ChartDocument.OdfMediaType.CHART);
+ Assert.assertEquals(Document.OdfMediaType.CHART.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ }
+
+ @Test
+ public void testGetOdfMediaType() throws Exception {
+
+ try {
+ Document.OdfMediaType chartType = ChartDocument.OdfMediaType.getOdfMediaType("CHART");
+ Assert.assertEquals("CHART", chartType.name());
+ Assert.assertEquals("application/vnd.oasis.opendocument.chart", chartType.getMediaTypeString());
+ Assert.assertEquals("odc", chartType.getSuffix());
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testGetMediaTypeString() throws Exception {
+ try {
+ ChartDocument.OdfMediaType odfMediaTypeChart = ChartDocument.OdfMediaType.valueOf(ChartDocument.OdfMediaType.class, ChartDocument.OdfMediaType.CHART.name());
+ String MediaType = odfMediaTypeChart.getMediaTypeString();
+ Assert.assertEquals("application/vnd.oasis.opendocument.chart", MediaType);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testLoadDocumentInputStream() throws Exception {
+ try {
+ InputStream inStream = this.getClass().getResourceAsStream(TEST_CHART_TEMPLATE);
+ ChartDocument chardoc = ChartDocument.loadDocument(inStream);
+ Assert.assertNotNull(chardoc);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testLoadDocumentFilePath() throws Exception {
+ try {
+ String filePath = this.getClass().getResource(TEST_CHART_TEMPLATE).getPath();
+ ChartDocument chardoc = ChartDocument.loadDocument(filePath);
+ Assert.assertNotNull(chardoc);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testLoadDocumentFile() throws Exception {
+ try {
+ String filePath = this.getClass().getResource(TEST_CHART_TEMPLATE).getPath();
+ File filedoc = new File(filePath);
+ Assert.assertNotNull(filedoc);
+ ChartDocument chardoc = ChartDocument.loadDocument(filedoc);
+ Assert.assertNotNull(chardoc);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+
+ }
+}
diff --git a/simple/src/test/java/org/odftoolkit/simple/GraphicsTemplateTest.java b/simple/src/test/java/org/odftoolkit/simple/GraphicsTemplateTest.java
index 9ebac14..3b85485 100644
--- a/simple/src/test/java/org/odftoolkit/simple/GraphicsTemplateTest.java
+++ b/simple/src/test/java/org/odftoolkit/simple/GraphicsTemplateTest.java
@@ -1,79 +1,80 @@
-/*
- * 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.simple;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test class for template aspects of graphics.
- * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
- */
-public class GraphicsTemplateTest {
-
- private static final String TEST_GRAPHICS_TEMPLATE = "/graphicTestTemplate.otg";
-
- @Test
- public void testLoadingAGraphicsTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_GRAPHICS_TEMPLATE));
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
- }
-
- @Test
- public void testSavingAGraphicsTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_GRAPHICS_TEMPLATE));
- File destination = File.createTempFile("simple-test", ".otg");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), loadedDocument.getMediaTypeString());
- }
-
- @Test
- public void testNewGraphicsTemplate() throws Exception {
- Document document = GraphicsDocument.newGraphicsTemplateDocument();
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("simple-test", ".otg");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof GraphicsDocument);
- }
-
- @Test
- public void testSwitchingOdfGraphicsDocument() throws Exception {
- GraphicsDocument document = GraphicsDocument.newGraphicsDocument();
- document.changeMode(GraphicsDocument.OdfMediaType.GRAPHICS_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- document = GraphicsDocument.newGraphicsTemplateDocument();
- document.changeMode(GraphicsDocument.OdfMediaType.GRAPHICS);
- Assert.assertEquals(Document.OdfMediaType.GRAPHICS.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- }
-}
+/*
+ * 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.simple;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.odftoolkit.simple.utils.ResourceUtilities;
+
+/**
+ * Test class for template aspects of graphics.
+ * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
+ */
+public class GraphicsTemplateTest {
+
+ private static final String TEST_GRAPHICS_TEMPLATE = "/graphicTestTemplate.otg";
+
+ @Test
+ public void testLoadingAGraphicsTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_GRAPHICS_TEMPLATE));
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
+ }
+
+ @Test
+ public void testSavingAGraphicsTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_GRAPHICS_TEMPLATE));
+ File destination = File.createTempFile("simple-test", ".otg", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), loadedDocument.getMediaTypeString());
+ }
+
+ @Test
+ public void testNewGraphicsTemplate() throws Exception {
+ Document document = GraphicsDocument.newGraphicsTemplateDocument();
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ File destination = File.createTempFile("simple-test", ".otg", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof GraphicsDocument);
+ }
+
+ @Test
+ public void testSwitchingOdfGraphicsDocument() throws Exception {
+ GraphicsDocument document = GraphicsDocument.newGraphicsDocument();
+ document.changeMode(GraphicsDocument.OdfMediaType.GRAPHICS_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ document = GraphicsDocument.newGraphicsTemplateDocument();
+ document.changeMode(GraphicsDocument.OdfMediaType.GRAPHICS);
+ Assert.assertEquals(Document.OdfMediaType.GRAPHICS.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ }
+}
diff --git a/simple/src/test/java/org/odftoolkit/simple/PresentationTemplateTest.java b/simple/src/test/java/org/odftoolkit/simple/PresentationTemplateTest.java
index b32190d..2a7ddb5 100644
--- a/simple/src/test/java/org/odftoolkit/simple/PresentationTemplateTest.java
+++ b/simple/src/test/java/org/odftoolkit/simple/PresentationTemplateTest.java
@@ -1,80 +1,82 @@
-/*
- * 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.simple;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test class for template aspects of presentations.
- * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
- */
-public class PresentationTemplateTest {
-
- private static final String TEST_PRESENTATION = "/presentationTestTemplate.otp";
-
- @Test
- public void testLoadingAPresentationTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_PRESENTATION));
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
- }
-
- @Test
- public void testSavingAPresentationTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_PRESENTATION));
- File destination = File.createTempFile("simple-test", ".otp");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), loadedDocument.getMediaTypeString());
- }
-
- @Test
- public void testNewPresentationTemplate() throws Exception {
- Document document = PresentationDocument.newPresentationTemplateDocument();
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- File destination = File.createTempFile("simple-test", ".otp");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof PresentationDocument);
- }
-
- @Test
- public void testSwitchingOdfPresentationDocument() throws Exception {
- PresentationDocument document = PresentationDocument.newPresentationDocument();
- document.changeMode(PresentationDocument.OdfMediaType.PRESENTATION_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- document = PresentationDocument.newPresentationTemplateDocument();
- document.changeMode(PresentationDocument.OdfMediaType.PRESENTATION);
- Assert.assertEquals(Document.OdfMediaType.PRESENTATION.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- }
-}
+/*
+ * 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.simple;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.odftoolkit.simple.utils.ResourceUtilities;
+
+
+/**
+ * Test class for template aspects of presentations.
+ * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
+ */
+public class PresentationTemplateTest {
+
+ private static final String TEST_PRESENTATION = "/presentationTestTemplate.otp";
+
+ @Test
+ public void testLoadingAPresentationTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_PRESENTATION));
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
+ }
+
+ @Test
+ public void testSavingAPresentationTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_PRESENTATION));
+ File destination = File.createTempFile("simple-test", ".otp", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), loadedDocument.getMediaTypeString());
+ }
+
+ @Test
+ public void testNewPresentationTemplate() throws Exception {
+ Document document = PresentationDocument.newPresentationTemplateDocument();
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ File destination = File.createTempFile("simple-test", ".otp", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof PresentationDocument);
+ }
+
+ @Test
+ public void testSwitchingOdfPresentationDocument() throws Exception {
+ PresentationDocument document = PresentationDocument.newPresentationDocument();
+ document.changeMode(PresentationDocument.OdfMediaType.PRESENTATION_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ document = PresentationDocument.newPresentationTemplateDocument();
+ document.changeMode(PresentationDocument.OdfMediaType.PRESENTATION);
+ Assert.assertEquals(Document.OdfMediaType.PRESENTATION.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ }
+}
diff --git a/simple/src/test/java/org/odftoolkit/simple/SpreadsheetTemplateTest.java b/simple/src/test/java/org/odftoolkit/simple/SpreadsheetTemplateTest.java
index b4c92df..79e7c4f 100644
--- a/simple/src/test/java/org/odftoolkit/simple/SpreadsheetTemplateTest.java
+++ b/simple/src/test/java/org/odftoolkit/simple/SpreadsheetTemplateTest.java
@@ -1,79 +1,80 @@
-/*
- * 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.simple;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test class for template aspects of calc documents.
- * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
- */
-public class SpreadsheetTemplateTest {
-
- private static final String TEST_SPREADSHEET_TEMPLATE = "/spreadsheetTestTemplate.ots";
-
- @Test
- public void testLoadingASpreadsheetTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_SPREADSHEET_TEMPLATE));
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
- }
-
- @Test
- public void testSavingASpreadsheetTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_SPREADSHEET_TEMPLATE));
- File destination = File.createTempFile("simple-test", ".ots");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), loadedDocument.getMediaTypeString());
- }
-
- @Test
- public void testNewSpreadsheetTemplate() throws Exception {
- Document document = SpreadsheetDocument.newSpreadsheetTemplateDocument();
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("simple-test", ".ots");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof SpreadsheetDocument);
- }
-
- @Test
- public void testSwitchingOdfSpreadsheetDocument() throws Exception {
- SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
- document.changeMode(SpreadsheetDocument.OdfMediaType.SPREADSHEET_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- document = SpreadsheetDocument.newSpreadsheetTemplateDocument();
- document.changeMode(SpreadsheetDocument.OdfMediaType.SPREADSHEET);
- Assert.assertEquals(Document.OdfMediaType.SPREADSHEET.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- }
-}
+/*
+ * 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.simple;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.odftoolkit.simple.utils.ResourceUtilities;
+
+/**
+ * Test class for template aspects of calc documents.
+ * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
+ */
+public class SpreadsheetTemplateTest {
+
+ private static final String TEST_SPREADSHEET_TEMPLATE = "/spreadsheetTestTemplate.ots";
+
+ @Test
+ public void testLoadingASpreadsheetTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_SPREADSHEET_TEMPLATE));
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
+ }
+
+ @Test
+ public void testSavingASpreadsheetTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_SPREADSHEET_TEMPLATE));
+ File destination = File.createTempFile("simple-test", ".ots", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), loadedDocument.getMediaTypeString());
+ }
+
+ @Test
+ public void testNewSpreadsheetTemplate() throws Exception {
+ Document document = SpreadsheetDocument.newSpreadsheetTemplateDocument();
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getMediaTypeString());
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ File destination = File.createTempFile("simple-test", ".ots", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof SpreadsheetDocument);
+ }
+
+ @Test
+ public void testSwitchingOdfSpreadsheetDocument() throws Exception {
+ SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
+ document.changeMode(SpreadsheetDocument.OdfMediaType.SPREADSHEET_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ document = SpreadsheetDocument.newSpreadsheetTemplateDocument();
+ document.changeMode(SpreadsheetDocument.OdfMediaType.SPREADSHEET);
+ Assert.assertEquals(Document.OdfMediaType.SPREADSHEET.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ }
+}
diff --git a/simple/src/test/java/org/odftoolkit/simple/TextTemplateTest.java b/simple/src/test/java/org/odftoolkit/simple/TextTemplateTest.java
index 3755e46..70e49b5 100644
--- a/simple/src/test/java/org/odftoolkit/simple/TextTemplateTest.java
+++ b/simple/src/test/java/org/odftoolkit/simple/TextTemplateTest.java
@@ -1,141 +1,142 @@
-/*
- * 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.simple;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test class for template aspects of calc documents.
- *
- * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
- */
-public class TextTemplateTest {
-
- private static final String TEST_TEXT_TEMPLATE = "/textTestTemplate.ott";
-
- @Test
- public void testLoadingATextTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_TEXT_TEMPLATE));
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
- document.getMediaTypeString());
- }
-
- @Test
- public void testSavingATextTemplate() throws Exception {
- Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_TEXT_TEMPLATE));
- File destination = File.createTempFile("simple-test", ".ott");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- }
-
- @Test
- public void testNewTextTemplate() throws Exception {
- Document document = TextDocument.newTextTemplateDocument();
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
- document.getMediaTypeString());
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("simple-test", ".ott");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof TextDocument);
- }
-
- @Test
- public void testNewTextMaster() throws Exception {
- Document document = TextDocument.newTextMasterDocument();
- Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
- document.getMediaTypeString());
- Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("simple-test", ".ott");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof TextDocument);
- }
-
- @Test
- public void testNewTextWeb() throws Exception {
- Document document = TextDocument.newTextWebDocument();
- Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(),
- document.getMediaTypeString());
- Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(),
- document.getPackage().getMediaTypeString());
- File destination = File.createTempFile("simple-test", ".ott");
- document.save(destination);
-
- // load again
- Document loadedDocument = Document.loadDocument(destination);
- Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(),
- loadedDocument.getMediaTypeString());
- Assert.assertTrue(document instanceof TextDocument);
- }
-
- @Test
- public void testSwitchingOdfTextDocument() throws Exception {
- TextDocument document = TextDocument.newTextDocument();
- document.changeMode(TextDocument.OdfMediaType.TEXT_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_WEB);
- Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_MASTER);
- Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- document = TextDocument.newTextTemplateDocument();
- document.changeMode(TextDocument.OdfMediaType.TEXT);
- Assert.assertEquals(Document.OdfMediaType.TEXT.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_MASTER);
- Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_WEB);
- Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- document = TextDocument.newTextMasterDocument();
- document.changeMode(TextDocument.OdfMediaType.TEXT);
- Assert.assertEquals(Document.OdfMediaType.TEXT.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_WEB);
- Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(), document.getPackage().getMediaTypeString());
-
- document = TextDocument.newTextWebDocument();
- document.changeMode(TextDocument.OdfMediaType.TEXT);
- Assert.assertEquals(Document.OdfMediaType.TEXT.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_TEMPLATE);
- Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
- document.changeMode(TextDocument.OdfMediaType.TEXT_MASTER);
- Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(), document.getPackage().getMediaTypeString());
- }
-}
+/*
+ * 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.simple;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.odftoolkit.simple.utils.ResourceUtilities;
+
+/**
+ * Test class for template aspects of calc documents.
+ *
+ * @author <a href="mailto:fhopf@odftoolkit.org">Florian Hopf</a>
+ */
+public class TextTemplateTest {
+
+ private static final String TEST_TEXT_TEMPLATE = "/textTestTemplate.ott";
+
+ @Test
+ public void testLoadingATextTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_TEXT_TEMPLATE));
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
+ document.getMediaTypeString());
+ }
+
+ @Test
+ public void testSavingATextTemplate() throws Exception {
+ Document document = Document.loadDocument(this.getClass().getResourceAsStream(TEST_TEXT_TEMPLATE));
+ File destination = File.createTempFile("simple-test", ".ott", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ }
+
+ @Test
+ public void testNewTextTemplate() throws Exception {
+ Document document = TextDocument.newTextTemplateDocument();
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
+ document.getMediaTypeString());
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ File destination = File.createTempFile("simple-test", ".ott", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof TextDocument);
+ }
+
+ @Test
+ public void testNewTextMaster() throws Exception {
+ Document document = TextDocument.newTextMasterDocument();
+ Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
+ document.getMediaTypeString());
+ Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ File destination = File.createTempFile("simple-test", ".ott", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof TextDocument);
+ }
+
+ @Test
+ public void testNewTextWeb() throws Exception {
+ Document document = TextDocument.newTextWebDocument();
+ Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(),
+ document.getMediaTypeString());
+ Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(),
+ document.getPackage().getMediaTypeString());
+ File destination = File.createTempFile("simple-test", ".ott", ResourceUtilities.getTempTestDirectory());
+ document.save(destination);
+
+ // load again
+ Document loadedDocument = Document.loadDocument(destination);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(),
+ loadedDocument.getMediaTypeString());
+ Assert.assertTrue(document instanceof TextDocument);
+ }
+
+ @Test
+ public void testSwitchingOdfTextDocument() throws Exception {
+ TextDocument document = TextDocument.newTextDocument();
+ document.changeMode(TextDocument.OdfMediaType.TEXT_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_WEB);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_MASTER);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ document = TextDocument.newTextTemplateDocument();
+ document.changeMode(TextDocument.OdfMediaType.TEXT);
+ Assert.assertEquals(Document.OdfMediaType.TEXT.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_MASTER);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_WEB);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ document = TextDocument.newTextMasterDocument();
+ document.changeMode(TextDocument.OdfMediaType.TEXT);
+ Assert.assertEquals(Document.OdfMediaType.TEXT.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_WEB);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_WEB.getMediaTypeString(), document.getPackage().getMediaTypeString());
+
+ document = TextDocument.newTextWebDocument();
+ document.changeMode(TextDocument.OdfMediaType.TEXT);
+ Assert.assertEquals(Document.OdfMediaType.TEXT.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_TEMPLATE);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ document.changeMode(TextDocument.OdfMediaType.TEXT_MASTER);
+ Assert.assertEquals(Document.OdfMediaType.TEXT_MASTER.getMediaTypeString(), document.getPackage().getMediaTypeString());
+ }
+}
diff --git a/simple/src/test/java/org/odftoolkit/simple/meta/OfficeMetaTest.java b/simple/src/test/java/org/odftoolkit/simple/meta/OfficeMetaTest.java
index 593c29c..2f4d83a 100644
--- a/simple/src/test/java/org/odftoolkit/simple/meta/OfficeMetaTest.java
+++ b/simple/src/test/java/org/odftoolkit/simple/meta/OfficeMetaTest.java
@@ -1,4 +1,4 @@
-/*
+/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
@@ -20,15 +20,11 @@
package org.odftoolkit.simple.meta;
import java.io.File;
-import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
-
import junit.framework.Assert;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.odftoolkit.odfdom.dom.attribute.meta.MetaValueTypeAttribute.Value;
@@ -224,7 +220,7 @@
fMetadata.setUserDefinedData(names.get(2), Value.BOOLEAN.toString(),
"false");
writeAndReload();
-
+
// test get
Assert.assertEquals(names, fMetadata.getUserDefinedDataNames());
Assert.assertEquals(Value.STRING.toString(), fMetadata.getUserDefinedDataType(names.get(0)));
@@ -269,7 +265,7 @@
Assert.assertNull(fMetadata.getPrintDate());
Assert.assertNotNull(fMetadata.getUserDefinedDataNames());
}
-
+
@Test
public void testReadDocumentMeta() throws Exception {
// create a new empty document
@@ -288,9 +284,9 @@
Assert.assertNotNull(meta.getLanguage());
textDoc.close();
}
-
+
private void writeAndReload() throws Exception {
- File persistedDocument = File.createTempFile(getClass().getName(), ".odt");
+ File persistedDocument = File.createTempFile(getClass().getName(), ".odt", ResourceUtilities.getTempTestDirectory());
persistedDocument.deleteOnExit();
doc.save(persistedDocument);
Thread.sleep(100);
@@ -298,5 +294,5 @@
metadom = doc.getMetaDom();
fMetadata = new Meta(metadom);
}
-
+
}
diff --git a/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java b/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java
index 56a8ea1..741793f 100644
--- a/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java
+++ b/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java
@@ -31,6 +31,7 @@
import java.util.logging.Logger;
import org.odftoolkit.odfdom.pkg.rdfa.Util;
+
/** Test utility class providing resources for the test in- and output */
public final class ResourceUtilities {
private ResourceUtilities() {
@@ -39,7 +40,7 @@
/**
* The relative path of the test file will be resolved and the absolute will
* be returned
- *
+ *
* @param relativeFilePath
* Path of the test resource relative to
* <code>src/test/resource/</code>.
@@ -64,7 +65,7 @@
/**
* The relative path of the test file will be resolved and the absolute will
* be returned
- *
+ *
* @param relativeFilePath
* Path of the test resource relative to
* <code>src/test/resource/</code>.
@@ -81,7 +82,7 @@
/**
* The relative path of the test file will be used to determine an absolute
* path to a temporary directory in the output directory.
- *
+ *
* @param relativeFilePath
* Path of the test resource relative to
* <code>src/test/resource/</code>.
@@ -96,7 +97,7 @@
/**
* The Input of the test file will be resolved and the absolute will be
* returned
- *
+ *
* @param relativeFilePath
* Path of the test resource relative to
* <code>src/test/resource/</code>.
@@ -109,7 +110,7 @@
/**
* Relative to the test output directory a test file will be returned
* dependent on the relativeFilePath provided.
- *
+ *
* @param relativeFilePath
* Path of the test output resource relative to
* <code>target/test-classes/</code>.
@@ -138,4 +139,10 @@
}
return testFolder;
}
+
+ public static File getTempTestDirectory() {
+ File tempDir = new File(ResourceUtilities.getTestOutputFolder() +"temp");
+ tempDir.mkdir(); //if it already exist no problem
+ return tempDir;
+ }
}