oscerd commented on code in PR #29828:
URL: https://github.com/apache/camel/pull/29828#discussion_r4584144020
##########
components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/integration/GoogleFirestoreITSupport.java:
##########
@@ -82,15 +82,31 @@ protected CamelContext createCamelContext() throws
Exception {
*/
protected void addFirestoreComponent(CamelContext context) {
GoogleFirestoreConfiguration configuration = new
GoogleFirestoreConfiguration();
+ configuration.setProjectId(service.projectId());
- if (SERVICE_ACCOUNT_KEY != null) {
- configuration.setServiceAccountKey("file:" + SERVICE_ACCOUNT_KEY);
- }
- if (PROJECT_ID != null) {
- configuration.setProjectId(PROJECT_ID);
- }
- if (DATABASE_ID != null) {
- configuration.setDatabaseId(DATABASE_ID);
+ if (isRemote()) {
+ configuration.setServiceAccountKey(
+ "file:" +
System.getProperty(GoogleFirestoreProperties.SERVICE_ACCOUNT_KEY));
Review Comment:
Done in f6e9355: with `-Dgoogle.instance.type=remote` and no
`google.firestore.serviceAccountKey`, the support class now fails with
`IllegalStateException: The google.firestore.serviceAccountKey system property
is required with -Dgoogle.instance.type=remote`, instead of passing `file:null`
to the component.
_Claude Code on behalf of Andrea Cosentino_
##########
components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/integration/GoogleFirestoreITSupport.java:
##########
@@ -82,15 +82,31 @@ protected CamelContext createCamelContext() throws
Exception {
*/
protected void addFirestoreComponent(CamelContext context) {
GoogleFirestoreConfiguration configuration = new
GoogleFirestoreConfiguration();
+ configuration.setProjectId(service.projectId());
- if (SERVICE_ACCOUNT_KEY != null) {
- configuration.setServiceAccountKey("file:" + SERVICE_ACCOUNT_KEY);
- }
- if (PROJECT_ID != null) {
- configuration.setProjectId(PROJECT_ID);
- }
- if (DATABASE_ID != null) {
- configuration.setDatabaseId(DATABASE_ID);
+ if (isRemote()) {
+ configuration.setServiceAccountKey(
+ "file:" +
System.getProperty(GoogleFirestoreProperties.SERVICE_ACCOUNT_KEY));
+ String databaseId =
System.getProperty(GoogleFirestoreProperties.DATABASE_ID);
+ if (databaseId != null) {
+ configuration.setDatabaseId(databaseId);
+ }
+ } else {
+ // Floci GCP is reached as an emulator: in plain text, with any
credentials
+ Firestore client = FirestoreOptions.newBuilder()
+ .setProjectId(service.projectId())
+ .setEmulatorHost(service.endpoint())
+ .build()
+ .getService();
+ configuration.setFirestoreClient(client);
+ // the endpoints do not close a client that they did not build: it
goes with the context
+
context.addLifecycleStrategy(LifecycleStrategySupport.adapt((OnCamelContextStopped)
stopped -> {
+ try {
+ client.close();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
Review Comment:
Done in f6e9355: the close is best-effort cleanup of the client that the
test injected, so a failure is now logged as a warning instead of being thrown
from the `OnCamelContextStopped` callback.
_Claude Code on behalf of Andrea Cosentino_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]