Skip to content

Commit

Permalink
Merge pull request #209 from JiriOndrusek/camel-quarkus-test-environment
Browse files Browse the repository at this point in the history
Proper test environment for the camel-quarkus recipes
  • Loading branch information
ia3andy authored Sep 24, 2024
2 parents c33ea87 + fe60e2e commit 50a7262
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package io.quarkus.updates.camel;

import org.openrewrite.Recipe;
import org.openrewrite.config.Environment;
import org.openrewrite.config.YamlResourceLoader;
import org.openrewrite.test.RecipeSpec;

import java.net.URI;
import java.util.Properties;

public class CamelQuarkusTestUtil {

public static RecipeSpec recipe3alpha(RecipeSpec spec) {
Expand Down Expand Up @@ -30,7 +36,18 @@ private static RecipeSpec recipe(RecipeSpec spec, String version) {
}

public static RecipeSpec recipe(RecipeSpec spec, String version, String... activerecipes) {
return spec.recipeFromResource("/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/" + version + ".yaml", activerecipes);
}

YamlResourceLoader yrl = new YamlResourceLoader(
CamelQuarkusTestUtil.class.getResourceAsStream("/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/" + version + ".yaml"), URI.create("rewrite.yml"), new Properties());
Recipe r = Environment.builder()
//classpath loader has to be initialized to load recipes from camel-upgrade-recipes dependency
.scanYamlResources()
//yaml single recipe with Quarkus recipe has to be present as it contains active recipe
.load(yrl)
.build()
.activateRecipes(activerecipes);

spec.recipes(r);
return spec;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package io.quarkus.updates.camel;

import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelUpdate41Test extends org.apache.camel.updates.camel44.CamelUpdate41Test {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3_8(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
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;

public class CamelUpdate42Test extends org.apache.camel.updates.camel44.CamelUpdate42Test {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3_8(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package io.quarkus.updates.camel;

import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelUpdate43Test extends org.apache.camel.updates.camel44.CamelUpdate43Test {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3_8(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package io.quarkus.updates.camel;

import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelUpdate44Test extends org.apache.camel.updates.camel44.CamelUpdate44Test {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3_8(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CameXmlDslRecipeTest extends org.apache.camel.updates.camel40.CameXmlDslRecipeTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelAPIsPropertiesTest extends org.apache.camel.updates.camel40.CamelAPIsPropertiesTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelAPIsTest extends org.apache.camel.updates.camel40.CamelAPIsTest {
}

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelBeanRecipeTest extends org.apache.camel.updates.camel40.CamelBeanRecipeTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelEIPRecipeTest extends org.apache.camel.updates.camel40.CamelEIPRecipeTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelHttpTest extends org.apache.camel.updates.camel40.CamelHttpTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelJmxTest extends org.apache.camel.updates.camel40.CamelAPIsTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package io.quarkus.updates.camel.camel40;

import io.quarkus.updates.camel.CamelQuarkusTestUtil;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.TypeValidation;

public class CamelYamlTest extends org.apache.camel.updates.camel40.CamelYamlTest {

@Override
public void defaults(RecipeSpec spec) {
//let the parser be initialized in the camel parent
super.defaults(spec);
//recipe has to be loaded differently
CamelQuarkusTestUtil.recipe3alpha(spec)
.typeValidationOptions(TypeValidation.none());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ description: Migrate `camel3` quarkus application to `camel4` quarkus.
recipeList:
# use the recipe from camel standalone migration
- org.apache.camel.updates.camel40.CamelMigrationRecipe
# workaround for https://issues.apache.org/jira/browse/CAMEL-21131
- org.openrewrite.java.camel.migrate.ChangePropertyValue
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.camel.migrate.removedExtensions
Expand Down

0 comments on commit 50a7262

Please sign in to comment.