Skip to content

Commit

Permalink
fix(java): adding resource and reflection configurations for native i…
Browse files Browse the repository at this point in the history
…mage testing (#809)

* fix(java): adding resource and reflection configurations for native image testing (#809)
  • Loading branch information
mpeddada1 authored May 31, 2022
1 parent 00ed2a8 commit 6126d4f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ integration)
;;
graalvm)
# Run Unit and Integration Tests with Native Image
mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test
mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test "-Dtest=com.google.cloud.spanner.jdbc.it.**"
RETURN_CODE=$?
;;
graalvm17)
# Run Unit and Integration Tests with Native Image
mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test
mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test "-Dtest=com.google.cloud.spanner.jdbc.it.**"
RETURN_CODE=$?
;;
samples)
Expand Down
3 changes: 2 additions & 1 deletion owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
'.github/release-please.yml',
'.github/sync-repo-settings.yaml',
'.github/blunderbuss.yml',
'.kokoro/nightly/integration.cfg'
'.kokoro/nightly/integration.cfg',
'.kokoro/build.sh'
])
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@
<exclude>com.google.cloud.spanner.jdbc.JdbcStatementTimeoutTest</exclude>
</excludes>
<reportNameSuffix>sponge_log</reportNameSuffix>
<systemPropertyVariables>
<spanner.testenv.config.class>
com.google.cloud.spanner.GceTestEnvConfig
</spanner.testenv.config.class>
<spanner.testenv.instance>
projects/gcloud-devel/instances/spanner-testing-east1
</spanner.testenv.instance>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -319,6 +327,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>org.graalvm.sdk:graal-sdk</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>com.google.api.grpc:grpc-google-cloud-spanner-v1</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>com.google.api.grpc:proto-google-cloud-spanner-admin-instance-v1</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>com.google.api.grpc:proto-google-cloud-spanner-admin-database-v1</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
<ignoredUnusedDeclaredDependencies>
<!-- TODO: Remove grpc-alts from ignored list once it has been removed from java-spanner -->
<ignoredDependency>io.grpc:grpc-alts</ignoredDependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Args = --initialize-at-build-time==com.google.cloud.spanner.IntegrationTestEnv,\
com.google.cloud.spanner.jdbc.it.JdbcIntegrationTestEnv,\
com.google.common.collect.RegularImmutableMap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"resources":{
"includes":[
{"pattern":".*.sql"},
{"pattern":".*.json"},
{"pattern":".*.txt"}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import com.google.cloud.spanner.testing.EmulatorSpannerHelper;
import com.google.common.base.Strings;
import com.google.common.io.BaseEncoding;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.math.BigDecimal;
import java.sql.BatchUpdateException;
Expand All @@ -54,7 +54,6 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;
import java.util.TimeZone;
import java.util.UUID;
Expand Down Expand Up @@ -1106,14 +1105,14 @@ private void assertDefaultParameterMetaData(ParameterMetaData pmd, int expectedP
}

private List<String> readValuesFromFile(String filename) {
File file = new File(Objects.requireNonNull(getClass().getResource(filename)).getFile());
StringBuilder builder = new StringBuilder();
try (Scanner scanner = new Scanner(file)) {
try (InputStream stream = ITJdbcPreparedStatementTest.class.getResourceAsStream(filename)) {
Scanner scanner = new Scanner(stream);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
builder.append(line).append("\n");
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
String[] array = builder.toString().split(";");
Expand Down

0 comments on commit 6126d4f

Please sign in to comment.