From 2a8259fd873ef0d5000cfe4bb2e3f513b61510fc Mon Sep 17 00:00:00 2001 From: Kirk Lund Date: Thu, 2 May 2019 11:00:10 -0700 Subject: [PATCH] GEODE-6731: Make TestUtil delegate to ResourceUtils * Make TestUtil delegate to ResourceUtils. * Add deprecation annotations and javadocs. * Use static import for all uses of ResourceUtils. --- .../geode/session/tests/ContainerInstall.java | 4 +- ...eConfigAreFullyRedactedAcceptanceTest.java | 71 +++---- ...radleBuildWithGeodeCoreAcceptanceTest.java | 7 +- ...loneClientManagementAPIAcceptanceTest.java | 10 +- .../web/RestFunctionExecuteDUnitTest.java | 8 +- .../controllers/RestAPIsWithSSLDUnitTest.java | 17 +- .../AssemblyContentsIntegrationTest.java | 5 +- .../apache/geode/BundledJarsJUnitTest.java | 5 +- .../GeodeDependencyJarIntegrationTest.java | 6 +- .../internal/web/RestSecurityWithSSLTest.java | 5 +- .../tools/pulse/PulseSecurityWithSSLTest.java | 6 +- .../cli/CreateMappingCommandDUnitTest.java | 5 +- .../geode/ClusterCommunicationsDUnitTest.java | 11 +- .../CacheServerSSLConnectionDUnitTest.java | 20 +- .../internal/SSLNoClientAuthDUnitTest.java | 18 +- ...ionedRegionCompactRangeIndexDUnitTest.java | 5 +- .../query/partitioned/PRQueryDUnitHelper.java | 6 +- .../geode/cache30/CacheXml66DUnitTest.java | 14 +- .../ReconnectWithCacheXMLDUnitTest.java | 6 +- .../geode/distributed/LocatorDUnitTest.java | 10 +- ...itionedRegionCacheXMLExampleDUnitTest.java | 5 +- .../cache/StartServerWithXmlDUnitTest.java | 7 +- .../jta/dunit/ExceptionsDUnitTest.java | 8 +- .../jta/dunit/IdleTimeOutDUnitTest.java | 7 +- .../jta/dunit/LoginTimeOutDUnitTest.java | 7 +- .../jta/dunit/MaxPoolSizeDUnitTest.java | 7 +- .../dunit/TransactionTimeOutDUnitTest.java | 6 +- .../dunit/TxnManagerMultiThreadDUnitTest.java | 6 +- .../jta/dunit/TxnTimeOutDUnitTest.java | 6 +- .../internal/tcp/TCPConduitDUnitTest.java | 9 +- .../geode/management/JMXMBeanDUnitTest.java | 16 +- ...yCommandFunctionRegistrationDUnitTest.java | 5 +- ...igServerRestartWithJarDeployDUnitTest.java | 6 +- ...onPersistenceServiceUsingDirDUnitTest.java | 7 +- .../DeployJarWithSSLDUnitTest.java | 6 +- .../pdx/JSONPdxClientServerDUnitTest.java | 4 +- .../client/internal/LocatorSSLJUnitTest.java | 5 +- .../DeclarativeIndexCreationJUnitTest.java | 6 +- .../tcpserver/TCPServerSSLJUnitTest.java | 8 +- .../cache/DiskRegCacheXmlJUnitTest.java | 6 +- ...kRegionIllegalCacheXMLvaluesJUnitTest.java | 5 +- .../sockets/RedundancyLevelJUnitTest.java | 6 +- .../AsyncEventQueueValidationsJUnitTest.java | 8 +- .../AbstractPoolCacheJUnitTest.java | 6 +- .../internal/datasource/CleanUpJUnitTest.java | 7 +- .../ConnectionPoolCacheImplJUnitTest.java | 5 +- .../ConnectionPoolingJUnitTest.java | 6 +- .../DataSourceFactoryJUnitTest.java | 6 +- .../internal/datasource/RestartJUnitTest.java | 7 +- .../jta/BlockingTimeOutJUnitTest.java | 6 +- .../internal/jta/DataSourceJTAJUnitTest.java | 18 +- .../jta/GlobalTransactionJUnitTest.java | 6 +- .../jta/TransactionTimeOutJUnitTest.java | 5 +- ...tatArchiveWriterReaderIntegrationTest.java | 12 +- .../HTTPServiceSSLSupportJUnitTest.java | 5 +- .../deployment/FunctionScannerTest.java | 5 +- .../execute/FunctionAdapterJUnitTest.java | 7 +- .../net/SocketCreatorFactoryJUnitTest.java | 18 +- .../internal/net/SocketCreatorJUnitTest.java | 4 +- .../internal/util/PluckStacksUnitTest.java | 6 +- .../LdapUserCredentialGenerator.java | 22 +- .../generator/PKCSCredentialGenerator.java | 21 +- .../XmlAuthzCredentialGenerator.java | 9 +- .../geode/experimental/driver/SSLTest.java | 21 +- .../apache/geode/internal/jta/CacheUtils.java | 6 +- .../apache/geode/test/util/ResourceUtils.java | 198 ++++++++++++++++-- .../org/apache/geode/util/test/TestUtil.java | 81 ------- .../util/ResourceUtilsIntegrationTest.java | 5 +- .../geode/test/util/ResourceUtilsTest.java | 4 +- .../lucene/LuceneIndexCreationDUnitTest.java | 6 +- ...eneIndexXmlParserIntegrationJUnitTest.java | 6 +- .../CacheConnectionIntegrationTest.java | 15 +- .../acceptance/CacheOperationsJUnitTest.java | 18 +- .../geode/internal/cache/wan/WANTestBase.java | 18 +- ...eceiverXmlParsingValidationsJUnitTest.java | 14 +- .../commands/ConnectCommandWithSSLTest.java | 6 +- 76 files changed, 595 insertions(+), 379 deletions(-) delete mode 100644 geode-junit/src/main/java/org/apache/geode/util/test/TestUtil.java diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/ContainerInstall.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/ContainerInstall.java index c064aebc7774..09d8e952e6e5 100644 --- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/ContainerInstall.java +++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/ContainerInstall.java @@ -14,6 +14,7 @@ */ package org.apache.geode.session.tests; +import static org.apache.geode.test.util.ResourceUtils.getResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -47,7 +48,6 @@ import org.apache.geode.internal.logging.LogService; import org.apache.geode.management.internal.configuration.utils.ZipUtils; -import org.apache.geode.util.test.TestUtil; /** * Base class for handling downloading and configuring J2EE containers. @@ -145,7 +145,7 @@ public ContainerInstall(String name, String downloadURL, ConnectionType connType clearPreviousInstall(installDir); - String resource = TestUtil.getResourcePath(getClass(), "/" + downloadURL); + String resource = getResource(getClass(), "/" + downloadURL).getPath(); URL url = Paths.get(resource).toUri().toURL(); logger.info("Installing container from URL " + url); diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/LogsAndDescribeConfigAreFullyRedactedAcceptanceTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/LogsAndDescribeConfigAreFullyRedactedAcceptanceTest.java index 82ab96979287..1c0cc17751b5 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/LogsAndDescribeConfigAreFullyRedactedAcceptanceTest.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/LogsAndDescribeConfigAreFullyRedactedAcceptanceTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER; +import static org.apache.geode.test.util.ResourceUtils.getResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -36,22 +37,23 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder; import org.apache.geode.test.junit.categories.LoggingTest; import org.apache.geode.test.junit.categories.SecurityTest; +import org.apache.geode.test.junit.rules.RequiresGeodeHome; import org.apache.geode.test.junit.rules.gfsh.GfshExecution; import org.apache.geode.test.junit.rules.gfsh.GfshRule; -import org.apache.geode.util.test.TestUtil; /** * This test class expects a "security.json" file to be visible on the member classpath. The - * security.json is consumed by {@link org.apache.geode.examples.security.ExampleSecurityManager} - * and should contain each username/password combination present (even though not all will actually - * be consumed by the Security Manager). + * security.json is consumed by {@link ExampleSecurityManager} and should contain each + * username/password combination present (even though not all will actually be consumed by the + * Security Manager). * + *

* Each password shares the string below for easier log scanning. */ @Category({SecurityTest.class, LoggingTest.class}) public class LogsAndDescribeConfigAreFullyRedactedAcceptanceTest { - private static String sharedPasswordString = "abcdefg"; + private static final String sharedPasswordString = "abcdefg"; private File propertyFile; private File securityPropertyFile; @@ -59,6 +61,9 @@ public class LogsAndDescribeConfigAreFullyRedactedAcceptanceTest { @Rule public GfshRule gfsh = new GfshRule(); + @Rule + public RequiresGeodeHome geodeHome = new RequiresGeodeHome(); + @Before public void createDirectoriesAndFiles() throws Exception { propertyFile = gfsh.getTemporaryFolder().newFile("geode.properties"); @@ -85,36 +90,32 @@ public void createDirectoriesAndFiles() throws Exception { startSecureLocatorAndServer(); } - private void startSecureLocatorAndServer() throws Exception { - try { - // The json is in the root resource directory. - String securityJson = TestUtil.getResourcePath( - LogsAndDescribeConfigAreFullyRedactedAcceptanceTest.class, "/security.json"); - // We want to add the folder to the classpath, so we strip off the filename. - securityJson = securityJson.substring(0, securityJson.length() - "security.json".length()); - String startLocatorCmd = - new CommandStringBuilder("start locator").addOption("name", "test-locator") - .addOption("properties-file", propertyFile.getAbsolutePath()) - .addOption("security-properties-file", securityPropertyFile.getAbsolutePath()) - .addOption("J", "-Dsecure-username-jd=user-jd") - .addOption("J", "-Dsecure-password-jd=password-jd") - .addOption("classpath", securityJson).getCommandString(); - - String startServerCmd = new CommandStringBuilder("start server") - .addOption("name", "test-server").addOption("user", "viaStartMemberOptions") - .addOption("password", sharedPasswordString + "-viaStartMemberOptions") - .addOption("properties-file", propertyFile.getAbsolutePath()) - .addOption("security-properties-file", securityPropertyFile.getAbsolutePath()) - .addOption("J", "-Dsecure-username-jd=user-jd") - .addOption("J", "-Dsecure-password-jd=" + sharedPasswordString + "-password-jd") - .addOption("server-port", "0") - .addOption("classpath", securityJson).getCommandString(); - - gfsh.execute(startLocatorCmd, startServerCmd); - } catch (Exception e) { - throw new Exception( - "Cluster could not start, failing beyond the intended scope of this test.", e); - } + private void startSecureLocatorAndServer() { + // The json is in the root resource directory. + String securityJson = + getResource(LogsAndDescribeConfigAreFullyRedactedAcceptanceTest.class, + "/security.json").getPath(); + // We want to add the folder to the classpath, so we strip off the filename. + securityJson = securityJson.substring(0, securityJson.length() - "security.json".length()); + String startLocatorCmd = + new CommandStringBuilder("start locator").addOption("name", "test-locator") + .addOption("properties-file", propertyFile.getAbsolutePath()) + .addOption("security-properties-file", securityPropertyFile.getAbsolutePath()) + .addOption("J", "-Dsecure-username-jd=user-jd") + .addOption("J", "-Dsecure-password-jd=password-jd") + .addOption("classpath", securityJson).getCommandString(); + + String startServerCmd = new CommandStringBuilder("start server") + .addOption("name", "test-server").addOption("user", "viaStartMemberOptions") + .addOption("password", sharedPasswordString + "-viaStartMemberOptions") + .addOption("properties-file", propertyFile.getAbsolutePath()) + .addOption("security-properties-file", securityPropertyFile.getAbsolutePath()) + .addOption("J", "-Dsecure-username-jd=user-jd") + .addOption("J", "-Dsecure-password-jd=" + sharedPasswordString + "-password-jd") + .addOption("server-port", "0") + .addOption("classpath", securityJson).getCommandString(); + + gfsh.execute(startLocatorCmd, startServerCmd); } @Test diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/GradleBuildWithGeodeCoreAcceptanceTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/GradleBuildWithGeodeCoreAcceptanceTest.java index 2013584c7145..014ac84fadf4 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/GradleBuildWithGeodeCoreAcceptanceTest.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/GradleBuildWithGeodeCoreAcceptanceTest.java @@ -15,6 +15,8 @@ package org.apache.geode.management.internal.rest; +import static org.apache.geode.test.util.ResourceUtils.copyDirectoryResource; +import static org.apache.geode.test.util.ResourceUtils.getResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -29,7 +31,6 @@ import org.apache.geode.internal.GemFireVersion; import org.apache.geode.test.junit.rules.RequiresGeodeHome; -import org.apache.geode.test.util.ResourceUtils; public class GradleBuildWithGeodeCoreAcceptanceTest { @@ -41,7 +42,7 @@ public class GradleBuildWithGeodeCoreAcceptanceTest { @Test public void testBasicGradleBuild() throws Exception { - URL projectDir = ResourceUtils.getResource("/gradle-test-projects/management"); + URL projectDir = getResource("/gradle-test-projects/management"); assertThat(projectDir).isNotNull(); String projectGroup = System.getProperty("projectGroup"); @@ -51,7 +52,7 @@ public void testBasicGradleBuild() throws Exception { String geodeVersion = GemFireVersion.getGemFireVersion(); File buildDir = temp.getRoot(); - ResourceUtils.copyDirectoryResource(projectDir, buildDir); + copyDirectoryResource(projectDir, buildDir); GradleConnector connector = GradleConnector.newConnector(); connector.useBuildDistribution(); diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java index ddd8e9be3b4c..9832c589764f 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java @@ -15,6 +15,7 @@ package org.apache.geode.management.internal.rest; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -45,7 +46,6 @@ import org.apache.geode.test.junit.rules.gfsh.GfshScript; import org.apache.geode.test.junit.rules.gfsh.internal.ProcessLogger; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; -import org.apache.geode.util.test.TestUtil; @RunWith(Parameterized.class) @UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class) @@ -75,8 +75,9 @@ public static void beforeClass() { * -keystore trusted.keystore -keypass password -storepass password \ * -ext san=ip:127.0.0.1,dns:localhost -storetype jks */ - trustStorePath = TestUtil.getResourcePath(StandaloneClientManagementAPIAcceptanceTest.class, - "/ssl/trusted.keystore"); + trustStorePath = + createTempFileFromResource(StandaloneClientManagementAPIAcceptanceTest.class, + "/ssl/trusted.keystore").getAbsolutePath(); assertThat(trustStorePath).as("java file resource not found").isNotBlank(); } @@ -85,7 +86,8 @@ public static void beforeClass() { public void clientCreatesRegionUsingClusterManagementService() throws Exception { JarBuilder jarBuilder = new JarBuilder(); String filePath = - TestUtil.getResourcePath(this.getClass(), "/ManagementClientCreateRegion.java"); + createTempFileFromResource(this.getClass(), "/ManagementClientCreateRegion.java") + .getAbsolutePath(); assertThat(filePath).as("java file resource not found").isNotBlank(); File outputJar = new File(tempDir.getRoot(), "output.jar"); diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/RestFunctionExecuteDUnitTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/RestFunctionExecuteDUnitTest.java index 0541f2247e8d..1197785838c2 100644 --- a/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/RestFunctionExecuteDUnitTest.java +++ b/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/RestFunctionExecuteDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.test.junit.rules.HttpResponseAssert.assertResponse; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -36,7 +37,6 @@ import org.apache.geode.test.junit.categories.RestAPITest; import org.apache.geode.test.junit.rules.GeodeDevRestClient; import org.apache.geode.test.junit.rules.GfshCommandRule; -import org.apache.geode.util.test.TestUtil; @Category({RestAPITest.class}) public class RestFunctionExecuteDUnitTest { @@ -110,8 +110,10 @@ public void connectToServer2() throws Exception { // find ImplementsFunction.java in the geode-core resource private static File loadClassToFile() { - String resourcePath = TestUtil.getResourcePath(Function.class.getClassLoader(), - "org/apache/geode/management/internal/deployment/ImplementsFunction.java"); + String resourcePath = + createTempFileFromResource(Function.class.getClassLoader(), + "org/apache/geode/management/internal/deployment/ImplementsFunction.java") + .getAbsolutePath(); assertThat(resourcePath).isNotNull(); return new File(resourcePath); diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java index e876f6c2ae6a..2715ce033a1d 100644 --- a/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java +++ b/geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java @@ -34,6 +34,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.distributed.ConfigurationProperties.SSL_WEB_ALIAS; import static org.apache.geode.distributed.ConfigurationProperties.SSL_WEB_SERVICE_REQUIRE_AUTHENTICATION; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; @@ -77,7 +78,6 @@ import org.apache.geode.test.dunit.rules.ClusterStartupRule; import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.categories.RestAPITest; -import org.apache.geode.util.test.TestUtil; /** * @since GemFire 8.0 @@ -99,7 +99,8 @@ public class RestAPIsWithSSLDUnitTest { private static File findTrustedJKSWithSingleEntry() { return new File( - TestUtil.getResourcePath(RestAPIsWithSSLDUnitTest.class, "/ssl/trusted.keystore")); + createTempFileFromResource(RestAPIsWithSSLDUnitTest.class, "/ssl/trusted.keystore") + .getAbsolutePath()); } private static File findTrustStore(Properties props) { @@ -249,9 +250,11 @@ public void testSimpleSSLWithMultiKey_KeyStore() throws Exception { Properties props = new Properties(); props.setProperty(SSL_KEYSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks")); + createTempFileFromResource(getClass(), "/org/apache/geode/internal/net/multiKey.jks") + .getAbsolutePath()); props.setProperty(SSL_TRUSTSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKeyTrust.jks")); + createTempFileFromResource(getClass(), + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath()); props.setProperty(SSL_KEYSTORE_PASSWORD, "password"); props.setProperty(SSL_TRUSTSTORE_PASSWORD, "password"); props.setProperty(SSL_KEYSTORE_TYPE, "JKS"); @@ -267,9 +270,11 @@ public void testSimpleSSLWithMultiKey_KeyStore_WithInvalidClientKey() throws Exc Properties props = new Properties(); props.setProperty(SSL_KEYSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks")); + createTempFileFromResource(getClass(), "/org/apache/geode/internal/net/multiKey.jks") + .getAbsolutePath()); props.setProperty(SSL_TRUSTSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKeyTrust.jks")); + createTempFileFromResource(getClass(), + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath()); props.setProperty(SSL_KEYSTORE_PASSWORD, "password"); props.setProperty(SSL_TRUSTSTORE_PASSWORD, "password"); props.setProperty(SSL_KEYSTORE_TYPE, "JKS"); diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java index 4d744811a9e8..5ae9486326c6 100644 --- a/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java +++ b/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -31,7 +32,6 @@ import org.junit.experimental.categories.Category; import org.apache.geode.test.junit.categories.RestAPITest; -import org.apache.geode.util.test.TestUtil; @Category({RestAPITest.class}) public class AssemblyContentsIntegrationTest { @@ -42,7 +42,8 @@ public class AssemblyContentsIntegrationTest { @Before public void loadExpectedAssemblyContent() throws IOException { String assemblyContent = - TestUtil.getResourcePath(AssemblyContentsIntegrationTest.class, "/assembly_content.txt"); + createTempFileFromResource(AssemblyContentsIntegrationTest.class, + "/assembly_content.txt").getAbsolutePath(); expectedAssemblyContent = Files.lines(Paths.get(assemblyContent)).collect(Collectors.toCollection(TreeSet::new)); diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/BundledJarsJUnitTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/BundledJarsJUnitTest.java index 5f26144b2dfb..bdc8ba4c453b 100644 --- a/geode-assembly/src/integrationTest/java/org/apache/geode/BundledJarsJUnitTest.java +++ b/geode-assembly/src/integrationTest/java/org/apache/geode/BundledJarsJUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertTrue; import java.io.File; @@ -34,7 +35,6 @@ import org.junit.experimental.categories.Category; import org.apache.geode.test.junit.categories.RestAPITest; -import org.apache.geode.util.test.TestUtil; @Category({RestAPITest.class}) public class BundledJarsJUnitTest { @@ -46,7 +46,8 @@ public class BundledJarsJUnitTest { @Before public void loadExpectedJars() throws IOException { String expectedJarFile = - TestUtil.getResourcePath(BundledJarsJUnitTest.class, "/expected_jars.txt"); + createTempFileFromResource(BundledJarsJUnitTest.class, "/expected_jars.txt") + .getAbsolutePath(); expectedJars = Files.lines(Paths.get(expectedJarFile)).collect(Collectors.toSet()); } diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java index 6d7e4c11806a..c5998d140e7f 100644 --- a/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java +++ b/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -31,7 +32,6 @@ import org.junit.experimental.categories.Category; import org.apache.geode.test.junit.categories.RestAPITest; -import org.apache.geode.util.test.TestUtil; @Category({RestAPITest.class}) public class GeodeDependencyJarIntegrationTest { @@ -42,8 +42,8 @@ public class GeodeDependencyJarIntegrationTest { @Before public void loadExpectedClassPath() throws IOException { String dependencyClasspath = - TestUtil.getResourcePath(AssemblyContentsIntegrationTest.class, - "/dependency_classpath.txt"); + createTempFileFromResource(AssemblyContentsIntegrationTest.class, + "/dependency_classpath.txt").getAbsolutePath(); expectedClasspathElements = Files.lines(Paths.get(dependencyClasspath)).collect(Collectors.toList()); diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java index 02dc83abe2a6..0bc239b57f71 100644 --- a/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java +++ b/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java @@ -24,7 +24,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.test.junit.rules.HttpResponseAssert.assertResponse; -import static org.apache.geode.util.test.TestUtil.getResourcePath; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.File; @@ -44,7 +44,8 @@ public class RestSecurityWithSSLTest { private static File KEYSTORE_FILE = - new File(getResourcePath(RestSecurityWithSSLTest.class, "/ssl/trusted.keystore")); + new File(createTempFileFromResource(RestSecurityWithSSLTest.class, "/ssl/trusted.keystore") + .getAbsolutePath()); @Rule public RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome(); diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/tools/pulse/PulseSecurityWithSSLTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/tools/pulse/PulseSecurityWithSSLTest.java index 49aeaa9ddc00..b5caa1f97232 100644 --- a/geode-assembly/src/integrationTest/java/org/apache/geode/tools/pulse/PulseSecurityWithSSLTest.java +++ b/geode-assembly/src/integrationTest/java/org/apache/geode/tools/pulse/PulseSecurityWithSSLTest.java @@ -37,7 +37,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_PROTOCOLS; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; -import static org.apache.geode.util.test.TestUtil.getResourcePath; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -57,12 +57,12 @@ import org.apache.geode.test.junit.rules.GeodeHttpClientRule; import org.apache.geode.test.junit.rules.LocatorStarterRule; - @Category({SecurityTest.class, PulseTest.class}) public class PulseSecurityWithSSLTest { private static File jks = - new File(getResourcePath(PulseSecurityWithSSLTest.class, "/ssl/trusted.keystore")); + new File(createTempFileFromResource(PulseSecurityWithSSLTest.class, "/ssl/trusted.keystore") + .getAbsolutePath()); @Rule public LocatorStarterRule locator = new LocatorStarterRule().withHttpService(); diff --git a/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java b/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java index ffa121e476e9..e04519f627dc 100644 --- a/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java +++ b/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java @@ -25,6 +25,7 @@ import static org.apache.geode.connectors.util.internal.MappingConstants.SCHEMA_NAME; import static org.apache.geode.connectors.util.internal.MappingConstants.SYNCHRONOUS_NAME; import static org.apache.geode.connectors.util.internal.MappingConstants.TABLE_NAME; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -79,7 +80,6 @@ import org.apache.geode.test.junit.rules.GfshCommandRule; import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder; import org.apache.geode.test.junit.rules.serializable.SerializableTestName; -import org.apache.geode.util.test.TestUtil; @Category({JDBCConnectorTest.class}) public class CreateMappingCommandDUnitTest { @@ -571,7 +571,8 @@ private static void assertValidResourcePDXMappingOnLocator(RegionMapping mapping } private File loadTestResource(String fileName) { - String filePath = TestUtil.getResourcePath(this.getClass(), fileName); + String filePath = + createTempFileFromResource(this.getClass(), fileName).getAbsolutePath(); assertThat(filePath).isNotNull(); return new File(filePath); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java index 156874077aa9..3c9d8038afba 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java @@ -31,6 +31,7 @@ import static org.apache.geode.internal.DataSerializableFixedID.SERIAL_ACKED_MESSAGE; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.DataInput; @@ -79,8 +80,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; import org.apache.geode.test.version.VersionManager; -import org.apache.geode.util.test.TestUtil; - /** * This class tests cluster tcp/ip communications both with and without SSL enabled @@ -309,8 +308,12 @@ public Properties getDistributedSystemProperties() { if (useSSL) { properties.put(SSL_ENABLED_COMPONENTS, "cluster,locator"); - properties.put(SSL_KEYSTORE, TestUtil.getResourcePath(this.getClass(), "server.keystore")); - properties.put(SSL_TRUSTSTORE, TestUtil.getResourcePath(this.getClass(), "server.keystore")); + properties.put(SSL_KEYSTORE, + createTempFileFromResource(this.getClass(), "server.keystore") + .getAbsolutePath()); + properties.put(SSL_TRUSTSTORE, + createTempFileFromResource(this.getClass(), "server.keystore") + .getAbsolutePath()); properties.put(SSL_PROTOCOLS, "TLSv1.2"); properties.put(SSL_KEYSTORE_PASSWORD, "password"); properties.put(SSL_TRUSTSTORE_PASSWORD, "password"); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/CacheServerSSLConnectionDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/CacheServerSSLConnectionDUnitTest.java index 986d04ee60c4..4a2d718bb058 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/CacheServerSSLConnectionDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/CacheServerSSLConnectionDUnitTest.java @@ -42,6 +42,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_REQUIRE_AUTHENTICATION; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -89,7 +90,6 @@ import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; import org.apache.geode.test.junit.categories.ClientServerTest; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; -import org.apache.geode.util.test.TestUtil; /** * Tests cacheserver ssl support added. See https://svn.gemstone.com/trac/gemfire/ticket/48995 for @@ -201,9 +201,11 @@ public void setUpServerVM(final boolean cacheServerSslenabled, int optionalLocat String.valueOf(cacheServerSslRequireAuth)); String keyStore = - TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, SERVER_KEY_STORE); + createTempFileFromResource(CacheServerSSLConnectionDUnitTest.class, SERVER_KEY_STORE) + .getAbsolutePath(); String trustStore = - TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, SERVER_TRUST_STORE); + createTempFileFromResource(CacheServerSSLConnectionDUnitTest.class, + SERVER_TRUST_STORE).getAbsolutePath(); gemFireProps.put(CLUSTER_SSL_KEYSTORE_TYPE, "jks"); gemFireProps.put(CLUSTER_SSL_KEYSTORE, keyStore); gemFireProps.put(CLUSTER_SSL_KEYSTORE_PASSWORD, "password"); @@ -230,9 +232,11 @@ private void getNewSSLSettings(Properties gemFireProps, String cacheServerSslpro gemFireProps.put(SSL_REQUIRE_AUTHENTICATION, String.valueOf(cacheServerSslRequireAuth)); String keyStore = - TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, SERVER_KEY_STORE); + createTempFileFromResource(CacheServerSSLConnectionDUnitTest.class, SERVER_KEY_STORE) + .getAbsolutePath(); String trustStore = - TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, SERVER_TRUST_STORE); + createTempFileFromResource(CacheServerSSLConnectionDUnitTest.class, SERVER_TRUST_STORE) + .getAbsolutePath(); gemFireProps.put(SSL_KEYSTORE_TYPE, "jks"); gemFireProps.put(SSL_KEYSTORE, keyStore); gemFireProps.put(SSL_KEYSTORE_PASSWORD, "password"); @@ -251,9 +255,11 @@ public void setUpClientVM(String host, int port, boolean cacheServerSslenabled, String cacheServerSslciphers = "any"; String keyStorePath = - TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, keyStore); + createTempFileFromResource(CacheServerSSLConnectionDUnitTest.class, keyStore) + .getAbsolutePath(); String trustStorePath = - TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, trustStore); + createTempFileFromResource(CacheServerSSLConnectionDUnitTest.class, trustStore) + .getAbsolutePath(); if (cacheServerSslenabled) { if (useOldSSLSettings) { diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/SSLNoClientAuthDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/SSLNoClientAuthDUnitTest.java index c1c39fcade79..6989849087d2 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/SSLNoClientAuthDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/SSLNoClientAuthDUnitTest.java @@ -25,6 +25,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_REQUIRE_AUTHENTICATION; import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_TRUSTSTORE_PASSWORD; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -52,7 +53,6 @@ import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; import org.apache.geode.test.junit.categories.MembershipTest; -import org.apache.geode.util.test.TestUtil; /** * Test for GEODE-396 @@ -118,8 +118,12 @@ public void setUpServerVM(boolean cacheServerSslenabled) throws Exception { gemFireProps.put(SERVER_SSL_CIPHERS, cacheServerSslciphers); gemFireProps.put(SERVER_SSL_REQUIRE_AUTHENTICATION, String.valueOf(cacheServerSslRequireAuth)); - String keyStore = TestUtil.getResourcePath(SSLNoClientAuthDUnitTest.class, DEFAULT_STORE); - String trustStore = TestUtil.getResourcePath(SSLNoClientAuthDUnitTest.class, DEFAULT_STORE); + String keyStore = + createTempFileFromResource(SSLNoClientAuthDUnitTest.class, DEFAULT_STORE) + .getAbsolutePath(); + String trustStore = + createTempFileFromResource(SSLNoClientAuthDUnitTest.class, DEFAULT_STORE) + .getAbsolutePath(); gemFireProps.put(SERVER_SSL_KEYSTORE_TYPE, "jks"); gemFireProps.put(SERVER_SSL_KEYSTORE, keyStore); gemFireProps.put(SERVER_SSL_KEYSTORE_PASSWORD, "password"); @@ -145,8 +149,12 @@ public void setUpClientVM(String host, int port, boolean cacheServerSslenabled, String cacheServerSslprotocols = "any"; String cacheServerSslciphers = "any"; - String keyStorePath = TestUtil.getResourcePath(SSLNoClientAuthDUnitTest.class, keyStore); - String trustStorePath = TestUtil.getResourcePath(SSLNoClientAuthDUnitTest.class, trustStore); + String keyStorePath = + createTempFileFromResource(SSLNoClientAuthDUnitTest.class, keyStore) + .getAbsolutePath(); + String trustStorePath = + createTempFileFromResource(SSLNoClientAuthDUnitTest.class, trustStore) + .getAbsolutePath(); // using new server-ssl-* properties gemFireProps.put(SERVER_SSL_ENABLED, String.valueOf(cacheServerSslenabled)); gemFireProps.put(SERVER_SSL_PROTOCOLS, cacheServerSslprotocols); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PartitionedRegionCompactRangeIndexDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PartitionedRegionCompactRangeIndexDUnitTest.java index c20c8b8c91c0..f0b91d33b250 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PartitionedRegionCompactRangeIndexDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PartitionedRegionCompactRangeIndexDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -43,7 +44,6 @@ import org.apache.geode.test.dunit.rules.ClusterStartupRule; import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.categories.OQLQueryTest; -import org.apache.geode.util.test.TestUtil; @Category({OQLQueryTest.class}) public class PartitionedRegionCompactRangeIndexDUnitTest implements Serializable { @@ -61,7 +61,8 @@ public class PartitionedRegionCompactRangeIndexDUnitTest implements Serializable private Properties getSystemProperties(String cacheXML) { Properties props = new Properties(); props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]"); - props.setProperty(CACHE_XML_FILE, TestUtil.getResourcePath(getClass(), cacheXML)); + props.setProperty(CACHE_XML_FILE, + createTempFileFromResource(getClass(), cacheXML).getAbsolutePath()); return props; } diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java index b23314802ecb..8fa8308deec8 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java @@ -14,6 +14,7 @@ */ package org.apache.geode.cache.query.partitioned; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -79,7 +80,6 @@ import org.apache.geode.test.dunit.SerializableRunnableIF; import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; /** * This is a helper class for the various Partitioned Query DUnit Test Cases @@ -1755,7 +1755,9 @@ public void run2() { public File findFile(String fileName) { - return new File(TestUtil.getResourcePath(PRQueryDUnitHelper.class, fileName)); + return new File( + createTempFileFromResource(PRQueryDUnitHelper.class, fileName) + .getAbsolutePath()); } public CacheSerializableRunnable getCacheSerializableRunnableForIndexCreationCheck( diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java index 29b0e34c0a7d..a85b65dbf124 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.cache30; import static org.apache.geode.distributed.ConfigurationProperties.ROLES; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -138,7 +139,6 @@ import org.apache.geode.test.dunit.NetworkUtils; import org.apache.geode.test.dunit.SerializableCallable; import org.apache.geode.test.dunit.VM; -import org.apache.geode.util.test.TestUtil; /** * Tests 7.0 cache.xml feature : Fixed Partitioning. @@ -4388,18 +4388,18 @@ public boolean accept(File dir, String name) { } else { - File example = new File(TestUtil.getResourcePath(getClass(), - "/org/apache/geode/cache/doc-files/example-cache.xml")); + File example = new File(createTempFileFromResource(getClass(), + "/org/apache/geode/cache/doc-files/example-cache.xml").getAbsolutePath()); FileInputStream fis = new FileInputStream(example); CacheXmlParser.parse(fis); - File example2 = new File(TestUtil.getResourcePath(getClass(), - "/org/apache/geode/cache/doc-files/example2-cache.xml")); + File example2 = new File(createTempFileFromResource(getClass(), + "/org/apache/geode/cache/doc-files/example2-cache.xml").getAbsolutePath()); fis = new FileInputStream(example2); CacheXmlParser.parse(fis); - File example3 = new File(TestUtil.getResourcePath(getClass(), - "/org/apache/geode/cache/doc-files/example3-cache.xml")); + File example3 = new File(createTempFileFromResource(getClass(), + "/org/apache/geode/cache/doc-files/example3-cache.xml").getAbsolutePath()); fis = new FileInputStream(example3); CacheXmlParser.parse(fis); } diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithCacheXMLDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithCacheXMLDUnitTest.java index db50b4406c20..c8fd582f3c80 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithCacheXMLDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithCacheXMLDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.internal.Assert.assertTrue; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import java.util.Properties; @@ -36,7 +37,6 @@ import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase; import org.apache.geode.test.junit.categories.ClientServerTest; import org.apache.geode.test.junit.categories.MembershipTest; -import org.apache.geode.util.test.TestUtil; /** * This test exercises auto-reconnect functionality when there is a cache-server that was started by @@ -71,7 +71,9 @@ public final void preTearDownCacheTestCase() { @Override public Properties getDistributedSystemProperties() { Properties result = super.getDistributedSystemProperties(); - String fileName = TestUtil.getResourcePath(getClass(), "ReconnectWithCacheXMLDUnitTest.xml"); + String fileName = + createTempFileFromResource(getClass(), "ReconnectWithCacheXMLDUnitTest.xml") + .getAbsolutePath(); result.put(ConfigurationProperties.CACHE_XML_FILE, fileName); result.put(ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION, "true"); result.put(ConfigurationProperties.DISABLE_AUTO_RECONNECT, "false"); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java index e07f57211aad..caf04def8169 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java @@ -41,6 +41,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; import static org.apache.geode.internal.logging.LogWriterLevel.ALL; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; @@ -107,7 +108,6 @@ import org.apache.geode.test.dunit.internal.DUnitLauncher; import org.apache.geode.test.dunit.rules.DistributedRule; import org.apache.geode.test.junit.categories.MembershipTest; -import org.apache.geode.util.test.TestUtil; /** * Tests the ability of the {@link Locator} API to start and stop locators running in remote VMs. @@ -1817,15 +1817,17 @@ private void startLocatorWithPortAndProperties(final int port, final Properties } private String getSingleKeyKeystore() { - return TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore"); + return createTempFileFromResource(getClass(), "/ssl/trusted.keystore").getAbsolutePath(); } private String getMultiKeyKeystore() { - return TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks"); + return createTempFileFromResource(getClass(), "/org/apache/geode/internal/net/multiKey.jks") + .getAbsolutePath(); } private String getMultiKeyTruststore() { - return TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKeyTrust.jks"); + return createTempFileFromResource(getClass(), + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath(); } private void startVerifyAndStopLocator(VM loc1, VM loc2, int port1, int port2, diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCacheXMLExampleDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCacheXMLExampleDUnitTest.java index b8db17f7cdda..aed3a0d8e218 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCacheXMLExampleDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCacheXMLExampleDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.test.dunit.Host.getHost; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.util.Properties; @@ -28,7 +29,6 @@ import org.apache.geode.cache.Region; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.cache.CacheTestCase; -import org.apache.geode.util.test.TestUtil; /** * This class tests regions created by xml files @@ -97,7 +97,8 @@ public void testExampleWithSubRegion() { private void createCache(String cacheXmlFileName) { Properties config = new Properties(); - String cacheXmlPath = TestUtil.getResourcePath(getClass(), cacheXmlFileName); + String cacheXmlPath = + createTempFileFromResource(getClass(), cacheXmlFileName).getAbsolutePath(); config.setProperty(CACHE_XML_FILE, cacheXmlPath); getSystem(config); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java index 9c3af80d8af3..ff5a6d8a8ad5 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.util.Properties; @@ -31,8 +32,6 @@ import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.rules.ClusterStartupRule; import org.apache.geode.test.dunit.rules.MemberVM; -import org.apache.geode.util.test.TestUtil; - public class StartServerWithXmlDUnitTest { @@ -49,7 +48,9 @@ public void before() throws Exception { Properties props = new Properties(); String locators = "localhost[" + locator.getPort() + "]"; props.setProperty(LOCATORS, locators); - String cacheXmlPath = TestUtil.getResourcePath(getClass(), "CacheServerWithZeroPort.xml"); + String cacheXmlPath = + createTempFileFromResource(getClass(), "CacheServerWithZeroPort.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, cacheXmlPath); server = cluster.getVM(1); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java index 3a1acb1fc0c5..60cf82878f5c 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.internal.jta.dunit; import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.io.BufferedReader; @@ -40,9 +41,8 @@ import org.apache.geode.test.dunit.LogWriterUtils; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; - +// TODO: this is a broken test that does not run public class ExceptionsDUnitTest extends JUnit4DistributedTestCase { static DistributedSystem ds; @@ -119,7 +119,9 @@ public static void init() throws Exception { int pid = OSProcess.getId(); String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); /** * Return file as string and then modify the string accordingly ** */ - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid); String modified_file_str = modifyFile(file_as_str); FileOutputStream fos = new FileOutputStream(path); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/IdleTimeOutDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/IdleTimeOutDUnitTest.java index 2030d188bf1b..56a12f6e59d0 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/IdleTimeOutDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/IdleTimeOutDUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.internal.jta.dunit; import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -48,8 +49,6 @@ import org.apache.geode.test.dunit.ThreadUtils; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; - public class IdleTimeOutDUnitTest extends JUnit4DistributedTestCase { @@ -132,7 +131,9 @@ public static String init(String className) throws Exception { path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); LogWriterUtils.getLogWriter().fine("PATH " + path); /** * Return file as string and then modify the string accordingly ** */ - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid); String modified_file_str = modifyFile(file_as_str); FileOutputStream fos = new FileOutputStream(path); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/LoginTimeOutDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/LoginTimeOutDUnitTest.java index a2daca2cd2e8..aaa1444e014a 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/LoginTimeOutDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/LoginTimeOutDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.io.BufferedReader; @@ -53,8 +54,6 @@ import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.WaitCriterion; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; - public class LoginTimeOutDUnitTest extends JUnit4DistributedTestCase { private static final Logger logger = LogService.getLogger(); @@ -132,7 +131,9 @@ public static String init(String className) throws Exception { String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); logger.debug("PATH " + path); /** * Return file as string and then modify the string accordingly ** */ - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid); String modified_file_str = modifyFile(file_as_str); FileOutputStream fos = new FileOutputStream(path); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/MaxPoolSizeDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/MaxPoolSizeDUnitTest.java index 9180db9e69e6..e396fe9c5b8b 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/MaxPoolSizeDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/MaxPoolSizeDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.test.dunit.Assert.fail; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -47,8 +48,6 @@ import org.apache.geode.test.dunit.ThreadUtils; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; - public class MaxPoolSizeDUnitTest extends JUnit4DistributedTestCase { @@ -123,7 +122,9 @@ public static String init(String className) throws Exception { String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); LogWriterUtils.getLogWriter().fine("PATH " + path); /** * Return file as string and then modify the string accordingly ** */ - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid); String modified_file_str = modifyFile(file_as_str); FileOutputStream fos = new FileOutputStream(path); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TransactionTimeOutDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TransactionTimeOutDUnitTest.java index eb1d17bf94a4..8ee9c1e1c6f7 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TransactionTimeOutDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TransactionTimeOutDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.test.dunit.Assert.fail; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -49,7 +50,6 @@ import org.apache.geode.test.dunit.ThreadUtils; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; /** * This test tests TransactionTimeOut functionality @@ -65,7 +65,9 @@ public static void init() throws Exception { Properties props = new Properties(); int pid = OSProcess.getId(); String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); String modified_file_str = file_as_str.replaceAll("newDB", "newDB_" + pid); FileOutputStream fos = new FileOutputStream(path); BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos)); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnManagerMultiThreadDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnManagerMultiThreadDUnitTest.java index f38298d3cb7b..237812f6d3c3 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnManagerMultiThreadDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnManagerMultiThreadDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.test.dunit.Assert.fail; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -52,7 +53,6 @@ import org.apache.geode.test.dunit.ThreadUtils; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; /** * This test case is to test the following test scenarios: 1) Behaviour of Transaction Manager in @@ -168,7 +168,9 @@ public static String init(String className) throws Exception { String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); LogWriterUtils.getLogWriter().fine("PATH " + path); /** * Return file as string and then modify the string accordingly ** */ - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid); String modified_file_str = modifyFile(file_as_str); String modified_file_str1 = modifyFile1(modified_file_str); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnTimeOutDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnTimeOutDUnitTest.java index b9a395858928..183349ac0fd0 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnTimeOutDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/TxnTimeOutDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.test.dunit.Assert.fail; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -47,7 +48,6 @@ import org.apache.geode.test.dunit.ThreadUtils; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.util.test.TestUtil; /** * This test sees if the TransactionTimeOut works properly @@ -62,7 +62,9 @@ public static void init() throws Exception { Properties props = new Properties(); int pid = OSProcess.getId(); String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); String modified_file_str = file_as_str.replaceAll("newDB", "newDB_" + pid); FileOutputStream fos = new FileOutputStream(path); BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos)); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java index 4da4a180afd2..9462c72f09fb 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.internal.tcp; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.File; import java.io.IOException; @@ -36,9 +37,6 @@ import org.apache.geode.test.dunit.IgnoredException; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; -import org.apache.geode.util.test.TestUtil; - - @RunWith(Parameterized.class) @Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class) @@ -55,8 +53,9 @@ public static Collection data() { Properties SSL = new Properties(); SSL.putAll(nonSSL); - final String keystorePath = TestUtil.getResourcePath(TCPConduitDUnitTest.class, - "/org/apache/geode/cache/client/internal/default.keystore"); + final String keystorePath = + createTempFileFromResource(TCPConduitDUnitTest.class, + "/org/apache/geode/cache/client/internal/default.keystore").getAbsolutePath(); SSL.setProperty(ConfigurationProperties.SSL_ENABLED_COMPONENTS, "cluster"); SSL.setProperty(ConfigurationProperties.SSL_KEYSTORE, keystorePath); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java index f5b7257175e2..15918e0011e5 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java @@ -34,6 +34,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.test.dunit.VM.getVM; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; @@ -62,7 +63,6 @@ import org.apache.geode.test.dunit.rules.DistributedRule; import org.apache.geode.test.junit.categories.JMXTest; import org.apache.geode.test.junit.rules.MBeanServerConnectionRule; -import org.apache.geode.util.test.TestUtil; /** * All the non-ssl enabled locators need to be in a different VM than the ssl enabled locators in @@ -95,11 +95,15 @@ public class JMXMBeanDUnitTest implements Serializable { @BeforeClass public static void beforeClass() { - singleKeystore = TestUtil.getResourcePath(JMXMBeanDUnitTest.class, "/ssl/trusted.keystore"); - multiKeystore = TestUtil.getResourcePath(JMXMBeanDUnitTest.class, - "/org/apache/geode/internal/net/multiKey.jks"); - multiKeyTruststore = TestUtil.getResourcePath(JMXMBeanDUnitTest.class, - "/org/apache/geode/internal/net/multiKeyTrust.jks"); + singleKeystore = + createTempFileFromResource(JMXMBeanDUnitTest.class, "/ssl/trusted.keystore") + .getAbsolutePath(); + multiKeystore = + createTempFileFromResource(JMXMBeanDUnitTest.class, + "/org/apache/geode/internal/net/multiKey.jks").getAbsolutePath(); + multiKeyTruststore = + createTempFileFromResource(JMXMBeanDUnitTest.class, + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath(); // setting up properties used to set the ssl properties used by the locators legacySSLProperties = new Properties(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java index ee2850232a8a..0d094a62dc80 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.management.internal.cli.commands; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -36,7 +37,6 @@ import org.apache.geode.test.junit.categories.FunctionServiceTest; import org.apache.geode.test.junit.rules.GfshCommandRule; import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder; -import org.apache.geode.util.test.TestUtil; @Category({FunctionServiceTest.class}) public class DeployCommandFunctionRegistrationDUnitTest { @@ -95,7 +95,8 @@ public void deployExtends() throws Exception { } private File loadTestResource(String fileName) throws URISyntaxException { - String filePath = TestUtil.getResourcePath(this.getClass(), fileName); + String filePath = + createTempFileFromResource(this.getClass(), fileName).getAbsolutePath(); assertThat(filePath).isNotNull(); return new File(filePath); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ClusterConfigServerRestartWithJarDeployDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ClusterConfigServerRestartWithJarDeployDUnitTest.java index 1cb7d7f61fb7..75cbf459a671 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ClusterConfigServerRestartWithJarDeployDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ClusterConfigServerRestartWithJarDeployDUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.management.internal.configuration; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -40,7 +41,6 @@ import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.rules.GfshCommandRule; import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder; -import org.apache.geode.util.test.TestUtil; public class ClusterConfigServerRestartWithJarDeployDUnitTest { @@ -87,8 +87,8 @@ public void functionExecutionAfterServerReconnect() throws Exception { private File getFunctionJar() throws IOException { JarBuilder jarBuilder = new JarBuilder(); String filePath = - TestUtil.getResourcePath(this.getClass(), - "/ClusterConfigServerRestartWithJarDeployFunction.java"); + createTempFileFromResource(this.getClass(), + "/ClusterConfigServerRestartWithJarDeployFunction.java").getAbsolutePath(); assertThat(filePath).as("java file resource not found").isNotBlank(); File functionJar = new File(temporaryFolder.newFolder(), "output.jar"); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ConfigurationPersistenceServiceUsingDirDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ConfigurationPersistenceServiceUsingDirDUnitTest.java index 22c450cab073..dfc7e59be2f9 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ConfigurationPersistenceServiceUsingDirDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/ConfigurationPersistenceServiceUsingDirDUnitTest.java @@ -25,6 +25,7 @@ import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.Host.getHost; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -45,7 +46,6 @@ import org.apache.geode.distributed.internal.InternalLocator; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase; -import org.apache.geode.util.test.TestUtil; public class ConfigurationPersistenceServiceUsingDirDUnitTest extends JUnit4CacheTestCase { @@ -256,8 +256,9 @@ public void updateClusterConfigDirWithTwoLocatorsRollingRestartAndRollingServerR private void copyClusterXml(final VM vm, final String clusterXml) { vm.invoke("Copying new cluster.xml from " + clusterXml, () -> { - String clusterXmlPath = TestUtil - .getResourcePath(ConfigurationPersistenceServiceUsingDirDUnitTest.class, clusterXml); + String clusterXmlPath = + createTempFileFromResource(ConfigurationPersistenceServiceUsingDirDUnitTest.class, + clusterXml).getAbsolutePath(); InputStream cacheXml = new FileInputStream(clusterXmlPath); assertNotNull("Could not create InputStream from " + clusterXmlPath, cacheXml); Files.createDirectories(Paths.get("cluster_config", "cluster")); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/DeployJarWithSSLDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/DeployJarWithSSLDUnitTest.java index 6920d4aecaba..10d314ffadd7 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/DeployJarWithSSLDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/configuration/DeployJarWithSSLDUnitTest.java @@ -24,7 +24,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_TYPE; -import static org.apache.geode.util.test.TestUtil.getResourcePath; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.File; import java.io.FileOutputStream; @@ -42,11 +42,11 @@ import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.rules.GfshCommandRule; - public class DeployJarWithSSLDUnitTest { private static File jks = - new File(getResourcePath(DeployJarWithSSLDUnitTest.class, "/ssl/trusted.keystore")); + new File(createTempFileFromResource(DeployJarWithSSLDUnitTest.class, "/ssl/trusted.keystore") + .getAbsolutePath()); @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/pdx/JSONPdxClientServerDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/pdx/JSONPdxClientServerDUnitTest.java index 21a3970574a4..5559e6005f54 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/pdx/JSONPdxClientServerDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/pdx/JSONPdxClientServerDUnitTest.java @@ -50,7 +50,7 @@ import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase; import org.apache.geode.test.junit.categories.RestAPITest; -import org.apache.geode.util.test.TestUtil; +import org.apache.geode.test.util.ResourceUtils; @Category({RestAPITest.class}) public class JSONPdxClientServerDUnitTest extends JUnit4CacheTestCase { @@ -239,7 +239,7 @@ private void validateReceivedJSON(Region region, TestObjectForJSONFormatter actu } String getJSONDir(String file) { - String path = TestUtil.getResourcePath(getClass(), file); + String path = ResourceUtils.getResource(getClass(), file).getPath(); return new File(path).getParent(); } diff --git a/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/LocatorSSLJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/LocatorSSLJUnitTest.java index 18a84f5c96a0..df9c211a3881 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/LocatorSSLJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/LocatorSSLJUnitTest.java @@ -21,6 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_TYPE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.IOException; import java.util.Properties; @@ -32,12 +33,12 @@ import org.apache.geode.distributed.Locator; import org.apache.geode.internal.net.SSLConfigurationFactory; import org.apache.geode.test.junit.categories.ClientServerTest; -import org.apache.geode.util.test.TestUtil; @Category({ClientServerTest.class}) public class LocatorSSLJUnitTest { private final String KEY_STORE = - TestUtil.getResourcePath(LocatorSSLJUnitTest.class, "default.keystore"); + createTempFileFromResource(LocatorSSLJUnitTest.class, "default.keystore") + .getAbsolutePath(); @After public void tearDownTest() { diff --git a/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java index 947766db43fa..1baeed1c2726 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java @@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -39,7 +40,6 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.test.junit.categories.OQLIndexTest; -import org.apache.geode.util.test.TestUtil; @Category({OQLIndexTest.class}) public class DeclarativeIndexCreationJUnitTest { @@ -50,7 +50,9 @@ public class DeclarativeIndexCreationJUnitTest { @Before public void setUp() throws Exception { Properties props = new Properties(); - props.setProperty(CACHE_XML_FILE, TestUtil.getResourcePath(getClass(), "cachequeryindex.xml")); + props.setProperty(CACHE_XML_FILE, + createTempFileFromResource(getClass(), "cachequeryindex.xml") + .getAbsolutePath()); props.setProperty(MCAST_PORT, "0"); ds = DistributedSystem.connect(props); cache = CacheFactory.create(ds); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java index ad0248e8b8fa..f3d841a86498 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java @@ -22,6 +22,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_PROTOCOLS; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.io.IOException; import java.net.InetAddress; @@ -49,7 +50,6 @@ import org.apache.geode.internal.net.SocketCreatorFactory; import org.apache.geode.internal.security.SecurableCommunicationChannel; import org.apache.geode.test.junit.categories.MembershipTest; -import org.apache.geode.util.test.TestUtil; @Category({MembershipTest.class}) public class TCPServerSSLJUnitTest { @@ -110,9 +110,11 @@ private Properties getSSLConfigurationProperties() { sslProperties.setProperty(SSL_ENABLED_COMPONENTS, SecurableCommunicationChannel.LOCATOR.getConstant()); sslProperties.setProperty(SSL_KEYSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks")); + createTempFileFromResource(getClass(), "/org/apache/geode/internal/net/multiKey.jks") + .getAbsolutePath()); sslProperties.setProperty(SSL_TRUSTSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKeyTrust.jks")); + createTempFileFromResource(getClass(), + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath()); sslProperties.setProperty(SSL_KEYSTORE_PASSWORD, "password"); sslProperties.setProperty(SSL_TRUSTSTORE_PASSWORD, "password"); sslProperties.setProperty(SSL_KEYSTORE_TYPE, "JKS"); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegCacheXmlJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegCacheXmlJUnitTest.java index 5afb15860a73..641d61e8d669 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegCacheXmlJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegCacheXmlJUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -36,7 +37,6 @@ import org.apache.geode.cache.Region; import org.apache.geode.cache.RegionAttributes; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; /** * This test is for testing Disk attributes set via xml. @@ -71,7 +71,9 @@ private void mkDirAndConnectDs() { // Connect to the GemFire distributed system Properties props = new Properties(); props.setProperty(NAME, "test"); - String path = TestUtil.getResourcePath(getClass(), "DiskRegCacheXmlJUnitTest.xml"); + String path = + createTempFileFromResource(getClass(), "DiskRegCacheXmlJUnitTest.xml") + .getAbsolutePath(); props.setProperty(MCAST_PORT, "0"); props.setProperty(CACHE_XML_FILE, path); ds = DistributedSystem.connect(props); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java index ea2005e7229b..21d2f24d1dbd 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.io.File; @@ -27,7 +28,6 @@ import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.CacheXmlException; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; /** * This test tests Illegal arguements being passed to create disk regions. The creation of the DWA @@ -44,7 +44,8 @@ public void createRegion(String path) { dir.deleteOnExit(); Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); - props.setProperty(CACHE_XML_FILE, TestUtil.getResourcePath(getClass(), path)); + props.setProperty(CACHE_XML_FILE, + createTempFileFromResource(getClass(), path).getAbsolutePath()); ds = DistributedSystem.connect(props); try { diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelJUnitTest.java index 58714e1a86f2..b5b2ad178726 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelJUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -33,7 +34,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.test.junit.categories.ClientSubscriptionTest; -import org.apache.geode.util.test.TestUtil; /** * Tests the proper intialization of redundancyLevel property. @@ -87,7 +87,9 @@ public void tearDown() throws Exception { */ @Test public void testRedundancyLevelSetThroughXML() { - String path = TestUtil.getResourcePath(getClass(), "RedundancyLevelJUnitTest.xml"); + String path = + createTempFileFromResource(getClass(), "RedundancyLevelJUnitTest.xml") + .getAbsolutePath(); Properties p = new Properties(); p.setProperty(MCAST_PORT, "0"); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java index 9eadeef2650c..381a3a4dc6a8 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventQueueValidationsJUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -40,7 +41,6 @@ import org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException; import org.apache.geode.internal.cache.wan.MyGatewayEventFilter; import org.apache.geode.test.junit.categories.AEQTest; -import org.apache.geode.util.test.TestUtil; @Category({AEQTest.class}) @RunWith(JUnitParamsRunner.class) @@ -90,8 +90,10 @@ public void testConcurrentParallelAsyncEventQueueAttributesOrderPolicyThread() { @Parameters(method = "getCacheXmlFileBaseNames") public void testAsyncEventQueueConfiguredFromXmlUsesFilter(String cacheXmlFileBaseName) { // Create cache with xml - String cacheXmlFileName = TestUtil.getResourcePath(getClass(), - getClass().getSimpleName() + "." + cacheXmlFileBaseName + ".cache.xml"); + String cacheXmlFileName = + createTempFileFromResource(getClass(), + getClass().getSimpleName() + "." + cacheXmlFileBaseName + ".cache.xml") + .getAbsolutePath(); cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create(); // Get region and do puts diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/AbstractPoolCacheJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/AbstractPoolCacheJUnitTest.java index 1110bfa5c8fb..7ead2a601f89 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/AbstractPoolCacheJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/AbstractPoolCacheJUnitTest.java @@ -23,6 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -45,7 +46,6 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; public class AbstractPoolCacheJUnitTest { @@ -59,7 +59,9 @@ public void setUp() throws Exception { props.setProperty(LOG_LEVEL, "info"); props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, ""); - String path = TestUtil.getResourcePath(AbstractPoolCacheJUnitTest.class, "/jta/cachejta.xml"); + String path = + createTempFileFromResource(AbstractPoolCacheJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); cache = CacheFactory.create(ds1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/CleanUpJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/CleanUpJUnitTest.java index 6b7433ed4fc6..3d54b157640e 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/CleanUpJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/CleanUpJUnitTest.java @@ -19,6 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.sql.Connection; @@ -33,8 +34,6 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; - /** * @@ -51,7 +50,9 @@ public class CleanUpJUnitTest { public void setUp() { props = new Properties(); props.setProperty(MCAST_PORT, "0"); - String path = TestUtil.getResourcePath(CleanUpJUnitTest.class, "/jta/cachejta.xml"); + String path = + createTempFileFromResource(CleanUpJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); cache = CacheFactory.create(ds1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolCacheImplJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolCacheImplJUnitTest.java index 0fd5e121c06c..e8fdad22b7f9 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolCacheImplJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolCacheImplJUnitTest.java @@ -21,6 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.sql.Connection; @@ -35,7 +36,6 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; /* * this is a Multithreaded test for datasource connection pool. @@ -53,7 +53,8 @@ public void setUp() { props = new Properties(); props.setProperty(MCAST_PORT, "0"); String path = - TestUtil.getResourcePath(ConnectionPoolCacheImplJUnitTest.class, "/jta/cachejta.xml"); + createTempFileFromResource(ConnectionPoolCacheImplJUnitTest.class, + "/jta/cachejta.xml").getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); cache = CacheFactory.create(ds1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolingJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolingJUnitTest.java index 4c6355ccadb4..b63658a35c86 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolingJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/ConnectionPoolingJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; @@ -41,7 +42,6 @@ import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.internal.logging.LogService; -import org.apache.geode.util.test.TestUtil; public class ConnectionPoolingJUnitTest { private static final Logger logger = LogService.getLogger(); @@ -61,7 +61,9 @@ public void setUp() throws Exception { encounteredException = false; props = new Properties(); props.setProperty(MCAST_PORT, "0"); - String path = TestUtil.getResourcePath(ConnectionPoolingJUnitTest.class, "/jta/cachejta.xml"); + String path = + createTempFileFromResource(ConnectionPoolingJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); cache = CacheFactory.create(ds1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/DataSourceFactoryJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/DataSourceFactoryJUnitTest.java index 067fcf353872..eac946e2f49f 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/DataSourceFactoryJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/DataSourceFactoryJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.sql.Connection; @@ -31,7 +32,6 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; public class DataSourceFactoryJUnitTest { @@ -43,7 +43,9 @@ public class DataSourceFactoryJUnitTest { public void setUp() { props = new Properties(); props.setProperty(MCAST_PORT, "0"); - String path = TestUtil.getResourcePath(DataSourceFactoryJUnitTest.class, "/jta/cachejta.xml"); + String path = + createTempFileFromResource(DataSourceFactoryJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); cache = CacheFactory.create(ds1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/RestartJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/RestartJUnitTest.java index 3dc181013204..1a74be0b4ba6 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/RestartJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/RestartJUnitTest.java @@ -19,6 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.fail; @@ -32,8 +33,6 @@ import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.internal.jndi.JNDIInvoker; -import org.apache.geode.util.test.TestUtil; - /** * @@ -53,7 +52,9 @@ public void testCleanUp() { try { props = new Properties(); props.setProperty(MCAST_PORT, "0"); - String path = TestUtil.getResourcePath(RestartJUnitTest.class, "/jta/cachejta.xml"); + String path = + createTempFileFromResource(RestartJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/BlockingTimeOutJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/BlockingTimeOutJUnitTest.java index 230ab34ffee7..a863c226bb6b 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/BlockingTimeOutJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/BlockingTimeOutJUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertNotNull; import java.io.BufferedReader; @@ -45,7 +46,6 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.internal.logging.LogService; -import org.apache.geode.util.test.TestUtil; public class BlockingTimeOutJUnitTest { private static final Logger logger = LogService.getLogger(); @@ -133,7 +133,9 @@ private static String init(String className) throws Exception { path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath(); logger.debug("PATH " + path); /** * Return file as string and then modify the string accordingly ** */ - String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + String file_as_str = readFile( + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid); String modified_file_str = modifyFile(file_as_str); FileOutputStream fos = new FileOutputStream(path); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/DataSourceJTAJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/DataSourceJTAJUnitTest.java index d60f623e7077..1f442dc953a3 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/DataSourceJTAJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/DataSourceJTAJUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.sql.Connection; import java.sql.SQLException; @@ -36,7 +37,6 @@ import org.apache.geode.cache.Region; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.InternalDistributedSystem; -import org.apache.geode.util.test.TestUtil; /** * This test case is to test the following test scenarios: 1) Get Simple DS outside transaction, @@ -87,7 +87,9 @@ public void testInsertUpdateOnSimpleAndXAdsCommit() throws Exception { // call to init method try { Properties props = new Properties(); - String path = TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"); + String path = + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds = connect(props); tableName = CacheUtils.init(ds, "JTATest"); @@ -263,7 +265,9 @@ public void testInsertUpdateOnSimpleAndXAdsRollback() throws Exception { // call to init method try { Properties props = new Properties(); - String path = TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"); + String path = + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds = connect(props); tableName = CacheUtils.init(ds, "JTATest"); @@ -551,7 +555,9 @@ public void testInsertsDDLRollback() throws Exception { // call to init method try { Properties props = new Properties(); - String path = TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"); + String path = + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds = connect(props); tableName = CacheUtils.init(ds, "JTATest"); @@ -712,7 +718,9 @@ public void testMultipleXAResourceCommit() throws Exception { // call to init method try { Properties props = new Properties(); - String path = TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"); + String path = + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds = connect(props); tableName = CacheUtils.init(ds, "JTATest"); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/GlobalTransactionJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/GlobalTransactionJUnitTest.java index 6d8e6bc4e217..1eaeb1462ef9 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/GlobalTransactionJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/GlobalTransactionJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.sql.Connection; @@ -39,7 +40,6 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.internal.datasource.GemFireBasicDataSource; import org.apache.geode.internal.datasource.GemFireTransactionDataSource; -import org.apache.geode.util.test.TestUtil; public class GlobalTransactionJUnitTest { @@ -53,7 +53,9 @@ public class GlobalTransactionJUnitTest { public void setUp() throws Exception { props = new Properties(); props.setProperty(MCAST_PORT, "0"); - String path = TestUtil.getResourcePath(GlobalTransactionJUnitTest.class, "/jta/cachejta.xml"); + String path = + createTempFileFromResource(GlobalTransactionJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath(); props.setProperty(CACHE_XML_FILE, path); ds1 = DistributedSystem.connect(props); cache = CacheFactory.create(ds1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeOutJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeOutJUnitTest.java index c02e80444d35..579b024d5c19 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeOutJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeOutJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.fail; import java.io.BufferedReader; @@ -47,7 +48,6 @@ import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.internal.datasource.GemFireTransactionDataSource; -import org.apache.geode.util.test.TestUtil; /** * TODO: this test has no assertions or validations of any sort @@ -73,7 +73,8 @@ public void setUp() throws Exception { String path = tmpFile.getAbsolutePath(); String file_as_str = - readFile(TestUtil.getResourcePath(TransactionTimeOutJUnitTest.class, "/jta/cachejta.xml")); + readFile(createTempFileFromResource(TransactionTimeOutJUnitTest.class, "/jta/cachejta.xml") + .getAbsolutePath()); String modified_file_str = file_as_str.replaceAll("newDB", "newDB_" + pid); FileOutputStream fos = new FileOutputStream(path); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatArchiveWriterReaderIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatArchiveWriterReaderIntegrationTest.java index a320f2ae97a6..65028fb21c28 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatArchiveWriterReaderIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/StatArchiveWriterReaderIntegrationTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.internal.statistics.StatArchiveFormat.NANOS_PER_MILLI; import static org.apache.geode.internal.statistics.TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; import static org.apache.geode.internal.statistics.TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -54,7 +55,6 @@ import org.apache.geode.internal.NanoTimer; import org.apache.geode.internal.statistics.StatArchiveReader.StatValue; import org.apache.geode.test.junit.categories.StatisticsTest; -import org.apache.geode.util.test.TestUtil; /** * Integration tests for {@link StatArchiveWriter} and {@link StatArchiveReader}. @@ -989,8 +989,9 @@ public void testWriteAfterSamplingBegins() throws Exception { // validate byte content of stat archive file against saved expected file - final File expected = new File(TestUtil.getResourcePath(getClass(), - "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs")); + final File expected = new File(createTempFileFromResource(getClass(), + "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs") + .getAbsolutePath()); assertTrue(expected + " does not exist!", expected.exists()); assertEquals(expected.length(), actual.length()); @@ -1394,8 +1395,9 @@ public void testWriteWhenSamplingBegins() throws Exception { // validate byte content of stat archive file against saved expected file - final File expected = new File(TestUtil.getResourcePath(getClass(), - "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs")); + final File expected = new File(createTempFileFromResource(getClass(), + "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs") + .getAbsolutePath()); assertTrue(expected + " does not exist!", expected.exists()); assertEquals(expected.length(), actual.length()); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/HTTPServiceSSLSupportJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/HTTPServiceSSLSupportJUnitTest.java index e5587d864b93..e8cb1be2532c 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/HTTPServiceSSLSupportJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/HTTPServiceSSLSupportJUnitTest.java @@ -23,6 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import java.io.File; @@ -35,7 +36,6 @@ import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.distributed.internal.DistributionConfigImpl; import org.apache.geode.internal.net.SocketCreatorFactory; -import org.apache.geode.util.test.TestUtil; /** * @since GemFire 8.1 @@ -62,7 +62,8 @@ public void tearDown() throws Exception { private static File findTrustedJKS() { return new File( - TestUtil.getResourcePath(HTTPServiceSSLSupportJUnitTest.class, "/ssl/trusted.keystore")); + createTempFileFromResource(HTTPServiceSSLSupportJUnitTest.class, + "/ssl/trusted.keystore").getAbsolutePath()); } public static String makePath(String[] strings) { diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java index 8555e0dbe8d5..e7be9ae2682c 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.management.internal.deployment; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -28,7 +29,6 @@ import org.apache.geode.test.compiler.JarBuilder; import org.apache.geode.test.junit.categories.GfshTest; -import org.apache.geode.util.test.TestUtil; @Category({GfshTest.class}) public class FunctionScannerTest { @@ -111,7 +111,8 @@ public void registerFunctionHierarchySplitAcrossTwoJars() throws Exception { } private File loadTestResource(String fileName) { - String filePath = TestUtil.getResourcePath(this.getClass(), fileName); + String filePath = + createTempFileFromResource(this.getClass(), fileName).getAbsolutePath(); assertThat(filePath).isNotNull(); return new File(filePath); diff --git a/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionAdapterJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionAdapterJUnitTest.java index aa6e2bc81273..f792a6beacee 100644 --- a/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionAdapterJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionAdapterJUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.cache.execute; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -28,7 +29,6 @@ import org.apache.geode.internal.InternalDataSerializer; import org.apache.geode.internal.Version; import org.apache.geode.internal.VersionedDataInputStream; -import org.apache.geode.util.test.TestUtil; public class FunctionAdapterJUnitTest { @@ -72,8 +72,9 @@ public void execute(final FunctionContext context) {} public void deserializePreGeodeFunctionAdapterShouldNotThrowIncompatibleException() throws Exception { FileInputStream fis = - new FileInputStream(TestUtil.getResourcePath(getClass(), getClass().getSimpleName() + "." - + "serializedFunctionAdapterWithDifferentSerialVersionUID.ser")); + new FileInputStream( + createTempFileFromResource(getClass(), getClass().getSimpleName() + "." + + "serializedFunctionAdapterWithDifferentSerialVersionUID.ser").getAbsolutePath()); DataInputStream dis = new VersionedDataInputStream(new DataInputStream(fis), Version.GFE_82); Object o = InternalDataSerializer.basicReadObject(dis); diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java index 6d2c8079bfc2..07ff006f8fd9 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java @@ -71,6 +71,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_REQUIRE_AUTHENTICATION; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -85,7 +86,6 @@ import org.apache.geode.distributed.internal.DistributionConfigImpl; import org.apache.geode.internal.security.SecurableCommunicationChannel; import org.apache.geode.test.junit.categories.MembershipTest; -import org.apache.geode.util.test.TestUtil; @Category({MembershipTest.class}) public class SocketCreatorFactoryJUnitTest { @@ -300,9 +300,11 @@ public void testNewSSLConfigSSLComponentAliasWithMultiKeyStore() throws Exceptio Properties properties = configureSSLProperties(SecurableCommunicationChannel.ALL.getConstant()); properties.setProperty(SSL_KEYSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks")); + createTempFileFromResource(getClass(), "/org/apache/geode/internal/net/multiKey.jks") + .getAbsolutePath()); properties.setProperty(SSL_TRUSTSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKeyTrust.jks")); + createTempFileFromResource(getClass(), + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath()); properties.setProperty(SSL_CLUSTER_ALIAS, "clusterKey"); properties.setProperty(SSL_DEFAULT_ALIAS, "serverKey"); @@ -329,9 +331,11 @@ public void testNewSSLConfigSSLComponentWithoutAliasWithMultiKeyStore() throws E Properties properties = configureSSLProperties(SecurableCommunicationChannel.ALL.getConstant()); properties.setProperty(SSL_KEYSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks")); + createTempFileFromResource(getClass(), "/org/apache/geode/internal/net/multiKey.jks") + .getAbsolutePath()); properties.setProperty(SSL_TRUSTSTORE, - TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKeyTrust.jks")); + createTempFileFromResource(getClass(), + "/org/apache/geode/internal/net/multiKeyTrust.jks").getAbsolutePath()); DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); @@ -549,6 +553,8 @@ public void testLegacyHttpServiceSSLConfig() throws IOException { } private File findTestJKS() { - return new File(TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore")); + return new File( + createTempFileFromResource(getClass(), "/ssl/trusted.keystore") + .getAbsolutePath()); } } diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorJUnitTest.java index 476978980333..2e4421fc30d3 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorJUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.internal.net; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -31,7 +32,6 @@ import org.apache.geode.internal.admin.SSLConfig; import org.apache.geode.test.junit.categories.MembershipTest; -import org.apache.geode.util.test.TestUtil; @Category({MembershipTest.class}) public class SocketCreatorJUnitTest { @@ -99,6 +99,6 @@ private void testBindExceptionMessageFormatting(InetAddress inetAddress) throws } private String getSingleKeyKeystore() { - return TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore"); + return createTempFileFromResource(getClass(), "/ssl/trusted.keystore").getAbsolutePath(); } } diff --git a/geode-core/src/test/java/org/apache/geode/internal/util/PluckStacksUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/util/PluckStacksUnitTest.java index 6d07b88ffdef..4a481f758b23 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/util/PluckStacksUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/util/PluckStacksUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.internal.util; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -24,15 +25,14 @@ import org.junit.Test; -import org.apache.geode.util.test.TestUtil; - public class PluckStacksUnitTest { @Test public void testPluckingStacksFromJVMGeneratedDump() throws Exception { LineNumberReader reader = new LineNumberReader( - new FileReader(TestUtil.getResourcePath(getClass(), "PluckStacksJstackGeneratedDump.txt"))); + new FileReader(createTempFileFromResource(getClass(), "PluckStacksJstackGeneratedDump.txt") + .getAbsolutePath())); Map> dumps = new PluckStacks().getThreadDumps(reader, "PluckStacksSystemGeneratedDump.txt"); diff --git a/geode-dunit/src/main/java/org/apache/geode/security/generator/LdapUserCredentialGenerator.java b/geode-dunit/src/main/java/org/apache/geode/security/generator/LdapUserCredentialGenerator.java index b339ae9f68d3..fa39a92ddcfb 100755 --- a/geode-dunit/src/main/java/org/apache/geode/security/generator/LdapUserCredentialGenerator.java +++ b/geode-dunit/src/main/java/org/apache/geode/security/generator/LdapUserCredentialGenerator.java @@ -15,6 +15,7 @@ package org.apache.geode.security.generator; import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_DHALGO; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.security.Principal; import java.util.Properties; @@ -28,7 +29,6 @@ import org.apache.geode.security.templates.LdapUserAuthenticator; import org.apache.geode.security.templates.UserPasswordAuthInit; import org.apache.geode.test.dunit.Assert; -import org.apache.geode.util.test.TestUtil; public class LdapUserCredentialGenerator extends CredentialGenerator { @@ -66,8 +66,9 @@ protected Properties initialize() throws IllegalArgumentException { } if (serverAuthEnabled) { - String keyStoreFile = TestUtil.getResourcePath(LdapUserCredentialGenerator.class, - PKCSCredentialGenerator.keyStoreDir + "/gemfire1.keystore"); + String keyStoreFile = + createTempFileFromResource(LdapUserCredentialGenerator.class, + PKCSCredentialGenerator.keyStoreDir + "/gemfire1.keystore").getAbsolutePath(); extraProps.setProperty(Handshake.PRIVATE_KEY_FILE_PROP, keyStoreFile); extraProps.setProperty(Handshake.PRIVATE_KEY_ALIAS_PROP, DistributionConfig.GEMFIRE_PREFIX); extraProps.setProperty(Handshake.PRIVATE_KEY_PASSWD_PROP, "gemfire"); @@ -103,8 +104,9 @@ public Properties getValidCredentials(final int index) { props.setProperty(SECURITY_CLIENT_DHALGO, CIPHERS[RANDOM.nextInt(CIPHERS.length)]); if (serverAuthEnabled) { - final String keyStoreFile = TestUtil.getResourcePath(PKCSCredentialGenerator.class, - PKCSCredentialGenerator.keyStoreDir + "/publickeyfile"); + final String keyStoreFile = + createTempFileFromResource(PKCSCredentialGenerator.class, + PKCSCredentialGenerator.keyStoreDir + "/publickeyfile").getAbsolutePath(); props.setProperty(Handshake.PUBLIC_KEY_FILE_PROP, keyStoreFile); props.setProperty(Handshake.PUBLIC_KEY_PASSWD_PROP, "gemfire"); } @@ -141,8 +143,9 @@ public Properties getValidCredentials(final Principal principal) { props.setProperty(SECURITY_CLIENT_DHALGO, CIPHERS[RANDOM.nextInt(CIPHERS.length)]); if (serverAuthEnabled) { - final String keyStoreFile = TestUtil.getResourcePath(PKCSCredentialGenerator.class, - PKCSCredentialGenerator.keyStoreDir + "/publickeyfile"); + final String keyStoreFile = + createTempFileFromResource(PKCSCredentialGenerator.class, + PKCSCredentialGenerator.keyStoreDir + "/publickeyfile").getAbsolutePath(); props.setProperty(Handshake.PUBLIC_KEY_FILE_PROP, keyStoreFile); props.setProperty(Handshake.PUBLIC_KEY_PASSWD_PROP, "gemfire"); } @@ -158,8 +161,9 @@ public Properties getInvalidCredentials(final int index) { props.setProperty(SECURITY_CLIENT_DHALGO, CIPHERS[RANDOM.nextInt(CIPHERS.length)]); if (serverAuthEnabled) { - final String keyStoreFile = TestUtil.getResourcePath(PKCSCredentialGenerator.class, - PKCSCredentialGenerator.keyStoreDir + "/publickeyfile"); + final String keyStoreFile = + createTempFileFromResource(PKCSCredentialGenerator.class, + PKCSCredentialGenerator.keyStoreDir + "/publickeyfile").getAbsolutePath(); props.setProperty(Handshake.PUBLIC_KEY_FILE_PROP, keyStoreFile); props.setProperty(Handshake.PUBLIC_KEY_PASSWD_PROP, "gemfire"); } diff --git a/geode-dunit/src/main/java/org/apache/geode/security/generator/PKCSCredentialGenerator.java b/geode-dunit/src/main/java/org/apache/geode/security/generator/PKCSCredentialGenerator.java index f98f34e2d2d5..3def27fa1463 100755 --- a/geode-dunit/src/main/java/org/apache/geode/security/generator/PKCSCredentialGenerator.java +++ b/geode-dunit/src/main/java/org/apache/geode/security/generator/PKCSCredentialGenerator.java @@ -14,6 +14,8 @@ */ package org.apache.geode.security.generator; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; + import java.security.Principal; import java.security.Provider; import java.security.Security; @@ -21,7 +23,6 @@ import org.apache.geode.security.templates.PKCSAuthInit; import org.apache.geode.security.templates.PKCSAuthenticator; -import org.apache.geode.util.test.TestUtil; public class PKCSCredentialGenerator extends CredentialGenerator { @@ -51,7 +52,8 @@ private static String getKeyStoreDir() { @Override protected Properties initialize() throws IllegalArgumentException { final String keyStoreFile = - TestUtil.getResourcePath(PKCSCredentialGenerator.class, keyStoreDir + "/publickeyfile"); + createTempFileFromResource(PKCSCredentialGenerator.class, + keyStoreDir + "/publickeyfile").getAbsolutePath(); final Properties props = new Properties(); props.setProperty(PKCSAuthenticator.PUBLIC_KEY_FILE, keyStoreFile); @@ -77,8 +79,9 @@ public String getAuthenticator() { @Override public Properties getInvalidCredentials(int index) { - final String keyStoreFile = TestUtil.getResourcePath(PKCSCredentialGenerator.class, - keyStoreDir + "/gemfire11.keystore"); + final String keyStoreFile = + createTempFileFromResource(PKCSCredentialGenerator.class, + keyStoreDir + "/gemfire11.keystore").getAbsolutePath(); final Properties props = new Properties(); props.setProperty(PKCSAuthInit.KEYSTORE_FILE_PATH, keyStoreFile); @@ -91,8 +94,9 @@ public Properties getInvalidCredentials(int index) { @Override public Properties getValidCredentials(int index) { final int aliasnum = (index % 10) + 1; - final String keyStoreFile = TestUtil.getResourcePath(PKCSCredentialGenerator.class, - keyStoreDir + "/gemfire" + aliasnum + ".keystore"); + final String keyStoreFile = + createTempFileFromResource(PKCSCredentialGenerator.class, + keyStoreDir + "/gemfire" + aliasnum + ".keystore").getAbsolutePath(); final Properties props = new Properties(); props.setProperty(PKCSAuthInit.KEYSTORE_FILE_PATH, keyStoreFile); @@ -104,8 +108,9 @@ public Properties getValidCredentials(int index) { @Override public Properties getValidCredentials(Principal principal) { - final String keyStoreFile = TestUtil.getResourcePath(PKCSCredentialGenerator.class, - keyStoreDir + principal.getName() + ".keystore"); + final String keyStoreFile = + createTempFileFromResource(PKCSCredentialGenerator.class, + keyStoreDir + principal.getName() + ".keystore").getAbsolutePath(); final Properties props = new Properties(); props.setProperty(PKCSAuthInit.KEYSTORE_FILE_PATH, keyStoreFile); diff --git a/geode-dunit/src/main/java/org/apache/geode/security/generator/XmlAuthzCredentialGenerator.java b/geode-dunit/src/main/java/org/apache/geode/security/generator/XmlAuthzCredentialGenerator.java index d80e5e0ca972..a6f21412e71b 100755 --- a/geode-dunit/src/main/java/org/apache/geode/security/generator/XmlAuthzCredentialGenerator.java +++ b/geode-dunit/src/main/java/org/apache/geode/security/generator/XmlAuthzCredentialGenerator.java @@ -14,6 +14,8 @@ */ package org.apache.geode.security.generator; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; + import java.security.Principal; import java.util.HashSet; import java.util.Properties; @@ -22,7 +24,6 @@ import org.apache.geode.cache.operations.OperationContext.OperationCode; import org.apache.geode.security.templates.UsernamePrincipal; import org.apache.geode.security.templates.XmlAuthorization; -import org.apache.geode.util.test.TestUtil; public class XmlAuthzCredentialGenerator extends AuthzCredentialGenerator { @@ -82,12 +83,14 @@ protected Properties init() throws IllegalArgumentException { if (this.generator.classCode().isDummy()) { final String xmlFilename = - TestUtil.getResourcePath(XmlAuthzCredentialGenerator.class, dirName + dummyXml); + createTempFileFromResource(XmlAuthzCredentialGenerator.class, dirName + dummyXml) + .getAbsolutePath(); sysProps.setProperty(XmlAuthorization.DOC_URI_PROP_NAME, xmlFilename); } else if (this.generator.classCode().isLDAP()) { final String xmlFilename = - TestUtil.getResourcePath(XmlAuthzCredentialGenerator.class, dirName + ldapXml); + createTempFileFromResource(XmlAuthzCredentialGenerator.class, dirName + ldapXml) + .getAbsolutePath(); sysProps.setProperty(XmlAuthorization.DOC_URI_PROP_NAME, xmlFilename); // } else if (this.generator.classCode().isPKCS()) { diff --git a/geode-experimental-driver/src/integrationTest/java/org/apache/geode/experimental/driver/SSLTest.java b/geode-experimental-driver/src/integrationTest/java/org/apache/geode/experimental/driver/SSLTest.java index 20a3ba305101..f094eb4c296b 100644 --- a/geode-experimental-driver/src/integrationTest/java/org/apache/geode/experimental/driver/SSLTest.java +++ b/geode-experimental-driver/src/integrationTest/java/org/apache/geode/experimental/driver/SSLTest.java @@ -24,6 +24,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.internal.Assert.assertTrue; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; @@ -52,7 +53,6 @@ import org.apache.geode.distributed.Locator; import org.apache.geode.internal.net.SocketCreatorFactory; import org.apache.geode.test.junit.categories.ClientServerTest; -import org.apache.geode.util.test.TestUtil; @Category({ClientServerTest.class}) public class SSLTest { @@ -63,19 +63,24 @@ public class SSLTest { public ExpectedException expectedException = ExpectedException.none(); private final String DEFAULT_KEY_STORE = - TestUtil.getResourcePath(SSLTest.class, "default.keystore"); + createTempFileFromResource(SSLTest.class, "default.keystore").getAbsolutePath(); private final String SERVER_KEY_STORE = - TestUtil.getResourcePath(SSLTest.class, "cacheserver.keystore"); + createTempFileFromResource(SSLTest.class, "cacheserver.keystore") + .getAbsolutePath(); private final String SERVER_TRUST_STORE = - TestUtil.getResourcePath(SSLTest.class, "cacheserver.truststore"); + createTempFileFromResource(SSLTest.class, "cacheserver.truststore") + .getAbsolutePath(); private final String BOGUSSERVER_KEY_STORE = - TestUtil.getResourcePath(SSLTest.class, "bogusserver.keystore"); + createTempFileFromResource(SSLTest.class, "bogusserver.keystore") + .getAbsolutePath(); private final String BOGUSCLIENT_KEY_STORE = - TestUtil.getResourcePath(SSLTest.class, "bogusclient.keystore"); + createTempFileFromResource(SSLTest.class, "bogusclient.keystore") + .getAbsolutePath(); private final String CLIENT_KEY_STORE = - TestUtil.getResourcePath(SSLTest.class, "client.keystore"); + createTempFileFromResource(SSLTest.class, "client.keystore").getAbsolutePath(); private final String CLIENT_TRUST_STORE = - TestUtil.getResourcePath(SSLTest.class, "client.truststore"); + createTempFileFromResource(SSLTest.class, "client.truststore") + .getAbsolutePath(); private Locator locator; private Cache cache; private Driver driver; diff --git a/geode-junit/src/main/java/org/apache/geode/internal/jta/CacheUtils.java b/geode-junit/src/main/java/org/apache/geode/internal/jta/CacheUtils.java index 1dbec0d38e6e..530ca789a3fd 100644 --- a/geode-junit/src/main/java/org/apache/geode/internal/jta/CacheUtils.java +++ b/geode-junit/src/main/java/org/apache/geode/internal/jta/CacheUtils.java @@ -22,6 +22,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import java.sql.Connection; import java.sql.ResultSet; @@ -39,7 +40,6 @@ import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.query.QueryService; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.util.test.TestUtil; public class CacheUtils { public static DistributedSystem ds; @@ -57,7 +57,9 @@ public static String init() throws Exception { public static String init(String className) throws Exception { Properties props = new Properties(); - props.setProperty(CACHE_XML_FILE, TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml")); + props.setProperty(CACHE_XML_FILE, + createTempFileFromResource(CacheUtils.class, "cachejta.xml") + .getAbsolutePath()); String tableName = ""; props.setProperty(MCAST_PORT, "0"); diff --git a/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java b/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java index 963153197d0d..cdd6f9d51ba0 100644 --- a/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java +++ b/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java @@ -21,7 +21,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.net.URISyntaxException; +import java.io.UncheckedIOException; import java.net.URL; import com.google.common.io.Resources; @@ -35,13 +35,20 @@ *

* See also {@link Resources#getResource(String)} and {@link Resources#getResource(Class, String)}. */ +@SuppressWarnings("unused") public class ResourceUtils { /** * Returns the class identified by {@code depth} element of the call stack. + * + * @throws ClassNotFoundException wrapped in RuntimeException if the class cannot be located */ - public static Class getCallerClass(final int depth) throws ClassNotFoundException { - return Class.forName(getCallerClassName(depth + 1)); + public static Class getCallerClass(final int depth) { + try { + return Class.forName(getCallerClassName(depth + 1)); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } } /** @@ -55,35 +62,177 @@ public static String getCallerClassName(final int depth) { * Finds {@code resourceName} using the {@code ClassLoader} of the caller class. * * @return the URL of the resource + * + * @throws AssertionError if the resource cannot be located + * + * @throws ClassNotFoundException wrapped in RuntimeException if the class cannot be located */ - public static URL getResource(final String resourceName) throws ClassNotFoundException { - URL configResource = getCallerClass(2).getResource(resourceName); - assertThat(configResource).as(resourceName).isNotNull(); - return configResource; + public static URL getResource(final String resourceName) { + URL resource = getCallerClass(2).getResource(resourceName); + assertThat(resource).as(resourceName).isNotNull(); + return resource; } /** * Finds {@code resourceName} using the {@code ClassLoader} of {@code classInSamePackage}. * * @return the URL of the resource + * + * @throws AssertionError if the resource cannot be located */ public static URL getResource(final Class classInSamePackage, final String resourceName) { - URL configResource = classInSamePackage.getResource(resourceName); - assertThat(configResource).as(resourceName).isNotNull(); - return configResource; + URL resource = classInSamePackage.getResource(resourceName); + assertThat(resource).as(resourceName).isNotNull(); + return resource; + } + + /** + * Finds {@code resourceName} using the specified {@code ClassLoader}. + * + * @return the URL of the resource + * + * @throws AssertionError if the resource cannot be located + */ + public static URL getResource(final ClassLoader classLoader, final String resourceName) { + URL resource = classLoader.getResource(resourceName); + assertThat(resource).as(resourceName).isNotNull(); + return resource; } /** * Copies a {@code resource} to a {@code file} in {@code targetFolder}. * * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason */ public static File createFileFromResource(final URL resource, final File targetFolder, - final String fileName) throws IOException, URISyntaxException { - File targetFile = new File(targetFolder, fileName); - IOUtils.copy(resource.openStream(), new FileOutputStream(targetFile)); - assertThat(targetFile).hasSameContentAs(new File(resource.toURI())); - return targetFile; + final String fileName) { + try { + File targetFile = new File(targetFolder, fileName); + IOUtils.copy(resource.openStream(), new FileOutputStream(targetFile)); + return targetFile; + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Copies a {@code resourceName} using the specified {@code ClassLoader} to a {@code file} in + * {@code targetFolder}. + * + * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason + */ + public static File createFileFromResource(final ClassLoader classLoader, + final String resourceName, final File targetFolder, final String fileName) { + URL resource = getResource(classLoader, resourceName); + return createFileFromResource(resource, targetFolder, fileName); + } + + /** + * Copies a {@code resource} to a {@code file} in {@code targetFolder}. + * + * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason + */ + public static File createTempFileFromResource(final URL resource, final String fileName) { + try { + File targetFile = File.createTempFile(fileName, null); + targetFile.deleteOnExit(); + IOUtils.copy(resource.openStream(), new FileOutputStream(targetFile)); + return targetFile; + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Copies a {@code resourceName} using the {@code ClassLoader} of {@code classInSamePackage} to a + * {@code file} in the temporary-file directory. + * + * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason + */ + public static File createTempFileFromResource(final Class classInSamePackage, + final String resourceName, final String fileName) { + URL resource = getResource(classInSamePackage, resourceName); + return createTempFileFromResource(resource, fileName); + } + + /** + * Copies a {@code resourceName} using the specified {@code ClassLoader} to a {@code file} in + * the temporary-file directory. + * + * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason + */ + public static File createTempFileFromResource(final ClassLoader classLoader, + final String resourceName, final String fileName) { + URL resource = getResource(classLoader, resourceName); + return createTempFileFromResource(resource, fileName); + } + + /** + * Copies a {@code resourceName} using the {@code ClassLoader} of {@code classInSamePackage} to a + * {@code file} in the temporary-file directory. + * + * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason + */ + public static File createTempFileFromResource(final Class classInSamePackage, + final String resourceName) { + String fileName = resourceName.replaceFirst(".*/", ""); + URL resource = getResource(classInSamePackage, resourceName); + return createTempFileFromResource(resource, fileName); + } + + /** + * Copies a {@code resourceName} using the specified {@code ClassLoader} to a {@code file} in + * the temporary-file directory. + * + * @return the newly created file + * + * @throws AssertionError if the resource cannot be located + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason + */ + public static File createTempFileFromResource(final ClassLoader classLoader, + final String resourceName) { + String fileName = resourceName.replaceFirst(".*/", ""); + URL resource = getResource(classLoader, resourceName); + return createTempFileFromResource(resource, fileName); } /** @@ -92,11 +241,20 @@ public static File createFileFromResource(final URL resource, final File targetF * @param resource a file-based resource referencing a directory * @param targetFolder the directory to which to copy the resource and all files within that * resource. + * + * @throws AssertionError if the resulting file does not exist + * + * @throws UncheckedIOException if an I/O exception occurs or the file exists but is a directory + * rather than a regular file, does not exist but cannot be created, or cannot be opened + * for any other reason */ - public static void copyDirectoryResource(final URL resource, final File targetFolder) - throws IOException { - File source = new File(resource.getPath()); - assertThat(source.exists()).as("Source does not exist: " + resource.getPath()); - FileUtils.copyDirectory(source, targetFolder); + public static void copyDirectoryResource(final URL resource, final File targetFolder) { + try { + File source = new File(resource.getPath()); + assertThat(source.exists()).as("Source does not exist: " + resource.getPath()); + FileUtils.copyDirectory(source, targetFolder); + } catch (IOException e) { + throw new UncheckedIOException(e); + } } } diff --git a/geode-junit/src/main/java/org/apache/geode/util/test/TestUtil.java b/geode-junit/src/main/java/org/apache/geode/util/test/TestUtil.java deleted file mode 100644 index 4192867c88a9..000000000000 --- a/geode-junit/src/main/java/org/apache/geode/util/test/TestUtil.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.apache.geode.util.test; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.FileSystemNotFoundException; -import java.nio.file.Paths; - -import org.apache.commons.io.FileUtils; - -public class TestUtil { - - /** - * Return the path to a named resource. This finds the resource on the classpath using the rules - * of class.getResource. For a relative path it will look in the same package as the class, for an - * absolute path it will start from the base package. - * - * Best practice is to put the resource in the same package as your test class and load it with - * this method. - * - * @param clazz the class to look relative too - * @param name the name of the resource, eg "cache.xml" - */ - public static String getResourcePath(Class clazz, String name) { - URL resource = clazz.getResource(name); - return getResourcePath(name, resource); - } - - /** - * Return the path to a named resource. This finds the resource on the classpath using the rules - * of ClassLoader.getResource. - * - * @param classLoader the ClassLoader to look up resource in - * @param name the name of the resource, eg "cache.xml" - */ - public static String getResourcePath(ClassLoader classLoader, String name) { - URL resource = classLoader.getResource(name); - return getResourcePath(name, resource); - } - - private static String getResourcePath(String name, URL resource) { - if (resource == null) { - throw new RuntimeException("Could not find resource " + name); - } - try { - return Paths.get(resource.toURI()).toAbsolutePath().toString(); - } catch (FileSystemNotFoundException e) { - // create a temporary copy when Paths.get() fails (eg: jar:file:/...) - return createTemporaryCopy(name, resource); - } catch (URISyntaxException e) { - throw new RuntimeException("Failed getting path to resource " + name, e); - } - } - - private static String createTemporaryCopy(String name, URL resource) { - try { - String filename = name.replaceFirst(".*/", ""); - File tmpFile = File.createTempFile(filename, null); - tmpFile.deleteOnExit(); - FileUtils.copyURLToFile(resource, tmpFile); - return tmpFile.getAbsolutePath(); - } catch (IOException e1) { - throw new RuntimeException("Failed getting path to resource " + name, e1); - } - } -} diff --git a/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsIntegrationTest.java b/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsIntegrationTest.java index 9c00e7d555eb..9185e3c36280 100644 --- a/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsIntegrationTest.java +++ b/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsIntegrationTest.java @@ -16,6 +16,7 @@ */ package org.apache.geode.test.util; +import static org.apache.geode.test.util.ResourceUtils.getResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -41,9 +42,9 @@ public class ResourceUtilsIntegrationTest { public TemporaryFolder temporaryFolder = new TemporaryFolder(); @Before - public void setUp() throws Exception { + public void setUp() { resourceName = ResourceUtilsTest.class.getSimpleName() + RESOURCE_SUFFIX; - resource = ResourceUtils.getResource(ResourceUtilsTest.class, resourceName); + resource = getResource(ResourceUtilsTest.class, resourceName); } @Test diff --git a/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsTest.java b/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsTest.java index 24c3c7aefc6c..0a8a042a4b24 100644 --- a/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsTest.java +++ b/geode-junit/src/test/java/org/apache/geode/test/util/ResourceUtilsTest.java @@ -34,7 +34,7 @@ public class ResourceUtilsTest { private String resourceName; @Before - public void setUp() throws Exception { + public void setUp() { className = getClass().getName(); resourceName = getClass().getSimpleName() + RESOURCE_SUFFIX; } @@ -45,7 +45,7 @@ public void getCallerClassName() { } @Test - public void getCallerClass() throws Exception { + public void getCallerClass() { assertThat(ResourceUtils.getCallerClass(1)).isEqualTo(getClass()); } diff --git a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java index d7062c4cf1b4..c5f3c9e05075 100644 --- a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java +++ b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java @@ -26,6 +26,7 @@ import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_SERIALIZER; import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME; import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; @@ -59,7 +60,6 @@ import org.apache.geode.test.dunit.AsyncInvocation; import org.apache.geode.test.dunit.SerializableRunnableIF; import org.apache.geode.test.junit.categories.LuceneTest; -import org.apache.geode.util.test.TestUtil; @Category({LuceneTest.class}) @RunWith(JUnitParamsRunner.class) @@ -469,8 +469,8 @@ public void verifyAsyncEventQueueIsCleanedUpIfRegionCreationFails() { } protected String getXmlFileForTest(String testName) { - return TestUtil.getResourcePath(getClass(), - getClassSimpleName() + "." + testName + ".cache.xml"); + return createTempFileFromResource(getClass(), + getClassSimpleName() + "." + testName + ".cache.xml").getAbsolutePath(); } protected String getClassSimpleName() { diff --git a/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexXmlParserIntegrationJUnitTest.java b/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexXmlParserIntegrationJUnitTest.java index 38c6ef4c9161..095d55a2cdd2 100644 --- a/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexXmlParserIntegrationJUnitTest.java +++ b/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexXmlParserIntegrationJUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -52,7 +53,6 @@ import org.apache.geode.internal.cache.xmlcache.CacheXmlParser; import org.apache.geode.internal.cache.xmlcache.RegionCreation; import org.apache.geode.test.junit.categories.LuceneTest; -import org.apache.geode.util.test.TestUtil; @Category({LuceneTest.class}) public class LuceneIndexXmlParserIntegrationJUnitTest { @@ -232,8 +232,8 @@ public void createIndex() throws FileNotFoundException { } private String getXmlFileForTest() { - return TestUtil.getResourcePath(getClass(), - getClass().getSimpleName() + "." + name.getMethodName() + ".cache.xml"); + return createTempFileFromResource(getClass(), + getClass().getSimpleName() + "." + name.getMethodName() + ".cache.xml").getAbsolutePath(); } } diff --git a/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheConnectionIntegrationTest.java b/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheConnectionIntegrationTest.java index 064800b04f25..fac1d3427f88 100644 --- a/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheConnectionIntegrationTest.java +++ b/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheConnectionIntegrationTest.java @@ -26,6 +26,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.internal.protocol.protobuf.v1.MessageUtil.validateGetResponse; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -73,7 +74,6 @@ import org.apache.geode.internal.protocol.protobuf.v1.serializer.exception.InvalidProtocolMessageException; import org.apache.geode.test.junit.categories.ClientServerTest; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; -import org.apache.geode.util.test.TestUtil; /** * Test that using the magic byte to indicate intend ot use ProtoBuf messages works @@ -232,9 +232,12 @@ private ClientProtocol.Message deserializeResponse(Socket socket, } private void updatePropertiesForSSLCache(Properties properties) { - String keyStore = TestUtil.getResourcePath(CacheConnectionIntegrationTest.class, DEFAULT_STORE); + String keyStore = + createTempFileFromResource(CacheConnectionIntegrationTest.class, DEFAULT_STORE) + .getAbsolutePath(); String trustStore = - TestUtil.getResourcePath(CacheConnectionIntegrationTest.class, DEFAULT_STORE); + createTempFileFromResource(CacheConnectionIntegrationTest.class, DEFAULT_STORE) + .getAbsolutePath(); properties.setProperty(SSL_ENABLED_COMPONENTS, "server"); properties.setProperty(SSL_PROTOCOLS, SSL_PROTOCOLS_VALUE); @@ -250,9 +253,11 @@ private void updatePropertiesForSSLCache(Properties properties) { private Socket getSSLSocket() throws IOException { String keyStorePath = - TestUtil.getResourcePath(CacheConnectionIntegrationTest.class, DEFAULT_STORE); + createTempFileFromResource(CacheConnectionIntegrationTest.class, DEFAULT_STORE) + .getAbsolutePath(); String trustStorePath = - TestUtil.getResourcePath(CacheConnectionIntegrationTest.class, DEFAULT_STORE); + createTempFileFromResource(CacheConnectionIntegrationTest.class, DEFAULT_STORE) + .getAbsolutePath(); SSLConfig sslConfig = new SSLConfig(); sslConfig.setEnabled(true); diff --git a/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java b/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java index c907704f92aa..d30b692680a7 100644 --- a/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java +++ b/geode-protobuf/src/integrationTest/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java @@ -24,6 +24,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.internal.protocol.protobuf.v1.MessageUtil.validateGetResponse; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -67,7 +68,6 @@ import org.apache.geode.internal.protocol.protobuf.v1.serializer.exception.InvalidProtocolMessageException; import org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufUtilities; import org.apache.geode.test.junit.categories.ClientServerTest; -import org.apache.geode.util.test.TestUtil; /** * Test operations using ProtoBuf @@ -362,8 +362,12 @@ private void validateRemoveResponse(Socket socket, } private void updatePropertiesForSSLCache(Properties properties) { - String keyStore = TestUtil.getResourcePath(CacheOperationsJUnitTest.class, DEFAULT_STORE); - String trustStore = TestUtil.getResourcePath(CacheOperationsJUnitTest.class, DEFAULT_STORE); + String keyStore = + createTempFileFromResource(CacheOperationsJUnitTest.class, DEFAULT_STORE) + .getAbsolutePath(); + String trustStore = + createTempFileFromResource(CacheOperationsJUnitTest.class, DEFAULT_STORE) + .getAbsolutePath(); properties.put(SSL_ENABLED_COMPONENTS, "server"); properties.put(ConfigurationProperties.SSL_PROTOCOLS, SSL_PROTOCOLS); @@ -378,8 +382,12 @@ private void updatePropertiesForSSLCache(Properties properties) { } private Socket getSSLSocket() throws IOException { - String keyStorePath = TestUtil.getResourcePath(CacheOperationsJUnitTest.class, DEFAULT_STORE); - String trustStorePath = TestUtil.getResourcePath(CacheOperationsJUnitTest.class, DEFAULT_STORE); + String keyStorePath = + createTempFileFromResource(CacheOperationsJUnitTest.class, DEFAULT_STORE) + .getAbsolutePath(); + String trustStorePath = + createTempFileFromResource(CacheOperationsJUnitTest.class, DEFAULT_STORE) + .getAbsolutePath(); SSLConfig sslConfig = new SSLConfig(); sslConfig.setEnabled(true); diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java index 9c7a2b3ec229..d86c970f1e19 100644 --- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java +++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java @@ -38,6 +38,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.Host.getHost; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hamcrest.Matchers.greaterThan; @@ -180,7 +181,6 @@ import org.apache.geode.test.dunit.WaitCriterion; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; import org.apache.geode.test.junit.categories.WanTest; -import org.apache.geode.util.test.TestUtil; @Category({WanTest.class}) public class WANTestBase extends DistributedTestCase { @@ -944,11 +944,11 @@ protected static void createCacheWithSSL(Integer locPort) { gemFireProps.put(GATEWAY_SSL_KEYSTORE_TYPE, "jks"); // this uses the default.keystore which is all jdk compliant in geode-dunit module - gemFireProps.put(GATEWAY_SSL_KEYSTORE, TestUtil.getResourcePath(WANTestBase.class, - "/org/apache/geode/cache/client/internal/default.keystore")); + gemFireProps.put(GATEWAY_SSL_KEYSTORE, createTempFileFromResource(WANTestBase.class, + "/org/apache/geode/cache/client/internal/default.keystore").getAbsolutePath()); gemFireProps.put(GATEWAY_SSL_KEYSTORE_PASSWORD, "password"); - gemFireProps.put(GATEWAY_SSL_TRUSTSTORE, TestUtil.getResourcePath(WANTestBase.class, - "/org/apache/geode/cache/client/internal/default.keystore")); + gemFireProps.put(GATEWAY_SSL_TRUSTSTORE, createTempFileFromResource(WANTestBase.class, + "/org/apache/geode/cache/client/internal/default.keystore").getAbsolutePath()); gemFireProps.put(GATEWAY_SSL_TRUSTSTORE_PASSWORD, "password"); gemFireProps.setProperty(MCAST_PORT, "0"); @@ -2033,11 +2033,11 @@ public static int createReceiverWithSSL(int locPort) { gemFireProps.put(GATEWAY_SSL_REQUIRE_AUTHENTICATION, "true"); gemFireProps.put(GATEWAY_SSL_KEYSTORE_TYPE, "jks"); - gemFireProps.put(GATEWAY_SSL_KEYSTORE, TestUtil.getResourcePath(WANTestBase.class, - "/org/apache/geode/cache/client/internal/default.keystore")); + gemFireProps.put(GATEWAY_SSL_KEYSTORE, createTempFileFromResource(WANTestBase.class, + "/org/apache/geode/cache/client/internal/default.keystore").getAbsolutePath()); gemFireProps.put(GATEWAY_SSL_KEYSTORE_PASSWORD, "password"); - gemFireProps.put(GATEWAY_SSL_TRUSTSTORE, TestUtil.getResourcePath(WANTestBase.class, - "/org/apache/geode/cache/client/internal/default.keystore")); + gemFireProps.put(GATEWAY_SSL_TRUSTSTORE, createTempFileFromResource(WANTestBase.class, + "/org/apache/geode/cache/client/internal/default.keystore").getAbsolutePath()); gemFireProps.put(GATEWAY_SSL_TRUSTSTORE_PASSWORD, "password"); gemFireProps.setProperty(MCAST_PORT, "0"); diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java b/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java index a5f2cbf2cc1f..369421b64062 100644 --- a/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java +++ b/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.internal.Assert.assertTrue; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -46,7 +47,6 @@ import org.apache.geode.test.junit.categories.WanTest; import org.apache.geode.test.junit.rules.serializable.SerializableTestName; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; -import org.apache.geode.util.test.TestUtil; @Category({WanTest.class}) @RunWith(Parameterized.class) @@ -68,15 +68,19 @@ public static Collection strategies() throws Exception { @Test(expected = CacheXmlException.class) public void multipleReceiversShouldThrowException() { - String cacheXmlFileName = TestUtil.getResourcePath(getClass(), - getClass().getSimpleName() + "." + testName.getMethodName() + ".cache.xml"); + String cacheXmlFileName = + createTempFileFromResource(getClass(), + getClass().getSimpleName() + "." + testName.getMethodName() + ".cache.xml") + .getAbsolutePath(); cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create(); } @Test public void correctConfiguration() { - String cacheXmlFileName = TestUtil.getResourcePath(getClass(), - getClass().getSimpleName() + "." + testName.getMethodName() + ".cache.xml"); + String cacheXmlFileName = + createTempFileFromResource(getClass(), + getClass().getSimpleName() + "." + testName.getMethodName() + ".cache.xml") + .getAbsolutePath(); cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create(); assertThat(cache.getGatewayReceivers()).isNotEmpty(); diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSSLTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSSLTest.java index c039f22ce1bc..a90f9a33df52 100644 --- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSSLTest.java +++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSSLTest.java @@ -48,6 +48,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_TYPE; +import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; @@ -69,7 +70,6 @@ import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.categories.GfshTest; import org.apache.geode.test.junit.rules.GfshCommandRule; -import org.apache.geode.util.test.TestUtil; @Category({GfshTest.class}) public class ConnectCommandWithSSLTest { @@ -86,8 +86,8 @@ public class ConnectCommandWithSSLTest { * -ext san=ip:127.0.0.1 -storetype jks */ - jks = new File(TestUtil.getResourcePath(ConnectCommandWithSSLTest.class.getClassLoader(), - "ssl/trusted.keystore")); + jks = new File(createTempFileFromResource(ConnectCommandWithSSLTest.class.getClassLoader(), + "ssl/trusted.keystore").getAbsolutePath()); } private static final Properties sslProperties = new Properties() {