You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/03/02 09:36:04 UTC

[camel] 01/03: CAMEL-16241: Added unit test

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 19b6cca3fb0d8d73d02bcd2019ab731b4900fcd7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Mar 2 09:55:14 2021 +0100

    CAMEL-16241: Added unit test
---
 .../camel/builder/endpoint/HttpsBasicAuthTest.java | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpsBasicAuthTest.java b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpsBasicAuthTest.java
new file mode 100644
index 0000000..1677e08
--- /dev/null
+++ b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpsBasicAuthTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.camel.builder.endpoint;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.endpoint.dsl.HttpEndpointBuilderFactory;
+import org.apache.camel.component.http.HttpEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class HttpsBasicAuthTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testHttps() throws Exception {
+        context.start();
+
+        context.addRoutes(new EndpointRouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                HttpEndpointBuilderFactory.HttpEndpointBuilder builder
+                        = https("inline").authenticationPreemptive(true).authMethod("Basic")
+                        .authUsername("prop.username").authPassword("prop.password");
+
+                Endpoint endpoint = builder.resolve(context);
+                assertNotNull(endpoint);
+                HttpEndpoint he = assertIsInstanceOf(HttpEndpoint.class, endpoint);
+                assertEquals("prop.username", he.getAuthUsername());
+                assertEquals("prop.password", he.getAuthPassword());
+            }
+        });
+
+        context.stop();
+    }
+
+}