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 2022/06/10 05:58:21 UTC
[camel] branch main updated: CAMEL-18168: camel-main - Add test for configuring apiProperties on rest
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new cabcdfef050 CAMEL-18168: camel-main - Add test for configuring apiProperties on rest
cabcdfef050 is described below
commit cabcdfef05001386b99a801a102885e208c58725
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 10 07:58:11 2022 +0200
CAMEL-18168: camel-main - Add test for configuring apiProperties on rest
---
.../camel/main/MainRestConfigurationTest.java | 66 ++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainRestConfigurationTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainRestConfigurationTest.java
new file mode 100644
index 00000000000..9ccce0c1e18
--- /dev/null
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainRestConfigurationTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.main;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.spi.RestConfiguration;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MainRestConfigurationTest {
+
+ @Test
+ public void testRestConfiguration() {
+ Properties properties = new Properties();
+ properties.setProperty("camel.rest.component", "platform-http");
+ properties.setProperty("camel.rest.enableCORS", "true");
+ properties.setProperty("camel.rest.apiContextPath", "/openapi");
+ properties.setProperty("camel.rest.apiVendorExtension", "true");
+ properties.setProperty("camel.rest.apiProperties[dummyKey]", "Dummy Value");
+ properties.setProperty("camel.rest.apiProperties[api.title]", "My Title");
+ properties.setProperty("camel.rest.apiProperties[api.version]", "1.2.3");
+ properties.setProperty("camel.rest.apiProperties[base.path]", "/mybase");
+
+ Main main = new Main();
+ main.setOverrideProperties(properties);
+
+ try {
+ main.start();
+
+ RestConfiguration rf = main.getCamelContext().getRestConfiguration();
+ assertEquals("platform-http", rf.getComponent());
+ assertTrue(rf.isEnableCORS());
+ assertEquals("/openapi", rf.getApiContextPath());
+ assertTrue(rf.isApiVendorExtension());
+
+ Map<String, Object> map = rf.getApiProperties();
+ Assertions.assertNotNull(map);
+
+ assertEquals("Dummy Value", map.get("dummyKey"));
+ assertEquals("My Title", map.get("api.title"));
+ assertEquals("1.2.3", map.get("api.version"));
+ assertEquals("/mybase", map.get("base.path"));
+ } finally {
+ main.stop();
+ }
+ }
+}