You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/09/22 11:24:21 UTC

[GitHub] [camel-quarkus] llowinge opened a new pull request #1818: Improve mock backend logging

llowinge opened a new pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818


   This PR is follow up to @ppalaga work in https://github.com/apache/camel-quarkus/pull/1782.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] llowinge commented on pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
llowinge commented on pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#issuecomment-696660667


   Currently blocked by https://github.com/quarkusio/quarkus/issues/12250


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga merged pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
ppalaga merged pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] llowinge commented on pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
llowinge commented on pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#issuecomment-696660667


   Currently blocked by https://github.com/quarkusio/quarkus/issues/12250


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#discussion_r494181758



##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       Oh, I see, it should be `CAMEL_QUARKUS_START_MOCK_BACKEND=false`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#discussion_r494180715



##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       I do not see an issue. What would you expect there?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#discussion_r494180715



##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       I do not see an issue. What would you expect there?

##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       Oh, I see, it should be `CAMEL_QUARKUS_START_MOCK_BACKEND=false`

##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       Thanks, good catch!




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] llowinge commented on a change in pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
llowinge commented on a change in pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#discussion_r494174661



##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       @ppalaga This is a typo ? `CAMEL_QUARKUS_FALLBACK_MOCK` ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] llowinge commented on a change in pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
llowinge commented on a change in pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#discussion_r494174661



##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       @ppalaga This is a typo ? `CAMEL_QUARKUS_FALLBACK_MOCK` ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #1818: Improve mock backend logging

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #1818:
URL: https://github.com/apache/camel-quarkus/pull/1818#discussion_r494181929



##########
File path: integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/TelegramRoutes.java
##########
@@ -21,37 +21,80 @@
 import java.io.InputStream;
 import java.util.stream.Stream;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import io.quarkus.arc.Unremovable;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.telegram.TelegramComponent;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class TelegramRoutes extends RouteBuilder {
 
+    @ConfigProperty(name = "telegram.authorization-token", defaultValue = "default-dummy-token")
+    String authToken;
+
+    @ConfigProperty(name = "quarkus.http.test-port")
+    int httpTestPort;
+    @ConfigProperty(name = "quarkus.http.port")
+    int httpPort;
+
+    private String getBaseUri() {
+        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+        return "default-dummy-token".equals(authToken)
+                ? "http://localhost:" + (isNativeMode ? httpPort : httpTestPort)
+                : "https://api.telegram.org";
+    }
+
+    /**
+     * We need to implement some conditional configuration of the {@link TelegramComponent} thus we create it
+     * programmatically and publish via CDI.
+     *
+     * @return a configured {@link TelegramComponent}
+     */
+    @Produces
+    @ApplicationScoped
+    @Unremovable
+    @Named
+    TelegramComponent telegram() {
+        final TelegramComponent result = new TelegramComponent();
+        result.setCamelContext(getContext());
+        result.setBaseUri(getBaseUri());
+        result.setAuthorizationToken(authToken);
+        return result;
+    }
+
     @Override
     public void configure() throws Exception {
+        if (MockBackendUtils.startMockBackend(true)) {
+            /* Start the mock Telegram API unless the user did export CAMEL_QUARKUS_FALLBACK_MOCK=false */

Review comment:
       Thanks, good catch!




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org