diff --git a/pom.xml b/pom.xml index fee4e71969..961e7a4423 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,9 @@ 5.36.0 - 6.16.4 + 6.16.0 + + 0.1 1.9.17 diff --git a/recipes-tests/pom.xml b/recipes-tests/pom.xml index e13e1eb792..1140b05f92 100644 --- a/recipes-tests/pom.xml +++ b/recipes-tests/pom.xml @@ -23,6 +23,16 @@ 2.13.3 4.5.14 + + + ${project.build.testOutputDirectory}/META-INF/rewrite/classpath + + + 3.18.6 + 4.5.14 + 4.4.16 + 4.0.3 + @@ -155,83 +165,13 @@ test - - - org.apache.camel - camel-api - test - - - org.apache.camel - camel-core-model - test - - - org.apache.camel - camel-json-validator - test - - - org.apache.camel - camel-support - test - + org.apache.camel - camel-catalog - test - - - org.apache.camel - camel-main - test - - - org.apache.camel - camel-activemq - test - - - org.apache.camel - camel-bean - test - - - org.apache.camel - camel-management-api - test - - - org.apache.camel - camel-tracing - test - - - org.apache.camel - camel-saga - test - - - org.apache.camel - camel-kafka - test - - - jackson-databind - com.fasterxml.jackson.core - - - - - org.apache.camel - camel-endpointdsl - test - - - org.apache.httpcomponents - httpclient - ${http.version} + camel-upgrade-recipes + ${camel-upgrade-recipes.version} test + test-jar @@ -301,6 +241,159 @@ + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + + + process-test-resources + + copy + + + + + + org.apache.camel + camel-activemq + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-api + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-bean + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-catalog + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-core-model + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-main + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-management-api + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-support + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-util + ${test.camel-quarkus-3-0.camel-version} + ${rewrite-tmp-classpath} + + + + org.apache.httpcomponents + httpclient + ${test.camel-quarkus-3-0.http-client-version} + ${rewrite-tmp-classpath} + + + org.apache.httpcomponents + httpcore + ${test.camel-quarkus-3-0.http-core-version} + ${rewrite-tmp-classpath} + + + + org.apache.camel + camel-api + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-base + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-base-engine + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-endpointdsl + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-core-model + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-json-validator + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-kafka + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-saga + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-support + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-tracing + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + org.apache.camel + camel-util + ${test.camel-quarkus-3-8.camel-version} + ${rewrite-tmp-classpath} + + + + + + diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate41Test.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate41Test.java index 5cd12a9882..6dce7ee4f4 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate41Test.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate41Test.java @@ -1,184 +1,4 @@ package io.quarkus.updates.camel; -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; -import org.openrewrite.yaml.Assertions; - -import static org.openrewrite.java.Assertions.java; -import static org.openrewrite.xml.Assertions.xml; - -public class CamelUpdate41Test implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3_8(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-core-model", "camel-tracing")) - .typeValidationOptions(TypeValidation.none()); - } - - /** - * doc - */ - @Test - void testAws2SnsQueueUrl() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath2Test extends RouteBuilder { - @Override - public void configure() { - from("direct:start") - .to("aws2-sns://mytopic?subject=mySubject&autoCreateTopic=true&subscribeSNStoSQS=true&queueUrl=https://xxxxx"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath2Test extends RouteBuilder { - @Override - public void configure() { - from("direct:start") - .to("aws2-sns://mytopic?subject=mySubject&autoCreateTopic=true&subscribeSNStoSQS=true&queueArn=arn:aws:sqs:xxxxx"); - } - } - """)); - } - - /** - * doc - */ - @Test - void testTracingTag() { - //language=java - rewriteRun(java(""" - import org.apache.camel.tracing.Tag; - - public class Test { - - public Tag test() { - return Tag.URL_SCHEME; - } - } - """, - """ - import org.apache.camel.tracing.TagConstants; - - public class Test { - - public TagConstants test() { - return TagConstants.URL_SCHEME; - } - } - """)); - } - - /** - * doc - */ - @Test - void testYamlDsl() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - beans: - - name: "myClient" - beanType: "com.foo.MyBean" - type: "groovy" - script: | - # groovy script here - """, """ - - beans: - - name: "myClient" - type: "com.foo.MyBean" - scriptLanguage: "groovy" - script: | - # groovy script here - """)); - } - - /** - * doc - */ - @Test - void testYamlDslNPE() { - //language=yaml - rewriteRun(Assertions.yaml(""" - apiVersion: v1 - kind: ServiceAccount - metadata: - name: camel-leader-election - --- - apiVersion: rbac.authorization.k8s.io/v1 - kind: Role - metadata: - name: camel-leader-election - rules: - - apiGroups: - - "" - - "coordination.k8s.io" - resources: - - configmaps - - secrets - - pods - - leases - verbs: - - create - - delete - - deletecollection - - get - - list - - patch - - update - - watch - --- - apiVersion: rbac.authorization.k8s.io/v1 - kind: RoleBinding - metadata: - name: camel-leader-election - subjects: - - kind: ServiceAccount - name: camel-leader-election - roleRef: - kind: Role - name: camel-leader-election - apiGroup: rbac.authorization.k8s.io - """)); - } - - /** - * doc - */ - @Test - void testXmlDsl() { - //language=xml - rewriteRun(xml(""" - - - - - - - - """, """ - - - - - - - - """)); - } - - - +public class CamelUpdate41Test extends org.apache.camel.updates.camel44.CamelUpdate41Test { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate42Test.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate42Test.java index 5ef2c0157d..f5db1e5a4a 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate42Test.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate42Test.java @@ -9,110 +9,5 @@ import static org.openrewrite.java.Assertions.java; -public class CamelUpdate42Test implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3_8(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-api", "camel-json-validator", "camel-support", "camel-saga")) - .typeValidationOptions(TypeValidation.none()); - } - - /** - * The option camel.main.debugger has been renamed to camel.debug.enabled. - * The documentation - */ - @Test - void testCamelMainDebugger() { - rewriteRun(Assertions.properties(""" - #test - quarkus.camel.main.debugger=true - camel.main.debugger=true - """, - """ - #test - quarkus.camel.debug.enabled=true - camel.debug.enabled=true - """)); - } - - /** - * The org.apache.camel.service.lra.LRAClient can now access Exchange to retrieve further context information. - * Therefore, there are following changes in interface methods - * - * As result of interface changes also the known implementation classes and usages have been adopted. - *

- * The documentation - * - */ - @Test - void testAddedExchangeIntoSaga() { - //language=java - rewriteRun(java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.builder.RouteBuilder; - import org.apache.camel.saga.CamelSagaCoordinator; - import org.apache.camel.saga.InMemorySagaCoordinator; - import org.apache.camel.saga.InMemorySagaService; - import java.util.concurrent.CompletableFuture; - - public class Saga01Test extends RouteBuilder { - - CamelContext camelContext; - - @Override - public void configure() { - InMemorySagaService sagaService = new InMemorySagaService(); - CompletableFuture s = sagaService.newSaga(); - try { - getContext().addService(sagaService); - } catch (Exception e) { - e.printStackTrace(); - } - - String uuid = camelContext.getUuidGenerator().generateUuid(); - - CamelSagaCoordinator coordinator = new InMemorySagaCoordinator(camelContext, sagaService, uuid); - coordinator.compensate(); - coordinator.complete(); - } - } - """, - """ - import org.apache.camel.CamelContext; - import org.apache.camel.builder.RouteBuilder; - import org.apache.camel.saga.CamelSagaCoordinator; - import org.apache.camel.saga.InMemorySagaCoordinator; - import org.apache.camel.saga.InMemorySagaService; - import java.util.concurrent.CompletableFuture; - - public class Saga01Test extends RouteBuilder { - - CamelContext camelContext; - - @Override - public void configure() { - InMemorySagaService sagaService = new InMemorySagaService(); - CompletableFuture s = sagaService.newSaga(/*Exchange parameter was added.*/(Exchange) null); - try { - getContext().addService(sagaService); - } catch (Exception e) { - e.printStackTrace(); - } - - String uuid = camelContext.getUuidGenerator().generateUuid(); - - CamelSagaCoordinator coordinator = new InMemorySagaCoordinator(camelContext, sagaService, uuid); - coordinator.compensate(/*Exchange parameter was added.*/(Exchange) null); - coordinator.complete(/*Exchange parameter was added.*/(Exchange) null); - } - } - """)); - } - - +public class CamelUpdate42Test extends org.apache.camel.updates.camel44.CamelUpdate42Test { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate43Test.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate43Test.java index b91f6a6217..9845cce934 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate43Test.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate43Test.java @@ -1,293 +1,4 @@ package io.quarkus.updates.camel; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.properties.Assertions; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -import static org.openrewrite.java.Assertions.java; -import static org.openrewrite.xml.Assertions.xml; - -public class CamelUpdate43Test implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3_8(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-api", "camel-core-model", "camel-support", "camel-base-engine", "camel-endpointdsl", "camel-kafka")) - .typeValidationOptions(TypeValidation.none()); - } - - /** - *

Moved class org.apache.camel.impl.engine.MemoryStateRepository from - * camel-base-engine to org.apache.camel.support.processor.state.MemoryStateRepository in camel-support.

- * - *

Moved class org.apache.camel.impl.engine.FileStateRepository - * from camel-base-engine to org.apache.camel.support.processor.state.FileStateRepository in camel-support.

- * - *

See the documentation

- */ - @Test - void testStateRepository() { - //language=java - rewriteRun(java(""" - import org.apache.camel.BindToRegistry; - import org.apache.camel.impl.engine.FileStateRepository; - import org.apache.camel.impl.engine.MemoryStateRepository; - - import java.io.File; - - public class CoreTest { - - @BindToRegistry("stateRepository") - private static final MemoryStateRepository stateRepository = new MemoryStateRepository(); - - // Create the repository in which the Kafka offsets will be persisted - FileStateRepository repository = FileStateRepository.fileStateRepository(new File("/path/to/repo.dat")); - } - """, - """ - import org.apache.camel.BindToRegistry; - import org.apache.camel.support.processor.state.FileStateRepository; - import org.apache.camel.support.processor.state.MemoryStateRepository; - - import java.io.File; - - public class CoreTest { - - @BindToRegistry("stateRepository") - private static final MemoryStateRepository stateRepository = new MemoryStateRepository(); - - // Create the repository in which the Kafka offsets will be persisted - FileStateRepository repository = FileStateRepository.fileStateRepository(new File("/path/to/repo.dat")); - } - """)); - } - - /** - *

The configuration for batch and stream has been renamed from batch-config to batchConfig and stream-config to streamConfig.

- * - *

For example before: - *

-     *     <resequence>
-     *         <stream-config timeout="1000" deliveryAttemptInterval="10"/>
-     *         <simple>${header.seqnum}</simple>
-     *         <to uri="mock:result" />
-     *     </resequence>
-     * 
- *

- * - *

And now after: - *

-     *     <resequence>
-     *         <streamConfig timeout="1000" deliveryAttemptInterval="10"/>
-     *         <simple>${header.seqnum}</simple>
-     *         <to uri="mock:result" />
-     *     </resequence>
-     * 
- *

- * - *

See the documentation

- */ - @Test - void testResequenceStramConfig() { - //language=xml - rewriteRun(xml(""" - - - - - - ${header.seqnum} - - - - - """, """ - - - - - - ${header.seqnum} - - - - - """)); - } - - /** - *

The configuration for batch and stream has been renamed from batch-config to batchConfig and stream-config to streamConfig.

- *

See the documentation

- */ - @Test - void testResequenceBatchConfig() { - //language=xml - rewriteRun(xml(""" - - - - - body - - - - - - """, """ - - - - - body - - - - - - """)); - } - - /** - *

Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.

- * - *

Update throttle expressions configured with maxRequestsPerPeriod to use maxConcurrentRequests instead, and remove any timePeriodMillis option.

- * - *

See the documentation

- */ - @Test - void testThrottleEIP() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class ThrottleEIPTest extends RouteBuilder { - @Override - public void configure() { - long maxRequestsPerPeriod = 100L; - Long maxRequests = Long.valueOf(maxRequestsPerPeriod); - - from("seda:a") - .throttle(maxRequestsPerPeriod).timePeriodMillis(500).asyncDelayed() - .to("seda:b"); - - from("seda:a") - .throttle(maxRequestsPerPeriod).timePeriodMillis(500) - .to("seda:b"); - - from("seda:c") - .throttle(maxRequestsPerPeriod) - .to("seda:d"); - - from("seda:a") - .throttle(maxRequests).timePeriodMillis(500).asyncDelayed() - .to("seda:b"); - - from("seda:a") - .throttle(maxRequests).timePeriodMillis(500) - .to("seda:b"); - - from("seda:c") - .throttle(maxRequests) - .to("seda:d"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class ThrottleEIPTest extends RouteBuilder { - @Override - public void configure() { - long maxRequestsPerPeriod = 100L; - Long maxRequests = Long.valueOf(maxRequestsPerPeriod); - - /* Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.*/from("seda:a") - .throttle(maxRequestsPerPeriod).asyncDelayed() - .to("seda:b"); - - /* Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.*/from("seda:a") - .throttle(maxRequestsPerPeriod) - .to("seda:b"); - - /* Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.*/from("seda:c") - .throttle(maxRequestsPerPeriod) - .to("seda:d"); - - /* Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.*/from("seda:a") - .throttle(maxRequests).asyncDelayed() - .to("seda:b"); - - /* Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.*/from("seda:a") - .throttle(maxRequests) - .to("seda:b"); - - /* Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.*/from("seda:c") - .throttle(maxRequests) - .to("seda:d"); - } - } - """)); - } - - /** - *

The header name for the List metadata has changed from org.apache.kafka.clients.producer.RecordMetadata - * to kafka.RECORD_META, and the header constant from KAFKA_RECORDMETA to KAFKA_RECORD_META.

- * - *

See the documentation

- */ - @Test - void testKafka() { - //language=java - rewriteRun(java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.Message; - import org.apache.camel.builder.endpoint.EndpointRouteBuilder; - import org.apache.camel.component.kafka.KafkaConstants; - import org.apache.kafka.clients.producer.RecordMetadata; - import org.apache.camel.support.DefaultMessage; - - import java.util.List; - - public class KafkaTest extends EndpointRouteBuilder { - private CamelContext context; - private final Message in = new DefaultMessage(context); - - @Override - public void configure() throws Exception { - - List recordMetaData1 = (List) in.getHeader(KafkaConstants.KAFKA_RECORDMETA); - - - from(kafka().orgApacheKafkaClientsProducerRecordmetadata()).to(mock("test")); - } - } - """, - """ - import org.apache.camel.CamelContext; - import org.apache.camel.Message; - import org.apache.camel.builder.endpoint.EndpointRouteBuilder; - import org.apache.camel.component.kafka.KafkaConstants; - import org.apache.kafka.clients.producer.RecordMetadata; - import org.apache.camel.support.DefaultMessage; - - import java.util.List; - - public class KafkaTest extends EndpointRouteBuilder { - private CamelContext context; - private final Message in = new DefaultMessage(context); - - @Override - public void configure() throws Exception { - - List recordMetaData1 = (List) in.getHeader(KafkaConstants.KAFKA_RECORD_META); - - - from(kafka().kafkaRecordMeta()).to(mock("test")); - } - } - """)); - } +public class CamelUpdate43Test extends org.apache.camel.updates.camel44.CamelUpdate43Test { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate44Test.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate44Test.java index 1063d081ab..d18040433d 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate44Test.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/CamelUpdate44Test.java @@ -1,526 +1,4 @@ package io.quarkus.updates.camel; -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.properties.Assertions; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -import static org.openrewrite.java.Assertions.java; - -public class CamelUpdate44Test implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3_8(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-api", "camel-util", "camel-base", "camel-core-model", "camel-json-validator")) - .typeValidationOptions(TypeValidation.none()); - } - - /** - * doc - */ - @Test - void testCamelMainRouteControllerProperty() { - //language=java - rewriteRun(Assertions.properties(""" - #test - camel.main.routeControllerBackOffDelay=1000 - camel.main.routeControllerSuperviseEnabled = true - """, - """ - #test - camel.routeController.backOffDelay=1000 - camel.routeController.enabled = true - """)); - } - - /** - * doc - */ - @Test - void testCamelMainRouteControllerDashedProperty() { - //language=java - rewriteRun(Assertions.properties(""" - #test - camel.main.route-controller-back-off-max-attempts = 10 - camel.main.route-controller-supervise-enabled = true - """, - """ - #test - camel.routeController.back-off-max-attempts = 10 - camel.routeController.enabled = true - """)); - } - - /** - * doc - */ - @Test - void testJsonValiidator() { - //language=java - rewriteRun(java( - """ - import org.apache.camel.component.jsonvalidator.DefaultJsonSchemaLoader; - - public class CustomJsonValidator extends DefaultJsonSchemaLoader { - } - """, - """ - import org.apache.camel.component.jsonvalidator.DefaultJsonUriSchemaLoader; - - public class CustomJsonValidator extends DefaultJsonUriSchemaLoader { - } - """)); - } - - /** - * doc - */ - @Test - void testStopWatchConstructor() { - //language=java - rewriteRun(java(""" - import org.apache.camel.util.StopWatch; - - public class StopWatchTest { - - public void test() { - StopWatch sw = new StopWatch(Long.parseLong("1")); - } - } - """, - """ - import org.apache.camel.util.StopWatch; - - public class StopWatchTest { - - public void test() { - StopWatch sw = /*Removed the deprecated constructor from the internal class org.apache.camel.util.StopWatch. - Users of this class are advised to use the default constructor if necessary.Changed exception thrown from IOException to Exception. - */new StopWatch(); - } - } - """)); - } - - /** - * doc - */ - @Test - void testExchangeGetCreated() { - //language=java - rewriteRun(java(""" - import org.apache.camel.Exchange; - - public class ExchangeTest { - - public void test() { - Exchange ex = null; - ex.getCreated(); - } - } - """, - """ - import org.apache.camel.Exchange; - - public class ExchangeTest { - - public void test() { - Exchange ex = null; - ex.getClock().getCreated(); - } - } - """)); - } - - /** - * doc - */ - @Test - void testPropertiesLookup() { - //language=java - rewriteRun(java(""" - import org.apache.camel.component.properties.PropertiesLookup; - - public class PropertiesLookupTest { - - public void test() throws Exception { - PropertiesLookup pl = null; - - pl.lookup("test"); - } - } - """, - """ - import org.apache.camel.component.properties.PropertiesLookup; - - public class PropertiesLookupTest { - - public void test() throws Exception { - PropertiesLookup pl = null; - - pl.lookup("test", null); - } - } - """)); - } - - /** - * doc - */ - @Test - void testJsonpath1() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath1Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().jsonpath("something", true, Object.class, "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath1Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_jsonpath("something", true, Object.class, "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * doc - */ - @Test - void testJsonpath2() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath2Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().jsonpathWriteAsString("something", true, "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath2Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_jsonpathWriteAsString("something", true, "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed tokenize(String token, boolean regex, int group, String groupDelimiter, boolean skipFirst) - */ - @Test - void testTokenize1() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize1Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().tokenize("token", true, 0, "groupDelimiter", true) - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize1Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_tokenize("token", true, 0, "groupDelimiter", true) - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed tokenize(String token, String headerName) - */ - @Test - void testTokenize2() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize2Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().tokenize("token", "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize2Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_tokenize("token", "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed tokenize(String token, String headerName, boolean regex) - */ - @Test - void testTokenize3() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize3Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().tokenize("token", "header", true) - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize3Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_tokenize("token", "header", true) - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed xpath(String text, String headerName) - */ - @Test - @Disabled //https://github.com/quarkusio/quarkus-updates/issues/142 - void testXpath1() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Xpath1Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().xpath("/invoice/@orderType = 'premium'", "invoiceDetails") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Xpath1Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_xpath("/invoice/@orderType = 'premium'", "invoiceDetails") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed xpath(String text, Class resultType, String headerName) - */ - @Test - @Disabled //https://github.com/quarkusio/quarkus-updates/issues/142 - void testXpath2() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Xpath2Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().xpath("text", Object.class, "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Xpath2Test extends RouteBuilder { - @Override - public void configure() { - /*Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details. - */from("direct:in").choice().when().removed_xpath("text", Object.class, "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed xpath(String text, Class resultType, Namespaces namespaces, String headerName) { - */ - @Test - @Disabled //https://github.com/quarkusio/quarkus-updates/issues/142 - void testXpath3() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Xpath3Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().xpath("text", Object.class, null, "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Xpath3Test extends RouteBuilder { - @Override - public void configure() { - /*Some of the Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.*/from("direct:in").choice().when().xpath("text", Object.class, "namespace", "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed xquery(String text, String headerName) - */ - @Test - @Disabled //https://github.com/quarkusio/quarkus-updates/issues/142 - void testXquery1() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Xquery1Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().xquery("text", "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Xquery1Test extends RouteBuilder { - @Override - public void configure() { - /*Some of the Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.*/from("direct:in").choice().when().xquery("text", "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed xquery(String text, Class resultType, String headerName) - */ - @Test - @Disabled //https://github.com/quarkusio/quarkus-updates/issues/142 - void testXquery2() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize1Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().xquery("text", Object.class, "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath2Test extends RouteBuilder { - @Override - public void configure() { - /*Some of the Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.*/from("direct:in").choice().when().jsonpathWriteAsString("something", true, "header") - .to("mock:premium"); - } - } - """)); - } - - /** - * Removed xquery(String text, Class resultType, Namespaces namespaces, String headerName) { - */ - @Test - @Disabled //https://github.com/quarkusio/quarkus-updates/issues/142 - void testXquery3() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class Tokenize1Test extends RouteBuilder { - @Override - public void configure() { - from("direct:in").choice().when().xquery("text", Object.class, "namespace", "header") - .to("mock:premium"); - } - } - """, - """ - import org.apache.camel.builder.RouteBuilder; - - public class Jsonpath2Test extends RouteBuilder { - @Override - public void configure() { - /*Some of the Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent. - See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.*/from("direct:in").choice().when().jsonpathWriteAsString("something", true, "header") - .to("mock:premium"); - } - } - """)); - } - +public class CamelUpdate44Test extends org.apache.camel.updates.camel44.CamelUpdate44Test { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CameXmlDslRecipeTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CameXmlDslRecipeTest.java index e185dacf90..957b889624 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CameXmlDslRecipeTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CameXmlDslRecipeTest.java @@ -1,115 +1,4 @@ package io.quarkus.updates.camel.camel40; -import static org.openrewrite.xml.Assertions.xml; - -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -public class CameXmlDslRecipeTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true)) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testDescription() { - //language=xml - rewriteRun(xml(""" - - - Something that this route do - - - Hello Camel K! - - - - - Something that this route2 do - - - Hello Camel K! - - - - - """, """ - - - - - Hello Camel K! - - - - - - - Hello Camel K! - - - - - """)); - } - - @Test - void testCircuitBreakerFull() { - //language=xml - rewriteRun(xml(""" - - - - 5643 - aaaa - 1 - true - 1 - 1 - - - - - """, """ - - - - - - - """)); - } - - @Test - void testCircuitBreaker() { - //language=xml - rewriteRun(xml(""" - - - - - true - 2000 - - - - - """, """ - - - - - - - - - """)); - } +public class CameXmlDslRecipeTest extends org.apache.camel.updates.camel40.CameXmlDslRecipeTest { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsPropertiesTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsPropertiesTest.java index 5992d12742..92d53bb689 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsPropertiesTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsPropertiesTest.java @@ -1,44 +1,4 @@ package io.quarkus.updates.camel.camel40; -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.properties.Assertions; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -public class CamelAPIsPropertiesTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec,"org.openrewrite.java.camel.migrate.ChangePropertyValue") - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true)) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testRejectedPolicyDiscardOldeste() { - rewriteRun(Assertions.properties(""" - #test - camel.threadpool.rejectedPolicy=DiscardOldest - """, - """ - #test - camel.threadpool.rejectedPolicy=Abort #DiscardOldest has been removed, consider Abort - """)); - } - - @Test - void testRejectedPolicyDiscard() { - rewriteRun(Assertions.properties(""" - #test - camel.threadpool.rejectedPolicy=Discard - """, - """ - #test - camel.threadpool.rejectedPolicy=Abort #Discard has been removed, consider Abort - """)); - } - +public class CamelAPIsPropertiesTest extends org.apache.camel.updates.camel40.CamelAPIsPropertiesTest { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsTest.java index 28ad7d1dd3..7db026d0c0 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelAPIsTest.java @@ -1,1169 +1,4 @@ package io.quarkus.updates.camel.camel40; -import static org.openrewrite.java.Assertions.java; - -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -public class CamelAPIsTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-api", - "camel-support", "camel-core-model", "camel-util", "camel-catalog", "camel-main", "camel-management-api")) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testRemovedExchangePatternInOptionalOut() { - //language=java - rewriteRun(java(""" - import org.apache.camel.ExchangePattern; - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - - String uri = "log:c"; - - from("direct:start") - .toD("log:a", true) - .to(ExchangePattern.InOptionalOut, "log:b") - .to(uri); - } - } - """, """ - import org.apache.camel.ExchangePattern; - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - - String uri = "log:c"; - - from("direct:start") - .toD("log:a", true) - .to(ExchangePattern./* InOptionalOut has been removed */, "log:b") - .to(uri); - } - } - """)); - } - - @Test - void testRemovedFullyExchangePatternInOptionalOut() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - - String uri = "log:c"; - - from("direct:start") - .toD("log:a", true) - .to(org.apache.camel.ExchangePattern.InOptionalOut, "log:b") - .to(uri); - } - } - """, """ - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - - String uri = "log:c"; - - from("direct:start") - .toD("log:a", true) - .to(org.apache.camel.ExchangePattern./* InOptionalOut has been removed */, "log:b") - .to(uri); - } - } - """)); - } - - @Test - void testComponentNameResolver() { - //language=java - rewriteRun(java(""" - import org.apache.camel.CamelContext; - - public class Test { - - CamelContext context; - - public void test() { - context.getEndpointMap().containsKey("bar://order"); - } - } - """, - """ - import org.apache.camel.CamelContext; - - public class Test { - - CamelContext context; - - public void test() { - context./* getEndpointMap has been removed, consider getEndpointRegistry() instead */().containsKey("bar://order"); - } - } - """)); - } - - @Test - void testFallbackConverterOnMethod() { - //language=java - rewriteRun(java(""" - import org.apache.camel.FallbackConverter; - - public class Test { - - @FallbackConverter - public void test() { - } - } - """, """ - import org.apache.camel.Converter; - - public class Test { - - @Converter(fallback = true) - public void test() { - } - } - """)); - } - - @Test - void testFallbackConverterOnClassDef() { - //language=java - rewriteRun(java(""" - import org.apache.camel.FallbackConverter; - - @FallbackConverter - public class Test { - } - """, """ - import org.apache.camel.Converter; - - @Converter(fallback = true) - public class Test { - } - """)); - } - - @Test - void testEndpointInject() { - //language=java - rewriteRun(java(""" - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.EndpointInject; - - public class Test { - - @EndpointInject(uri = "mock:out") - private MockEndpoint endpoint; - } - """, """ - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.EndpointInject; - - public class Test { - - @EndpointInject("mock:out") - private MockEndpoint endpoint; - } - """)); - } - - @Test - void testProduce() { - //language=java - rewriteRun(java(""" - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.Produce; - - public class Test { - - @Produce(uri = "test") - private MockEndpoint endpoint() { - return null; - } - } - """, """ - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.Produce; - - public class Test { - - @Produce("test") - private MockEndpoint endpoint() { - return null; - } - } - """)); - } - - @Test - void testConsume() { - //language=java - rewriteRun(java(""" - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.Consume; - - public class Test { - - @Consume(uri = "test") - private MockEndpoint endpoint() { - return null; - } - } - """, """ - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.Consume; - - public class Test { - - @Consume("test") - private MockEndpoint endpoint() { - return null; - } - } - """)); - } - - @Test - void testUriEndpoint() { - //language=java - rewriteRun(java(""" - import org.apache.camel.spi.UriEndpoint; - import org.apache.camel.support.DefaultEndpoint; - - @UriEndpoint(firstVersion = "2.0.0", label = "rest", lenientProperties = true) - public class MicrometerEndpoint extends DefaultEndpoint { - } - """, """ - import org.apache.camel.Category; - import org.apache.camel.spi.UriEndpoint; - import org.apache.camel.support.DefaultEndpoint; - - @UriEndpoint(firstVersion = "2.0.0",category = {Category.rest}, lenientProperties = true) - public class MicrometerEndpoint extends DefaultEndpoint { - } - """)); - } - - @Test - void testUriEndpointWithUnknownValue() { - //language=java - rewriteRun(java(""" - import org.apache.camel.spi.UriEndpoint; - import org.apache.camel.support.DefaultEndpoint; - - @UriEndpoint(firstVersion = "2.0.0", label = "test", lenientProperties = true) - public class MicrometerEndpoint extends DefaultEndpoint { - } - """, - """ - import org.apache.camel.Category; - import org.apache.camel.spi.UriEndpoint; - import org.apache.camel.support.DefaultEndpoint; - - @UriEndpoint(firstVersion = "2.0.0",category = {Category."test"/*unknown_value*/}, lenientProperties = true) - public class MicrometerEndpoint extends DefaultEndpoint { - } - """)); - } - - @Test - void testAsyncCallback() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.ProducerTemplate; - import org.apache.camel.Exchange; - - public class Test { - ProducerTemplate template; - - public void test() { - Exchange exchange = context.getEndpoint("direct:start").createExchange(); - exchange.getIn().setBody("Hello"); - - template.asyncCallback("direct:start", exchange, null); - } - - } - """, - """ - import org.apache.camel.ProducerTemplate; - import org.apache.camel.Exchange; - - public class Test { - ProducerTemplate template; - - public void test() { - Exchange exchange = context.getEndpoint("direct:start").createExchange(); - exchange.getIn().setBody("Hello"); - - /* Method 'asyncCallback()' has been replaced by 'asyncSend()' or 'asyncRequest()'.*/template.asyncCallback("direct:start", exchange, null); - } - - } - """)); - } - - @Test - void testOnCamelContextStart() { - //language=java - rewriteRun(java(""" - import org.apache.camel.spi.OnCamelContextStart; - import org.apache.camel.CamelContext; - - public class Test implements OnCamelContextStart{ - public void onContextStart(CamelContext context) { - } - } - """, """ - import org.apache.camel.spi.OnCamelContextStarting; - import org.apache.camel.CamelContext; - - public class Test implements OnCamelContextStarting{ - public void onContextStart(CamelContext context) { - } - } - """)); - } - - @Test - void testOnCamelContextStop() { - //language=java - rewriteRun(java(""" - import org.apache.camel.spi.OnCamelContextStop; - import org.apache.camel.CamelContext; - - public class Test implements OnCamelContextStop{ - public void onContextStop(CamelContext context) { - } - } - """, """ - import org.apache.camel.spi.OnCamelContextStopping; - import org.apache.camel.CamelContext; - - public class Test implements OnCamelContextStopping{ - public void onContextStop(CamelContext context) { - } - } - """)); - } - - @Test - void testAdapt() { - //language=java - rewriteRun(java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - - public class Test { - - CamelContext context; - - public void test() { - context.adapt(ModelCamelContext.class).getRouteDefinition("forMocking"); - } - } - """, """ - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - - public class Test { - - CamelContext context; - - public void test() { - ((ModelCamelContext)context).getRouteDefinition("forMocking"); - } - } - """)); - } - - @Test - void testMoreOccurrencesAdapt() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - - public class Test { - - CamelContext context, c1, c2, c3; - - public ModelCamelContext test() { - context.adapt(ModelCamelContext.class).getRouteDefinition("forMocking"); - c1.adapt(ModelCamelContext.class).getRegistry(); - c2.adapt(ModelCamelContext.class); - return c3.adapt(ModelCamelContext.class); - } - } - """, """ - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - - public class Test { - - CamelContext context, c1, c2, c3; - - public ModelCamelContext test() { - ((ModelCamelContext)context).getRouteDefinition("forMocking"); - ((ModelCamelContext)c1).getRegistry(); - /*Method 'adapt' was removed.*/c2.adapt(ModelCamelContext.class); - return /*Method 'adapt' was removed.*/c3.adapt(ModelCamelContext.class); - } - } - """)); - } - - @Test - void testAdaptStandalone() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - - public class Test { - - CamelContext context; - - public void test() { - - context.adapt(ModelCamelContext.class); - } - } - """, """ - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - - public class Test { - - CamelContext context; - - public void test() { - - /*Method 'adapt' was removed.*/context.adapt(ModelCamelContext.class); - } - } - """)); - } - - @Test - void testAdapt2() { - //language=java - rewriteRun(java(""" - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.impl.engine.DefaultHeadersMapFactory; - - public class Test { - - CamelContext context; - - public DefaultHeadersMapFactory test() { - return context.adapt(ExtendedCamelContext.class).getHeadersMapFactory(); - } - } - """, """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.impl.engine.DefaultHeadersMapFactory; - - public class Test { - - CamelContext context; - - public DefaultHeadersMapFactory test() { - return context.getCamelContextExtension().getHeadersMapFactory(); - } - } - """)); - } - - @Test - void testComponenetNameResolverViaPluginHelper() { - //language=java - rewriteRun(java(""" - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.ComponentNameResolver; - - public class Test { - - CamelContext context; - - public void test() { - ComponentNameResolver ec = context.getExtension(ExtendedCamelContext.class).getComponentNameResolver(); - } - } - """, - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.ComponentNameResolver; - import org.apache.camel.support.PluginHelper; - - public class Test { - - CamelContext context; - - public void test() { - ComponentNameResolver ec = PluginHelper.getComponentNameResolver(context); - } - } - """)); - } - - @Test - void testModelJAXBContextFactoryViaPluginHelper() { - //language=java - rewriteRun(java(""" - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.ModelJAXBContextFactory; - - public class Test { - - ExtendedCamelContext ecc; - CamelContext context; - - public void test() { - ModelJAXBContextFactory jcf = ecc.getModelJAXBContextFactory(); - ModelJAXBContextFactory jcf2 = context.getExtension(ExtendedCamelContext.class).getModelJAXBContextFactory(); - } - } - """, - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.ModelJAXBContextFactory; - import org.apache.camel.support.PluginHelper; - - public class Test { - - ExtendedCamelContext ecc; - CamelContext context; - - public void test() { - ModelJAXBContextFactory jcf = PluginHelper.getModelJAXBContextFactory(ecc); - ModelJAXBContextFactory jcf2 = PluginHelper.getModelJAXBContextFactory(context); - } - } - """)); - } - - @Test - void testModelToXMLDumperViaPluginHelper() { - //language=java - rewriteRun(java(""" - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.ModelToXMLDumper; - - public class Test { - - ExtendedCamelContext ecc; - CamelContext context; - - public void test() { - ModelToXMLDumper xd = ecc.getModelToXMLDumper(); - ModelToXMLDumper xd2 = context.getExtension(ExtendedCamelContext.class).getModelToXMLDumper(); - } - } - """, - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.ModelToXMLDumper; - import org.apache.camel.support.PluginHelper; - - public class Test { - - ExtendedCamelContext ecc; - CamelContext context; - - public void test() { - ModelToXMLDumper xd = PluginHelper.getModelToXMLDumper(ecc); - ModelToXMLDumper xd2 = PluginHelper.getModelToXMLDumper(context); - } - } - """)); - } - - @Test - void getRoutesLoaderViaPluginHelper() { - //language=java - rewriteRun(java(""" - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.RoutesLoader; - - public class Test { - - ExtendedCamelContext ecc; - CamelContext context; - - public void test() { - RoutesLoader rl = ecc.getRoutesLoader(); - RoutesLoader rl = context.getExtension(ExtendedCamelContext.class).getRoutesLoader(); - } - } - """, - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - import org.apache.camel.spi.RoutesLoader; - import org.apache.camel.support.PluginHelper; - - public class Test { - - ExtendedCamelContext ecc; - CamelContext context; - - public void test() { - RoutesLoader rl = PluginHelper.getRoutesLoader(ecc); - RoutesLoader rl = PluginHelper.getRoutesLoader(context); - } - } - """)); - } - - @Test - void testRuntimeCatalog() { - //language=java - rewriteRun(java( - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.catalog.RuntimeCamelCatalog; - - public class Test { - - CamelContext context; - - public void test() { - final CamelRuntimeCatalog catalog = (CamelRuntimeCatalog) context.getExtension(RuntimeCamelCatalog.class); - } - } - """, - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.catalog.RuntimeCamelCatalog; - - public class Test { - - CamelContext context; - - public void test() { - final CamelRuntimeCatalog catalog = (CamelRuntimeCatalog) context.getCamelContextExtension().getContextPlugin(RuntimeCamelCatalog.class); - } - } - """)); - } - - @Test - void testAdaptRouteDefinition() { - //language=java - rewriteRun(java( - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - import org.apache.camel.impl.engine.DefaultHeadersMapFactory; - - public class Test { - - CamelContext context; - - public DefaultHeadersMapFactory test() { - AdviceWith.adviceWith(context.adapt(ModelCamelContext.class).getRouteDefinition("forMocking"), context, null); - } - } - """, - """ - package org.apache.camel.quarkus.component.test.it; - - import org.apache.camel.CamelContext; - import org.apache.camel.model.ModelCamelContext; - import org.apache.camel.impl.engine.DefaultHeadersMapFactory; - - public class Test { - - CamelContext context; - - public DefaultHeadersMapFactory test() { - AdviceWith.adviceWith(((ModelCamelContext)context).getRouteDefinition("forMocking"), context, null); - } - } - """)); - } - - @Test - void testDecoupleExtendedCamelContext() { - //language=java - rewriteRun(java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.ExtendedCamelContext; - - public class Test { - - CamelContext getCamelContext() { - return null; - } - - public Object test() { - return getCamelContext().adapt(ExtendedCamelContext.class).getPeriodTaskScheduler(); - } - } - """, """ - import org.apache.camel.CamelContext; - - public class Test { - - CamelContext getCamelContext() { - return null; - } - - public Object test() { - return getCamelContext().getCamelContextExtension().getPeriodTaskScheduler(); - } - } - """)); - } - - @Test - void testDecoupleExtendedExchange() { - //language=java - rewriteRun(java(""" - import org.apache.camel.Exchange; - import org.apache.camel.ExtendedExchange; - import org.apache.camel.spi.Synchronization; - - public class Test { - - Exchange exchange; - Synchronization onCompletion; - - public void test() { - // add exchange callback - exchange.adapt(ExtendedExchange.class).addOnCompletion(onCompletion); - } - } - """, """ - import org.apache.camel.Exchange; - import org.apache.camel.spi.Synchronization; - - public class Test { - - Exchange exchange; - Synchronization onCompletion; - - public void test() { - // add exchange callback - exchange.getExchangeExtension().addOnCompletion(onCompletion); - } - } - """)); - } - - @Test - void testDecoupleExtendedExchange2() { - //language=java - rewriteRun(java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.catalog.RuntimeCamelCatalog; - - public class Test { - - CamelContext context; - - public void test() { - final Something catalog = (Something) context.getExtension(RuntimeCamelCatalog.class); - } - } - """, - """ - import org.apache.camel.CamelContext; - import org.apache.camel.catalog.RuntimeCamelCatalog; - - public class Test { - - CamelContext context; - - public void test() { - final Something catalog = (Something) context.getCamelContextExtension().getContextPlugin(RuntimeCamelCatalog.class); - } - } - """)); - } - - @Test - void testExchangeIsFailureHandled() { - //language=java - rewriteRun(java(""" - import org.apache.camel.Exchange; - import org.apache.camel.ExchangePropertyKey; - - public class Test { - - Exchange exchange; - - public void test() { - boolean failureHandled = exchange.getProperty(ExchangePropertyKey.FAILURE_HANDLED); - exchange.removeProperty(ExchangePropertyKey.FAILURE_HANDLED); - exchange.setProperty(ExchangePropertyKey.FAILURE_HANDLED, failureHandled); - } - } - """, """ - import org.apache.camel.Exchange; - - public class Test { - - Exchange exchange; - - public void test() { - boolean failureHandled = exchange.getExchangeExtension().isFailureHandled(); - exchange.getExchangeExtension().setFailureHandled(false); - exchange.getExchangeExtension().setFailureHandled(failureHandled); - } - } - """)); - } - - @Test - void testThreadPoolRejectedPolicy() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy; - - import static org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy.Discard; - import static org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy.DiscardOldest; - - public class Test { - - public void test() { - ThreadPoolRejectedPolicy policy = ThreadPoolRejectedPolicy.Discard; - ThreadPoolRejectedPolicy policy2 = Discard; - ThreadPoolRejectedPolicy policy3 = ThreadPoolRejectedPolicy.DiscardOldest; - ThreadPoolRejectedPolicy policy4 = DiscardOldest; - } - } - """, - """ - import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy; - - /*'ThreadPoolRejectedPolicy.Discard' has been removed, consider using 'ThreadPoolRejectedPolicy.Abort'.*/import static org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy.Discard; - /*'ThreadPoolRejectedPolicy.DiscardOldest' has been removed, consider using 'ThreadPoolRejectedPolicy.Abort'.*/import static org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy.DiscardOldest; - - public class Test { - - public void test() { - ThreadPoolRejectedPolicy policy = /*'ThreadPoolRejectedPolicy.Discard' has been removed, consider using 'ThreadPoolRejectedPolicy.Abort'.*/ThreadPoolRejectedPolicy.Discard; - ThreadPoolRejectedPolicy policy2 = Discard; - ThreadPoolRejectedPolicy policy3 = /*'ThreadPoolRejectedPolicy.DiscardOldest' has been removed, consider using 'ThreadPoolRejectedPolicy.Abort'.*/ThreadPoolRejectedPolicy.DiscardOldest; - ThreadPoolRejectedPolicy policy4 = DiscardOldest; - } - } - """)); - } - - @Test - void testSimpleBuilder() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.builder.SimpleBuilder; - """, - """ - /*'java.beans.SimpleBeanInfo' has been removed, (class was used internally).*/import org.apache.camel.builder.SimpleBuilder; - """)); - } - - @Test - void testOneIntrospectionSupport() { - //language=java - rewriteRun(spec -> CamelQuarkusTestUtil.recipe(spec, "3alpha", "org.openrewrite.java.camel.migrate.ChangeTypes"), - java(""" - import org.apache.camel.support.IntrospectionSupport; - - import static org.apache.camel.support.IntrospectionSupport; - - - public class Test { - - public void test() { - IntrospectionSupport is; - } - } - """, """ - import org.apache.camel.impl.engine.IntrospectionSupport; - - public class Test { - - public void test() { - IntrospectionSupport is; - } - } - """)); - } - - @Test - void testMultiIntrospectionSupport() { - //language=java - rewriteRun(spec -> CamelQuarkusTestUtil.recipe(spec, "3alpha", "org.openrewrite.java.camel.migrate.ChangeTypes"), - java(""" - import org.apache.camel.support.IntrospectionSupport; - - import static org.apache.camel.support.IntrospectionSupport.getGetterShorthandName; - import static org.apache.camel.support.IntrospectionSupport.isGetter; - import static org.apache.camel.support.IntrospectionSupport.isSetter; - - public class Test { - - public void test() { - IntrospectionSupport is; - isGetter(null); - isSetter(null); - getGetterShorthandName(null); - } - } - """, """ - import org.apache.camel.impl.engine.IntrospectionSupport; - - import static org.apache.camel.impl.engine.IntrospectionSupport.*; - - public class Test { - - public void test() { - IntrospectionSupport is; - isGetter(null); - isSetter(null); - getGetterShorthandName(null); - } - } - """)); - } - - @Test - void testarchetypeCatalogAsXml() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.catalog.CamelCatalog; - - public class Test { - - static CamelCatalog catalog; - - public void test() { - String schema = catalog.archetypeCatalogAsXml(); - } - } - """, - """ - import org.apache.camel.catalog.CamelCatalog; - - public class Test { - - static CamelCatalog catalog; - - public void test() { - String schema = /* Method 'archetypeCatalogAsXml' has been removed. */catalog.archetypeCatalogAsXml(); - } - } - """)); - } - - @Test - void testMainListenerConfigureImpl() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.CamelContext; - import org.apache.camel.main.MainListener; - - public class Test implements MainListener { - - @Override - public void configure(CamelContext context) { - //do something - } - } - """, - """ - import org.apache.camel.CamelContext; - import org.apache.camel.main.MainListener; - - public class Test implements MainListener { - - /* Method 'configure' was removed from `org.apache.camel.main.MainListener`, consider using 'beforeConfigure' or 'afterConfigure'. */@Override - public void configure(CamelContext context) { - //do something - } - } - """)); - } - - @Test - void testDumpRoutes() { - //language=java - rewriteRun(spec -> spec.expectedCyclesThatMakeChanges(2), java(""" - import org.apache.camel.CamelContext; - - public class Test { - public void test(CamelContext context) { - boolean dump = context.isDumpRoutes(); - context.setDumpRoutes(true); - } - } - """, - """ - import org.apache.camel.CamelContext; - - public class Test { - public void test(CamelContext context) { - boolean dump = /* Method 'getDumpRoutes' returns String value ('xml' or 'yaml' or 'false'). */context.getDumpRoutes(); - /* Method 'setDumpRoutes' accepts String parameter ('xml' or 'yaml' or 'false'). */context.setDumpRoutes(true); - } - } - """)); - } - - @Test - void testAdapt3() { - //language=java - rewriteRun(java( - """ - import jakarta.enterprise.context.ApplicationScoped; - import jakarta.inject.Inject; - 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.core.MediaType; - - import org.apache.camel.CamelContext; - import org.apache.camel.ProducerTemplate; - import org.apache.camel.builder.AdviceWith; - import org.apache.camel.builder.AdviceWithRouteBuilder; - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.model.ModelCamelContext; - import org.jboss.logging.Logger; - import org.wildfly.common.Assert; - - public class Test { - public void test(CamelContext context) { - // advice the first route using the inlined AdviceWith route builder - // which has extended capabilities than the regular route builder - AdviceWith.adviceWith(context.adapt(ModelCamelContext.class).getRouteDefinition("forMocking"), context, - new AdviceWithRouteBuilder() { - @Override - public void configure() throws Exception { - mockEndpoints("direct:mock.*", "log:mock.*"); - } - }); - } - } - """, - """ - import jakarta.enterprise.context.ApplicationScoped; - import jakarta.inject.Inject; - 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.core.MediaType; - - import org.apache.camel.CamelContext; - import org.apache.camel.ProducerTemplate; - import org.apache.camel.builder.AdviceWith; - import org.apache.camel.builder.AdviceWithRouteBuilder; - import org.apache.camel.component.mock.MockEndpoint; - import org.apache.camel.model.ModelCamelContext; - import org.jboss.logging.Logger; - import org.wildfly.common.Assert; - - public class Test { - public void test(CamelContext context) { - // advice the first route using the inlined AdviceWith route builder - // which has extended capabilities than the regular route builder - AdviceWith.adviceWith(((ModelCamelContext)context).getRouteDefinition("forMocking"), context, - new AdviceWithRouteBuilder() { - @Override - public void configure() throws Exception { - mockEndpoints("direct:mock.*", "log:mock.*"); - } - }); - } - } - """)); - } - - @Test - void testBacklogTracerEventMessage() { - //language=java - rewriteRun(java(""" - import org.apache.camel.api.management.mbean.BacklogTracerEventMessage; - - public class Test { - - public void test() { - BacklogTracerEventMessage msg; - } - } - """, """ - import org.apache.camel.spi.BacklogTracerEventMessage; - - public class Test { - - public void test() { - BacklogTracerEventMessage msg; - } - } - """)); - } -} +public class CamelAPIsTest extends org.apache.camel.updates.camel40.CamelAPIsTest { +} \ No newline at end of file diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelBeanRecipeTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelBeanRecipeTest.java index b819a606ba..4315813d37 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelBeanRecipeTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelBeanRecipeTest.java @@ -1,173 +1,4 @@ package io.quarkus.updates.camel.camel40; -import static org.openrewrite.java.Assertions.java; - -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -public class CamelBeanRecipeTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-bean", "camel-core-model")) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testClassTypeAndInt() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(com.foo.MyOrder, int)"); - } - } - """, """ - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(com.foo.MyOrder.class, int.class)"); - } - } - """ - - )); - } - - @Test - void testClassTypeAndBoolean() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(com.foo.MyOrder, true)"); - } - } - """, """ - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(com.foo.MyOrder.class, true)"); - } - } - """ - - )); - } - - @Test - void testClassTypeAndFloat() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(com.foo.MyOrder, float)"); - } - } - """, """ - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(com.foo.MyOrder.class, float.class)"); - } - } - """ - - )); - } - - @Test - void testDoubleAndChar() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(double, char)"); - } - } - """, """ - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(double.class, char.class)"); - } - } - """ - - )); - } - - @Test - void testMultipleTo() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(double, char)") - .to("bean:myBean?method=bar(float, int)"); - } - } - """, """ - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .to("bean:myBean?method=foo(double.class, char.class)") - .to("bean:myBean?method=bar(float.class, int.class)"); - } - } - """ - - )); - } - +public class CamelBeanRecipeTest extends org.apache.camel.updates.camel40.CamelBeanRecipeTest { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelEIPRecipeTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelEIPRecipeTest.java index 40d6146e24..73b59fec86 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelEIPRecipeTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelEIPRecipeTest.java @@ -1,108 +1,4 @@ package io.quarkus.updates.camel.camel40; -import static org.openrewrite.java.Assertions.java; - -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -public class CamelEIPRecipeTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-activemq", "camel-core-model")) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testRemovedEIPInOptionalOut() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .inOut("activemq:queue:testqueue") - .to("log:result_a"); - } - } - """, """ - import org.apache.camel.ExchangePattern; - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .setExchangePattern(ExchangePattern.InOut).to("activemq:queue:testqueue") - .to("log:result_a"); - } - } - """ - - )); - } - - @Test - void testRemovedEIPOutOptionalIn() { - //language=java - rewriteRun(java(""" - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .inOut("activemq:queue:testqueue") - .to("log:result_a"); - } - } - """, """ - import org.apache.camel.ExchangePattern; - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .setExchangePattern(ExchangePattern.InOut).to("activemq:queue:testqueue") - .to("log:result_a"); - } - } - """ - - )); - } - - @Test - void testRemovedEIPOutIn() { - //language=java - rewriteRun(java(""" - import org.apache.camel.ExchangePattern; - import org.apache.camel.builder.RouteBuilder; - - public class MySimpleToDRoute extends RouteBuilder { - - @Override - public void configure() { - from("direct:a") - .setExchangePattern(ExchangePattern.InOut).to("activemq:queue:testqueue") - .to("log:result_a"); - } - } - """ - - )); - } - +public class CamelEIPRecipeTest extends org.apache.camel.updates.camel40.CamelEIPRecipeTest { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelHttpTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelHttpTest.java index c98358f0fd..5edaf3d6bc 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelHttpTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelHttpTest.java @@ -1,140 +1,4 @@ package io.quarkus.updates.camel.camel40; -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -import static org.openrewrite.java.Assertions.java; - -public class CamelHttpTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec) - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-api", - "camel-support", "camel-core-model", "camel-util", "camel-catalog", "camel-main", "httpclient" - ,"httpcore", "httpclient")) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testHttp() { - //language=java - rewriteRun(java( - """ - import jakarta.inject.Named; - - import org.apache.http.HttpHost; - import org.apache.http.auth.AuthScope; - import org.apache.http.auth.UsernamePasswordCredentials; - import org.apache.http.client.protocol.HttpClientContext; - import org.apache.http.impl.auth.BasicScheme; - import org.apache.http.impl.client.BasicAuthCache; - import org.apache.http.impl.client.BasicCredentialsProvider; - import org.apache.http.protocol.HttpContext; - import org.eclipse.microprofile.config.ConfigProvider; - - import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN; - import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN_PASSWORD; - - public class HttpProducers { - - @Named - HttpContext basicAuthContext() { - Integer port = ConfigProvider.getConfig().getValue("quarkus.http.test-port", Integer.class); - - UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(USER_ADMIN, USER_ADMIN_PASSWORD); - BasicCredentialsProvider provider = new BasicCredentialsProvider(); - provider.setCredentials(AuthScope.ANY, credentials); - - BasicAuthCache authCache = new BasicAuthCache(); - BasicScheme basicAuth = new BasicScheme(); - authCache.put(new HttpHost("localhost", port), basicAuth); - - HttpClientContext context = HttpClientContext.create(); - context.setAuthCache(authCache); - context.setCredentialsProvider(provider); - - return context; - } - } - """, - """ - import jakarta.inject.Named; - import org.apache.hc.client5.http.auth.AuthScope; - import org.apache.hc.client5.http.auth.UsernamePasswordCredentials; - import org.apache.hc.client5.http.impl.auth.BasicAuthCache; - import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; - import org.apache.hc.client5.http.impl.auth.BasicScheme; - import org.apache.hc.client5.http.protocol.HttpClientContext; - import org.apache.hc.core5.http.HttpHost; - import org.apache.hc.core5.http.protocol.HttpContext; - import org.eclipse.microprofile.config.ConfigProvider; - - import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN; - import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN_PASSWORD; - - public class HttpProducers { - - @Named - HttpContext basicAuthContext() { - Integer port = ConfigProvider.getConfig().getValue("quarkus.http.test-port", Integer.class); - - UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(USER_ADMIN, USER_ADMIN_PASSWORD); - BasicCredentialsProvider provider = new BasicCredentialsProvider(); - provider.setCredentials(new AuthScope(null, -1), credentials); - - BasicAuthCache authCache = new BasicAuthCache(); - BasicScheme basicAuth = new BasicScheme(); - authCache.put(new HttpHost("localhost", port), basicAuth); - - HttpClientContext context = HttpClientContext.create(); - context.setAuthCache(authCache); - context.setCredentialsProvider(provider); - - return context; - } - } - """)); - } - @Test - void testNoopHostnameVerifier() { - //language=java - rewriteRun(java( - """ - import jakarta.inject.Named; - import org.apache.camel.CamelContext; - import org.apache.http.conn.ssl.NoopHostnameVerifier; - import org.eclipse.microprofile.config.ConfigProvider; - - public class HttpProducers { - - CamelContext context; - - @Named - public NoopHostnameVerifier x509HostnameVerifier() { - return NoopHostnameVerifier.INSTANCE; - } - } - """, - """ - import jakarta.inject.Named; - import org.apache.camel.CamelContext; - import org.apache.hc.client5.http.conn.ssl.NoopHostnameVerifier; - import org.eclipse.microprofile.config.ConfigProvider; - - public class HttpProducers { - - CamelContext context; - - @Named - public NoopHostnameVerifier x509HostnameVerifier() { - return NoopHostnameVerifier.INSTANCE; - } - } - """)); - } +public class CamelHttpTest extends org.apache.camel.updates.camel40.CamelHttpTest { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelJmxTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelJmxTest.java index ccf3164062..0045833f1c 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelJmxTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelJmxTest.java @@ -1,55 +1,4 @@ package io.quarkus.updates.camel.camel40; -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; - -import static org.openrewrite.java.Assertions.java; - -public class CamelJmxTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec, "org.openrewrite.java.camel.migrate.ChangeManagedChoiceMBeanMethodName", - "org.openrewrite.java.camel.migrate.ChangeManagedFailoverLoadBalancerMBeanMethodName") - .parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("camel-management-api")) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testRenamedMethods() { - //language=java - rewriteRun(java( - """ - import org.apache.camel.api.management.mbean.ManagedChoiceMBean; - import org.apache.camel.api.management.mbean.ManagedFailoverLoadBalancerMBean; - - public class Test { - - void test() { - ManagedChoiceMBean mbean = null; - mbean.choiceStatistics(); - ManagedFailoverLoadBalancerMBean mbean2 = null; - mbean2.exceptionStatistics(); - } - } - """, - """ - import org.apache.camel.api.management.mbean.ManagedChoiceMBean; - import org.apache.camel.api.management.mbean.ManagedFailoverLoadBalancerMBean; - - public class Test { - - void test() { - ManagedChoiceMBean mbean = null; - mbean.extendedInformation(); - ManagedFailoverLoadBalancerMBean mbean2 = null; - mbean2.extendedInformation(); - } - } - """)); - } +public class CamelJmxTest extends org.apache.camel.updates.camel40.CamelAPIsTest { } diff --git a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelYamlTest.java b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelYamlTest.java index 0c15fc0092..5758f5ca3f 100644 --- a/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelYamlTest.java +++ b/recipes-tests/src/test/java/io/quarkus/updates/camel/camel40/CamelYamlTest.java @@ -1,217 +1,4 @@ package io.quarkus.updates.camel.camel40; -import io.quarkus.updates.camel.CamelQuarkusTestUtil; -import org.junit.jupiter.api.Test; -import org.openrewrite.test.RecipeSpec; -import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; -import org.openrewrite.yaml.Assertions; - -public class CamelYamlTest implements RewriteTest { - - @Override - public void defaults(RecipeSpec spec) { - CamelQuarkusTestUtil.recipe3alpha(spec) - .typeValidationOptions(TypeValidation.none()); - } - - @Test - void testStepsToFrom1() { - //language=yaml - rewriteRun(Assertions.yaml(""" - route: - from: - uri: "direct:info" - steps: - log: "message" - """, """ - route: - from: - uri: "direct:info" - steps: - log: "message" - """)); - } - - @Test - void testStepsToFrom2() { - //language=yaml - rewriteRun(Assertions.yaml(""" - from: - uri: "direct:info" - steps: - log: "message" - """, """ - from: - uri: "direct:info" - steps: - log: "message" - """)); - } - - @Test - void testStepsToFrom3() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - from: - uri: "direct:start" - steps: - - filter: - expression: - simple: "${in.header.continue} == true" - steps: - - to: - uri: "log:filtered" - - to: - uri: "log:original" - """, """ - - from: - uri: "direct:start" - steps: - - filter: - expression: - simple: "${in.header.continue} == true" - steps: - - to: - uri: "log:filtered" - - to: - uri: "log:original" - """)); - } - - @Test - void testRouteConfigurationWithOnException() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - route-configuration: - - id: "yamlRouteConfiguration" - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - """, """ - - route-configuration: - id: "yamlRouteConfiguration" - on-exception: - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - """)); - } - - @Test - void testRouteConfigurationWithoutOnException() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - route-configuration: - - id: "__id" - """, """ - - route-configuration: - id: "__id" - """)); - } - - @Test - void testDoubleDocument() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - route-configuration: - - id: "yamlRouteConfiguration1" - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - --- - - route-configuration: - - id: "yamlRouteConfiguration2" - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - """, """ - - route-configuration: - id: "yamlRouteConfiguration1" - on-exception: - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - --- - - route-configuration: - id: "yamlRouteConfiguration2" - on-exception: - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - """)); - } - - @Test - void testDoubleDocumentSimple() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - route-configuration: - - id: "__id1" - --- - - route-configuration: - - id: "__id2" - """, """ - - route-configuration: - id: "__id1" - --- - - route-configuration: - id: "__id2" - """)); - } - - @Test - void testRouteConfigurationIdempotent() { - //language=yaml - rewriteRun(Assertions.yaml(""" - - route-configuration: - id: "yamlRouteConfiguration" - on-exception: - - on-exception: - handled: - constant: "true" - exception: - - "org.apache.camel.quarkus.core.it.routeconfigurations.RouteConfigurationsException" - steps: - - set-body: - constant: - expression: "onException has been triggered in yamlRouteConfiguration" - """)); - } +public class CamelYamlTest extends org.apache.camel.updates.camel40.CamelYamlTest { } diff --git a/recipes/pom.xml b/recipes/pom.xml index 0c9f276716..2b34941a7b 100644 --- a/recipes/pom.xml +++ b/recipes/pom.xml @@ -133,6 +133,13 @@ ${junit.version} test + + + + org.apache.camel + camel-upgrade-recipes + ${camel-upgrade-recipes.version} + diff --git a/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusJavaVisitor.java b/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusJavaVisitor.java deleted file mode 100644 index 3210c61ea8..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusJavaVisitor.java +++ /dev/null @@ -1,123 +0,0 @@ -package io.quarkus.updates.camel; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.java.JavaIsoVisitor; -import org.openrewrite.java.MethodMatcher; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -/** - * Parent of Camel visitors, skips visit methods in case that there is no camel package imported. - *

- * Every method visit* is marked as final and methods doVisit* are used instead. - *

- *

- * Simple cache for methodMatchers is implemented here. Usage: call MethodMatcher getMethodMatcher(String signature). - *

- */ -public abstract class AbstractCamelQuarkusJavaVisitor extends JavaIsoVisitor { - private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCamelQuarkusJavaVisitor.class); - - //There is no need to initialize all patterns at the class start. - //Map is a cache for created patterns - private static final Map methodMatchers = new HashMap<>(); - - @Override - public final J.Import visitImport(J.Import _import, ExecutionContext context) { - - return executeVisitWithCatch(() -> doVisitImport(_import, context), _import, context); - } - - @Override - public final J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext context) { - return executeVisitWithCatch(() -> doVisitClassDeclaration(classDecl, context), classDecl, context); - } - - @Override - public final J.FieldAccess visitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext context) { - return executeVisitWithCatch(() -> doVisitFieldAccess(fieldAccess, context), fieldAccess, context); - } - - @Override - public final J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext context) { - return executeVisitWithCatch(() -> doVisitMethodDeclaration(method, context), method, context); - } - - @Override - public final J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - return executeVisitWithCatch(() -> doVisitMethodInvocation(method, context), method, context); - } - - @Override - public final J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext context) { - return executeVisitWithCatch(() -> doVisitAnnotation(annotation, context), annotation, context); - } - - @Override - public final J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext context) { - return executeVisitWithCatch(() -> doVisitNewClass(newClass, context), newClass, context); - } - - - //-------------------------------- internal methods used by children--------------------------------- - - protected J.Import doVisitImport(J.Import _import, ExecutionContext context) { - return super.visitImport(_import, context); - } - - protected J.ClassDeclaration doVisitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext context) { - return super.visitClassDeclaration(classDecl, context); - } - - protected J.FieldAccess doVisitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext context) { - return super.visitFieldAccess(fieldAccess, context); - } - - protected J.MethodDeclaration doVisitMethodDeclaration(J.MethodDeclaration method, ExecutionContext context) { - return super.visitMethodDeclaration(method, context); - } - - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - return super.visitMethodInvocation(method, context); - } - - protected J.Annotation doVisitAnnotation(J.Annotation annotation, ExecutionContext context) { - return super.visitAnnotation(annotation, context); - } - protected J.NewClass doVisitNewClass(J.NewClass newClass, ExecutionContext context) { - return super.visitNewClass(newClass, context); - } - - // ------------------------------------------ helper methods ------------------------------------------- - - // If the migration fails - do not fail whole migration process, only this one recipe - protected T executeVisitWithCatch(Supplier visitMethod, T origValue, ExecutionContext context) { - try { - return visitMethod.get(); - } catch (Exception e) { - LOGGER.warn(String.format("Internal error detected in %s, recipe is skipped.", getClass().getName()), e); - return origValue; - } - } - - protected MethodMatcher getMethodMatcher(String signature) { - synchronized (methodMatchers) { - MethodMatcher matcher = methodMatchers.get(signature); - - if (matcher == null) { - matcher = new MethodMatcher(signature); - methodMatchers.put(signature, matcher); - } - - return matcher; - } - } -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusXmlVisitor.java b/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusXmlVisitor.java deleted file mode 100644 index ed0bd38c7a..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusXmlVisitor.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.quarkus.updates.camel; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.xml.XmlIsoVisitor; -import org.openrewrite.xml.tree.Xml; -import org.openrewrite.yaml.YamlIsoVisitor; -import org.openrewrite.yaml.tree.Yaml; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.function.Supplier; - -/** - * Parent of Camel xml visitors, catches any exception, logs it and then continues. - */ -public abstract class AbstractCamelQuarkusXmlVisitor extends XmlIsoVisitor { - private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCamelQuarkusXmlVisitor.class); - - @Override - public final Xml.Tag visitTag(Xml.Tag tag, ExecutionContext executionContext) { - return executeVisitWithCatch(() -> doVisitTag(tag, executionContext), tag, executionContext); - } - - - //-------------------------------- internal methods used by children--------------------------------- - - - public Xml.Tag doVisitTag(Xml.Tag tag, ExecutionContext executionContext) { - return super.visitTag(tag, executionContext); - } - - // If the migration fails - do not fail whole migration process, only this one recipe - protected T executeVisitWithCatch(Supplier visitMethod, T origValue, ExecutionContext context) { - try { - return visitMethod.get(); - } catch (Exception e) { - LOGGER.warn(String.format("Internal error detected in %s, recipe is skipped.", getClass().getName()), e); - return origValue; - } - } - -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusYamlVisitor.java b/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusYamlVisitor.java deleted file mode 100644 index 6df5e751a6..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/AbstractCamelQuarkusYamlVisitor.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.quarkus.updates.camel; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.java.JavaIsoVisitor; -import org.openrewrite.java.MethodMatcher; -import org.openrewrite.java.tree.J; -import org.openrewrite.yaml.YamlIsoVisitor; -import org.openrewrite.yaml.tree.Yaml; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; - -/** - * Parent of Camel yaml visitors, catches any exception, logs it and then continues. - */ -public abstract class AbstractCamelQuarkusYamlVisitor extends YamlIsoVisitor { - private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCamelQuarkusYamlVisitor.class); - - /** - * Method is called before start of visiting a new document. - * Implementations might need to clear all local state from previous document. - */ - protected abstract void clearLocalCache(); - - - @Override - public final Yaml.Document visitDocument(Yaml.Document document, ExecutionContext o) { - clearLocalCache(); - Yaml.Document d = super.visitDocument(document, o); - return d; - } - - @Override - public final Yaml.Mapping.Entry visitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext executionContext) { - return executeVisitWithCatch(() -> doVisitMappingEntry(entry, executionContext), entry, executionContext); - } - - @Override - public final Yaml.Sequence visitSequence(Yaml.Sequence sequence, ExecutionContext executionContext) { - return executeVisitWithCatch(() -> doVisitSequence(sequence, executionContext), sequence, executionContext); - } - - @Override - public final Yaml.Mapping visitMapping(Yaml.Mapping mapping, ExecutionContext executionContext) { - return executeVisitWithCatch(() -> - doVisitMapping(mapping, executionContext) - , mapping, executionContext); - } - - //-------------------------------- internal methods used by children--------------------------------- - - - public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext executionContext) { - return super.visitMappingEntry(entry, executionContext); - } - - public Yaml.Sequence doVisitSequence(Yaml.Sequence sequence, ExecutionContext executionContext) { - return super.visitSequence(sequence, executionContext); - } - - public Yaml.Mapping doVisitMapping(Yaml.Mapping mapping, ExecutionContext executionContext) { - return super.visitMapping(mapping, executionContext); - } - - // If the migration fails - do not fail whole migration process, only this one recipe - protected T executeVisitWithCatch(Supplier visitMethod, T origValue, ExecutionContext context) { - try { - return visitMethod.get(); - } catch (Exception e) { - LOGGER.warn(String.format("Internal error detected in %s, recipe is skipped.", getClass().getName()), e); - return origValue; - } - } - -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/RecipesUtil.java b/recipes/src/main/java/io/quarkus/updates/camel/RecipesUtil.java deleted file mode 100644 index 7a9bb7813d..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/RecipesUtil.java +++ /dev/null @@ -1,283 +0,0 @@ -package io.quarkus.updates.camel; - -import org.openrewrite.Cursor; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Preconditions; -import org.openrewrite.Tree; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.search.UsesType; -import org.openrewrite.java.tree.Comment; -import org.openrewrite.java.tree.Expression; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JContainer; -import org.openrewrite.java.tree.JRightPadded; -import org.openrewrite.java.tree.JavaType; -import org.openrewrite.java.tree.Space; -import org.openrewrite.java.tree.TextComment; -import org.openrewrite.marker.Markers; -import org.openrewrite.properties.PropertiesVisitor; -import org.openrewrite.xml.tree.Xml; -import org.openrewrite.yaml.tree.Yaml; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Optional; -import java.util.UUID; -import java.util.function.Function; - -import static org.openrewrite.Tree.randomId; - -public class RecipesUtil { - - - // ---------------- visitors - public static TreeVisitor newVisitor(AbstractCamelQuarkusJavaVisitor visitor) { - return Preconditions.check(new UsesType<>("org.apache.camel..*", false), visitor); - } - - public static TreeVisitor newVisitor(String requiredImport, AbstractCamelQuarkusJavaVisitor visitor) { - return Preconditions.check(new UsesType<>(requiredImport, false), visitor); - } - - - //---------------- annotations helpers - - public static J.Annotation createAnnotation(J.Annotation annotation, String name, Function argMatcher, String args) { - - LinkedList originalArguments = annotation.getArguments() == null ? new LinkedList<>() : new LinkedList<>(annotation.getArguments()); - - String newArgName = args.replaceAll("=.*", "").trim(); - - //remove argument with the same name as the new one - if(argMatcher == null) { - originalArguments.add(new J.Empty(randomId(), Space.format(args), Markers.EMPTY)); - } else { - for (ListIterator iter = originalArguments.listIterator(); iter.hasNext(); ) { - Expression expr = iter.next(); - if (argMatcher.apply(expr.toString().replaceAll("\\s", ""))) { - iter.set(new J.Empty(randomId(), Space.format(args), Markers.EMPTY)); - } - } - } - - //construct arguments for the new annotation - List> newArgs = new LinkedList<>(); - for(Expression e: originalArguments) { - newArgs.add(new JRightPadded<>(e, Space.EMPTY, Markers.EMPTY)); - } - - J.Identifier newAnnotationIdentifier = new J.Identifier(randomId(), annotation.getPrefix(), Markers.EMPTY, - Collections.emptyList(), name, JavaType.ShallowClass.build("java.lang.Object"), null); - JContainer arguments = JContainer.build( - Space.EMPTY, - newArgs, - Markers.EMPTY); - return new J.Annotation(UUID.randomUUID(), annotation.getPrefix(), Markers.EMPTY, - newAnnotationIdentifier, arguments); - } - - public static Optional getValueOfArgs(List expressions, String parameter) { - if(expressions == null || expressions.isEmpty()) { - return Optional.empty(); - } - return expressions.stream() - .filter(e -> e.toString().replaceAll("\\s", "").startsWith(parameter + "=")) - .map(e -> e.toString().replaceAll("\\s", "").replaceFirst(parameter + "=", "")) - .findFirst(); - } - - public static boolean methodInvocationAreArgumentEmpty(J.MethodInvocation mi) { - return mi.getArguments().stream().filter(e -> !(e instanceof J.Empty)).findAny().isEmpty(); - } - - //-------------- methods helping with comments ---- - - public static Comment createMultinlineComment(String text) { - return new TextComment(true, text, null, Markers.EMPTY); - } - public static Comment createComment(String text) { - return new TextComment(false, text, null, Markers.EMPTY); - } - public static Xml.Comment createXmlComment(String text) { - return new Xml.Comment(UUID.randomUUID(), null, Markers.EMPTY, text); - } - - public static boolean isCommentBeforeElement(J element, String comment) { - return element != null && - element.getPrefix() != null && - element.getPrefix().getComments() != null && - !element.getPrefix().getComments().isEmpty() && - element.getPrefix().getComments().stream() - .filter(c -> (c instanceof TextComment && comment.equals(((TextComment) c).getText()))) - .findAny().isPresent(); - } - - //--------------- typeCast helper -------------------------------- - - public static J createTypeCast(Object type, Expression arg) { - return new J.TypeCast( - Tree.randomId(), - Space.EMPTY, - Markers.EMPTY, - RecipesUtil.createParentheses(type), - arg); - } - - // -------------------- other helper methods - - public static J.ControlParentheses createParentheses(T t) { - return new J.ControlParentheses( - Tree.randomId(), - Space.EMPTY, - Markers.EMPTY, - padRight(t)); - } - - public static J.Identifier createIdentifier(Space prefix, String name, String type) { - return new J.Identifier(randomId(), prefix, Markers.EMPTY, Collections.emptyList(), name, - JavaType.ShallowClass.build(type), null); - } - - public static Expression createNullExpression() { - return new J.Literal(UUID.randomUUID(), Space.SINGLE_SPACE, Markers.EMPTY, null, "null", null, JavaType.Primitive.Null); - } - - public static J.Literal createStringLiteral(String value) { - return new J.Literal(UUID.randomUUID(), Space.EMPTY, Markers.EMPTY, value, "\""+value+"\"", null, JavaType.Primitive.String); - } - - - - private static JRightPadded padRight(T tree) { - return new JRightPadded<>(tree, Space.EMPTY, Markers.EMPTY); - } - - public static String getProperty(Cursor cursor) { - StringBuilder asProperty = new StringBuilder(); - Iterator path = cursor.getPath(); - int i = 0; - while (path.hasNext()) { - Object next = path.next(); - if (next instanceof Yaml.Mapping.Entry) { - Yaml.Mapping.Entry entry = (Yaml.Mapping.Entry) next; - if (i++ > 0) { - asProperty.insert(0, '.'); - } - asProperty.insert(0, entry.getKey().getValue()); - } - if (next instanceof Xml.Tag) { - Xml.Tag t = (Xml.Tag) next; - if (i++ > 0) { - asProperty.insert(0, '/'); - } - asProperty.insert(0, t.getName()); - } - } - return asProperty.toString(); - } - - public enum Category { - DATAMINING("datamining"), - AI("ai"), - API("api"), - AZURE("azure"), - BATCH("batch"), - BIGDATA("bigdata"), - BITCOIN("bitcoin"), - BLOCKCHAIN("blockchain"), - CACHE("cache"), - CHAT("chat"), - CLOUD("cloud"), - CLUSTERING("clustering"), - CMS("cms"), - COMPUTE("compute"), - COMPUTING("computing"), - CONTAINER("container"), - CORE("core"), - CRM("crm"), - DATA("data"), - DATABASE("database"), - DATAGRID("datagrid"), - DEEPLEARNING("deeplearning"), - DEPLOYMENT("deployment"), - DOCUMENT("document"), - ENDPOINT("endpoint"), - ENGINE("engine"), - EVENTBUS("eventbus"), - FILE("file"), - HADOOP("hadoop"), - HCM("hcm"), - HL7("hl7"), - HTTP("http"), - IOT("iot"), - IPFS("ipfs"), - JAVA("java"), - LDAP("ldap"), - LEDGER("ledger"), - LOCATION("location"), - LOG("log"), - MAIL("mail"), - MANAGEMENT("management"), - MESSAGING("messaging"), - MLLP("mllp"), - MOBILE("mobile"), - MONITORING("monitoring"), - NETWORKING("networking"), - NOSQL("nosql"), - OPENAPI("openapi"), - PAAS("paas"), - PAYMENT("payment"), - PLANNING("planning"), - PRINTING("printing"), - PROCESS("process"), - QUEUE("queue"), - REACTIVE("reactive"), - REPORTING("reporting"), - REST("rest"), - RPC("rpc"), - RSS("rss"), - SAP("sap"), - SCHEDULING("scheduling"), - SCRIPT("script"), - SEARCH("search"), - SECURITY("security"), - SERVERLESS("serverless"), - SHEETS("sheets"), - SOAP("soap"), - SOCIAL("social"), - SPRING("spring"), - SQL("sql"), - STREAMS("streams"), - SUPPORT("support"), - SWAGGER("swagger"), - SYSTEM("system"), - TCP("tcp"), - TESTING("testing"), - TRANSFORMATION("transformation"), - UDP("udp"), - VALIDATION("validation"), - VOIP("voip"), - WEBSERVICE("webservice"), - WEBSOCKET("websocket"), - WORKFLOW("workflow"); - - private final String value; - - Category(final String value) { - this.value = value; - } - - /** - * Returns the string representation of this value - * - * @return Returns the string representation of this value - */ - public String getValue() { - return this.value; - } - } - -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelAPIsRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelAPIsRecipe.java deleted file mode 100644 index 49544670d7..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelAPIsRecipe.java +++ /dev/null @@ -1,334 +0,0 @@ -package io.quarkus.updates.camel.camel40.java; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.Tree; -import org.openrewrite.TreeVisitor; -import org.openrewrite.internal.lang.Nullable; -import org.openrewrite.java.AddImport; -import org.openrewrite.java.ChangeType; -import org.openrewrite.java.ImplementInterface; -import org.openrewrite.java.JavaTemplate; -import org.openrewrite.java.RemoveImplements; -import org.openrewrite.java.search.UsesMethod; -import org.openrewrite.java.search.UsesType; -import org.openrewrite.java.tree.Comment; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaType; -import org.openrewrite.java.tree.Space; -import org.openrewrite.java.tree.TypeUtils; -import org.openrewrite.marker.Markers; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; -import io.quarkus.updates.camel.RecipesUtil; - -import java.beans.SimpleBeanInfo; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; -import java.util.regex.Pattern; - -/** - * Recipe migrating changes between Camel 3.x to 4.x, for more details see the - * documentation. - */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelAPIsRecipe extends Recipe { - - private static final String MATCHER_CONTEXT_GET_ENDPOINT_MAP = "org.apache.camel.CamelContext getEndpointMap()"; - private static final String MATCHER_CONTEXT_GET_EXT = "org.apache.camel.CamelContext getExtension(java.lang.Class)"; - private static final String M_PRODUCER_TEMPLATE_ASYNC_CALLBACK = "org.apache.camel.ProducerTemplate asyncCallback(..)"; - private static final String M_CONTEXT_ADAPT = "org.apache.camel.CamelContext adapt(java.lang.Class)"; - private static final String M_CONTEXT_SET_DUMP_ROUTES = "org.apache.camel.CamelContext setDumpRoutes(java.lang.Boolean)"; - private static final String M_CONTEXT_IS_DUMP_ROUTES = "org.apache.camel.CamelContext isDumpRoutes()"; - private static final String M_EXCHANGE_ADAPT = "org.apache.camel.Exchange adapt(java.lang.Class)"; - private static final String M_EXCHANGE_GET_PROPERTY = "org.apache.camel.Exchange getProperty(org.apache.camel.ExchangePropertyKey)"; - private static final String M_EXCHANGE_REMOVE_PROPERTY = "org.apache.camel.Exchange removeProperty(org.apache.camel.ExchangePropertyKey)"; - private static final String M_EXCHANGE_SET_PROPERTY = "org.apache.camel.Exchange setProperty(..)"; - private static final String M_CATALOG_ARCHETYPE_AS_XML = "org.apache.camel.catalog.CamelCatalog archetypeCatalogAsXml()"; - - @Override - public String getDisplayName() { - return "Camel API changes"; - } - - @Override - public String getDescription() { - return "Apache Camel API migration from version 3.20 or higher to 4.0. Removal of deprecated APIs."; - } - - @Override - public TreeVisitor getVisitor() { - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - - //Cache for all methodInvocations CamelContext adapt(java.lang.Class). - private Map adaptCache = new HashMap<>(); - - @Override - protected J.Import doVisitImport(J.Import _import, ExecutionContext context) { - J.Import im = super.doVisitImport(_import, context); - - //Removed Discard and DiscardOldest from org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy. - if(im.isStatic() && im.getTypeName().equals("org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy") - && im.getQualid() != null - && ("Discard".equals(im.getQualid().getSimpleName()) || "DiscardOldest".equals(im.getQualid().getSimpleName()))) { - Comment comment = RecipesUtil.createMultinlineComment(String.format("'ThreadPoolRejectedPolicy.%s' has been removed, consider using 'ThreadPoolRejectedPolicy.Abort'.", im.getQualid().getSimpleName())); - im = im.withComments(Collections.singletonList(comment)); - - } - //Removed org.apache.camel.builder.SimpleBuilder. - // Was mostly used internally in Camel with the Java DSL in some situations. - else if("org.apache.camel.builder.SimpleBuilder".equals(im.getTypeName())) { - Comment comment = RecipesUtil.createMultinlineComment(String.format("'%s' has been removed, (class was used internally).", SimpleBeanInfo.class.getCanonicalName())); - im = im.withComments(Collections.singletonList(comment)); - - } - - //Move the following class from org.apache.camel.api.management.mbean.BacklogTracerEventMessage in camel-management-api JAR to org.apache.camel.spi.BacklogTracerEventMessage in camel-api JAR. - // - // BacklogTracerEventMessage moved from `org.apache.camel.api.management.mbean.BacklogTracerEventMessage` - // to `org.apache.camel.spi.BacklogTracerEventMessage` - doAfterVisit( - new ChangeType( - "org.apache.camel.api.management.mbean.BacklogTracerEventMessage", - "org.apache.camel.spi.BacklogTracerEventMessage", true).getVisitor()); - - - return im; - } - - @Override - protected J.ClassDeclaration doVisitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext context) { - J.ClassDeclaration cd = super.doVisitClassDeclaration(classDecl, context); - - //Removed org.apache.camel.spi.OnCamelContextStart. Use org.apache.camel.spi.OnCamelContextStarting instead. - if(cd.getImplements() != null && cd.getImplements().stream() - .anyMatch(f -> TypeUtils.isOfClassType(f.getType(), "org.apache.camel.spi.OnCamelContextStart"))) { - - doAfterVisit(new ImplementInterface(cd, "org.apache.camel.spi.OnCamelContextStarting")); - doAfterVisit(new RemoveImplements("org.apache.camel.spi.OnCamelContextStart", null).getVisitor()); - - } //Removed org.apache.camel.spi.OnCamelContextStop. Use org.apache.camel.spi.OnCamelContextStopping instead. - else if(cd.getImplements() != null && cd.getImplements().stream() - .anyMatch(f -> TypeUtils.isOfClassType(f.getType(), "org.apache.camel.spi.OnCamelContextStop"))) { - - doAfterVisit(new ImplementInterface(cd, "org.apache.camel.spi.OnCamelContextStopping")); - doAfterVisit(new RemoveImplements("org.apache.camel.spi.OnCamelContextStop", null).getVisitor()); - - } - return cd; - } - - @Override - protected J.FieldAccess doVisitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext context) { - J.FieldAccess fa = super.doVisitFieldAccess(fieldAccess, context); - //The org.apache.camel.ExchangePattern has removed InOptionalOut. - if("InOptionalOut".equals(fieldAccess.getSimpleName()) && fa.getType() != null && fa.getType().isAssignableFrom(Pattern.compile("org.apache.camel.ExchangePattern"))) { - return fa.withName(new J.Identifier(UUID.randomUUID(), fa.getPrefix(), Markers.EMPTY, Collections.emptyList(), "/* " + fa.getSimpleName() + " has been removed */", fa.getType(), null)); - } - - else if(("Discard".equals(fa.getSimpleName()) || "DiscardOldest".equals(fa.getSimpleName())) - && fa.getType() != null && fa.getType().isAssignableFrom(Pattern.compile("org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy")) - ) { - Comment comment = RecipesUtil.createMultinlineComment(String.format("'ThreadPoolRejectedPolicy.%s' has been removed, consider using 'ThreadPoolRejectedPolicy.Abort'.", fa.getSimpleName())); - fa = fa.withComments(Collections.singletonList(comment)); - - } - - - return fa; - } - - - @Override - protected J.MethodDeclaration doVisitMethodDeclaration(J.MethodDeclaration method, ExecutionContext context) { - J.MethodDeclaration md = super.doVisitMethodDeclaration(method, context); - - //Method 'configure' was removed from `org.apache.camel.main.MainListener`, consider using 'beforeConfigure' or 'afterConfigure'. - if("configure".equals(md.getSimpleName()) - && JavaType.Primitive.Void.equals(md.getReturnTypeExpression().getType()) - && md.getMethodType().getDeclaringType().isAssignableFrom(Pattern.compile("org.apache.camel.main.MainListener")) - && !md.getParameters().isEmpty() - && md.getParameters().size() == 1 - && md.getParameters().get(0) instanceof J.VariableDeclarations - && ((J.VariableDeclarations)md.getParameters().get(0)).getType().isAssignableFrom(Pattern.compile("org.apache.camel.CamelContext"))) { - Comment comment = RecipesUtil.createMultinlineComment(String.format(" Method '%s' was removed from `%s`, consider using 'beforeConfigure' or 'afterConfigure'. ", md.getSimpleName(), "org.apache.camel.main.MainListener")); - md = md.withComments(Collections.singletonList(comment)); - } - - return md; - } - - @Override - protected J.Annotation doVisitAnnotation(J.Annotation annotation, ExecutionContext context) { - J.Annotation a = super.doVisitAnnotation(annotation, context); - - //Removed @FallbackConverter as you should use @Converter(fallback = true) instead. - if (a.getType().toString().equals("org.apache.camel.FallbackConverter")) { - maybeAddImport("org.apache.camel.Converter", null, false); - maybeRemoveImport("org.apache.camel.FallbackConverter"); - - return RecipesUtil.createAnnotation(annotation, "Converter", null, "fallback = true"); - } - //Removed uri attribute on @EndpointInject, @Produce, and @Consume as you should use value (default) instead. - //For example @Produce(uri = "kafka:cheese") should be changed to @Produce("kafka:cheese") - else if (a.getType().toString().equals("org.apache.camel.EndpointInject")) { - Optional originalValue = RecipesUtil.getValueOfArgs(a.getArguments(), "uri"); - if(originalValue.isPresent()) { - return RecipesUtil.createAnnotation(annotation, "EndpointInject", s -> s.startsWith("uri="), originalValue.get()); - } - } - //Removed uri attribute on @EndpointInject, @Produce, and @Consume as you should use value (default) instead. - //For example @Produce(uri = "kafka:cheese") should be changed to @Produce("kafka:cheese") - else if (a.getType().toString().equals("org.apache.camel.Produce")) { - Optional originalValue = RecipesUtil.getValueOfArgs(a.getArguments(), "uri"); - if(originalValue.isPresent()) { - return RecipesUtil.createAnnotation(annotation, "Produce", s -> s.startsWith("uri="), originalValue.get()); - } - } - //Removed uri attribute on @EndpointInject, @Produce, and @Consume as you should use value (default) instead. - //For example @Produce(uri = "kafka:cheese") should be changed to @Produce("kafka:cheese") - else if (a.getType().toString().equals("org.apache.camel.Consume")) { - Optional originalValue = RecipesUtil.getValueOfArgs(a.getArguments(), "uri"); - if(originalValue.isPresent()) { - return RecipesUtil.createAnnotation(annotation, "Consume", s -> s.startsWith("uri="), originalValue.get()); - } - } - // Removed label on @UriEndpoint as you should use category instead. - else if (a.getType().toString().equals("org.apache.camel.spi.UriEndpoint")) { - - Optional originalValue = RecipesUtil.getValueOfArgs(a.getArguments(), "label"); - if(originalValue.isPresent()) { - maybeAddImport("org.apache.camel.Category", null, false); - - String newValue; - try { - newValue = RecipesUtil.Category.valueOf(originalValue.get().toUpperCase().replaceAll("\"", "")).getValue(); - } catch(IllegalArgumentException e) { - newValue = originalValue.get() + "/*unknown_value*/"; - } - - return RecipesUtil.createAnnotation(annotation, "UriEndpoint", s -> s.startsWith("label="), "category = {Category." + newValue + "}"); - } - } - - return a; - } - - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - - //if adapt method invocation is used as a select for another method invocation, it is replaced - if(mi.getSelect() != null && adaptCache.containsKey(mi.getSelect().getId())) { - getCursor().putMessage("adapt_cast", mi.getSelect().getId()); - } else - // context.getExtension(ExtendedCamelContext.class).getComponentNameResolver() -> PluginHelper.getComponentNameResolver(context) - if (getMethodMatcher(MATCHER_CONTEXT_GET_ENDPOINT_MAP).matches(mi, false)) { - mi = mi.withName(new J.Identifier(UUID.randomUUID(), mi.getPrefix(), Markers.EMPTY, Collections.emptyList(), - "/* " + mi.getSimpleName() + " has been removed, consider getEndpointRegistry() instead */", mi.getType(), null)); - } - // ProducerTemplate.asyncCallback() has been replaced by 'asyncSend(') or 'asyncRequest()' - else if(getMethodMatcher(M_PRODUCER_TEMPLATE_ASYNC_CALLBACK).matches(mi, false)) { - Comment comment = RecipesUtil.createMultinlineComment(String.format(" Method '%s()' has been replaced by 'asyncSend()' or 'asyncRequest()'.", mi.getSimpleName())); - mi = mi.withComments(Collections.singletonList(comment)); - } - //context.adapt(ModelCamelContext.class) -> ((ModelCamelContext) context) - else if (getMethodMatcher(M_CONTEXT_ADAPT).matches(mi, false)) { - if (mi.getType().isAssignableFrom(Pattern.compile("org.apache.camel.model.ModelCamelContext"))) { - J.Identifier type = RecipesUtil.createIdentifier(mi.getPrefix(), "ModelCamelContext", "java.lang.Object"); - J.ControlParentheses cp = RecipesUtil.createParentheses(RecipesUtil.createTypeCast(type, mi.getSelect())); - //put the type cast into cache in case it is replaced lately - mi = mi.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment("Method 'adapt' was removed."))); - adaptCache.put(method.getId(), cp); - } else if (mi.getType().isAssignableFrom(Pattern.compile("org.apache.camel.ExtendedCamelContext"))) { - mi = mi.withName(mi.getName().withSimpleName("getCamelContextExtension")).withArguments(Collections.emptyList()); - maybeRemoveImport("org.apache.camel.ExtendedCamelContext"); - } - } - //exchange.adapt(ExtendedExchange.class) -> exchange.getExchangeExtension() - else if (getMethodMatcher(M_EXCHANGE_ADAPT).matches(mi, false) - && mi.getType().isAssignableFrom(Pattern.compile("org.apache.camel.ExtendedExchange"))) { - mi = mi.withName(mi.getName().withSimpleName("getExchangeExtension")).withArguments(Collections.emptyList()); - maybeRemoveImport("org.apache.camel.ExtendedExchange"); - } - //newExchange.getProperty(ExchangePropertyKey.FAILURE_HANDLED) -> newExchange.getExchangeExtension().isFailureHandled() - else if(getMethodMatcher(M_EXCHANGE_GET_PROPERTY).matches(mi, false) - && mi.getArguments().get(0).toString().endsWith("FAILURE_HANDLED")) { - mi = mi.withName(mi.getName().withSimpleName("getExchangeExtension().isFailureHandled")).withArguments(Collections.emptyList()); - maybeRemoveImport("org.apache.camel.ExchangePropertyKey"); - } - //exchange.removeProperty(ExchangePropertyKey.FAILURE_HANDLED); -> exchange.getExchangeExtension().setFailureHandled(false); - else if(getMethodMatcher(M_EXCHANGE_REMOVE_PROPERTY).matches(mi, false) - && mi.getArguments().get(0).toString().endsWith("FAILURE_HANDLED")) { - mi = mi.withName(mi.getName().withSimpleName("getExchangeExtension().setFailureHandled")).withArguments(Collections.singletonList(RecipesUtil.createIdentifier(Space.EMPTY, "false", "java.lang.Boolean"))); - maybeRemoveImport("org.apache.camel.ExchangePropertyKey"); - } - //exchange.setProperty(ExchangePropertyKey.FAILURE_HANDLED, failureHandled); -> exchange.getExchangeExtension().setFailureHandled(failureHandled); - else if(getMethodMatcher(M_EXCHANGE_SET_PROPERTY).matches(mi, false) - && mi.getArguments().get(0).toString().endsWith("FAILURE_HANDLED")) { - mi = mi.withName(mi.getName() - .withSimpleName("getExchangeExtension().setFailureHandled")) - .withArguments(Collections.singletonList(mi.getArguments().get(1).withPrefix(Space.EMPTY))); - maybeRemoveImport("org.apache.camel.ExchangePropertyKey"); - } - //'org.apache.camel.catalogCamelCatalog.archetypeCatalogAsXml()` has been removed - else if(getMethodMatcher(M_CATALOG_ARCHETYPE_AS_XML).matches(mi, false)) { - mi = mi.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(" Method '" + mi.getSimpleName() + "' has been removed. "))); - } - //context().setDumpRoutes(true); -> context().setDumpRoutes("xml");(or "yaml") - else if(getMethodMatcher(M_CONTEXT_SET_DUMP_ROUTES).matches(mi, false)) { - mi = mi.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(" Method '" + mi.getSimpleName() + "' accepts String parameter ('xml' or 'yaml' or 'false'). "))); - } - //Boolean isDumpRoutes(); -> getDumpRoutes(); with returned type String - else if(getMethodMatcher(M_CONTEXT_IS_DUMP_ROUTES).matches(mi, false)) { - mi = mi.withName(mi.getName().withSimpleName("getDumpRoutes")).withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(" Method 'getDumpRoutes' returns String value ('xml' or 'yaml' or 'false'). "))); - } - // (CamelRuntimeCatalog) context.getExtension(RuntimeCamelCatalog.class) -> context.getCamelContextExtension().getContextPlugin(RuntimeCamelCatalog.class); - else if (getMethodMatcher(MATCHER_CONTEXT_GET_EXT).matches(mi, false)) { - - mi = mi.withName(mi.getName().withSimpleName("getCamelContextExtension().getContextPlugin")) - .withMethodType(mi.getMethodType()); - //remove type cast before expression - if(getCursor().getParent().getValue() instanceof J.TypeCast && ((J.TypeCast)getCursor().getParent().getValue()).getType().equals(mi.getType())) { - getCursor().getParent().putMessage("remove_type_cast", mi); - } - - } - return mi; - } - - @Override - public @Nullable J postVisit(J tree, ExecutionContext context) { - J j = super.postVisit(tree, context); - - UUID adaptCast = getCursor().getMessage("adapt_cast"); - - if(adaptCast != null) { - J.MethodInvocation mi = (J.MethodInvocation)j; - J.ControlParentheses cp = (J.ControlParentheses) adaptCache.get(adaptCast); - - J.MethodInvocation m = mi.withSelect(cp); - return m; - } - - J removeTypeCast = getCursor().getMessage("remove_type_cast"); - - if(removeTypeCast != null) { - return removeTypeCast; - } - - return j; - } - - }); - } - -} - diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelBeanRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelBeanRecipe.java deleted file mode 100644 index fa8966d618..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelBeanRecipe.java +++ /dev/null @@ -1,144 +0,0 @@ -package io.quarkus.updates.camel.camel40.java; - -import java.util.Arrays; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import io.quarkus.updates.camel.RecipesUtil; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.ChangeLiteral; -import org.openrewrite.java.tree.Expression; -import org.openrewrite.java.tree.J; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; - -public class CamelBeanRecipe extends Recipe { - - private final String primitive[] = new String[] { "byte", "short", "int", "float", "double", "long", "char", - "String" }; - - @Override - public String getDisplayName() { - return "Camel bean recipe"; - } - - @Override - public String getDescription() { - return "Camel bean recipe."; - } - - @Override - public TreeVisitor getVisitor() { - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - Pattern findMethodPattern = Pattern.compile("method=.*"); - - if (mi.getSimpleName().equals("to")) { - List arguments = method.getArguments(); - - for (int i = 0; i < arguments.size(); i++) { - Expression argument = arguments.get(i); - if (argument instanceof J.Literal - && ((J.Literal) argument).getType().getClassName().equals("java.lang.String") - && findMethodPattern - .matcher((String) (((J.Literal) method.getArguments().get(i)).getValue())) - .find()) { - - String uriWithMethod = (String) (((J.Literal) method.getArguments().get(i)).getValue()); - - String uriWithoutMethod = uriWithMethod.split("=")[0]; - - String methodNameAndArgs = uriWithMethod.split("=")[1]; - - //method without any args, we can simply return the mi in that case. - if(!methodNameAndArgs.contains("(") && !methodNameAndArgs.contains(")")) { - return mi; - } - - String methodName = extractMethodName(methodNameAndArgs); - - String actualArgs = methodNameAndArgs.substring( - methodNameAndArgs.indexOf("(") + 1, - methodNameAndArgs.indexOf(")")); - - String updatedArg = uriWithoutMethod + "=" + methodName + "(" + updateMethodArgument(actualArgs) - + ")"; - - doAfterVisit(new ChangeLiteral<>(argument, p -> updatedArg)); - - return mi; - - } - - } - - } - - return mi; - } - - }); - - } - - private String extractMethodName(String methodCallString) { - // Regular expression to match the method call pattern - Pattern pattern = Pattern.compile("^([a-zA-Z_$][a-zA-Z0-9_$]*)\\(.+\\)$"); - Matcher matcher = pattern.matcher(methodCallString); - - // Check if the string matches the method call pattern - if (matcher.matches()) { - // Extract the method name from the matched group - String methodName = matcher.group(1); - return methodName; - } else { - // Return null if the string doesn't match the method call pattern - return null; - } - } - - private String updateMethodArgument(String argument) { - - Pattern identifierPattern = Pattern.compile("^[a-zA-Z_$][a-zA-Z0-9_$]*$"); - Pattern fullyQualifiedPattern = Pattern - .compile("^([a-zA-Z_$][a-zA-Z0-9_$]*\\.)*[a-zA-Z_$][a-zA-Z0-9_$]*$"); - - String updatedArgs = Arrays.asList(argument.split(",")).stream().map(arg -> { - if (arg.endsWith(".class")) { - return arg; - } - - if (Arrays.asList(primitive).contains(arg.trim())) { - return arg + ".class"; - } - - Matcher fullyQualifiedMatcher = fullyQualifiedPattern.matcher(arg); - if (!fullyQualifiedMatcher.matches()) { - return arg; - } - - String[] parts = arg.split("\\."); - - for (String part : parts) { - Matcher identifierMatcher = identifierPattern.matcher(part); - if (!identifierMatcher.matches()) { - return arg; - } - } - - return arg + ".class"; - - }).collect(Collectors.joining(",")); - - return updatedArgs; - - } - -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelEIPRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelEIPRecipe.java deleted file mode 100644 index a8b4bcce4a..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelEIPRecipe.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.quarkus.updates.camel.camel40.java; - -import io.quarkus.updates.camel.RecipesUtil; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.AddImport; -import org.openrewrite.java.tree.J; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; - -public class CamelEIPRecipe extends Recipe { - - @Override - public String getDisplayName() { - return "Replaces removed method camel EIP"; - } - - @Override - public String getDescription() { - return "The InOnly and InOut EIPs have been removed. Instead, use 'SetExchangePattern' or 'To' where you can specify the exchange pattern to use."; - } - - @Override - public TreeVisitor getVisitor() { - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - - if (mi.getSimpleName().equals("inOut") || mi.getSimpleName().equals("inOnly")) { - String name = mi.getSimpleName().substring(0, 1).toUpperCase() + mi.getSimpleName().substring(1); - mi = mi.withName(mi.getName().withSimpleName("setExchangePattern(ExchangePattern."+name+").to")); - doAfterVisit(new AddImport<>("org.apache.camel.ExchangePattern", null, false)); - } - return mi; - } - - }); - - } - -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelHttpRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelHttpRecipe.java deleted file mode 100644 index 1a28471f3f..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelHttpRecipe.java +++ /dev/null @@ -1,115 +0,0 @@ -package io.quarkus.updates.camel.camel40.java; - -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.internal.lang.Nullable; -import org.openrewrite.java.ChangeType; -import org.openrewrite.java.JavaTemplate; -import org.openrewrite.java.tree.J; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; - -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelHttpRecipe extends Recipe { - - private static final String SET_CREDENTIALS = "org.apache.http.impl.client.BasicCredentialsProvider setCredentials(..)"; - private static final String SCOPE_ANY = "AuthScope.ANY"; - - @Override - public String getDisplayName() { - return "Camel Http Extension changes"; - } - - @Override - public String getDescription() { - return "Camel Http Extension changes."; - } - - @Override - public TreeVisitor getVisitor() { - - - return RecipesUtil.newVisitor("org.apache.http..*", new AbstractCamelQuarkusJavaVisitor() { - @Override - protected J.Import doVisitImport(J.Import _import, ExecutionContext context) { - doAfterVisit( - new ChangeType("org.apache.http.HttpHost", - "org.apache.hc.core5.http.HttpHost", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.client.protocol.HttpClientContext", - "org.apache.hc.client5.http.protocol.HttpClientContext", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.protocol.HttpContext", - "org.apache.hc.core5.http.protocol.HttpContext", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.impl.auth.BasicScheme", - "org.apache.hc.client5.http.impl.auth.BasicScheme", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.impl.client.BasicAuthCache", - "org.apache.hc.client5.http.impl.auth.BasicAuthCache", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.impl.client.BasicCredentialsProvider", - "org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.auth.AuthScope", - "org.apache.hc.client5.http.auth.AuthScope", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.auth.UsernamePasswordCredentials", - "org.apache.hc.client5.http.auth.UsernamePasswordCredentials", true).getVisitor()); - doAfterVisit( - new ChangeType( - "org.apache.http.conn.ssl.NoopHostnameVerifier", - "org.apache.hc.client5.http.conn.ssl.NoopHostnameVerifier", true).getVisitor()); - - return super.doVisitImport(_import, context); - } - - @Override - protected J.FieldAccess doVisitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext context) { - J.FieldAccess f = super.doVisitFieldAccess(fieldAccess, context); - - //The component has been upgraded to use Apache HttpComponents v5 - //AuthScope.ANY -> new AuthScope(null, -1) - if("ANY".equals(f.getSimpleName()) && "org.apache.http.auth.AuthScope".equals(f.getType().toString())) { - JavaTemplate.Builder templateBuilder = JavaTemplate.builder( "new AuthScope(null, -1)"); - J.NewClass nc = templateBuilder.build().apply(updateCursor(fieldAccess), - f.getCoordinates().replace()) - .withPrefix(f.getPrefix() - ); - getCursor().putMessage("authScopeNewClass", nc); - } - return f; - } - - - @Override - public @Nullable J postVisit(J tree, ExecutionContext context) { - J j = super.postVisit(tree, context); - - //use a new class instead of original element - J.NewClass newClass = getCursor().getMessage("authScopeNewClass"); - if(newClass != null) { - maybeAddImport("org.apache.hc.client5.http.auth.AuthScope", null, false); - return newClass; - } - - return j; - } - - }); - } - -} \ No newline at end of file diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/CircuitBreakerXmlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/CircuitBreakerXmlDslRecipe.java deleted file mode 100644 index 21b904fe2b..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/CircuitBreakerXmlDslRecipe.java +++ /dev/null @@ -1,127 +0,0 @@ -package io.quarkus.updates.camel.camel40.xml; - -import io.quarkus.updates.camel.AbstractCamelQuarkusXmlVisitor; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.Tree; -import org.openrewrite.TreeVisitor; -import org.openrewrite.internal.ListUtils; -import org.openrewrite.marker.Markers; -import org.openrewrite.xml.XPathMatcher; -import org.openrewrite.xml.XmlIsoVisitor; -import org.openrewrite.xml.tree.Xml; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - *

- * Camel Migration guide - *

- * The following options in camel-resilience4j was mistakenly not defined as attributes: - *
    - *
  • bulkheadEnabled
  • - *
  • bulkheadMaxConcurrentCalls
  • - *
  • bulkheadMaxWaitDuration
  • - *
  • timeoutEnabled
  • - *
  • timeoutExecutorService
  • - *
  • timeoutDuration
  • - *
  • timeoutCancelRunningFuture
  • - *
- * - * These options were not exposed in YAML DSL, and in XML DSL you need to migrate from: - * - *
- * <circuitBreaker>
- *     <resilience4jConfiguration>
- *         <timeoutEnabled>true</timeoutEnabled>
- *         <timeoutDuration>2000</timeoutDuration>
- *     </resilience4jConfiguration>
- * ...
- * </circuitBreaker>
- * </pre>
- *
- * To use attributes instead:
- *
- * 
- * <circuitBreaker>
- *     <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
- * ...
- * </circuitBreaker>
- * 
- */ -public class CircuitBreakerXmlDslRecipe extends Recipe { - - private final static String RESILIENCE4J_XPATH = "*/circuitBreaker/resilience4jConfiguration"; - private static final XPathMatcher RESILIENCE4J_MATCHER = new XPathMatcher(RESILIENCE4J_XPATH); - - private static final Map ATTRIBUTE_MATCHERS = Stream.of( - "bulkheadEnabled", - "bulkheadMaxConcurrentCalls", - "bulkheadMaxWaitDuration", - "timeoutEnabled", - "timeoutExecutorService", - "timeoutDuration", - "timeoutCancelRunningFuture") - .collect(Collectors.toMap( - k -> k, - k -> new XPathMatcher(RESILIENCE4J_XPATH + "/" + k), - (v1, v2) -> v1 //conflict can not happen - )); - - @Override - public String getDisplayName() { - return "Camel XMl DSL Circuit Breaker changes"; - } - - @Override - public String getDescription() { - return "Apache Camel XML DSL Circuit Breaker migration from version 3.20 or higher to 4.0."; - } - - @Override - public TreeVisitor getVisitor() { - return new AbstractCamelQuarkusXmlVisitor() { - - @Override - public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) { - Xml.Tag t = super.doVisitTag(tag, ctx); - - if (RESILIENCE4J_MATCHER.matches(getCursor())) { - Map values = ctx.pollMessage(RESILIENCE4J_XPATH); - - if (values != null && !values.isEmpty()) { - //create list of values - List toAdd = values.entrySet().stream() - .map(e -> autoFormat(new Xml.Attribute(Tree.randomId(), "", Markers.EMPTY, - new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, e.getKey()), - "", - autoFormat(new Xml.Attribute.Value(Tree.randomId(), "", Markers.EMPTY, - Xml.Attribute.Value.Quote.Double, - e.getValue()), ctx)), ctx)) - .collect(Collectors.toList()); - - return t.withAttributes(ListUtils.concatAll(t.getAttributes(), toAdd)); - } - } - - for(Map.Entry entry : ATTRIBUTE_MATCHERS.entrySet()) { - if (entry.getValue().matches(getCursor())) { - if(t.getValue().isPresent() && !t.getValue().get().isEmpty()) { - Map values = ctx.getMessage(RESILIENCE4J_XPATH, new LinkedHashMap<>()); - values.put(entry.getKey(), t.getValue().get()); - ctx.putMessage(RESILIENCE4J_XPATH, values); - } - //skip tag - return null; - } - } - - return t; - } - }; - } -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/XmlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/XmlDslRecipe.java deleted file mode 100644 index a80e9b446f..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/XmlDslRecipe.java +++ /dev/null @@ -1,83 +0,0 @@ -package io.quarkus.updates.camel.camel40.xml; - -import io.quarkus.updates.camel.AbstractCamelQuarkusXmlVisitor; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.Tree; -import org.openrewrite.TreeVisitor; -import org.openrewrite.internal.ListUtils; -import org.openrewrite.marker.Markers; -import org.openrewrite.xml.XPathMatcher; -import org.openrewrite.xml.XmlIsoVisitor; -import org.openrewrite.xml.tree.Xml; - -/** - *

- * Camel Migration guide - *

- * The to set a description on a route or node, has been changed from an element to an attribute. - * - * Before: - *
- * <route id="myRoute">
- *   <description>Something that this route do</description>
- *   <from uri="kafka:cheese"/>
- *   ...
- * </route>
- * 
- * After: - *
- * <route id="myRoute" description="Something that this route do">
- *   <from uri="kafka:cheese"/>
- *   ...
- * </route>
- * 
- */ -public class XmlDslRecipe extends Recipe { - - private static final XPathMatcher ROUTE_DESCRIPTION_XPATH_MATCHER = new XPathMatcher("/routes/route/description"); - private static final XPathMatcher ROUTE_XPATH_MATCHER = new XPathMatcher("/routes/route"); - - @Override - public String getDisplayName() { - return "Camel XMl DSL changes"; - } - - @Override - public String getDescription() { - return "Apache Camel XML DSL migration from version 3.20 or higher to 4.0."; - } - - @Override - public TreeVisitor getVisitor() { - return new AbstractCamelQuarkusXmlVisitor() { - - @Override - public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) { - Xml.Tag t = super.doVisitTag(tag, ctx); - - - if (ROUTE_XPATH_MATCHER.matches(getCursor())) { - String d = ctx.pollMessage("description"); - if(d != null) { - return t.withAttributes(ListUtils.concat(t.getAttributes(), autoFormat(new Xml.Attribute(Tree.randomId(), "", Markers.EMPTY, - new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, "description"), - "", - autoFormat(new Xml.Attribute.Value(Tree.randomId(), "", Markers.EMPTY, - Xml.Attribute.Value.Quote.Double, - d), ctx)), ctx))); - } - } - if (ROUTE_DESCRIPTION_XPATH_MATCHER.matches(getCursor())) { - //save description into context for parent - t.getValue().ifPresent(s -> ctx.putMessage("description", s)); - //skip tag - return null; - - } - - return t; - } - }; - } -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlRouteConfigurationSequenceRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlRouteConfigurationSequenceRecipe.java deleted file mode 100644 index b3ad29d33d..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlRouteConfigurationSequenceRecipe.java +++ /dev/null @@ -1,108 +0,0 @@ -package io.quarkus.updates.camel.camel40.yaml; - -import io.quarkus.updates.camel.AbstractCamelQuarkusYamlVisitor; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.yaml.JsonPathMatcher; -import org.openrewrite.yaml.format.IndentsVisitor; -import org.openrewrite.yaml.style.IndentsStyle; -import org.openrewrite.yaml.tree.Yaml; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import static org.openrewrite.Tree.randomId; - -/** - * Camel API changes requires several changes in YAML route definition. - * Route-configuration children sequence is replaced with mappingEntry (with special migration of "on-exception") - */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelQuarkusYamlRouteConfigurationSequenceRecipe extends Recipe { - - private static JsonPathMatcher MATCHER_ROUTE_CONFIGURATION = new JsonPathMatcher("$.route-configuration"); - private static JsonPathMatcher MATCHER_ROUTE_CONFIGURATION_ON_EXCEPTION = new JsonPathMatcher("$.route-configuration.on-exception"); - - @Override - public String getDisplayName() { - return "Camel Yaml changes regarding route-configuration children"; - } - - @Override - public String getDescription() { - return "Camel YAML changes. route-configuration children sequence is replaced with mappingEntry (with special migration of \"on-exception\")."; - } - - @Override - public TreeVisitor getVisitor() { - - return new AbstractCamelQuarkusYamlVisitor() { - - private Yaml.Sequence sequenceToReplace; - private boolean indentRegistered = false; - - @Override - protected void clearLocalCache() { - sequenceToReplace = null; - } - - @Override - public Yaml.Sequence doVisitSequence(Yaml.Sequence sequence, ExecutionContext context) { - Yaml.Sequence s = super.doVisitSequence(sequence, context); - - //if there is a sequence in a route-configuration, it has to be replaced with mapping - if (new JsonPathMatcher("$.route-configuration").matches(getCursor().getParent())) { - this.sequenceToReplace = s; - } - return s; - } - - @Override - public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext context) { - Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, context); - - //if current mapping contains an entry with sequence belonging to route-configuration, remove the sequence - if (e.getValue() == sequenceToReplace) { - List entries = new ArrayList<>(); - for (Yaml.Sequence.Entry sEntry : sequenceToReplace.getEntries()) { - - if (sEntry.getBlock() instanceof Yaml.Mapping) { - ((Yaml.Mapping) sEntry.getBlock()).getEntries().forEach(y -> { - //if entry is on-exception from the route-configuration sequence, it has to be handled differently - if ("on-exception".equals(y.getKey().getValue())) { - Yaml.Sequence newSequence = sequenceToReplace.copyPaste(); - //keep only on-exception item - List filteredEntries = newSequence.getEntries().stream() - .filter(se -> ((Yaml.Mapping) se.getBlock()).getEntries().stream() - .filter(me -> "on-exception".equals(me.getKey().getValue())).findFirst().isPresent()) - .collect(Collectors.toList()); - - entries.add(y.withValue(newSequence.withEntries(filteredEntries)).withPrefix("\n")); - } else { - entries.add(y.withPrefix("\n")); - } - }); - } - } - Yaml.Mapping.Entry resultr = e.withValue(new Yaml.Mapping(randomId(), sequenceToReplace.getMarkers(), sequenceToReplace.getOpeningBracketPrefix(), entries, null, null)); - - if(!indentRegistered) { - indentRegistered = true; - //TODO might probably change indent in original file, may this happen? - doAfterVisit(new IndentsVisitor(new IndentsStyle(2), null)); - } - - return resultr; - } - return e; - } - }; - } - -} - diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlStepsInFromRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlStepsInFromRecipe.java deleted file mode 100644 index 261ee4f0eb..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlStepsInFromRecipe.java +++ /dev/null @@ -1,128 +0,0 @@ -package io.quarkus.updates.camel.camel40.yaml; - -import io.quarkus.updates.camel.AbstractCamelQuarkusYamlVisitor; -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.yaml.JsonPathMatcher; -import org.openrewrite.yaml.YamlIsoVisitor; -import org.openrewrite.yaml.format.IndentsVisitor; -import org.openrewrite.yaml.style.IndentsStyle; -import org.openrewrite.yaml.tree.Yaml; - -import java.util.ArrayList; -import java.util.List; - -/** - * Fixes following yaml change. - * - * The backwards compatible mode Camel 3.14 or older, which allowed to have steps as child to route has been removed. - * - * The old syntax: - * - *
- * - route:
- *     from:
- *       uri: "direct:info"
- *     steps:
- *     - log: "message"
- * 
- * should be changed to: - *
- * - route:
- *     from:
- *       uri: "direct:info"
- *       steps:
- *       - log: "message"
- * 
- */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelQuarkusYamlStepsInFromRecipe extends Recipe { - - private static String[] PATHS_TO_PRE_CHECK = new String[] {"route.from"}; - private static JsonPathMatcher MATCHER_WITHOUT_ROUTE = new JsonPathMatcher("$.steps"); - private static JsonPathMatcher MATCHER_WITH_ROUTE = new JsonPathMatcher("$.route.steps"); - - - @Override - public String getDisplayName() { - return "Camel Yaml steps not allowed as route child"; - } - - @Override - public String getDescription() { - return "The YAML DSL backwards compatible mode in Camel 3.14 or older, which allowed 'steps' to be defined as a child of 'route' has been removed."; - } - - - @Override - public TreeVisitor getVisitor() { - - return new AbstractCamelQuarkusYamlVisitor() { - //both variables has to be set to null, to mark the migration done - Yaml.Mapping from = null; - Yaml.Mapping.Entry steps = null; - - @Override - protected void clearLocalCache() { - //do nothing - } - - @Override - public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext context) { - Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, context); - - if(steps == null && (MATCHER_WITH_ROUTE.matches(getCursor()) || MATCHER_WITHOUT_ROUTE.matches(getCursor()))) { - steps = e; - if(from != null) { - moveSteps(); - } - return null; - } - return e; - - } - - @Override - public Yaml.Mapping doVisitMapping(Yaml.Mapping mapping, ExecutionContext context) { - Yaml.Mapping m = super.doVisitMapping(mapping, context); - - String prop = RecipesUtil.getProperty(getCursor()); - if(("route.from".equals(prop) || "from".equals(prop)) && from == null) { - from = m; - if(steps != null) { - moveSteps(); - } - } - - return m; - } - - private void moveSteps() { - doAfterVisit(new YamlIsoVisitor() { - - @Override - public Yaml.Mapping visitMapping(Yaml.Mapping mapping, ExecutionContext c) { - Yaml.Mapping m = super.visitMapping(mapping, c); - - if(m == from) { - List entries = new ArrayList<>(m.getEntries()); - entries.add(steps.copyPaste().withPrefix("\n")); - m = m.withEntries(entries); - } - - return m; - }}); - - //TODO might probably change indent in original file, may this happen? - doAfterVisit(new IndentsVisitor(new IndentsStyle(2), null)); - } - }; - } - -} - diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel41/CamelCoreRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel41/CamelCoreRecipe.java deleted file mode 100644 index 39829c75be..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel41/CamelCoreRecipe.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.quarkus.updates.camel.camel41; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.tree.Expression; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaType; - -import java.util.regex.Pattern; - -/** - * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the - * documentation. - */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelCoreRecipe extends Recipe { - - private static final String M_TO = "org.apache.camel.model.ProcessorDefinition to(..)"; - private static final String M_FROM = "org.apache.camel.model.ProcessorDefinition from(..)"; - private static final String AWS2_URL_WITH_QUEUE_REGEXP = "(aws2-sns://[a-zA-z]+?.*)queueUrl=https://(.+)"; - private static final Pattern AWS2_URL_WITH_QUEUE_URL = Pattern.compile(AWS2_URL_WITH_QUEUE_REGEXP); - - @Override - public String getDisplayName() { - return "Camel Core changes"; - } - - @Override - public String getDescription() { - return "Apache Camel Core migration from version 4.0 to 4.1."; - } - - - @Override - public TreeVisitor getVisitor() { - - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - @Override - public J.Literal visitLiteral(J.Literal literal, ExecutionContext context) { - J.Literal l = super.visitLiteral(literal, context); - - //is it possible to precondition that aws2 is present? - if(JavaType.Primitive.String.equals(l.getType()) && AWS2_URL_WITH_QUEUE_URL.matcher((String)l.getValue()).matches()) { - String newUrl = ((String) l.getValue()).replaceFirst(AWS2_URL_WITH_QUEUE_REGEXP, "$1queueArn=arn:aws:sqs:$2"); - l = RecipesUtil.createStringLiteral(newUrl); - } - - return l; - } - }); - } -} \ No newline at end of file diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel41/XmlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel41/XmlDslRecipe.java deleted file mode 100644 index d5f79c24f4..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel41/XmlDslRecipe.java +++ /dev/null @@ -1,90 +0,0 @@ -package io.quarkus.updates.camel.camel41; - -import io.quarkus.updates.camel.AbstractCamelQuarkusXmlVisitor; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.Tree; -import org.openrewrite.TreeVisitor; -import org.openrewrite.internal.ListUtils; -import org.openrewrite.marker.Markers; -import org.openrewrite.xml.XPathMatcher; -import org.openrewrite.xml.XmlIsoVisitor; -import org.openrewrite.xml.tree.Xml; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - *

- * Camel Migration guide - *

- * - * Before: - *
- *     <bean name="myBean" type="groovy" beanType="com.foo.MyBean">
- *         <script>
- *           <!-- groovy code here to create the bean -->
- *         </script>
- *     </bean>
- * 
- * After: - *
- *     <bean name="myBean" type="com.foo.MyBean"
- *           scriptLanguage="groovy">
- *         <script>
- *           <!-- groovy code here to create the bean -->
- *         </script>
- *     </bean>
- * 
- */ -public class XmlDslRecipe extends Recipe { - - private static final XPathMatcher XML_BEAN_MATCHER = new XPathMatcher("*/bean"); - - @Override - public String getDisplayName() { - return "Camel XMl DSL changes"; - } - - @Override - public String getDescription() { - return "Apache Camel XML DSL migration from version 4.0 to 4.1."; - } - - @Override - public TreeVisitor getVisitor() { - return new AbstractCamelQuarkusXmlVisitor() { - - @Override - public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) { - Xml.Tag t = super.doVisitTag(tag, ctx); - - if (XML_BEAN_MATCHER.matches(getCursor()) && t.getChild("script").isPresent()) { - //type ans beanType has to be present in the attributes - //and their values has to be gathered - Optional typeAttr = t.getAttributes().stream().filter(a -> "type".equals(a.getKeyAsString())).findAny(); - Optional beanTypeAttr = t.getAttributes().stream().filter(a -> "beanType".equals(a.getKeyAsString())).findAny(); - //if values are not empty, migrate tag - if(typeAttr.isPresent() && !typeAttr.get().getValueAsString().isEmpty() && beanTypeAttr.isPresent() && !beanTypeAttr.get().getValueAsString().isEmpty()) { - // gather attributes - List attrs = new ArrayList<>(t.getAttributes()); - attrs.remove(typeAttr.get()); - attrs.remove(beanTypeAttr.get()); - - //migrate values - Xml.Attribute.Value tmp = typeAttr.get().getValue(); - attrs.add(typeAttr.get().withValue(beanTypeAttr.get().getValue())); - attrs.add(beanTypeAttr.get().withKey(new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, "scriptLanguage")).withValue(tmp)); - - t = t.withAttributes(attrs); - } - - } - - return t; - } - }; - } -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel41/YamlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel41/YamlDslRecipe.java deleted file mode 100644 index d344348ab1..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel41/YamlDslRecipe.java +++ /dev/null @@ -1,104 +0,0 @@ -package io.quarkus.updates.camel.camel41; - -import io.quarkus.updates.camel.AbstractCamelQuarkusYamlVisitor; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.Cursor; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.yaml.JsonPathMatcher; -import org.openrewrite.yaml.tree.Yaml; - -import java.util.List; -import java.util.Optional; - -/** - * Fixes following yaml change. - * - * When creating beans from an inlined script. - * The name of the script was defined in type, but has been changed to a new scriptLanguage attribute. - * And beanType has been removed as you must use type instead. - * - * The old syntax: - * - *
- *     - beans:
- *       - name: "myClient"
- *         beanType: "com.foo.MyBean"
- *         type: "groovy"
- *         script: |
- *           # groovy script here
- * 
- * should be changed to: - *
- *   - beans:
- *     - name: "myClient"
- *       type: "com.foo.MyBean"
- *       scriptLanguage: "groovy"
- *       script: |
- *         # groovy script here
- * 
- */ -@EqualsAndHashCode(callSuper = true) -@Value -public class YamlDslRecipe extends Recipe { - - private static JsonPathMatcher MATCHER_WITHOUT_ROUTE = new JsonPathMatcher("$.beans"); - - @Override - public String getDisplayName() { - return "Changes for creation of inlined beans."; - } - - @Override - public String getDescription() { - return "If inlined bean is created, parameters `type` and `beanType` has bean changed."; - } - - @Override - public TreeVisitor getVisitor() { - - return new AbstractCamelQuarkusYamlVisitor() { - - @Override - protected void clearLocalCache() { - //nothing to do - } - - @Override - public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext ctx) { - Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, ctx); - - //getCursor().getParent() is mapping with 4 entries -> I can check the siblings - //parent(4) is beans - Cursor parent4 = getCursor().getParent(4); - //check that this mapping entry is currently under "beans" sequence - //parent(2) has to be mapping (represents the bean) - if (parent4 != null && parent4.getParent() != null && MATCHER_WITHOUT_ROUTE.matches(parent4) && getCursor().getParent().getValue() instanceof Yaml.Mapping) { - //get entries - Yaml.Mapping m = getCursor().getParent().getValue(); - List entries = m.getEntries(); - Optional typeEntry = entries.stream().filter(me -> "type".equals(me.getKey().getValue())).findAny(); - Optional beanTypeEntry = entries.stream().filter(me -> "beanType".equals(me.getKey().getValue())).findAny(); - - if (typeEntry.isPresent() && typeEntry.get().getValue() instanceof Yaml.Scalar && !((Yaml.Scalar) typeEntry.get().getValue()).getValue().isEmpty() - && beanTypeEntry.isPresent() && beanTypeEntry.get().getValue() instanceof Yaml.Scalar && !((Yaml.Scalar) beanTypeEntry.get().getValue()).getValue().isEmpty()) { - - //modify the current entry - if ("type".equals(e.getKey().getValue())) { - return e.withKey(((Yaml.Scalar) entry.getKey().copyPaste()).withValue("scriptLanguage")); - } - if ("beanType".equals(e.getKey().getValue())) { - return e.withKey(((Yaml.Scalar) entry.getKey().copyPaste()).withValue("type")); - } - } - } - - return e; - } - }; - } - -} - diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel42/CamelSagaRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel42/CamelSagaRecipe.java deleted file mode 100644 index 4ff1bb0885..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel42/CamelSagaRecipe.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.quarkus.updates.camel.camel42; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.tree.Expression; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaType; -import org.openrewrite.java.tree.Space; - -import java.util.Collections; -import java.util.regex.Pattern; - -/** - * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the - * documentation. - */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelSagaRecipe extends Recipe { - - private static final String M_NEW_SAGA = "org.apache.camel.saga.InMemorySagaService newSaga()"; - private static final String M_SAGA_COORDINATOR_COMPENSATE = "org.apache.camel.saga.CamelSagaCoordinator compensate()"; - private static final String M_SAGA_COORDINATOR_COMPLETE = "org.apache.camel.saga.CamelSagaCoordinator complete()"; - - @Override - public String getDisplayName() { - return "Camel Core changes"; - } - - @Override - public String getDescription() { - return "Apache Camel Core migration from version 4.0 to 4.1."; - } - - - @Override - public TreeVisitor getVisitor() { - - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - - if ((getMethodMatcher(M_NEW_SAGA).matches(mi, false) - || getMethodMatcher(M_SAGA_COORDINATOR_COMPENSATE).matches(mi, false) - || getMethodMatcher(M_SAGA_COORDINATOR_COMPLETE).matches(mi, false)) - && RecipesUtil.methodInvocationAreArgumentEmpty(mi)) { - J.Identifier type = RecipesUtil.createIdentifier(Space.EMPTY, "Exchange", "import org.apache.camel.Exchange"); - J.TypeCast cp = (J.TypeCast) RecipesUtil.createTypeCast(type, RecipesUtil.createNullExpression()); - mi = mi.withArguments(Collections.singletonList(cp.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment("Exchange parameter was added."))))); - } - - return mi; - } - }); - } -} \ No newline at end of file diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelResequenceEIPXmlRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelResequenceEIPXmlRecipe.java deleted file mode 100644 index de69e53722..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelResequenceEIPXmlRecipe.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.quarkus.updates.camel.camel43; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.xml.XPathMatcher; -import org.openrewrite.xml.XmlIsoVisitor; -import org.openrewrite.xml.tree.Xml; - -/** - *

The configuration for batch and stream has been renamed from batch-config to batchConfig and stream-config to streamConfig.

- * - *

For example before: - *

- *     <resequence>
- *         <stream-config timeout="1000" deliveryAttemptInterval="10"/>
- *         <simple>${header.seqnum}</simple>
- *         <to uri="mock:result" />
- *     </resequence>
- * 
- *

- * - *

And now after: - *

- *     <resequence>
- *         <streamConfig timeout="1000" deliveryAttemptInterval="10"/>
- *         <simple>${header.seqnum}</simple>
- *         <to uri="mock:result" />
- *     </resequence>
- * 
- *

- * - *

See the documentation

- */ -public class CamelResequenceEIPXmlRecipe extends Recipe { - - private static final XPathMatcher XML_RESEQUENCE_STREAM_CONFIG_MATCHER = new XPathMatcher("*/route/resequence/stream-config"); - private static final XPathMatcher XML_RESEQUENCE_BATCH_CONFIG_MATCHER = new XPathMatcher("*/route/resequence/batch-config"); - - @Override - public String getDisplayName() { - return "Camel Resequence DSL changes"; - } - - @Override - public String getDescription() { - return "Batch and stream attributes were renamed in Resequence EIP XML DSL."; - } - - @Override - public TreeVisitor getVisitor() { - return new XmlIsoVisitor<>() { - - @Override - public Xml.Tag visitTag(final Xml.Tag tag, final ExecutionContext ctx) { - Xml.Tag t = super.visitTag(tag, ctx); - - if (XML_RESEQUENCE_STREAM_CONFIG_MATCHER.matches(getCursor()) ) { - t = t.withName("streamConfig"); - } - else if (XML_RESEQUENCE_BATCH_CONFIG_MATCHER.matches(getCursor()) ) { - t = t.withName("batchConfig"); - } - - return t; - } - }; - } -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelThrottleEIPRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelThrottleEIPRecipe.java deleted file mode 100644 index 549f133fcb..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelThrottleEIPRecipe.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.quarkus.updates.camel.camel43; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.Space; - -import java.util.Collections; - -/** - * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the - * documentation. - */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelThrottleEIPRecipe extends Recipe { - - private static final String M_THROTTLE_PRIMITIVE = "org.apache.camel.model.ProcessorDefinition throttle(long)"; - private static final String M_THROTTLE_TIME_PERIOD_MILLIS_PRIMITIVE = "org.apache.camel.model.ThrottleDefinition timePeriodMillis(long)"; - private static String WARNING_COMMENT = " Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period."; - - @Override - public String getDisplayName() { - return "Camel Core changes"; - } - - @Override - public String getDescription() { - return "Apache Camel Core migration from version 4.0 to 4.1."; - } - - - @Override - public TreeVisitor getVisitor() { - - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - - if (getMethodMatcher(M_THROTTLE_PRIMITIVE).matches(mi, false) - && !RecipesUtil.isCommentBeforeElement(mi, WARNING_COMMENT)) { - mi = mi.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(WARNING_COMMENT))); - getCursor().putMessage("throttle-migrated", true); - } - else if (getMethodMatcher(M_THROTTLE_TIME_PERIOD_MILLIS_PRIMITIVE).matches(mi, false)) { - if(mi.getSelect() instanceof J.MethodInvocation) { - return (J.MethodInvocation)mi.getSelect(); - } else { - return null; - } - } - - return mi; - } - }); - } -} \ No newline at end of file diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel44/CamelCoreRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel44/CamelCoreRecipe.java deleted file mode 100644 index fe3c21abc3..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/camel44/CamelCoreRecipe.java +++ /dev/null @@ -1,111 +0,0 @@ -package io.quarkus.updates.camel.camel44; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.tree.Expression; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.Space; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the - * documentation. - */ -@EqualsAndHashCode(callSuper = true) -@Value -public class CamelCoreRecipe extends Recipe { - - private static final String M_EXCHANGE_GET_CREATED = "org.apache.camel.Exchange getCreated()"; - private static final String M_PROPERTIES_LOOKUP_LOOKUP = "org.apache.camel.component.properties.PropertiesLookup lookup(java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_JSONPATH1 = "org.apache.camel.builder.ExpressionClause jsonpath(java.lang.String, boolean, java.lang.Class, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_JSONPATH2 = "org.apache.camel.builder.ExpressionClause jsonpathWriteAsString(java.lang.String, boolean, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_XPATH1 = "org.apache.camel.builder.ExpressionClause xpath(java.lang.String, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_XPATH2 = "org.apache.camel.builder.ExpressionClause xpath(java.lang.String, java.lang.Class, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_XPATH3 = "org.apache.camel.builder.ExpressionClause xpath(java.lang.String, java.lang.Class, org.apache.camel.support.builder.Namespaces, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_TOKENIZE1 = "org.apache.camel.builder.ExpressionClause tokenize(java.lang.String, boolean, int, java.lang.String, boolean)"; - private static final String M_EXPRESSION_CAUSE_TOKENIZE2 = "org.apache.camel.builder.ExpressionClause tokenize(java.lang.String, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_TOKENIZE3 = "org.apache.camel.builder.ExpressionClause tokenize(java.lang.String, java.lang.String, boolean)"; - private static final String M_EXPRESSION_CAUSE_XQUERY1 = "org.apache.camel.builder.ExpressionClause xquery(java.lang.String, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_XQUERY2 = "org.apache.camel.builder.ExpressionClause xquery(java.lang.String, java.lang.Class, java.lang.String)"; - private static final String M_EXPRESSION_CAUSE_XQUERY3 = "org.apache.camel.builder.ExpressionClause xquery(java.lang.String, java.lang.Class, boolean, java.lang.String)"; - private static final String CONST_STOP_WATCH_LONG01 = "org.apache.camel.util.StopWatch (long)"; - private static final String CONST_STOP_WATCH_LONG02 = "org.apache.camel.util.StopWatch (java.lang.Long)"; - - @Override - public String getDisplayName() { - return "Camel Core changes"; - } - - @Override - public String getDescription() { - return "Apache Camel Core migration from version 4.3 to 4.4."; - } - - @Override - public TreeVisitor getVisitor() { - - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - - if (getMethodMatcher(M_EXCHANGE_GET_CREATED).matches(mi, false)) { - //add call to getClock before call of getCreated - mi = mi.withName(mi.getName().withSimpleName("getClock().getCreated")); - } - else if (getMethodMatcher(M_PROPERTIES_LOOKUP_LOOKUP).matches(mi, false) - && mi.getArguments().size() == 1) { //without the condition, the recipes is applied again - //add default value null - List arguments = new ArrayList<>(mi.getArguments()); - arguments.add(RecipesUtil.createNullExpression()); - mi = mi.withArguments(arguments); - } - else if(getMethodMatcher(M_EXPRESSION_CAUSE_JSONPATH1).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_JSONPATH2).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE1).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE2).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE3).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_XPATH1).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_XPATH2).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_XPATH3).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY1).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY2).matches(mi,false) || - getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY3).matches(mi,false)) { - mi = mi.withName(RecipesUtil.createIdentifier(Space.EMPTY, "removed_" + mi.getSimpleName(), mi.getType().toString())) - .withComments(Collections.singletonList(RecipesUtil.createMultinlineComment( - "Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent.\n" + - "See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.\n"))); - } - - return mi; - } - - @Override - protected J.NewClass doVisitNewClass(J.NewClass newClass, ExecutionContext context) { - J.NewClass nc = super.doVisitNewClass(newClass, context); - - - //can not use org.openrewrite.java.DeleteMethodArgument, because it doesn't modify calls of constructors - if ((getMethodMatcher(CONST_STOP_WATCH_LONG01).matches(nc) || getMethodMatcher(CONST_STOP_WATCH_LONG02).matches(nc)) - && nc.getArguments().size() == 1) { //without the condition, the recipes is applied againorg.openrewrite.properties.ChangePropertyKey - nc = nc.withArguments(Collections.emptyList()). - withComments(Collections.singletonList(RecipesUtil.createMultinlineComment( - "Removed the deprecated constructor from the internal class org.apache.camel.util.StopWatch.\n" + - "Users of this class are advised to use the default constructor if necessary.Changed exception thrown from IOException to Exception.\n"))); - - } - - return nc; - } - }); - } -} \ No newline at end of file diff --git a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/ChangePropertyKeyWithCaseChange.java b/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/ChangePropertyKeyWithCaseChange.java deleted file mode 100644 index 67b32be8e9..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/ChangePropertyKeyWithCaseChange.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.quarkus.updates.camel.customRecipes; - -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Option; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.properties.PropertiesVisitor; -import org.openrewrite.properties.tree.Properties; - -/** - * Replaces prefix with the new one and changes the suffix tp start with lower case - */ -@Value -@EqualsAndHashCode(callSuper = false) -public class ChangePropertyKeyWithCaseChange extends Recipe { - - @Option(displayName = "Old property key", - description = "The property key to rename.") - String oldPropertyKey; - - @Option(displayName = "New prefix before any group", - description = "The prefix to be replaced with.") - String newPrefix; - - @Override - public String getDisplayName() { - return "Change prefix of property with Camel case"; - } - - @Override - public String getDescription() { - return "Change prefix of property with Camel case"; - } - - @Override - public PropertiesVisitor getVisitor() { - return new PropertiesVisitor<>() { - @Override - public Properties visitEntry(Properties.Entry entry, ExecutionContext p) { - if (entry.getKey().matches(oldPropertyKey)) { - entry = entry.withKey(getKey(entry)) - .withPrefix(entry.getPrefix()); - } - return super.visitEntry(entry, p); - } - - //replace key - private String getKey(Properties.Entry entry) { - return newPrefix + entry.getKey().replaceFirst(oldPropertyKey, "$1").substring(0,1).toLowerCase() - + entry.getKey().replaceFirst(oldPropertyKey, "$1").substring(1); - - } - }; - } -} diff --git a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/MoveGetterToPluginHelper.java b/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/MoveGetterToPluginHelper.java deleted file mode 100644 index 0c3bf74e23..0000000000 --- a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/MoveGetterToPluginHelper.java +++ /dev/null @@ -1,83 +0,0 @@ -package io.quarkus.updates.camel.customRecipes; - -import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor; -import io.quarkus.updates.camel.RecipesUtil; -import lombok.EqualsAndHashCode; -import lombok.Value; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Option; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; -import org.openrewrite.java.AddImport; -import org.openrewrite.java.JavaTemplate; -import org.openrewrite.java.tree.J; - -import java.util.regex.Pattern; - -/** - * Replaces prefix with the new one and changes the suffix tp start with lower case - */ -@Value -@EqualsAndHashCode(callSuper = false) -public class MoveGetterToPluginHelper extends Recipe { - - private static final String MATCHER_GET_NAME_RESOLVER = "org.apache.camel.ExtendedCamelContext getComponentNameResolver()"; - private static final String MATCHER_GET_MODEL_JAXB_CONTEXT_FACTORY = "org.apache.camel.ExtendedCamelContext getModelJAXBContextFactory()"; - private static final String MATCHER_GET_MODEL_TO_XML_DUMPER = "org.apache.camel.ExtendedCamelContext getModelToXMLDumper()"; - private static final Pattern EXTERNAL_CONTEXT_TYPE = Pattern.compile("org.apache.camel.ExtendedCamelContext"); - private static final String MATCHER_CONTEXT_GET_EXT = "org.apache.camel.CamelContext getExtension(java.lang.Class)"; - - @Option(displayName = "Method name", - description = "Name of the method on external camel context.") - String oldMethodName; - - @Override - public String getDisplayName() { - return "Move getter from context to PluginHelper."; - } - - @Override - public String getDescription() { - return "Move getter from context to PluginHelper"; - } - - @Override - public TreeVisitor getVisitor() { - return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() { - @Override - protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) { - J.MethodInvocation mi = super.doVisitMethodInvocation(method, context); - - // extendedContext.getModelJAXBContextFactory() -> PluginHelper.getModelJAXBContextFactory(extendedContext) - if (getMethodMatcher(getOldMethodMatcher()).matches(mi, false)) { - if (mi.getSelect() instanceof J.MethodInvocation && getMethodMatcher(MATCHER_CONTEXT_GET_EXT).matches(((J.MethodInvocation) mi.getSelect()).getMethodType())) { - J.MethodInvocation innerInvocation = (J.MethodInvocation) mi.getSelect(); - mi = JavaTemplate.builder(getNewMethodFromContext()) - //.contextSensitive() - .build() - .apply(getCursor(), mi.getCoordinates().replace(), innerInvocation.getSelect()); - doAfterVisit(new AddImport<>("org.apache.camel.support.PluginHelper", null, false)); - } else if (mi.getSelect().getType().isAssignableFrom(EXTERNAL_CONTEXT_TYPE)) { - mi = JavaTemplate.builder(getNewMethodFromExternalContextContext()) - //.contextSensitive() - .build() - .apply(getCursor(), mi.getCoordinates().replace(), mi.getSelect()); - doAfterVisit(new AddImport<>("org.apache.camel.support.PluginHelper", null, false)); - } - } - - return mi; - } - - private String getOldMethodMatcher() { - return "org.apache.camel.ExtendedCamelContext " + oldMethodName + "()"; - } - private String getNewMethodFromContext() { - return "PluginHelper." + oldMethodName + "(#{any(org.apache.camel.CamelContext)})"; - } - private String getNewMethodFromExternalContextContext() { - return "PluginHelper." + oldMethodName + "(#{any(org.apache.camel.ExtendedCamelContext)})"; - } - }); - } -} diff --git a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml index c452eed082..34bcbce2c0 100644 --- a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml +++ b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml @@ -27,95 +27,5 @@ name: io.quarkus.updates.camel.camel44.CamelQuarkusMigrationRecipe displayName: Migrates `camel 4.0` application to `camel 4.4` description: Migrates `camel 4.0` quarkus application to `camel 4.4`. recipeList: - # to camel 4.1 - - io.quarkus.updates.camel.camel41.CamelCoreRecipe - - io.quarkus.updates.camel.camel41.XmlDslRecipe - - io.quarkus.updates.camel.camel41.YamlDslRecipe - - io.quarkus.updates.camel.camel41.TracingTag - # to camel 4.2 - - io.quarkus.updates.camel.camel42.CamelMainDebugger - - io.quarkus.updates.camel.camel42.CamelSagaRecipe - # to camel 4.3 - - io.quarkus.updates.camel.camel43.StateRepository - - io.quarkus.updates.camel.camel43.CamelResequenceEIPXmlRecipe - - io.quarkus.updates.camel.camel43.CamelThrottleEIPRecipe - - io.quarkus.updates.camel.camel43.KafkaMetadata - # to camel 4.4 - - io.quarkus.updates.camel.camel44.CamelCoreRecipe - - io.quarkus.updates.camel.camel44.RouteControllerProperties - - io.quarkus.updates.camel.camel44.DefaultJsonSchemaLoader ---- -#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_1.html#_camel_tracing -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel41.TracingTag -displayName: Tag Enum has been deprecated -description: The Tag Enum containing constants for tagging spans has been deprecated. Instead, use constants from the TagConstants. -recipeList: - - org.openrewrite.java.ChangeType: - oldFullyQualifiedTypeName: org.apache.camel.tracing.Tag - newFullyQualifiedTypeName: org.apache.camel.tracing.TagConstants ---- -#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_2.html#_camel_main -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel42.CamelMainDebugger -displayName: The option camel.main.debugger has been renamed -description: The option camel.main.debugger has been renamed to camel.debug.enabled. -recipeList: - - org.openrewrite.properties.ChangePropertyKey: - oldPropertyKey: (.*)camel.main.debugger - newPropertyKey: $1camel.debug.enabled - regex: true ---- -#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_3.html#_camel_core -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel43.StateRepository -displayName: MemoryStateRepository and FileStateRepository were moved to another package and library -description: Moved classes MemoryStateRepository and FileStateRepositor from camel-base-engine to camel-support. -recipeList: - - org.openrewrite.java.ChangeType: - oldFullyQualifiedTypeName: org.apache.camel.impl.engine.MemoryStateRepository - newFullyQualifiedTypeName: org.apache.camel.support.processor.state.MemoryStateRepository - - org.openrewrite.java.ChangeType: - oldFullyQualifiedTypeName: org.apache.camel.impl.engine.FileStateRepository - newFullyQualifiedTypeName: org.apache.camel.support.processor.state.FileStateRepository ---- -#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_3.html#_camel_kafka_2 -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel43.KafkaMetadata -displayName: The header name for the List metadata has changed -description: The header name for the List metadata has changed also the dsl method for metadata changed. -recipeList: - - org.openrewrite.java.ChangeMethodName: - methodPattern: org.apache.camel.builder.endpoint.dsl.KafkaEndpointBuilderFactory$KafkaHeaderNameBuilder orgApacheKafkaClientsProducerRecordmetadata() - newMethodName: kafkaRecordMeta - - org.openrewrite.java.ReplaceConstantWithAnotherConstant: - existingFullyQualifiedConstantName: org.apache.camel.component.kafka.KafkaConstants.KAFKA_RECORDMETA - fullyQualifiedConstantName: org.apache.camel.component.kafka.KafkaConstants.KAFKA_RECORD_META ---- -#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_json_validator -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel44.DefaultJsonSchemaLoader -displayName: Replace deprecated DefaultJsonSchemaLoader with DefaultJsonUriSchemaLoader -description: Replaces deprecated class with its successor. -recipeList: - - org.openrewrite.java.ChangeType: - oldFullyQualifiedTypeName: org.apache.camel.component.jsonvalidator.DefaultJsonSchemaLoader - newFullyQualifiedTypeName: org.apache.camel.component.jsonvalidator.DefaultJsonUriSchemaLoader ---- -#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_main -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel44.RouteControllerProperties -displayName: Replace 'camel.main.routeController' with `camel.routecontroller' -recipeList: - - org.openrewrite.properties.ChangePropertyKey: - oldPropertyKey: camel.main.routeControllerSuperviseEnabled - newPropertyKey: camel.routeController.enabled - - org.openrewrite.properties.ChangePropertyKey: - oldPropertyKey: camel.main.route-controller-supervise-enabled - newPropertyKey: camel.routeController.enabled - - io.quarkus.updates.camel.customRecipes.ChangePropertyKeyWithCaseChange: - oldPropertyKey: camel.main.routeController(.*) - newPrefix: camel.routeController. - - io.quarkus.updates.camel.customRecipes.ChangePropertyKeyWithCaseChange: - oldPropertyKey: camel.main.route-controller-(.*) - newPrefix: camel.routeController. +# use the recipe from camel standalone migration + - org.apache.camel.updates.camel44.CamelMigrationRecipe \ No newline at end of file diff --git a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml index c93006c1b8..33acd10ab6 100644 --- a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml +++ b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml @@ -35,24 +35,8 @@ name: io.quarkus.updates.camel.camel40.CamelQuarkusMigrationRecipe displayName: Migrate `camel3` application to `camel4.` description: Migrate `camel3` quarkus application to `camel4` quarkus. recipeList: - - io.quarkus.updates.camel.camel40.xml.XmlDslRecipe - - io.quarkus.updates.camel.camel40.xml.CircuitBreakerXmlDslRecipe - - io.quarkus.updates.camel.camel40.yaml.CamelQuarkusYamlRouteConfigurationSequenceRecipe - - io.quarkus.updates.camel.camel40.yaml.CamelQuarkusYamlStepsInFromRecipe - - io.quarkus.updates.camel.camel40.java.CamelAPIsRecipe - - io.quarkus.updates.camel.camel40.java.CamelEIPRecipe - - io.quarkus.updates.camel.camel40.java.CamelBeanRecipe - - io.quarkus.updates.camel.camel40.java.CamelHttpRecipe - - io.quarkus.updates.camel.camel40.UsePluginHelperForContextGetters ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.camel.migrate.ChangeTypes -displayName: Migrate moved types between Came 3.x and Camel 4.x -description: Change type of classes related to change of API. -recipeList: - - org.openrewrite.java.ChangeType: - oldFullyQualifiedTypeName: org.apache.camel.support.IntrospectionSupport - newFullyQualifiedTypeName: org.apache.camel.impl.engine.IntrospectionSupport + # use the recipe from camel standalone migration + - org.apache.camel.updates.camel40.CamelMigrationRecipe --- type: specs.openrewrite.org/v1beta/recipe name: org.openrewrite.java.camel.migrate.removedExtensions @@ -135,53 +119,3 @@ recipeList: - org.openrewrite.maven.RemoveDependency: groupId: org.apache.camel.quarkus artifactId: camel-quarkus-xstream ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.camel.migrate.ChangePropertyValue -displayName: Camel API changes in application.properties -description: Apache Camel API migration from version 3.20 or higher to 4.0. Removal of deprecated APIs, which could be part of the application.properties. -#todo would be better to put a comment about changed property and its alternative, once the openrewrite recipe allows that -recipeList: - - org.openrewrite.properties.ChangePropertyValue: - propertyKey: camel.threadpool.rejectedPolicy - newValue: "Abort #DiscardOldest has been removed, consider Abort" - oldValue: DiscardOldest - - org.openrewrite.properties.ChangePropertyValue: - propertyKey: camel.threadpool.rejectedPolicy - newValue: "Abort #Discard has been removed, consider Abort" - oldValue: Discard ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.camel.migrate.ChangeManagedChoiceMBeanMethodName -displayName: Change of method names brought by Camel JMX API changes -description: MBeans now use a consistent method name of `extendedInformation`. -recipeList: - - org.openrewrite.java.ChangeMethodName: - methodPattern: org.apache.camel.api.management.mbean.ManagedChoiceMBean choiceStatistics() - newMethodName: extendedInformation - matchOverrides: null - ignoreDefinition: null ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.camel.migrate.ChangeManagedFailoverLoadBalancerMBeanMethodName -displayName: Change of method names brought by Camel JMX API changes -description: MBeans now use a consistent method name of `extendedInformation`. -recipeList: - - org.openrewrite.java.ChangeMethodName: - methodPattern: org.apache.camel.api.management.mbean.ManagedFailoverLoadBalancerMBean exceptionStatistics() - newMethodName: extendedInformation - matchOverrides: null - ignoreDefinition: null ---- -type: specs.openrewrite.org/v1beta/recipe -name: io.quarkus.updates.camel.camel40.UsePluginHelperForContextGetters -displayName: Replace context.getExtension(ExtendedCamelContext.class).get* with PluginHelper.get*(context) -recipeList: - - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper: - oldMethodName: getComponentNameResolver - - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper: - oldMethodName: getModelJAXBContextFactory - - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper: - oldMethodName: getModelToXMLDumper - - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper: - oldMethodName: getRoutesLoader \ No newline at end of file