Permalink
Browse files

#ODFTOOLKIT-453# Temporary test files moved into build directory. Pat…

…ched by Ian Cunningham

git-svn-id: https://svn.apache.org/repos/asf/incubator/odf/trunk@1795827 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 99d5b03 commit cad87604d3dfbd7a871ea001b21fe32fdc577edc @svanteschubert svanteschubert committed May 22, 2017
@@ -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 @@ public void testLoadingAChartTemplate() throws Exception {
@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 @@ public void testNewChartTemplate() throws Exception {
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
@@ -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 @@ public void testLoadingAGraphicsTemplate() throws Exception {
@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 @@ public void testNewGraphicsTemplate() throws Exception {
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
@@ -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 @@ public void testLoadingAPresentationTemplate() throws Exception {
@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 @@ public void testNewPresentationTemplate() throws Exception {
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
@@ -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 @@ public void testLoadingASpreadsheetTemplate() throws Exception {
@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 @@ public void testNewSpreadsheetTemplate() throws Exception {
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
@@ -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 @@ public void testLoadingATextTemplate() throws Exception {
@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 @@ public void testNewTextTemplate() throws Exception {
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 @@ public void testNewTextMaster() throws Exception {
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 @@ public void testNewTextWeb() throws Exception {
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
@@ -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 String getAbsolutePath(String relativeFilePath) throws FileNotFoun
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 @@ public static File newTestOutputFile(String relativeFilePath) {
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 @@ public static String getTestOutputFolder() {
} 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;
}
}
Oops, something went wrong.

0 comments on commit cad8760

Please sign in to comment.