From e3fb2b273f939314d9cdbce539f373d6fc77d0ad Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Tue, 22 Feb 2022 10:07:26 -0500 Subject: [PATCH] fix(java): make system property accessible for native image compilation (#1694) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(java): make system properties accessible for native image compilation * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- google-cloud-spanner/pom.xml | 38 +++++++++++++++++-- .../cloud/spanner/IntegrationTestEnv.java | 7 ++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/google-cloud-spanner/pom.xml b/google-cloud-spanner/pom.xml index 46b11e401c8..2aeaa0ddfc7 100644 --- a/google-cloud-spanner/pom.xml +++ b/google-cloud-spanner/pom.xml @@ -16,6 +16,10 @@ google-cloud-spanner 0.31.0 + com.google.cloud.spanner.GceTestEnvConfig + projects/gcloud-devel/instances/spanner-testing-east1 + gcloud-devel + projects/gcloud-devel/locations/us-east1/keyRings/cmek-test-key-ring/cryptoKeys/cmek-test-key @@ -70,10 +74,10 @@ maven-failsafe-plugin - com.google.cloud.spanner.GceTestEnvConfig - projects/gcloud-devel/instances/spanner-testing-east1 - gcloud-devel - projects/gcloud-devel/locations/us-east1/keyRings/cmek-test-key-ring/cryptoKeys/cmek-test-key + ${spanner.testenv.config.class} + ${spanner.testenv.instance} + ${spanner.gce.config.project_id} + ${spanner.testenv.kms_key.name} 3000 @@ -100,6 +104,32 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${spanner.testenv.config.class} + ${spanner.testenv.instance} + ${spanner.gce.config.project_id} + ${spanner.testenv.kms_key.name} + + 3000 + + + + org.graalvm.buildtools + native-maven-plugin + + + -Dspanner.testenv.config.class=${spanner.testenv.config.class} + + + + + org.codehaus.mojo diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java index 103b6f626ba..3f4db8b9135 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java @@ -42,6 +42,8 @@ public class IntegrationTestEnv extends ExternalResource { /** Names a property that provides the class name of the {@link TestEnvConfig} to use. */ public static final String TEST_ENV_CONFIG_CLASS_NAME = "spanner.testenv.config.class"; + public static final String CONFIG_CLASS = System.getProperty(TEST_ENV_CONFIG_CLASS_NAME, null); + /** * Names a property that, if set, identifies an existing Cloud Spanner instance to use for tests. */ @@ -62,12 +64,11 @@ public RemoteSpannerHelper getTestHelper() { @SuppressWarnings("unchecked") protected void initializeConfig() throws ClassNotFoundException, InstantiationException, IllegalAccessException { - String configClassName = System.getProperty(TEST_ENV_CONFIG_CLASS_NAME, null); - if (configClassName == null) { + if (CONFIG_CLASS == null) { throw new NullPointerException("Property " + TEST_ENV_CONFIG_CLASS_NAME + " needs to be set"); } Class configClass; - configClass = (Class) Class.forName(configClassName); + configClass = (Class) Class.forName(CONFIG_CLASS); config = configClass.newInstance(); }