From b79bae894f96e62db8571fb209149f3a1d63c8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Str=C3=A4hle?= Date: Wed, 15 May 2024 11:49:27 +0200 Subject: [PATCH] Add integration tests using maven-invoker plugin --- crd-generator/maven-plugin/pom.xml | 35 +++++++++ .../it/project-explicit/invoker.properties | 19 +++++ .../src/it/project-explicit/pom.xml | 73 +++++++++++++++++++ .../maven/example/explicit/v1/Multiple.java | 25 +++++++ .../example/explicit/v1/MultipleSpec.java | 24 ++++++ .../maven/example/explicit/v2/Multiple.java | 25 +++++++ .../example/explicit/v2/MultipleSpec.java | 24 ++++++ .../src/it/project-explicit/verify.groovy | 23 ++++++ .../src/it/project-scan/invoker.properties | 19 +++++ .../maven-plugin/src/it/project-scan/pom.xml | 69 ++++++++++++++++++ .../crd/maven/example/simple/v1/Multiple.java | 25 +++++++ .../maven/example/simple/v1/MultipleSpec.java | 23 ++++++ .../crd/maven/example/simple/v2/Multiple.java | 25 +++++++ .../maven/example/simple/v2/MultipleSpec.java | 23 ++++++ .../src/it/project-scan/verify.groovy | 23 ++++++ .../maven-plugin/src/it/settings.xml | 52 +++++++++++++ .../crd/generator/maven/plugin/Verify.java | 25 +++++++ 17 files changed, 532 insertions(+) create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/invoker.properties create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/pom.xml create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/Multiple.java create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/MultipleSpec.java create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/Multiple.java create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/MultipleSpec.java create mode 100644 crd-generator/maven-plugin/src/it/project-explicit/verify.groovy create mode 100644 crd-generator/maven-plugin/src/it/project-scan/invoker.properties create mode 100644 crd-generator/maven-plugin/src/it/project-scan/pom.xml create mode 100644 crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/Multiple.java create mode 100644 crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/MultipleSpec.java create mode 100644 crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/Multiple.java create mode 100644 crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/MultipleSpec.java create mode 100644 crd-generator/maven-plugin/src/it/project-scan/verify.groovy create mode 100644 crd-generator/maven-plugin/src/it/settings.xml create mode 100644 crd-generator/maven-plugin/src/test/java/io/fabric8/crd/generator/maven/plugin/Verify.java diff --git a/crd-generator/maven-plugin/pom.xml b/crd-generator/maven-plugin/pom.xml index 90da64d4672..e95238c91b3 100644 --- a/crd-generator/maven-plugin/pom.xml +++ b/crd-generator/maven-plugin/pom.xml @@ -31,6 +31,11 @@ maven-plugin + + + ${project.version} + + org.apache.maven @@ -91,6 +96,36 @@ + + + org.apache.maven.plugins + maven-invoker-plugin + + ${project.build.directory}/it + true + + src/it/settings.xml + verify + true + ${skipTests} + true + invoker.properties + + ${project.version} + ${project.artifactId} + ${project.groupId} + + + + + integration-tests + + install + run + + + + diff --git a/crd-generator/maven-plugin/src/it/project-explicit/invoker.properties b/crd-generator/maven-plugin/src/it/project-explicit/invoker.properties new file mode 100644 index 00000000000..8f844e67068 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/invoker.properties @@ -0,0 +1,19 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +invoker.goals.1=clean package +invoker.mavenOpts= +invoker.debug=false diff --git a/crd-generator/maven-plugin/src/it/project-explicit/pom.xml b/crd-generator/maven-plugin/src/it/project-explicit/pom.xml new file mode 100644 index 00000000000..c51e2b66c29 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + io.fabric8.crd.generator.samples + project-explicit + 0.1-SNAPSHOT + jar + + + + org.projectlombok + lombok + provided + @lombok.version@ + + + io.fabric8 + kubernetes-client-api + @fabric8-client.version@ + + + + + + + io.fabric8 + crd-generator-maven-plugin + + + + generate + + + + io.fabric8.crd.maven.example.explicit.v1.Multiple + io.fabric8.crd.maven.example.explicit.v2.Multiple + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + diff --git a/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/Multiple.java b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/Multiple.java new file mode 100644 index 00000000000..5fa08dad22f --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/Multiple.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.explicit.v1; + +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.Version; + +@Group("sample.fabric8.io") +@Version(value = "v1", storage = false) +public class Multiple extends CustomResource { +} diff --git a/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/MultipleSpec.java b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/MultipleSpec.java new file mode 100644 index 00000000000..165b79fd6d0 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v1/MultipleSpec.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.explicit.v1; + +public class MultipleSpec { + private String v1; + + public String getV1() { + return v1; + } +} diff --git a/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/Multiple.java b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/Multiple.java new file mode 100644 index 00000000000..44f6ba4d8d4 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/Multiple.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.explicit.v2; + +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.Version; + +@Group("sample.fabric8.io") +@Version("v2") +public class Multiple extends CustomResource { +} diff --git a/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/MultipleSpec.java b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/MultipleSpec.java new file mode 100644 index 00000000000..04632bf6aa2 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/src/main/java/io/fabric8/crd/maven/example/explicit/v2/MultipleSpec.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.explicit.v2; + +public class MultipleSpec { + private String v2; + + public String getV2() { + return v2; + } +} diff --git a/crd-generator/maven-plugin/src/it/project-explicit/verify.groovy b/crd-generator/maven-plugin/src/it/project-explicit/verify.groovy new file mode 100644 index 00000000000..5f499c2f824 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-explicit/verify.groovy @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import io.fabric8.crd.generator.maven.plugin.Verify; + + +[ "multiples.sample.fabric8.io-v1" ].each { + Verify.verifyExist(new File(basedir, sprintf("/target/classes/META-INF/fabric8/%s.yml",it))) +} + +true diff --git a/crd-generator/maven-plugin/src/it/project-scan/invoker.properties b/crd-generator/maven-plugin/src/it/project-scan/invoker.properties new file mode 100644 index 00000000000..8f844e67068 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/invoker.properties @@ -0,0 +1,19 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +invoker.goals.1=clean package +invoker.mavenOpts= +invoker.debug=false diff --git a/crd-generator/maven-plugin/src/it/project-scan/pom.xml b/crd-generator/maven-plugin/src/it/project-scan/pom.xml new file mode 100644 index 00000000000..9af9e89dbf8 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + io.fabric8.crd.generator.samples + scan-project + 0.1-SNAPSHOT + + jar + + + + org.projectlombok + lombok + provided + @lombok.version@ + + + io.fabric8 + kubernetes-client-api + @fabric8-client.version@ + + + + + + + io.fabric8 + crd-generator-maven-plugin + @fabric8-client.version@ + + + + generate + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + diff --git a/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/Multiple.java b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/Multiple.java new file mode 100644 index 00000000000..1c3d25255fe --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/Multiple.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.simple.v1; + +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.Version; + +@Group("sample.fabric8.io") +@Version(value = "v1", storage = false) +public class Multiple extends CustomResource { +} diff --git a/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/MultipleSpec.java b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/MultipleSpec.java new file mode 100644 index 00000000000..9a013c8e99c --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v1/MultipleSpec.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.simple.v1; + +import lombok.Data; + +@Data +public class MultipleSpec { + private String v1; +} diff --git a/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/Multiple.java b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/Multiple.java new file mode 100644 index 00000000000..c913c1e28a9 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/Multiple.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.simple.v2; + +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.Version; + +@Group("sample.fabric8.io") +@Version("v2") +public class Multiple extends CustomResource { +} diff --git a/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/MultipleSpec.java b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/MultipleSpec.java new file mode 100644 index 00000000000..4e94866de7f --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/src/main/java/io/fabric8/crd/maven/example/simple/v2/MultipleSpec.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.maven.example.simple.v2; + +import lombok.Data; + +@Data +public class MultipleSpec { + private String v2; +} diff --git a/crd-generator/maven-plugin/src/it/project-scan/verify.groovy b/crd-generator/maven-plugin/src/it/project-scan/verify.groovy new file mode 100644 index 00000000000..5f499c2f824 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/project-scan/verify.groovy @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import io.fabric8.crd.generator.maven.plugin.Verify; + + +[ "multiples.sample.fabric8.io-v1" ].each { + Verify.verifyExist(new File(basedir, sprintf("/target/classes/META-INF/fabric8/%s.yml",it))) +} + +true diff --git a/crd-generator/maven-plugin/src/it/settings.xml b/crd-generator/maven-plugin/src/it/settings.xml new file mode 100644 index 00000000000..9264dac4e13 --- /dev/null +++ b/crd-generator/maven-plugin/src/it/settings.xml @@ -0,0 +1,52 @@ + + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + diff --git a/crd-generator/maven-plugin/src/test/java/io/fabric8/crd/generator/maven/plugin/Verify.java b/crd-generator/maven-plugin/src/test/java/io/fabric8/crd/generator/maven/plugin/Verify.java new file mode 100644 index 00000000000..70c61320498 --- /dev/null +++ b/crd-generator/maven-plugin/src/test/java/io/fabric8/crd/generator/maven/plugin/Verify.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.generator.maven.plugin; + +import java.io.File; + +class Verify { + static void verifyExist(File file) { + if (!file.exists()) + throw new AssertionError("File " + file.getAbsoluteFile() + " does not exist"); + } +}