diff options
| author | Robert Gemmell <robbie@apache.org> | 2012-10-12 11:44:13 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2012-10-12 11:44:13 +0000 |
| commit | 65cba5397294ddd5349bdb9837c4a10d91f2ca0b (patch) | |
| tree | 5ac98649e42a8d48ca46e94cae1120dde99044dc /qpid/java/common/src/test | |
| parent | a0b7800e8d8554f76dcd8715768b08b6e8b9c507 (diff) | |
| download | qpid-python-65cba5397294ddd5349bdb9837c4a10d91f2ca0b.tar.gz | |
QPID-4335, QPID-4353: Refactored broker plugins to use simplified ServiceLoader-based model rather than embedding Felix to use OSGi.
Removed the ability to reload security configuration because this feature is not very useful in
its current form and was making our code hard to refactor.
Modified all tests to use jars rather than classes. This makes them closer to real-world deployments, e.g. the META-INF/services
file is read from within the jar.
Also moved various system tests from their respective modules into "systests". This removes the need for most modules to depend
on systests, thus simplifying our dependency graph.
Applied patch from myself, Keith Wall and Phil Harvey <phil@philharveyonline.com>
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1397519 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common/src/test')
| -rw-r--r-- | qpid/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java index 056d11faaa..d77049c780 100644 --- a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java +++ b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java @@ -21,6 +21,10 @@ package org.apache.qpid.test.utils; import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import junit.framework.TestCase; import org.apache.qpid.util.FileUtils; @@ -30,6 +34,7 @@ import org.apache.qpid.util.FileUtils; public class TestFileUtils { private static final String SYSTEM_TMP_DIR = System.getProperty("java.io.tmpdir"); + private static final String SUFFIX = "tmp"; /** * Create and return a temporary directory that will be deleted on exit. @@ -60,4 +65,49 @@ public class TestFileUtils return testDir; } + + public static File createTempFile(TestCase testcase) + { + return createTempFile(testcase, SUFFIX); + } + + public static File createTempFile(TestCase testcase, String suffix) + { + String prefix = testcase.getClass().getSimpleName() + "-" + testcase.getName(); + + File tmpFile; + try + { + tmpFile = File.createTempFile(prefix, suffix); + tmpFile.deleteOnExit(); + } + catch (IOException e) + { + throw new RuntimeException("Cannot create temporary file with prefix " + prefix + " and suffix " + SUFFIX, e); + } + + return tmpFile; + } + + /** + * Creates a temporary file from the resource name given, using the resource name as the file suffix. + * + * This is required because the tests use the jar files as their class path. + */ + public static File createTempFileFromResource(TestCase testCase, String resourceName) + { + File dst = createTempFile(testCase, resourceName); + InputStream in = testCase.getClass().getResourceAsStream(resourceName); + try + { + FileUtils.copy(in, dst); + } + catch (Exception e) + { + throw new RuntimeException("Cannot copy resource " + resourceName + + " to temp file " + dst.getAbsolutePath(), e); + } + dst.deleteOnExit(); + return dst; + } } |
