index
int64 0
0
| repo_id
stringlengths 9
205
| file_path
stringlengths 31
246
| content
stringlengths 1
12.2M
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-yaml/src/main/java/org/apache/camel/k/quarkus/it
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-yaml/src/main/java/org/apache/camel/k/quarkus/it/support/MyBean.java
|
/*
* 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.k.quarkus.it.support;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class MyBean {
private String name;
public MyBean() {
}
public MyBean(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "MyBean{" +
"name='" + name + '\'' +
'}';
}
}
| 3,500 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeCustomizerIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class RuntimeCustomizerIT extends RuntimeCustomizerTest {
}
| 3,501 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeCustomizerFallbackIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class RuntimeCustomizerFallbackIT extends RuntimeCustomizerFallbackTest {
}
| 3,502 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeCustomizerFallbackTest.java
|
/*
* 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.k.quarkus.it;
import java.util.Map;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.path.json.JsonPath;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.apache.camel.util.CollectionHelper.mapOf;
import static org.assertj.core.api.Assertions.assertThat;
@TestProfile(RuntimeCustomizerFallbackTest.Profile.class)
@QuarkusTest
public class RuntimeCustomizerFallbackTest {
@Test
public void testContextCustomizerFromPropertiesFallback() {
JsonPath p = given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect/context")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getBoolean("message-history")).isFalse();
assertThat(p.getBoolean("load-type-converters")).isFalse();
}
public static class Profile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return mapOf(
"customizer.test.enabled", "true",
"customizer.test.message-history", "false"
);
}
}
}
| 3,503 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
|
/*
* 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.k.quarkus.it;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.path.json.JsonPath;
import org.apache.camel.k.quarkus.Application;
import org.apache.camel.quarkus.core.FastCamelContext;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
@QuarkusTest
public class RuntimeTest {
@Test
public void inspect() {
JsonPath p = given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getString("camel-context"))
.isEqualTo(FastCamelContext.class.getName());
assertThat(p.getString("camel-k-runtime"))
.isEqualTo(Application.Runtime.class.getName());
assertThat(p.getString("routes-collector"))
.isEqualTo(Application.NoRoutesCollector.class.getName());
}
@Test
public void properties() {
given().get("/test/property/my-property").then().statusCode(200).body(is("my-test-value"));
given().get("/test/property/root.key").then().statusCode(200).body(is("root.value"));
given().get("/test/property/001.key").then().statusCode(200).body(is("001.value"));
given().get("/test/property/002.key").then().statusCode(200).body(is("002.value"));
given().get("/test/property/a.key").then().statusCode(200).body(is("a.002"));
given().get("/test/property/flat-property").then().statusCode(200).body(is("flat-value"));
}
}
| 3,504 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeCustomizerTest.java
|
/*
* 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.k.quarkus.it;
import java.util.Map;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.path.json.JsonPath;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.apache.camel.util.CollectionHelper.mapOf;
import static org.assertj.core.api.Assertions.assertThat;
@TestProfile(RuntimeCustomizerTest.Profile.class)
@QuarkusTest
public class RuntimeCustomizerTest {
@Test
public void testContextCustomizerFromProperties() {
JsonPath p = given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect/context")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getBoolean("message-history")).isFalse();
assertThat(p.getBoolean("load-type-converters")).isFalse();
}
public static class Profile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return mapOf(
"camel.k.customizer.test.enabled", "true",
"camel.k.customizer.test.message-history", "false"
);
}
}
}
| 3,505 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class RuntimeIT extends RuntimeTest {
}
| 3,506 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it/Application.java
|
/*
* 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.k.quarkus.it;
import java.util.Collections;
import java.util.Map;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.component.properties.PropertiesComponent;
import org.apache.camel.k.Runtime;
import org.apache.camel.main.BaseMainSupport;
import org.apache.camel.quarkus.main.CamelMain;
import static org.apache.camel.k.quarkus.Application.instance;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext camelContext;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public JsonObject inspect() {
return Json.createObjectBuilder()
.add(
"camel-context",
instance(CamelContext.class).map(Object::getClass).map(Class::getName).orElse(""))
.add(
"camel-k-runtime",
instance(Runtime.class).map(Object::getClass).map(Class::getName).orElse(""))
.add(
"routes-collector",
instance(CamelMain.class).map(BaseMainSupport::getRoutesCollector).map(Object::getClass).map(Class::getName).orElse(""))
.add(
"global-options",
Json.createObjectBuilder(
(Map) instance(CamelMain.class)
.map(BaseMainSupport::getCamelContext)
.map(CamelContext::getGlobalOptions)
.orElseGet(Collections::emptyMap))
.build())
.build();
}
@GET
@Path("/inspect/context")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspectContext() {
return Json.createObjectBuilder()
.add("message-history", camelContext.isMessageHistory())
.add("load-type-converters", camelContext.isLoadTypeConverters())
.add("name", camelContext.getName())
.build();
}
@GET
@Path("/property/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String property(@PathParam("name") String name) {
return instance(CamelContext.class)
.map(CamelContext::getPropertiesComponent)
.map(PropertiesComponent.class::cast)
.flatMap(pc -> pc.resolveProperty(name)).orElse("");
}
@SuppressWarnings("unchecked")
@GET
@Path("/properties")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject properties() {
return Json.createObjectBuilder(
instance(CamelContext.class)
.map(CamelContext::getPropertiesComponent)
.map(PropertiesComponent.class::cast)
.map(PropertiesComponent::loadProperties)
.map(Map.class::cast)
.orElseGet(Collections::emptyMap)
).build();
}
}
| 3,507 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it/support/TestCustomizer.java
|
/*
* 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.k.quarkus.it.support;
import org.apache.camel.CamelContext;
import org.apache.camel.k.ContextCustomizer;
public class TestCustomizer implements ContextCustomizer {
private boolean messageHistory = true;
public boolean isMessageHistory() {
return messageHistory;
}
public void setMessageHistory(boolean messageHistory) {
this.messageHistory = messageHistory;
}
@Override
public void apply(CamelContext camelContext) {
camelContext.setMessageHistory(messageHistory);
camelContext.setLoadTypeConverters(false);
}
}
| 3,508 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-xml/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-xml/src/test/java/org/apache/camel/k/quarkus/it/RuntimeWithXmlTest.java
|
/*
* 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.k.quarkus.it;
import java.util.Map;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.junit.jupiter.api.Test;
import static org.apache.camel.util.CollectionHelper.mapOf;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
@QuarkusTestResource(RuntimeWithXmlTest.Resources.class)
public class RuntimeWithXmlTest {
@Test
public void inspect() {
JsonPath p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/runtime/inspect")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("route-definitions", String.class))
.containsExactlyInAnyOrder("route-simple", "route-with-expression", "greetings");
assertThat(p.getList("rest-definitions", String.class))
.containsExactlyInAnyOrder("rest-greetings");
}
public static class Resources implements QuarkusTestResourceLifecycleManager {
@Override
public Map<String, String> start() {
final String res = System.getProperty("camel.k.test.dir.resources", ".");
return mapOf(
// sources
"camel.k.sources[0].location", "file:" + res + "/routes.xml",
"camel.k.sources[0].type", "source",
"camel.k.sources[1].location", "file:" + res + "/rests.xml",
"camel.k.sources[1].type", "source",
"camel.k.sources[2].location", "file:" + res + "/routes-with-expression.xml",
"camel.k.sources[2].type", "source",
// misc
"the.body", "10"
);
}
@Override
public void stop() {
}
}
}
| 3,509 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-xml/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-xml/src/test/java/org/apache/camel/k/quarkus/it/RuntimeWithXmlIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class RuntimeWithXmlIT extends RuntimeWithXmlTest {
}
| 3,510 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-xml/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-runtime-xml/src/main/java/org/apache/camel/k/quarkus/it/Application.java
|
/*
* 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.k.quarkus.it;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class Application {
}
| 3,511 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-sinkbinding/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-sinkbinding/src/test/java/org/apache/camel/k/quarkus/it/KnativeSinkBindingIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class KnativeSinkBindingIT extends KnativeSinkBindingTest {
}
| 3,512 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-sinkbinding/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-sinkbinding/src/test/java/org/apache/camel/k/quarkus/it/KnativeSinkBindingTest.java
|
/*
* 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.k.quarkus.it;
import java.util.Map;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.component.knative.spi.Knative;
import org.junit.jupiter.api.Test;
import static org.apache.camel.util.CollectionHelper.mapOf;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTestResource(KnativeSinkBindingTest.Resource.class)
@QuarkusTest
public class KnativeSinkBindingTest {
@Test
public void sinkbinding() {
JsonPath p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/customizers/sinkbinding")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getString("name")).isEqualTo("mychannel");
assertThat(p.getString("type")).isEqualTo(Knative.Type.channel.name());
assertThat(p.getString("apiVersion")).isEqualTo("messaging.knative.dev/v1beta1");
assertThat(p.getString("kind")).isEqualTo("InMemoryChannel");
}
@Test
public void resources() {
JsonPath p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/resource/mychannel")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getString("url")).isEqualTo("http://theurl");
assertThat(p.getString("name")).isEqualTo("mychannel");
assertThat(p.getString("type")).isEqualTo(Knative.Type.channel.name());
assertThat(p.getString("apiVersion")).isEqualTo("messaging.knative.dev/v1beta1");
assertThat(p.getString("kind")).isEqualTo("InMemoryChannel");
}
public static final class Resource implements QuarkusTestResourceLifecycleManager {
@Override
public Map<String, String> start() {
return mapOf(
"k.sink", "http://theurl",
"camel.k.customizer.sinkbinding.enabled", "true",
"camel.k.customizer.sinkbinding.name", "mychannel",
"camel.k.customizer.sinkbinding.type", "channel",
"camel.k.customizer.sinkbinding.kind", "InMemoryChannel",
"camel.k.customizer.sinkbinding.api-version", "messaging.knative.dev/v1beta1"
);
}
@Override
public void stop() {
}
}
}
| 3,513 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-sinkbinding/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-sinkbinding/src/main/java/org/apache/camel/k/quarkus/it/KnativeSinkBindingApplication.java
|
/*
* 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.k.quarkus.it;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.component.knative.spi.KnativeResource;
import org.apache.camel.k.knative.customizer.KnativeSinkBindingContextCustomizer;
@Path("/test")
@ApplicationScoped
public class KnativeSinkBindingApplication {
@Inject
CamelContext context;
@GET
@Path("/customizers/sinkbinding")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject sinkbindingCustomizer() {
var customizer = context.getRegistry().lookupByNameAndType("sinkbinding", KnativeSinkBindingContextCustomizer.class);
if (customizer == null) {
return Json.createObjectBuilder().build();
}
return Json.createObjectBuilder()
.add("name", customizer.getName())
.add("apiVersion", customizer.getApiVersion())
.add("kind", customizer.getKind())
.add("type", customizer.getType().name())
.build();
}
@GET
@Path("/resource/{name}")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject resource(@PathParam("name") String name) {
var resource = context.getRegistry().lookupByNameAndType(name, KnativeResource.class);
if (resource == null) {
return Json.createObjectBuilder().build();
}
return Json.createObjectBuilder()
.add("url", resource.getUrl())
.add("name", resource.getName())
.add("type", resource.getType().name())
.add("apiVersion", resource.getObjectApiVersion())
.add("kind", resource.getObjectKind())
.build();
}
}
| 3,514 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class KnativeIT extends KnativeTest {
}
| 3,515 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java
|
/*
* 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.k.quarkus.it;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory;
import org.apache.camel.component.knative.http.KnativeHttpProducerFactory;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class KnativeTest {
@Test
public void inspect() {
JsonPath p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getString("consumer-factory"))
.isEqualTo(KnativeHttpConsumerFactory.class.getName());
assertThat(p.getString("producer-factory"))
.isEqualTo(KnativeHttpProducerFactory.class.getName());
}
}
| 3,516 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java
|
/*
* 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.k.quarkus.it;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.runtime.annotations.RegisterForReflection;
import org.apache.camel.CamelContext;
import org.apache.camel.component.knative.KnativeComponent;
@RegisterForReflection(targets = { String.class })
@Path("/test")
@ApplicationScoped
public class KnativeApplication {
@Inject
CamelContext context;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
return Json.createObjectBuilder()
.add("producer-factory", context.getComponent("knative", KnativeComponent.class).getProducerFactory().getClass().getName())
.add("consumer-factory", context.getComponent("knative", KnativeComponent.class).getConsumerFactory().getClass().getName())
.build();
}
}
| 3,517 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-consumer/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-consumer/src/test/java/org/apache/camel/k/quarkus/it/KnativeConsumerTest.java
|
/*
* 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.k.quarkus.it;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory;
import org.apache.camel.component.knative.http.KnativeHttpProducerFactory;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class KnativeConsumerTest {
@Test
public void inspect() {
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getString("consumer-factory"))
.isEqualTo(KnativeHttpConsumerFactory.class.getName());
assertThat(p.getString("producer-factory"))
.isEqualTo(KnativeHttpProducerFactory.class.getName());
}
}
| 3,518 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-consumer/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-consumer/src/test/java/org/apache/camel/k/quarkus/it/KnativeConsumerIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class KnativeConsumerIT extends KnativeConsumerTest {
}
| 3,519 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-consumer/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-consumer/src/main/java/org/apache/camel/k/quarkus/it/KnativeConsumerApplication.java
|
/*
* 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.k.quarkus.it;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.component.knative.KnativeComponent;
@Path("/test")
@ApplicationScoped
public class KnativeConsumerApplication {
@Inject
CamelContext context;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
var component = context.getComponent("knative", KnativeComponent.class);
var builder = Json.createObjectBuilder();
if (component.getProducerFactory() != null) {
builder.add("producer-factory", component.getProducerFactory().getClass().getName());
}
if (component.getConsumerFactory() != null) {
builder.add("consumer-factory", component.getConsumerFactory().getClass().getName());
}
return builder.build();
}
}
| 3,520 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-registry/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-registry/src/test/java/org/apache/camel/k/quarkus/it/KnativeEnvFromRegistryIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class KnativeEnvFromRegistryIT extends KnativeEnvFromRegistryTest {
}
| 3,521 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-registry/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-registry/src/test/java/org/apache/camel/k/quarkus/it/KnativeEnvFromRegistryTest.java
|
/*
* 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.k.quarkus.it;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import org.apache.camel.Exchange;
import org.apache.camel.component.cloudevents.CloudEvent;
import org.apache.camel.component.cloudevents.CloudEvents;
import org.apache.camel.component.knative.spi.Knative;
import org.apache.camel.component.knative.spi.KnativeResource;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
@QuarkusTest
public class KnativeEnvFromRegistryTest {
@Test
public void inspect() {
KnativeResource p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.as(KnativeResource.class);
assertThat(p.getEndpointKind()).isEqualTo(Knative.EndpointKind.source);
assertThat(p.getMetadata()).containsEntry(Knative.KNATIVE_CLOUD_EVENT_TYPE, "camel.k.evt");
assertThat(p.getMetadata()).containsEntry(Knative.SERVICE_META_PATH, "/knative");
}
@Test
public void invokeEndpoint() {
final String payload = "test";
given()
.body(payload)
.header(Exchange.CONTENT_TYPE, "text/plain")
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_VERSION), CloudEvents.v1_0.version())
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TYPE), "org.apache.camel.event")
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_ID), "myEventID")
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TIME), DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()))
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE), "/somewhere")
.when()
.post("/knative")
.then()
.statusCode(200)
.body(is(payload.toUpperCase()));
}
@Test
public void invokeRoute() {
final String payload = "hello";
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
.body(payload)
.post("/test/execute")
.then()
.statusCode(200)
.body(is(payload.toUpperCase()));
}
}
| 3,522 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-registry/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-registry/src/main/java/org/apache/camel/k/quarkus/it/KnativeEnvFromRegistryApplication.java
|
/*
* 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.k.quarkus.it;
import java.util.Objects;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.bind.JsonbBuilder;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.runtime.annotations.RegisterForReflection;
import org.apache.camel.CamelContext;
import org.apache.camel.FluentProducerTemplate;
import org.apache.camel.component.knative.KnativeEndpoint;
import org.apache.camel.component.knative.spi.Knative;
import org.apache.camel.component.knative.spi.KnativeEnvironment;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@RegisterForReflection(targets = { String.class })
@Path("/test")
@ApplicationScoped
public class KnativeEnvFromRegistryApplication {
@Inject
CamelContext context;
@Inject
FluentProducerTemplate template;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public String inspect() {
return context.getEndpoint("knative:endpoint/from", KnativeEndpoint.class)
.getConfiguration()
.getEnvironment()
.lookup(Knative.Type.endpoint, "from")
.filter(entry -> Objects.equals(Knative.EndpointKind.source, entry.getEndpointKind()))
.findFirst()
.map(def -> JsonbBuilder.create().toJson(def))
.orElseThrow(IllegalArgumentException::new);
}
@POST
@Path("/execute")
@Produces(MediaType.TEXT_PLAIN)
public String execute(String payload) {
return template.to("direct:process").withBody(payload).request(String.class);
}
@jakarta.enterprise.inject.Produces
KnativeEnvironment environment(
@ConfigProperty(name = "camel.knative.listening.port") int port) {
return KnativeEnvironment.on(
KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, "process")
.withEndpointKind(Knative.EndpointKind.source)
.withMeta(Knative.SERVICE_META_PATH, "/knative")
.build(),
KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, "from")
.withEndpointKind(Knative.EndpointKind.source)
.withMeta(Knative.SERVICE_META_PATH, "/knative")
.withMeta(Knative.KNATIVE_CLOUD_EVENT_TYPE, "camel.k.evt")
.build(),
KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, "process")
.withEndpointKind(Knative.EndpointKind.sink)
.withMeta(Knative.SERVICE_META_URL, String.format("http://localhost:%d/knative", port))
.build()
);
}
}
| 3,523 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-kamelet/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
|
/*
* 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.k.quarkus.it;
import java.util.Locale;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
@QuarkusTest
public class RuntimeTest {
@Test
public void inspect() {
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("templates", String.class)).containsExactlyInAnyOrder("to-upper", "set-body");
}
@Test
public void invokeProcess() {
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
.get("/test/execute/process")
.then()
.statusCode(200)
.body(is("template"));
}
@Test
public void invokeProcessWithParams() {
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
.get("/test/execute/process-params")
.then()
.statusCode(200)
.body(is("template"));
}
@Test
public void executeTemplate() {
final String payload = "test";
String result = given()
.body(payload)
.header(Exchange.CONTENT_TYPE, "text/plain")
.when()
.post("/test/execute/{templateId}", "to-upper")
.then()
.statusCode(200)
.extract()
.asString();
assertThat(result).isEqualTo(payload.toUpperCase(Locale.US));
}
}
| 3,524 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-kamelet/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class RuntimeIT extends RuntimeTest {
}
| 3,525 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-kamelet/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-kamelet/src/main/java/org/apache/camel/k/quarkus/it/Application.java
|
/*
* 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.k.quarkus.it;
import java.util.stream.Collectors;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.runtime.annotations.RegisterForReflection;
import org.apache.camel.CamelContext;
import org.apache.camel.FluentProducerTemplate;
import org.apache.camel.model.Model;
import org.apache.camel.model.RouteTemplateDefinition;
@RegisterForReflection(targets = { String.class })
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@Inject
FluentProducerTemplate template;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
var templates = context.getCamelContextExtension().getContextPlugin(Model.class).getRouteTemplateDefinitions();
var ids = templates.stream().map(RouteTemplateDefinition::getId).collect(Collectors.toList());
return Json.createObjectBuilder()
.add("templates", Json.createArrayBuilder(ids))
.build();
}
@GET
@Path("/execute/{id}")
@Produces(MediaType.TEXT_PLAIN)
public String execute(@PathParam("id") String id) {
return template.to("direct:" + id).request(String.class);
}
@POST
@Path("/execute/{templateId}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String invoke(@PathParam("templateId") String templateId, String message) {
return template.toF("kamelet:%s/test?message=%s", templateId, message).request(String.class);
}
}
| 3,526 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-properties/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-properties/src/test/java/org/apache/camel/k/quarkus/it/KnativeEnvFromPropertiesTest.java
|
/*
* 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.k.quarkus.it;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import org.apache.camel.Exchange;
import org.apache.camel.component.cloudevents.CloudEvent;
import org.apache.camel.component.cloudevents.CloudEvents;
import org.apache.camel.component.knative.spi.Knative;
import org.apache.camel.component.knative.spi.KnativeResource;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
@QuarkusTest
public class KnativeEnvFromPropertiesTest {
@Test
public void inspect() {
KnativeResource p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.as(KnativeResource.class);
assertThat(p.getEndpointKind()).isEqualTo(Knative.EndpointKind.source);
assertThat(p.getCloudEventType()).isEqualTo("camel.k.evt");
assertThat(p.getPath()).isEqualTo("/knative");
}
@Test
public void invokeEndpoint() {
final String payload = "test";
given()
.body(payload)
.header(Exchange.CONTENT_TYPE, "text/plain")
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_VERSION), CloudEvents.v1_0.version())
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TYPE), "org.apache.camel.event")
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_ID), "myEventID")
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TIME), DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()))
.header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE), "/somewhere")
.when()
.post("/knative")
.then()
.statusCode(200)
.body(is(payload.toUpperCase()));
}
@Test
public void invokeRoute() {
final String payload = "hello";
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
.body(payload)
.post("/test/execute")
.then()
.statusCode(200)
.body(is(payload.toUpperCase()));
}
}
| 3,527 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-properties/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-properties/src/test/java/org/apache/camel/k/quarkus/it/KnativeEnvFromPropertiesIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class KnativeEnvFromPropertiesIT extends KnativeEnvFromPropertiesTest {
}
| 3,528 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-properties/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-env-from-properties/src/main/java/org/apache/camel/k/quarkus/it/KnativeEnvFromPropertiesApplication.java
|
/*
* 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.k.quarkus.it;
import java.util.Objects;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.bind.JsonbBuilder;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.runtime.annotations.RegisterForReflection;
import org.apache.camel.CamelContext;
import org.apache.camel.FluentProducerTemplate;
import org.apache.camel.component.knative.KnativeEndpoint;
import org.apache.camel.component.knative.spi.Knative;
@RegisterForReflection(targets = { String.class })
@Path("/test")
@ApplicationScoped
public class KnativeEnvFromPropertiesApplication {
@Inject
CamelContext context;
@Inject
FluentProducerTemplate template;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public String inspect() {
return context.getEndpoint("knative:endpoint/from", KnativeEndpoint.class)
.getConfiguration()
.getEnvironment()
.lookup(Knative.Type.endpoint, "from")
.filter(entry -> Objects.equals(Knative.EndpointKind.source, entry.getEndpointKind()))
.findFirst()
.map(def -> JsonbBuilder.create().toJson(def))
.orElseThrow(IllegalArgumentException::new);
}
@POST
@Path("/execute")
@Produces(MediaType.TEXT_PLAIN)
public String execute(String payload) {
return template.to("direct:process").withBody(payload).request(String.class);
}
}
| 3,529 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-cron/src/test/java/org/apache/camel/k/quarkus/cron
|
Create_ds/camel-k-runtime/itests/camel-k-itests-cron/src/test/java/org/apache/camel/k/quarkus/cron/deployment/CronTest.java
|
/*
* 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.k.quarkus.cron.deployment;
import java.util.concurrent.TimeUnit;
import io.quarkus.test.junit.QuarkusTest;
import org.apache.camel.k.cron.CronSourceLoaderInterceptor;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.when;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.is;
@QuarkusTest
public class CronTest {
@Test
public void cronInterceptorIsRegistered() {
when()
.get("/test/find-cron-interceptor")
.then()
.statusCode(200)
.body(is(CronSourceLoaderInterceptor.class.getName()));
}
@Test
public void cronInvokesShutdown() {
when()
.get("/test/load")
.then()
.statusCode(200)
.body(is("1"));
await().atMost(10, TimeUnit.SECONDS).until(() -> {
String result = when()
.get("/test/stopped")
.then()
.statusCode(200)
.extract().body().asString();
return "true".equals(result);
});
}
}
| 3,530 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-cron/src/test/java/org/apache/camel/k/quarkus/cron
|
Create_ds/camel-k-runtime/itests/camel-k-itests-cron/src/test/java/org/apache/camel/k/quarkus/cron/deployment/CronIT.java
|
/*
* 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.k.quarkus.cron.deployment;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class CronIT extends CronTest {
}
| 3,531 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-cron/src/main/java/org/apache/camel/k/quarkus/cron
|
Create_ds/camel-k-runtime/itests/camel-k-itests-cron/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java
|
/*
* 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.k.quarkus.cron.deployment;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader;
import org.apache.camel.k.Runtime;
import org.apache.camel.k.cron.CronSourceLoaderInterceptor;
import org.apache.camel.k.support.Constants;
import org.apache.camel.k.support.DelegatingRuntime;
import org.apache.camel.support.ResourceHelper;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@Inject
Runtime runtime;
private final AtomicBoolean stopped = new AtomicBoolean();
@GET
@Path("/find-cron-interceptor")
@Produces(MediaType.TEXT_PLAIN)
public String findCronInterceptor() {
return context.getCamelContextExtension()
.getFactoryFinder(Constants.SOURCE_LOADER_INTERCEPTOR_RESOURCE_PATH)
.findClass("cron")
.map(Class::getName)
.orElse("");
}
@GET
@Path("/load")
@Produces(MediaType.TEXT_PLAIN)
public String load() throws Exception {
final String code = ""
+ "\n- from:"
+ "\n uri: \"timer:tick?period=1&delay=60000\""
+ "\n steps:"
+ "\n - log: \"${body}\"";
final YamlRoutesBuilderLoader loader = new YamlRoutesBuilderLoader();
loader.setCamelContext(context);
loader.build();
final Runtime rt = new DelegatingRuntime(runtime) {
@Override
public void stop() throws Exception {
stopped.set(true);
}
};
final CronSourceLoaderInterceptor interceptor = new CronSourceLoaderInterceptor();
interceptor.setRuntime(rt);
interceptor.setOverridableComponents("timer");
final RouteBuilder builder = (RouteBuilder)loader.loadRoutesBuilder(
ResourceHelper.fromBytes(
"my-cron.yaml",
code.getBytes(StandardCharsets.UTF_8)
)
);
builder.addLifecycleInterceptor(interceptor);
try {
context.addRoutes(builder);
} catch (Exception e) {
throw new RuntimeException(e);
}
return "" + context.getRoutesSize();
}
@GET
@Path("/stopped")
@Produces(MediaType.TEXT_PLAIN)
public String stopped() {
return "" + stopped.get();
}
}
| 3,532 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/XmlLoaderTest.java
|
/*
* 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.k.loader.xml.quarkus;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class XmlLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;
try (InputStream is = XmlLoaderTest.class.getResourceAsStream("/routes.xml")) {
code = IOHelper.loadText(is);
}
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoute")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains("xml");
assertThat(p.getList("endpoints", String.class)).contains("direct://xml", "log://xml");
}
}
| 3,533 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/XmlLoaderIT.java
|
/*
* 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.k.loader.xml.quarkus;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class XmlLoaderIT extends XmlLoaderTest {
}
| 3,534 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/Application.java
|
/*
* 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.k.loader.xml.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".xml", code);
}
}
| 3,535 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-jsh/src/test/java/org/apache/camel/k/loader/jsh
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-jsh/src/test/java/org/apache/camel/k/loader/jsh/it/JshLoaderTest.java
|
/*
* 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.k.loader.jsh.it;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
//@Disabled
@DisabledOnIntegrationTest
@QuarkusTest
public class JshLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;
try (InputStream is = JshLoaderTest.class.getResourceAsStream("/routes.jsh")) {
code = IOHelper.loadText(is);
}
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/routes")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
//assertThat(p.getList("components", String.class)).contains("direct", "log");
//assertThat(p.getList("routes", String.class)).contains("jsh");
//assertThat(p.getList("endpoints", String.class)).contains("direct://jsh", "log://jsh");
}
}
| 3,536 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-jsh/src/main/java/org/apache/camel/k/loader/jsh/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-jsh/src/main/java/org/apache/camel/k/loader/jsh/quarkus/it/JshApplication.java
|
/*
* 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.k.loader.jsh.quarkus.it;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class JshApplication {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".jsh", code);
}
}
| 3,537 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/YamlLoaderIT.java
|
/*
* 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.k.loader.yaml.quarkus;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class YamlLoaderIT extends YamlLoaderTest {
}
| 3,538 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/YamlLoaderTest.java
|
/*
* 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.k.loader.yaml.quarkus;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class YamlLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;
try (InputStream is = YamlLoaderTest.class.getResourceAsStream("/routes.yaml")) {
code = IOHelper.loadText(is);
}
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoute")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class))
.contains("direct", "log");
assertThat(p.getList("routes", String.class))
.contains("yaml");
assertThat(p.getList("endpoints", String.class))
.contains("direct://yaml", "log://yaml");
}
}
| 3,539 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java
|
/*
* 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.k.loader.yaml.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".yaml", code);
}
}
| 3,540 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-kotlin/src/test/java/org/apache/camel/k/loader/kotlin
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-kotlin/src/test/java/org/apache/camel/k/loader/kotlin/quarkus/KotlinLoaderTest.java
|
/*
* 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.k.loader.kotlin.quarkus;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class KotlinLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;
try (InputStream is = KotlinLoaderTest.class.getResourceAsStream("/routes.kts")) {
code = IOHelper.loadText(is);
}
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoute")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains("kotlin");
assertThat(p.getList("endpoints", String.class)).contains("direct://kotlin", "log://kotlin");
}
}
| 3,541 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-kotlin/src/main/java/org/apache/camel/k/loader/kotlin
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-kotlin/src/main/java/org/apache/camel/k/loader/kotlin/quarkus/Application.java
|
/*
* 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.k.loader.kotlin.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".kts", code);
}
}
| 3,542 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-core/src/test/java/org/apache/camel/k/core/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java
|
/*
* 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.k.core.quarkus.deployment;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.k.listener.ContextConfigurer;
import org.apache.camel.k.listener.SourcesConfigurer;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class CoreTest {
@Test
public void testServices() {
JsonPath p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
.get("/test/services")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("services", String.class)).contains(
ContextConfigurer.class.getName(),
SourcesConfigurer.class.getName()
);
}
}
| 3,543 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-core/src/test/java/org/apache/camel/k/core/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreIT.java
|
/*
* 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.k.core.quarkus.deployment;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class CoreIT extends org.apache.camel.k.core.quarkus.deployment.CoreTest {
}
| 3,544 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-core/src/main/java/org/apache/camel/k/core/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-core/src/main/java/org/apache/camel/k/core/quarkus/deployment/Application.java
|
/*
* 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.k.core.quarkus.deployment;
import java.util.ServiceLoader;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.Runtime;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext camelContext;
@GET
@Path("/services")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getServices() {
JsonArrayBuilder builder = Json.createArrayBuilder();
ServiceLoader.load(Runtime.Listener.class).forEach(listener -> {
builder.add(listener.getClass().getName());
});
return Json.createObjectBuilder()
.add("services", builder)
.build();
}
}
| 3,545 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-js/src/test/java/org/apache/camel/k/loader/js
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/JavaScriptLoaderIT.java
|
/*
* 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.k.loader.js.quarkus;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class JavaScriptLoaderIT extends JavaScriptLoaderTest {
}
| 3,546 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-js/src/test/java/org/apache/camel/k/loader/js
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/JavaScriptLoaderTest.java
|
/*
* 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.k.loader.js.quarkus;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class JavaScriptLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;
try (InputStream is = JavaScriptLoaderTest.class.getResourceAsStream("/routes.js")) {
code = IOHelper.loadText(is);
}
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoute")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains("js");
assertThat(p.getList("endpoints", String.class)).contains("direct://js", "log://js");
}
}
| 3,547 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-js/src/main/java/org/apache/camel/k/loader/js
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/Application.java
|
/*
* 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.k.loader.js.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".js", code);
}
}
| 3,548 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-java/src/test
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-java/src/test/resources/MyRoutes.java
|
/*
* 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.
*/
import org.apache.camel.builder.RouteBuilder;
public class MyRoutes extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:java")
.routeId("java")
.to("log:java");
}
}
| 3,549 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-java/src/test/java/org/apache/camel/k/loader
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-java/src/test/java/org/apache/camel/k/loader/jsh/JavaLoaderTest.java
|
/*
* 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.k.loader.jsh;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@DisabledOnIntegrationTest
@QuarkusTest
public class JavaLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;
try (InputStream is = JavaLoaderTest.class.getResourceAsStream("/MyRoutes.java")) {
code = IOHelper.loadText(is);
}
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoutes")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains("java");
assertThat(p.getList("endpoints", String.class)).contains("direct://java", "log://java");
}
}
| 3,550 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-java/src/main/java/org/apache/camel/k/loader/jsh
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-java/src/main/java/org/apache/camel/k/loader/jsh/quarkus/Application.java
|
/*
* 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.k.loader.jsh.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".java", code);
}
}
| 3,551 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-groovy/src/test/java/org/apache/camel/k/loader/yaml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-groovy/src/test/java/org/apache/camel/k/loader/yaml/quarkus/GroovyLoaderTest.java
|
/*
* 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.k.loader.yaml.quarkus;
import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@DisabledOnIntegrationTest
@QuarkusTest
public class GroovyLoaderTest {
String code;
@BeforeEach
public void setUpRoute() throws IOException {
try (InputStream is = GroovyLoaderTest.class.getResourceAsStream("/routes.groovy")) {
code = IOHelper.loadText(is);
}
}
@Test
public void testLoadRoutes() throws IOException {
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoute")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains("groovy");
assertThat(p.getList("endpoints", String.class)).contains("direct://groovy", "log://groovy");
}
}
| 3,552 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-groovy/src/main/java/org/apache/camel/k/loader/yaml
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-groovy/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java
|
/*
* 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.k.loader.yaml.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{name}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name + ".groovy", code);
}
}
| 3,553 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-producer/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-producer/src/test/java/org/apache/camel/k/quarkus/it/KnativeProducerIT.java
|
/*
* 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.k.quarkus.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class KnativeProducerIT extends KnativeProducerTest {
}
| 3,554 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-producer/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-producer/src/test/java/org/apache/camel/k/quarkus/it/KnativeProducerTest.java
|
/*
* 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.k.quarkus.it;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory;
import org.apache.camel.component.knative.http.KnativeHttpProducerFactory;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class KnativeProducerTest {
@Test
public void inspect() {
JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.get("/test/inspect")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getString("consumer-factory"))
.isEqualTo(KnativeHttpConsumerFactory.class.getName());
assertThat(p.getString("producer-factory"))
.isEqualTo(KnativeHttpProducerFactory.class.getName());
}
}
| 3,555 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-producer/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-knative-producer/src/main/java/org/apache/camel/k/quarkus/it/KnativeProducerApplication.java
|
/*
* 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.k.quarkus.it;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.component.knative.KnativeComponent;
@Path("/test")
@ApplicationScoped
public class KnativeProducerApplication {
@Inject
CamelContext context;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
var component = context.getComponent("knative", KnativeComponent.class);
var builder = Json.createObjectBuilder();
if (component.getProducerFactory() != null) {
builder.add("producer-factory", component.getProducerFactory().getClass().getName());
}
if (component.getConsumerFactory() != null) {
builder.add("consumer-factory", component.getConsumerFactory().getClass().getName());
}
return builder.build();
}
}
| 3,556 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-polyglot/src/test/java/org/apache/camel/k/itests/polyglot
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-polyglot/src/test/java/org/apache/camel/k/itests/polyglot/quarkus/PolyglotTest.java
|
/*
* 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.k.itests.polyglot.quarkus;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import jakarta.ws.rs.core.MediaType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class PolyglotTest {
@ParameterizedTest
@ValueSource(strings = { "yaml", "xml" })
public void loadRoute(String loaderName) throws IOException {
final byte[] code;
try (InputStream is = PolyglotTest.class.getResourceAsStream("/routes." + loaderName)) {
code = is.readAllBytes();
}
JsonPath p = RestAssured.given()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/{loaderName}/MyRoute", Map.of("loaderName", loaderName))
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();
assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains(loaderName);
assertThat(p.getList("endpoints", String.class)).contains("direct://" + loaderName, "log://" + loaderName);
}
}
| 3,557 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-polyglot/src/test/java/org/apache/camel/k/itests/polyglot
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-polyglot/src/test/java/org/apache/camel/k/itests/polyglot/quarkus/PolyglotIT.java
|
/*
* 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.k.itests.polyglot.quarkus;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class PolyglotIT extends PolyglotTest {
}
| 3,558 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-polyglot/src/main/java/org/apache/camel/k/itests/polyglot
|
Create_ds/camel-k-runtime/itests/camel-k-itests-loader-polyglot/src/main/java/org/apache/camel/k/itests/polyglot/quarkus/Application.java
|
/*
* 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.k.itests.polyglot.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.k.loader.support.LoaderSupport;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@POST
@Path("/load-routes/{loaderName}/{name}")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("loaderName") String loaderName, @PathParam("name") String name, byte[] code) throws Exception {
return LoaderSupport.inspectSource(context, name + "." + loaderName, code);
}
}
| 3,559 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-master/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-master/src/test/java/org/apache/camel/k/quarkus/master/MasterTest.java
|
/*
* 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.k.quarkus.master;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.path.json.JsonPath;
import org.apache.camel.support.cluster.RebalancingCamelClusterService;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.when;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
public class MasterTest {
@Test
public void hasClusterService() {
JsonPath path = when()
.get("/test/inspect")
.then()
.statusCode(200)
.extract().jsonPath();
assertThat(path.getString("cluster-service")).isEqualTo(RebalancingCamelClusterService.class.getName());
assertThat(path.getString("cluster-service-res")).isEqualTo("camel-k-res");
}
}
| 3,560 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-master/src/test/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-master/src/test/java/org/apache/camel/k/quarkus/master/MasterIT.java
|
/*
* 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.k.quarkus.master;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class MasterIT extends MasterTest {
}
| 3,561 |
0 |
Create_ds/camel-k-runtime/itests/camel-k-itests-master/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/itests/camel-k-itests-master/src/main/java/org/apache/camel/k/quarkus/master/Application.java
|
/*
* 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.k.quarkus.master;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.component.kubernetes.cluster.KubernetesClusterService;
import org.apache.camel.support.cluster.RebalancingCamelClusterService;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
var rebalancingService = context.hasService(RebalancingCamelClusterService.class);
var service = (KubernetesClusterService) rebalancingService.getDelegate();
return Json.createObjectBuilder()
.add("cluster-service", service != null ? rebalancingService.getClass().getName() : "")
.add("cluster-service-res", service != null ? service.getKubernetesResourceName() : "")
.build();
}
}
| 3,562 |
0 |
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/Application.java
|
/*
* 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.k.quarkus;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import io.quarkus.arc.Arc;
import io.quarkus.arc.ArcContainer;
import io.quarkus.arc.InstanceHandle;
import io.quarkus.runtime.Quarkus;
import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.main.BaseMainSupport;
import org.apache.camel.main.MainListener;
import org.apache.camel.main.RoutesCollector;
import org.apache.camel.spi.Resource;
public final class Application {
private Application() {
}
/**
* The camel-k runtime impl based on camel-quarkus
*/
public static class Runtime implements org.apache.camel.k.Runtime {
private final BaseMainSupport main;
private final AtomicBoolean stopped;
public Runtime(BaseMainSupport main) {
this.main = main;
this.main.configure().setAutoConfigurationLogSummary(false);
this.stopped = new AtomicBoolean();
}
@Override
public CamelContext getCamelContext() {
return main.getCamelContext();
}
@Override
public void addRoutes(RoutesBuilder builder) {
main.configure().addRoutesBuilder(builder);
}
@Override
public void setProperties(Properties properties) {
main.setOverrideProperties(properties);
}
@Override
public void stop() throws Exception {
if (!this.stopped.compareAndExchange(false, true)) {
Quarkus.asyncExit();
}
}
}
/**
* Adapts main events to camel-k runtime lifecycle
*/
public static class ListenerAdapter implements MainListener {
private final org.apache.camel.k.Runtime.Listener[] listeners;
public ListenerAdapter(List<org.apache.camel.k.Runtime.Listener> listeners) {
this.listeners = listeners.stream()
.sorted(Comparator.comparingInt(org.apache.camel.k.Runtime.Listener::getOrder))
.toArray(org.apache.camel.k.Runtime.Listener[]::new);
}
@Override
public void beforeInitialize(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.Initializing);
invokeListeners(org.apache.camel.k.Runtime.Phase.ConfigureProperties);
}
@Override
public void beforeConfigure(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.ConfigureRoutes);
}
@Override
public void afterConfigure(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.ConfigureContext);
}
@Override
public void beforeStart(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.Starting);
}
@Override
public void afterStart(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.Started);
}
@Override
public void beforeStop(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.Stopping);
}
@Override
public void afterStop(BaseMainSupport main) {
invokeListeners(org.apache.camel.k.Runtime.Phase.Stopped);
}
private void invokeListeners(org.apache.camel.k.Runtime.Phase phase) {
org.apache.camel.k.Runtime runtime = instance(org.apache.camel.k.Runtime.class)
.orElseThrow(() -> new IllegalStateException("Unable to fine a Runtime instance"));
for (int i = 0; i < listeners.length; i ++) {
listeners[i].accept(phase, runtime);
}
}
}
/**
* Since routes are programmatically loaded, create a no-hop collector
*/
public static class NoRoutesCollector implements RoutesCollector {
@Override
public Collection<RoutesBuilder> collectRoutesFromDirectory(CamelContext camelContext, String excludePattern, String includePattern) {
return Collections.emptyList();
}
@Override
public Collection<Resource> findRouteResourcesFromDirectory(CamelContext camelContext, String excludePattern, String includePattern) {
return Collections.emptyList();
}
@Override
public List<RoutesBuilder> collectRoutesFromRegistry(CamelContext camelContext, String excludePattern, String includePattern) {
return Collections.emptyList();
}
}
// *********************************
//
// Helpers
//
// *********************************
public static Optional<ArcContainer> container() {
return Optional.of(Arc.container());
}
public static <T> Optional<T> instance(Class<T> type) {
return container()
.map(container -> container.instance(type))
.map(InstanceHandle::get);
}
}
| 3,563 |
0 |
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationProducers.java
|
/*
* 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.k.quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;
import io.quarkus.arc.Unremovable;
import org.apache.camel.k.Runtime;
@ApplicationScoped
public class ApplicationProducers {
private volatile Runtime runtime;
public void setRuntime(Runtime runtime) {
this.runtime = runtime;
}
@Unremovable
@Singleton
@Produces
Runtime runtime() {
return this.runtime;
}
}
| 3,564 |
0 |
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRecorder.java
|
/*
* 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.k.quarkus;
import java.util.List;
import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import org.apache.camel.k.Runtime;
import org.apache.camel.main.MainListener;
import org.apache.camel.main.RoutesCollector;
import org.apache.camel.quarkus.main.CamelMain;
import org.slf4j.LoggerFactory;
@Recorder
public class ApplicationRecorder {
public void version(String version) {
LoggerFactory.getLogger(Runtime.class).info("Apache Camel K Runtime {}", version);
}
public RuntimeValue<MainListener> createMainListener(List<Runtime.Listener> listeners) {
return new RuntimeValue<>(new Application.ListenerAdapter(listeners));
}
public void publishRuntime(RuntimeValue<CamelMain> main, BeanContainer container) {
container.instance(ApplicationProducers.class).setRuntime(new Application.Runtime(main.getValue()));
}
public RuntimeValue<RoutesCollector> createRoutesCollector() {
return new RuntimeValue<>(new Application.NoRoutesCollector());
}
}
| 3,565 |
0 |
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationConfigSourceProvider.java
|
/*
* 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.k.quarkus;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.smallrye.config.PropertiesConfigSource;
import org.apache.camel.component.kubernetes.properties.ConfigMapPropertiesFunction;
import org.apache.camel.k.support.RuntimeSupport;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
public class ApplicationConfigSourceProvider implements ConfigSourceProvider {
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
final Map<String, String> sysProperties = new HashMap<>();
// explicit disable looking up configmap and secret using the KubernetesClient
sysProperties.put(ConfigMapPropertiesFunction.CLIENT_ENABLED, "false");
final Map<String, String> appProperties = RuntimeSupport.loadApplicationProperties();
final Map<String, String> usrProperties = RuntimeSupport.loadUserProperties();
return List.of(
new PropertiesConfigSource(sysProperties, "camel-k-sys", ConfigSource.DEFAULT_ORDINAL + 1000),
new PropertiesConfigSource(appProperties, "camel-k-app", ConfigSource.DEFAULT_ORDINAL),
new PropertiesConfigSource(usrProperties, "camel-k-usr", ConfigSource.DEFAULT_ORDINAL + 1)
);
}
}
| 3,566 |
0 |
Create_ds/camel-k-runtime/camel-k-runtime/deployment/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/camel-k-runtime/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/RuntimeFeature.java
|
/*
* 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.k.quarkus.deployment;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;
public class RuntimeFeature {
private static final String FEATURE = "camel-k-runtime";
@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}
}
| 3,567 |
0 |
Create_ds/camel-k-runtime/camel-k-runtime/deployment/src/main/java/org/apache/camel/k/quarkus
|
Create_ds/camel-k-runtime/camel-k-runtime/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/RuntimeProcessor.java
|
/*
* 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.k.quarkus.deployment;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.BeanContainerBuildItem;
import io.quarkus.arc.deployment.SyntheticBeansRuntimeInitBuildItem;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Consume;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import org.apache.camel.k.Runtime;
import org.apache.camel.k.quarkus.ApplicationProducers;
import org.apache.camel.k.quarkus.ApplicationRecorder;
import org.apache.camel.k.support.RuntimeSupport;
import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainBuildItem;
import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainListenerBuildItem;
import org.apache.camel.quarkus.core.deployment.main.spi.CamelRoutesCollectorBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem;
public class RuntimeProcessor {
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
CamelMainListenerBuildItem mainListener(ApplicationRecorder recorder) {
List<Runtime.Listener> listeners = new ArrayList<>();
ServiceLoader.load(Runtime.Listener.class).forEach(listeners::add);
return new CamelMainListenerBuildItem(recorder.createMainListener(listeners));
}
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
CamelRoutesCollectorBuildItem routesCollector(ApplicationRecorder recorder) {
return new CamelRoutesCollectorBuildItem(recorder.createRoutesCollector());
}
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
@Consume(SyntheticBeansRuntimeInitBuildItem.class)
CamelRuntimeTaskBuildItem registerRuntime(
ApplicationRecorder recorder,
CamelMainBuildItem camelMain,
BeanContainerBuildItem beanContainer) {
recorder.publishRuntime(camelMain.getInstance(), beanContainer.getValue());
recorder.version(RuntimeSupport.getRuntimeVersion());
return new CamelRuntimeTaskBuildItem("camel-k-runtime");
}
@BuildStep
List<AdditionalBeanBuildItem> unremovableBeans() {
return List.of(
AdditionalBeanBuildItem.unremovableOf(ApplicationProducers.class)
);
}
}
| 3,568 |
0 |
Create_ds/camel-k-runtime/support/camel-k-apt/src/main/java/org/apache/camel/k/tooling
|
Create_ds/camel-k-runtime/support/camel-k-apt/src/main/java/org/apache/camel/k/tooling/apt/CamelProcessor.java
|
/*
* 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.k.tooling.apt;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Set;
import java.util.function.BiConsumer;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
import org.apache.camel.k.annotation.Customizer;
import org.apache.camel.k.annotation.LoaderInterceptor;
@SupportedAnnotationTypes({
"org.apache.camel.k.annotation.Customizer",
"org.apache.camel.k.annotation.LoaderInterceptor",
})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class CamelProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (TypeElement annotation : annotations) {
Set<? extends Element> ae = roundEnv.getElementsAnnotatedWith(annotation);
for (Element element: ae) {
on(element, LoaderInterceptor.class, (e, a) -> {
service(
output("META-INF/services/org/apache/camel/k/loader/interceptor/%s", a.value()),
e
);
});
on(element, Customizer.class, (e, a) -> {
service(
output("META-INF/services/org/apache/camel/k/customizer/%s", a.value()),
e
);
});
}
}
return false;
}
// ******************************
//
// helpers
//
// ******************************
private Path output(String fmt, Object... args) {
try {
FileObject result;
try {
result = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", String.format(fmt, args));
} catch (IOException e) {
result = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", String.format(fmt, args));
}
Path answer = Paths.get(result.toUri());
if (!Files.exists(answer.getParent())) {
Files.createDirectories(answer.getParent());
}
return answer;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void service(Path target, String type) {
try {
Files.write(
target,
String.format("class=%s", type).getBytes(StandardCharsets.UTF_8),
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING
);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void service(Path target, TypeElement type) {
service(target, type.getQualifiedName().toString());
}
private <T extends Annotation> void on(Element element, Class<T> annotationType, BiConsumer<TypeElement, T> consumer) {
if (element instanceof TypeElement) {
T annotation = element.getAnnotation(annotationType);
if (annotation != null) {
consumer.accept((TypeElement) element, annotation);
}
}
}
}
| 3,569 |
0 |
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling
|
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java
|
/*
* 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.k.tooling.maven;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import static org.apache.camel.k.tooling.maven.support.MavenSupport.sha1Hex;
@Mojo(
name = "generate-dependency-list",
defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class GenerateDependencyListMojo extends AbstractMojo {
private static final String[] CHECKSUM_TYPES = {"md5", "sha1"};
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;
@Parameter(property = "dependencies.file", defaultValue = "${project.build.directory}/dependencies.yaml")
private String outputFile;
@Parameter(defaultValue = "true")
private boolean includeLocation;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Path output = Paths.get(this.outputFile);
try {
if (Files.notExists(output.getParent())) {
Files.createDirectories(output.getParent());
}
} catch (IOException e) {
throw new MojoExecutionException("Exception while generating dependencies list", e);
}
try (Writer writer = Files.newBufferedWriter(output, StandardCharsets.UTF_8)) {
List<Map<String, String>> deps = project.getArtifacts().stream()
.filter(this::isCompileOrRuntime)
.map(this::artifactToMap)
.collect(Collectors.toList());
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(options);
yaml.dump(Collections.singletonMap("dependencies", deps), writer);
} catch (IOException e) {
throw new MojoExecutionException("Exception while generating dependencies list", e);
}
}
private boolean isCompileOrRuntime(Artifact artifact) {
return Objects.equals(artifact.getScope(), DefaultArtifact.SCOPE_COMPILE)
|| Objects.equals(artifact.getScope(), DefaultArtifact.SCOPE_RUNTIME);
}
private Map<String, String> artifactToMap(Artifact artifact) {
Map<String, String> dep = new LinkedHashMap<>();
dep.put("id", artifact.getId());
if (artifact.getFile() == null) {
return dep;
}
if (includeLocation) {
dep.put("location", artifact.getFile().getAbsolutePath());
}
try {
String location = artifact.getFile().getAbsolutePath();
String checksum = null;
for (String checksumType : CHECKSUM_TYPES) {
Path checksumFile = Paths.get(location + "." + checksumType);
if (Files.exists(checksumFile)) {
checksum = checksumType + ":" + Files.readString(checksumFile, StandardCharsets.UTF_8);
break;
}
}
if (checksum == null) {
try (InputStream is = Files.newInputStream(artifact.getFile().toPath())) {
checksum = "sha1:" + sha1Hex(is);
}
}
dep.put("checksum", checksum);
} catch (IOException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
return dep;
}
}
| 3,570 |
0 |
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling
|
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateSupport.java
|
/*
* 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.k.tooling.maven;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
public final class GenerateSupport {
private GenerateSupport() {
}
public static String getResourceAsString(String resource) throws IOException {
try (InputStream is = GenerateSupport.class.getResourceAsStream(resource)) {
if (is == null) {
throw new IllegalStateException("Unable to find catalog-license.txt");
}
return IOUtils.toString(is, StandardCharsets.UTF_8);
}
}
}
| 3,571 |
0 |
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling
|
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
|
/*
* 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.k.tooling.maven;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import org.apache.camel.catalog.DefaultCamelCatalog;
import org.apache.camel.catalog.quarkus.QuarkusRuntimeProvider;
import org.apache.camel.impl.engine.AbstractCamelContext;
import org.apache.camel.k.catalog.model.Artifact;
import org.apache.camel.k.catalog.model.CamelArtifact;
import org.apache.camel.k.catalog.model.CamelCapability;
import org.apache.camel.k.catalog.model.CamelLoader;
import org.apache.camel.k.catalog.model.CamelScheme;
import org.apache.camel.k.catalog.model.CatalogComponentDefinition;
import org.apache.camel.k.catalog.model.CatalogDataFormatDefinition;
import org.apache.camel.k.catalog.model.CatalogDefinition;
import org.apache.camel.k.catalog.model.CatalogLanguageDefinition;
import org.apache.camel.k.catalog.model.CatalogOtherDefinition;
import org.apache.camel.k.catalog.model.CatalogSupport;
import org.apache.camel.k.catalog.model.k8s.ObjectMeta;
import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalog;
import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalogSpec;
import org.apache.camel.k.catalog.model.k8s.crd.RuntimeSpec;
import org.apache.camel.k.tooling.maven.support.MavenSupport;
import org.apache.camel.quarkus.core.FastCamelContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
@Mojo(
name = "generate-catalog",
defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class GenerateCatalogMojo extends AbstractMojo {
private static final List<String> KNOWN_HTTP_URIS = Arrays.asList(
"ahc",
"ahc-ws",
"atmosphere-websocket",
"cxf",
"cxfrs",
"grpc",
"jetty",
"knative",
"netty-http",
"platform-http",
"rest",
"restlet",
"servlet",
"spark-rest",
"spring-ws",
"undertow",
"webhook",
"websocket"
);
private static final List<String> KNOWN_PASSIVE_URIS = Arrays.asList(
"bean",
"binding",
"browse",
"class",
"controlbus",
"dataformat",
"dataset",
"direct",
"direct-vm",
"language",
"log",
"mock",
"ref",
"seda",
"stub",
"test",
"validator",
"vm"
);
@Parameter(property = "catalog.path", defaultValue = "${project.build.directory}")
private String outputPath;
@Parameter(property = "catalog.file", defaultValue = "camel-catalog-${runtime.version}.yaml")
private String outputFile;
@Parameter(property = "components.exclusion.list")
private Set<String> componentsExclusionList;
@Parameter(property = "dataformats.exclusion.list")
private Set<String> dataformatsExclusionList;
@Parameter(property = "languages.exclusion.list")
private Set<String> languagesExclusionList;
@Parameter(property = "others.exclusion.list")
private Set<String> othersExclusionList;
@Parameter(property = "dsls.exclusion.list")
private Set<String> dslsExclusionList;
@Parameter(property = "capabilities.exclusion.list")
private Set<String> capabilitiesExclusionList;
// ********************
//
// ********************
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Path output = Paths.get(this.outputPath, this.outputFile);
try {
if (Files.notExists(output.getParent())) {
Files.createDirectories(output.getParent());
}
if (Files.exists(output)) {
Files.delete(output);
}
} catch (IOException e) {
throw new MojoExecutionException("Exception while generating camel catalog", e);
}
final org.apache.camel.catalog.CamelCatalog catalog = new DefaultCamelCatalog();
catalog.setRuntimeProvider(new QuarkusRuntimeProvider());
final String runtimeVersion = MavenSupport.getVersion(getClass(), "/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties");
final String catalogName = String.format("camel-catalog-%s", runtimeVersion.toLowerCase(Locale.US));
try {
CamelCatalogSpec.Builder catalogSpec = new CamelCatalogSpec.Builder();
RuntimeSpec.Builder runtimeSpec = new RuntimeSpec.Builder()
.version(runtimeVersion)
.provider("quarkus");
MavenSupport.getVersion(
AbstractCamelContext.class,
"org.apache.camel", "camel-base",
version -> runtimeSpec.putMetadata("camel.version", version));
MavenSupport.getVersion(
FastCamelContext.class,
"io.quarkus", "quarkus-core",
version -> runtimeSpec.putMetadata("quarkus.version", version));
MavenSupport.getVersion(
QuarkusRuntimeProvider.class,
"org.apache.camel.quarkus", "camel-quarkus-catalog",
version -> runtimeSpec.putMetadata("camel-quarkus.version", version));
runtimeSpec.putMetadata("quarkus.native-builder-image", MavenSupport.getApplicationProperty(getClass(), "quarkus.native-builder-image"));
runtimeSpec.putMetadata("jib.maven-plugin.version",
MavenSupport.getApplicationProperty(getClass(), "jib.maven-plugin.version"));
runtimeSpec.putMetadata("jib.layer-filter-extension-maven.version",
MavenSupport.getApplicationProperty(getClass(), "jib.layer-filter-extension-maven.version"));
runtimeSpec.applicationClass("io.quarkus.bootstrap.runner.QuarkusEntryPoint");
runtimeSpec.addDependency("org.apache.camel.k", "camel-k-runtime");
addCapabilities(runtimeSpec, catalogSpec);
catalogSpec.runtime(runtimeSpec.build());
process(catalog, catalogSpec);
ObjectMeta.Builder metadata = new ObjectMeta.Builder()
.name(catalogName)
.putLabels("app", "camel-k")
.putLabels("camel.apache.org/catalog.version", catalog.getCatalogVersion())
.putLabels("camel.apache.org/catalog.loader.version", catalog.getLoadedVersion())
.putLabels("camel.apache.org/runtime.version", runtimeVersion);
CamelCatalog cr = new CamelCatalog.Builder()
.metadata(metadata.build())
.spec(catalogSpec.build())
.build();
//
// apiVersion: camel.apache.org/v1
// kind: CamelCatalog
// metadata:
// name: catalog-x.y.z-main
// labels:
// app: "camel-k"
// camel.apache.org/catalog.version: x.y.x
// camel.apache.org/catalog.loader.version: x.y.z
// camel.apache.org/runtime.version: x.y.x
// camel.apache.org/runtime.provider: main
// spec:
// version:
// runtimeVersion:
// status:
// artifacts:
//
try (Writer writer = Files.newBufferedWriter(output, StandardCharsets.UTF_8)) {
YAMLFactory factory = new YAMLFactory()
.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
.configure(YAMLGenerator.Feature.WRITE_DOC_START_MARKER, false);
// write license header
writer.write(
GenerateSupport.getResourceAsString("/catalog-license.txt")
);
getLog().info("Writing catalog file to: " + output);
// write catalog data
ObjectMapper mapper = new ObjectMapper(factory);
mapper.registerModule(new Jdk8Module());
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.writeValue(writer, cr);
}
} catch (IOException e) {
throw new MojoExecutionException("Exception while generating catalog", e);
}
}
// ********************
//
// ********************
public void process(
org.apache.camel.catalog.CamelCatalog catalog,
CamelCatalogSpec.Builder specBuilder) {
Map<String, CamelArtifact> artifacts = new TreeMap<>();
processComponents(catalog, artifacts);
processLanguages(catalog, artifacts);
processDataFormats(catalog, artifacts);
processOthers(catalog, artifacts);
processLoaders(specBuilder);
specBuilder.putAllArtifacts(artifacts);
}
private void processLoaders(CamelCatalogSpec.Builder specBuilder) {
if (dslsExclusionList != null) {
getLog().info("dsls.exclusion.list: " + dslsExclusionList);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("yaml")) {
specBuilder.putLoader(
"yaml",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-yaml-dsl")
.addLanguage("yaml")
.putMetadata("native", "true")
.build()
);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("groovy")) {
specBuilder.putLoader(
"groovy",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-groovy-dsl")
.addLanguage("groovy")
.putMetadata("native", "true")
.putMetadata("sources-required-at-build-time", "true")
.build()
);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("kts")) {
specBuilder.putLoader(
"kts",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-kotlin-dsl")
.addLanguage("kts")
.putMetadata("native", "true")
.putMetadata("sources-required-at-build-time", "true")
.build()
);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("js")) {
specBuilder.putLoader(
"js",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-js-dsl")
.addLanguage("js")
// Guest languages are not yet supported on Mandrel in native mode.
.putMetadata("native", "false")
.build()
);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("xml")) {
specBuilder.putLoader(
"xml",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-xml-io-dsl")
.addLanguage("xml")
.putMetadata("native", "true")
.build()
);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("java")) {
specBuilder.putLoader(
"java",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-java-joor-dsl")
.addLanguages("java")
.putMetadata("native", "true")
.putMetadata("sources-required-at-build-time", "true")
.build()
);
}
if (dslsExclusionList != null && !dslsExclusionList.contains("jsh")) {
specBuilder.putLoader(
"jsh",
CamelLoader.fromArtifact("org.apache.camel.quarkus", "camel-quarkus-jsh-dsl")
.addLanguages("jsh")
// Native mode is not yet supported due to https://github.com/apache/camel-quarkus/issues/4458.
.putMetadata("native", "false")
.putMetadata("sources-required-at-build-time", "true")
.build()
);
}
}
private void processComponents(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
final Set<String> elements = new TreeSet<>(catalog.findComponentNames());
if (componentsExclusionList != null) {
getLog().info("components.exclusion.list: " + componentsExclusionList);
elements.removeAll(componentsExclusionList);
}
for (String name : elements) {
String json = catalog.componentJSonSchema(name);
CatalogComponentDefinition definition = CatalogSupport.unmarshallComponent(json);
artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
CamelArtifact.Builder builder = artifactBuilder(artifact, definition);
builder.addJavaType(definition.getJavaType());
definition.getSchemes().map(StringUtils::trimToNull).filter(Objects::nonNull).forEach(scheme -> {
builder.addScheme(
new CamelScheme.Builder()
.id(scheme)
.http(KNOWN_HTTP_URIS.contains(scheme))
.passive(KNOWN_PASSIVE_URIS.contains(scheme))
.build());
});
return builder.build();
});
}
}
private void processLanguages(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
final Set<String> elements = new TreeSet<>(catalog.findLanguageNames());
if (languagesExclusionList != null) {
getLog().info("languages.exclusion.list: " + languagesExclusionList);
elements.removeAll(languagesExclusionList);
}
for (String name : elements) {
String json = catalog.languageJSonSchema(name);
CatalogLanguageDefinition definition = CatalogSupport.unmarshallLanguage(json);
artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
CamelArtifact.Builder builder = artifactBuilder(artifact, definition);
builder.addLanguage(definition.getName());
builder.addJavaType(definition.getJavaType());
return builder.build();
});
}
}
private void processDataFormats(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
final Set<String> elements = new TreeSet<>(catalog.findDataFormatNames());
if (dataformatsExclusionList != null) {
getLog().info("dataformats.exclusion.list: " + dataformatsExclusionList);
elements.removeAll(dataformatsExclusionList);
}
for (String name : elements) {
String json = catalog.dataFormatJSonSchema(name);
CatalogDataFormatDefinition definition = CatalogSupport.unmarshallDataFormat(json);
artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
CamelArtifact.Builder builder = artifactBuilder(artifact, definition);
builder.addDataformat(definition.getName());
builder.addJavaType(definition.getJavaType());
return builder.build();
});
}
}
private void processOthers(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
final Set<String> elements = new TreeSet<>(catalog.findOtherNames());
if (othersExclusionList != null) {
getLog().info("others.exclusion.list: " + othersExclusionList);
elements.removeAll(othersExclusionList);
}
for (String name : elements) {
String json = catalog.otherJSonSchema(name);
CatalogOtherDefinition definition = CatalogSupport.unmarshallOther(json);
artifacts.compute(definition.getArtifactId(), (key, artifact) -> artifactBuilder(artifact, definition).build());
}
}
private CamelArtifact.Builder artifactBuilder(CamelArtifact artifact, CatalogDefinition definition) {
CamelArtifact.Builder builder = new CamelArtifact.Builder();
if (artifact != null) {
builder.from(artifact);
} else {
Objects.requireNonNull(definition.getGroupId());
Objects.requireNonNull(definition.getArtifactId());
builder.groupId(definition.getGroupId());
builder.artifactId(definition.getArtifactId());
}
return builder;
}
private void addCapabilities(RuntimeSpec.Builder runtimeSpec, CamelCatalogSpec.Builder catalogSpec) {
List<Artifact> artifacts = new ArrayList<>();
artifacts.add(Artifact.from("org.apache.camel.k", "camel-k-cron"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "cron", artifacts, true);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-microprofile-health"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "health", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-platform-http"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "platform-http", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-rest"));
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-platform-http"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "rest", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-microprofile-fault-tolerance"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "circuit-breaker", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-opentracing"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "tracing", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-opentelemetry"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "telemetry", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.k", "camel-k-master"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "master", artifacts, true);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.k", "camel-k-resume-kafka"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "resume-kafka", artifacts, true);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-hashicorp-vault"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "hashicorp-vault", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-azure-key-vault"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "azure-key-vault", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-aws-secrets-manager"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "aws-secrets-manager", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-google-secret-manager"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "gcp-secret-manager", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.k", "camel-k-knative-impl"));
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-knative"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "knative", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("io.micrometer", "micrometer-registry-prometheus"));
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-micrometer"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "prometheus", artifacts, false);
artifacts.clear();
artifacts.add(Artifact.from("org.apache.camel.quarkus", "camel-quarkus-management"));
artifacts.add(Artifact.from("org.apache.camel", "camel-jaxb"));
artifacts.add(Artifact.from("org.jolokia", "jolokia-jvm"));
addCapabilityAndDependecies(runtimeSpec, catalogSpec, "jolokia", artifacts, false);
}
private void addCapabilityAndDependecies(RuntimeSpec.Builder runtimeSpec, CamelCatalogSpec.Builder catalogSpec, String name,
List<Artifact> artifacts, boolean addDependency) {
if (capabilitiesExclusionList != null && !capabilitiesExclusionList.contains(name)) {
CamelCapability.Builder capBuilder = new CamelCapability.Builder();
artifacts.forEach(artifact -> capBuilder.addDependency(artifact.getGroupId(), artifact.getArtifactId()));
CamelCapability dependency = capBuilder.build();
runtimeSpec.putCapability(name, dependency);
if (addDependency && !artifacts.isEmpty()) {
catalogSpec.putArtifact(new CamelArtifact.Builder()
.groupId(artifacts.get(0).getGroupId())
.artifactId(artifacts.get(0).getArtifactId())
.build());
}
}
}
}
| 3,572 |
0 |
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling
|
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java
|
/*
* 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.k.tooling.maven;
import java.io.FileInputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import io.apicurio.datamodels.Library;
import io.apicurio.datamodels.models.openapi.OpenApiDocument;
import io.apicurio.datamodels.models.util.JsonUtil;
import org.apache.camel.CamelContext;
import org.apache.camel.generator.openapi.RestDslXmlGenerator;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
@Mojo(
name = "generate-rest-xml",
inheritByDefault = false,
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true,
requiresProject = false)
class GenerateRestXML extends AbstractMojo {
@Parameter(property = "openapi.spec")
private String inputFile;
@Parameter(property = "dsl.out")
private String outputFile;
@Override
public void execute() throws MojoExecutionException {
if (inputFile == null) {
throw new MojoExecutionException("Missing input file: " + inputFile);
}
Path input = Paths.get(this.inputFile);
if (!Files.exists(input)) {
throw new MojoExecutionException("Unable to read the input file: " + inputFile);
}
try {
JsonFactory factory = null;
if (inputFile.endsWith(".yaml") || inputFile.endsWith(".yml")) {
factory = new YAMLFactory();
}
ObjectMapper mapper = new ObjectMapper(factory);
mapper.findAndRegisterModules();
FileInputStream fis = new FileInputStream(inputFile);
JsonNode node = mapper.readTree(fis);
OpenApiDocument document = (OpenApiDocument) Library.readDocument(JsonUtil.toObject(node));
final Writer writer;
if (outputFile != null) {
Path output = Paths.get(this.outputFile);
if (output.getParent() != null && Files.notExists(output.getParent())) {
Files.createDirectories(output.getParent());
}
if (Files.exists(output)) {
Files.delete(output);
}
writer = Files.newBufferedWriter(output);
} else {
writer = new PrintWriter(System.out);
}
final CamelContext context = new DefaultCamelContext();
final String dsl = RestDslXmlGenerator.toXml(document).generate(context);
try (writer) {
writer.write(dsl);
}
} catch (Exception e) {
throw new MojoExecutionException("Exception while generating rest xml", e);
}
}
}
| 3,573 |
0 |
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven
|
Create_ds/camel-k-runtime/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java
|
/*
* 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.k.tooling.maven.support;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;
import java.util.function.Consumer;
public final class MavenSupport {
private MavenSupport() {
}
public static String getApplicationProperty(Class<?> clazz, String property){
try (InputStream is = clazz.getResourceAsStream("/app.properties")) {
Properties p = new Properties();
p.load(is);
return p.getProperty( property );
} catch (Exception ignored) {
}
return "";
}
public static String getVersion(Class<?> clazz, String path) {
String version = null;
// try to load from maven properties first
try (InputStream is = clazz.getResourceAsStream(path)) {
if (is != null) {
Properties p = new Properties();
p.load(is);
version = p.getProperty("version", "");
}
} catch (Exception ignored) {
}
// fallback to using Java API
if (version == null) {
Package aPackage = clazz.getPackage();
if (aPackage != null) {
version = getVersion(aPackage);
}
}
if (version == null) {
// we could not compute the version so use a blank
throw new IllegalStateException("Unable to determine runtime version");
}
return version;
}
public static String getVersion(Package pkg) {
String version = pkg.getImplementationVersion();
if (version == null) {
version = pkg.getSpecificationVersion();
}
return version;
}
public static void getVersion(Class<?> clazz, String path, Consumer<String> consumer) {
consumer.accept(
MavenSupport.getVersion(clazz, path)
);
}
public static void getVersion(Class<?> clazz, String groupId, String artifactId, Consumer<String> consumer) {
getVersion(
clazz,
String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId),
consumer);
}
public static String getVersion(Class<?> clazz, String groupId, String artifactId) {
return MavenSupport.getVersion(
clazz,
String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId));
}
public static String bytesToHex(byte[] hash) {
StringBuilder hexString = new StringBuilder();
for (byte b : hash) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
public static String sha1Hex(InputStream is) throws NoSuchAlgorithmException, IOException {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
byte[] buffer = new byte[1024];
for (int read = is.read(buffer, 0, 1024); read > -1; read = is.read(buffer, 0, 1024)) {
digest.update(buffer, 0, read);
}
return bytesToHex(digest.digest());
}
}
| 3,574 |
0 |
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation/Customizer.java
|
/*
* 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.k.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Customizer {
String value();
}
| 3,575 |
0 |
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation/LoaderInterceptor.java
|
/*
* 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.k.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface LoaderInterceptor {
String value();
}
| 3,576 |
0 |
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation
|
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation/yaml/JsonSchemaIgnore.java
|
/*
* 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.k.annotation.yaml;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonSchemaIgnore {
}
| 3,577 |
0 |
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation
|
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation/yaml/YAMLStepParser.java
|
/*
* 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.k.annotation.yaml;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface YAMLStepParser {
String id();
Class<?> definition();
boolean schema() default true;
}
| 3,578 |
0 |
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation
|
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation/yaml/YAMLMixIn.java
|
/*
* 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.k.annotation.yaml;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface YAMLMixIn {
Class<?>[] value() default {};
}
| 3,579 |
0 |
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation
|
Create_ds/camel-k-runtime/support/camel-k-annotations/src/main/java/org/apache/camel/k/annotation/yaml/YAMLNodeDefinition.java
|
/*
* 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.k.annotation.yaml;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apache.camel.reifier.AbstractReifier;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface YAMLNodeDefinition {
Class<? extends AbstractReifier>[] reifiers() default {};
}
| 3,580 |
0 |
Create_ds/camel-k-runtime/support/camel-k-itests-support/camel-k-itests-loader-inspector/src/main/java/org/apache/camel/k/loader
|
Create_ds/camel-k-runtime/support/camel-k-itests-support/camel-k-itests-loader-inspector/src/main/java/org/apache/camel/k/loader/support/LoaderSupport.java
|
/*
* 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.k.loader.support;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import jakarta.json.Json;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObject;
import org.apache.camel.CamelContext;
import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.k.Runtime;
import org.apache.camel.spi.RoutesLoader;
import org.apache.camel.support.PluginHelper;
import org.apache.camel.support.ResourceHelper;
public final class LoaderSupport {
private LoaderSupport() {
}
public static JsonObject inspectSource(CamelContext context, String location, byte[] code) throws Exception {
final Runtime runtime = Runtime.on(context);
final ExtendedCamelContext ecc = runtime.getExtendedCamelContext();
final RoutesLoader loader = PluginHelper.getRoutesLoader(ecc);
final Collection<RoutesBuilder> builders = loader.findRoutesBuilders(ResourceHelper.fromBytes(location, code));
for (RoutesBuilder builder: builders) {
runtime.addRoutes(builder);
}
return Json.createObjectBuilder()
.add("components", extractComponents(context))
.add("routes", extractRoutes(context))
.add("endpoints", extractEndpoints(context))
.build();
}
public static JsonObject inspectSource(CamelContext context,String location, String code) throws Exception {
return inspectSource(context, location, code.getBytes(StandardCharsets.UTF_8));
}
public static JsonArrayBuilder extractComponents(CamelContext context) {
JsonArrayBuilder answer = Json.createArrayBuilder();
context.getComponentNames().forEach(answer::add);
return answer;
}
public static JsonArrayBuilder extractRoutes(CamelContext context) {
JsonArrayBuilder answer = Json.createArrayBuilder();
context.getRoutes().forEach(r -> answer.add(r.getId()));
return answer;
}
public static JsonArrayBuilder extractEndpoints(CamelContext context) {
JsonArrayBuilder answer = Json.createArrayBuilder();
context.getEndpoints().forEach(e -> answer.add(e.getEndpointUri()));
return answer;
}
}
| 3,581 |
0 |
Create_ds/camel-k-runtime/support/camel-k-itests-support/camel-k-itests-runtime-inspector/src/main/java/org/apache/camel/k/runtime
|
Create_ds/camel-k-runtime/support/camel-k-itests-support/camel-k-itests-runtime-inspector/src/main/java/org/apache/camel/k/runtime/support/RuntimeInspector.java
|
/*
* 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.k.runtime.support;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.Route;
import org.apache.camel.model.Model;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.model.ToDefinition;
import org.apache.camel.model.rest.RestDefinition;
import org.eclipse.microprofile.config.Config;
import static org.apache.camel.model.ProcessorDefinitionHelper.filterTypeInOutputs;
@Path("/runtime")
@ApplicationScoped
public class RuntimeInspector {
@Inject
CamelContext camelContext;
@Inject
Config config;
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
return Json.createObjectBuilder()
.add("routes", Json.createArrayBuilder(
camelContext.getRoutes().stream()
.map(Route::getId)
.collect(Collectors.toList())))
.add("route-definitions", Json.createArrayBuilder(
camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRouteDefinitions().stream()
.map(RouteDefinition::getId)
.collect(Collectors.toList())))
.add("rest-definitions", Json.createArrayBuilder(
camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRestDefinitions().stream()
.map(RestDefinition::getId)
.collect(Collectors.toList())))
.build();
}
@GET
@Path("/property/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String property(@PathParam("name") String name) {
return config.getValue(name, String.class);
}
@GET
@Path("/registry/beans/{name}")
@Produces(MediaType.APPLICATION_JSON)
public String bean(@PathParam("name") String name) throws Exception {
Object bean = camelContext.getRegistry().lookupByName(name);
if (bean == null) {
throw new IllegalArgumentException("Bean with name: " + name + " not found");
}
try (Jsonb jsonb = JsonbBuilder.create()) {
return jsonb.toJson(bean);
}
}
@GET
@Path("/route-outputs/{name}")
@Produces(MediaType.APPLICATION_JSON)
public JsonArray routeOutputs(@PathParam("name") String name) {
RouteDefinition def = camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRouteDefinition(name);
if (def == null) {
throw new IllegalArgumentException("RouteDefinition with name: " + name + " not found");
}
Collection<ToDefinition> toDefinitions = filterTypeInOutputs(def.getOutputs(), ToDefinition.class);
List<String> endpoints = toDefinitions.stream()
.map(td -> td.getEndpointUri())
.collect(Collectors.toList());
return Json.createArrayBuilder(endpoints).build();
}
}
| 3,582 |
0 |
Create_ds/camel-k-runtime/support/camel-k-test/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/support/camel-k-test/src/main/java/org/apache/camel/k/test/AvailablePortFinder.java
|
/*
* 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.k.test;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
/**
* Finds currently available server ports.
*/
public final class AvailablePortFinder {
/**
* Creates a new instance.
*/
private AvailablePortFinder() {
// Do nothing
}
/**
* Gets the next available port.
*
* @throws IllegalStateException if there are no ports available
* @return the available port
*/
public static int getNextAvailable() {
try (ServerSocket ss = new ServerSocket()) {
ss.setReuseAddress(true);
ss.bind(new InetSocketAddress((InetAddress) null, 0), 1);
return ss.getLocalPort();
} catch (IOException e) {
throw new IllegalStateException("Cannot find free port", e);
}
}
/**
* Reserve a list of random and not in use network ports and place them in Map.
*/
public static Map<String, Integer> reserveNetworkPorts(String... names) {
return reserveNetworkPorts(Function.identity(), names);
}
/**
* Reserve a list of random and not in use network ports and place them in Map.
*/
public static <T> Map<String, T> reserveNetworkPorts(Function<Integer, T> converter, String... names) {
Map<String, T> reservedPorts = new HashMap<>();
for (String name : names) {
reservedPorts.put(name, converter.apply(getNextAvailable()));
}
return reservedPorts;
}
}
| 3,583 |
0 |
Create_ds/camel-k-runtime/support/camel-k-test/src/main/java/org/apache/camel/k
|
Create_ds/camel-k-runtime/support/camel-k-test/src/main/java/org/apache/camel/k/test/CamelKTestSupport.java
|
/*
* 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.k.test;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
public final class CamelKTestSupport {
private CamelKTestSupport() {
}
public static Properties asProperties(String... properties) {
if ((properties.length & 1) != 0) {
throw new InternalError("length is odd");
}
Properties answer = new Properties();
for (int i = 0; i < properties.length; i += 2) {
answer.setProperty(
Objects.requireNonNull(properties[i]),
Objects.requireNonNull(properties[i + 1]));
}
return answer;
}
public static Properties asProperties(Map<String, Object> properties) {
Properties answer = new Properties();
answer.putAll(properties);
return answer;
}
}
| 3,584 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/Artifact.java
|
/*
* 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.k.catalog.model;
import java.util.Comparator;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonPropertyOrder({"groupId", "artifactId", "version"})
public interface Artifact extends Comparable<Artifact> {
String getGroupId();
String getArtifactId();
Optional<String> getVersion();
@Override
default int compareTo(Artifact o) {
return Comparator
.comparing(Artifact::getGroupId)
.thenComparing(Artifact::getArtifactId)
.thenComparing(Artifact::getVersion, Comparator.comparing(c -> c.orElse("")))
.compare(this, o);
}
static Artifact from(String groupId, String artifactId) {
return new Artifact() {
@Override
public String getGroupId() {
return groupId;
}
@Override
public String getArtifactId() {
return artifactId;
}
@Override
public Optional<String> getVersion() {
return Optional.empty();
}
};
}
}
| 3,585 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CatalogDefinition.java
|
/*
* 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.k.catalog.model;
public class CatalogDefinition {
private String groupId;
private String artifactId;
private String version;
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
| 3,586 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelCapability.java
|
/*
* 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.k.catalog.model;
import java.util.Collections;
import java.util.SortedSet;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@Value.Style(depluralize = true)
@JsonDeserialize(builder = CamelCapability.Builder.class)
@JsonPropertyOrder({"groupId", "artifactId", "version"})
public interface CamelCapability {
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<Artifact> getDependencies() {
return Collections.emptySortedSet();
}
static CamelCapability forArtifact(String groupId, String artifactId) {
return new Builder().addDependency(groupId, artifactId).build();
}
class Builder extends ImmutableCamelCapability.Builder {
public Builder addDependency(String groupId, String artifactId) {
return super.addDependencies(Artifact.from(groupId, artifactId));
}
}
}
| 3,587 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelLoader.java
|
/*
* 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.k.catalog.model;
import java.util.Collections;
import java.util.SortedMap;
import java.util.SortedSet;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@Value.Style(depluralize = true)
@JsonDeserialize(builder = CamelLoader.Builder.class)
@JsonPropertyOrder({"groupId", "artifactId", "version"})
public interface CamelLoader extends Artifact {
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<String> getLanguages() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<Artifact> getDependencies() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedMap<String, String> getMetadata() {
return Collections.emptySortedMap();
}
static Builder fromArtifact(String groupId, String artifactId) {
return new Builder().groupId(groupId).artifactId(artifactId);
}
class Builder extends ImmutableCamelLoader.Builder {
public Builder addDependency(String groupId, String artifactId) {
return super.addDependencies(Artifact.from(groupId, artifactId));
}
}
}
| 3,588 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CatalogSupport.java
|
/*
* 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.k.catalog.model;
import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper;
public final class CatalogSupport {
private CatalogSupport() {
}
private static <T> T unmarshall(String json, Class<T> type) {
try {
return new ObjectMapper().readValue(json, type);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
public static CatalogComponentDefinition unmarshallComponent(String json) {
return unmarshall(json, CatalogComponentDefinition.Container.class).unwrap();
}
public static CatalogLanguageDefinition unmarshallLanguage(String json) {
return unmarshall(json, CatalogLanguageDefinition.Container.class).unwrap();
}
public static CatalogDataFormatDefinition unmarshallDataFormat(String json) {
return unmarshall(json, CatalogDataFormatDefinition.Container.class).unwrap();
}
public static CatalogOtherDefinition unmarshallOther(String json) {
return unmarshall(json, CatalogOtherDefinition.Container.class).unwrap();
}
}
| 3,589 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CatalogDataFormatDefinition.java
|
/*
* 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.k.catalog.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public final class CatalogDataFormatDefinition extends CatalogDefinition {
private String name;
private String javaType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getJavaType() {
return javaType;
}
public void setJavaType(String javaType) {
this.javaType = javaType;
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
private final CatalogDataFormatDefinition delegate;
@JsonCreator
public Container(
@JsonProperty("dataformat") CatalogDataFormatDefinition delegate) {
this.delegate = delegate;
}
public CatalogDataFormatDefinition unwrap() {
return delegate;
}
}
}
| 3,590 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelScheme.java
|
/*
* 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.k.catalog.model;
import java.util.Collections;
import java.util.Comparator;
import java.util.Optional;
import java.util.SortedSet;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@JsonDeserialize(builder = CamelScheme.Builder.class)
public interface CamelScheme extends Comparable<CamelScheme> {
String getId();
@Value.Auxiliary
@Value.Default
default boolean http() {
return false;
}
@Value.Auxiliary
@Value.Default
default boolean passive() {
return false;
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<String> getRequiredCapabilities() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
Optional<CamelScopedArtifact> getProducer();
@Value.Auxiliary
Optional<CamelScopedArtifact> getConsumer();
@Override
default int compareTo(CamelScheme o) {
return Comparator
.comparing(CamelScheme::getId)
.compare(this, o);
}
class Builder extends ImmutableCamelScheme.Builder {
}
}
| 3,591 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelScopedArtifact.java
|
/*
* 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.k.catalog.model;
import java.util.Collections;
import java.util.SortedSet;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@Value.Style(depluralize = true)
@JsonDeserialize(builder = CamelScopedArtifact.Builder.class)
@JsonPropertyOrder({"dependencies", "required-capabilities"})
public interface CamelScopedArtifact {
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<Artifact> getDependencies() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<String> getRequiredCapabilities() {
return Collections.emptySortedSet();
}
class Builder extends ImmutableCamelScopedArtifact.Builder {
public Builder addDependency(String groupId, String artifactId) {
return super.addDependencies(Artifact.from(groupId, artifactId));
}
}
}
| 3,592 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CatalogOtherDefinition.java
|
/*
* 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.k.catalog.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public final class CatalogOtherDefinition extends CatalogDefinition {
private String label;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
private final CatalogOtherDefinition delegate;
@JsonCreator
public Container(
@JsonProperty("other") CatalogOtherDefinition delegate) {
this.delegate = delegate;
}
public CatalogOtherDefinition unwrap() {
return delegate;
}
}
}
| 3,593 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CatalogLanguageDefinition.java
|
/*
* 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.k.catalog.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public final class CatalogLanguageDefinition extends CatalogDefinition {
private String name;
private String javaType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getJavaType() {
return javaType;
}
public void setJavaType(String javaType) {
this.javaType = javaType;
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
private final CatalogLanguageDefinition delegate;
@JsonCreator
public Container(
@JsonProperty("language") CatalogLanguageDefinition delegate) {
this.delegate = delegate;
}
public CatalogLanguageDefinition unwrap() {
return delegate;
}
}
}
| 3,594 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelArtifact.java
|
/*
* 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.k.catalog.model;
import java.util.Collections;
import java.util.SortedSet;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@Value.Style(depluralize = true)
@JsonDeserialize(builder = CamelArtifact.Builder.class)
@JsonPropertyOrder({"groupId", "artifactId", "version"})
public interface CamelArtifact extends Artifact {
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<CamelScheme> getSchemes() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<String> getLanguages() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<String> getDataformats() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<Artifact> getDependencies() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<Artifact> getExclusions() {
return Collections.emptySortedSet();
}
@Value.Auxiliary
@Value.Default
@Value.NaturalOrder
default SortedSet<String> getJavaTypes() {
return Collections.emptySortedSet();
}
static Builder from(String groupId, String artifactId) {
return new Builder().groupId(groupId).artifactId(artifactId);
}
class Builder extends ImmutableCamelArtifact.Builder {
public Builder addDependency(String groupId, String artifactId) {
return super.addDependencies(Artifact.from(groupId, artifactId));
}
}
}
| 3,595 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CatalogComponentDefinition.java
|
/*
* 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.k.catalog.model;
import java.util.stream.Stream;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.camel.util.StringHelper;
@JsonIgnoreProperties(ignoreUnknown = true)
public final class CatalogComponentDefinition extends CatalogDefinition {
private String scheme;
private String alternativeSchemes;
private String javaType;
public Stream<String> getSchemes() {
final String schemeIDs = StringHelper.trimToNull(alternativeSchemes);
return schemeIDs == null
? Stream.of(scheme)
: Stream.concat(
Stream.of(scheme),
StringHelper.splitAsStream(schemeIDs, ","));
}
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getAlternativeSchemes() {
return alternativeSchemes;
}
public void setAlternativeSchemes(String alternativeSchemes) {
this.alternativeSchemes = alternativeSchemes;
}
public String getJavaType() {
return javaType;
}
public void setJavaType(String javaType) {
this.javaType = javaType;
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
private final CatalogComponentDefinition delegate;
@JsonCreator
public Container(
@JsonProperty("component") CatalogComponentDefinition delegate) {
this.delegate = delegate;
}
public CatalogComponentDefinition unwrap() {
return delegate;
}
}
}
| 3,596 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/k8s/TypeMeta.java
|
/*
* 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.k.catalog.model.k8s;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@JsonDeserialize(builder = TypeMeta.Builder.class)
public interface TypeMeta {
@Value.Default
default String getApiVersion() {
return "camel.apache.org/v1";
}
@Value.Default
default String getKind() {
return "CamelCatalog";
}
class Builder extends ImmutableTypeMeta.Builder {
}
}
| 3,597 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/k8s/ObjectMeta.java
|
/*
* 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.k.catalog.model.k8s;
import java.util.Collections;
import java.util.SortedMap;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;
@Value.Immutable
@JsonDeserialize(builder = ObjectMeta.Builder.class)
public interface ObjectMeta {
String getName();
@Value.Default
@Value.NaturalOrder
default SortedMap<String, String> getLabels() {
return Collections.emptySortedMap();
}
class Builder extends ImmutableObjectMeta.Builder {
}
}
| 3,598 |
0 |
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/k8s
|
Create_ds/camel-k-runtime/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/k8s/crd/RuntimeSpec.java
|
/*
* 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.k.catalog.model.k8s.crd;
import java.util.Collections;
import java.util.SortedMap;
import java.util.SortedSet;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.camel.k.catalog.model.Artifact;
import org.apache.camel.k.catalog.model.CamelCapability;
import org.immutables.value.Value;
@Value.Immutable
@Value.Style(depluralize = true)
@JsonDeserialize(builder = RuntimeSpec.Builder.class)
@JsonPropertyOrder({ "version", "runtimeVersion", "artifacts" })
public interface RuntimeSpec {
String getProvider();
String getVersion();
String getApplicationClass();
@Value.Default
@Value.NaturalOrder
default SortedMap<String, String> getMetadata() {
return Collections.emptySortedMap();
}
@Value.Default
@Value.NaturalOrder
default SortedSet<Artifact> getDependencies() {
return Collections.emptySortedSet();
}
@Value.Default
@Value.NaturalOrder
default SortedMap<String, CamelCapability> getCapabilities() {
return Collections.emptySortedMap();
}
class Builder extends ImmutableRuntimeSpec.Builder {
public Builder addDependency(String groupId, String artifactId) {
return super.addDependencies(Artifact.from(groupId, artifactId));
}
}
}
| 3,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.