From 4cd226ecad38c408ddced7c754a4d17e4d050054 Mon Sep 17 00:00:00 2001 From: gtoison Date: Fri, 15 Dec 2023 09:21:44 +0100 Subject: [PATCH] Attempt at an integration test for the noClassOk option --- src/it/noClassOk/invoker.properties | 20 +++++ src/it/noClassOk/pom.xml | 89 +++++++++++++++++++ .../src/main/java/META-INF/MANIFEST.MF | 0 src/it/noClassOk/src/main/java/test.txt | 0 .../src/main/resources/app.properties | 17 ++++ src/it/noClassOk/src/test/java/Whatever.java | 19 ++++ src/it/noClassOk/verify.groovy | 38 ++++++++ 7 files changed, 183 insertions(+) create mode 100644 src/it/noClassOk/invoker.properties create mode 100644 src/it/noClassOk/pom.xml create mode 100644 src/it/noClassOk/src/main/java/META-INF/MANIFEST.MF create mode 100644 src/it/noClassOk/src/main/java/test.txt create mode 100644 src/it/noClassOk/src/main/resources/app.properties create mode 100644 src/it/noClassOk/src/test/java/Whatever.java create mode 100644 src/it/noClassOk/verify.groovy diff --git a/src/it/noClassOk/invoker.properties b/src/it/noClassOk/invoker.properties new file mode 100644 index 00000000..fc511d4a --- /dev/null +++ b/src/it/noClassOk/invoker.properties @@ -0,0 +1,20 @@ +# +# Copyright 2005-2023 the original author or authors. +# +# 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 +# +# https://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 = clean verify site -X + +# The expected result of the build, possible values are "success" (default) and "failure" +invoker.buildResult = success diff --git a/src/it/noClassOk/pom.xml b/src/it/noClassOk/pom.xml new file mode 100644 index 00000000..822f1a7e --- /dev/null +++ b/src/it/noClassOk/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + + + spotbugs-maven-plugin.it + testing + noClassOk + noClassOk + jar + + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + com.github.spotbugs + spotbugs-maven-plugin + @pom.version@ + + true + true + + + + default-spotbugs + + check + + verify + + + + + + + + + + org.apache.maven.plugins + maven-jxr-plugin + @jxrPluginVersion@ + + + com.github.spotbugs + spotbugs-maven-plugin + @pom.version@ + + true + true + + + + + diff --git a/src/it/noClassOk/src/main/java/META-INF/MANIFEST.MF b/src/it/noClassOk/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 00000000..e69de29b diff --git a/src/it/noClassOk/src/main/java/test.txt b/src/it/noClassOk/src/main/java/test.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/it/noClassOk/src/main/resources/app.properties b/src/it/noClassOk/src/main/resources/app.properties new file mode 100644 index 00000000..70221204 --- /dev/null +++ b/src/it/noClassOk/src/main/resources/app.properties @@ -0,0 +1,17 @@ +# +# Copyright 2005-2023 the original author or authors. +# +# 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 +# +# https://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. +# + +nothing=all diff --git a/src/it/noClassOk/src/test/java/Whatever.java b/src/it/noClassOk/src/test/java/Whatever.java new file mode 100644 index 00000000..fa1b066e --- /dev/null +++ b/src/it/noClassOk/src/test/java/Whatever.java @@ -0,0 +1,19 @@ +/* + * Copyright 2005-2023 the original author or authors. + * + * 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 + * + * https://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. + */ + +public class Whatever { + +} diff --git a/src/it/noClassOk/verify.groovy b/src/it/noClassOk/verify.groovy new file mode 100644 index 00000000..861203e0 --- /dev/null +++ b/src/it/noClassOk/verify.groovy @@ -0,0 +1,38 @@ +/* + * Copyright 2005-2023 the original author or authors. + * + * 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 + * + * https://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 groovy.xml.XmlSlurper + +File spotbugsHtml = new File(basedir, 'target/site/spotbugs.html') +assert !spotbugsHtml.exists() + +File spotbugXdoc = new File(basedir, 'target/spotbugs.xml') +assert !spotbugXdoc.exists() + +File spotbugXml = new File(basedir, 'target/spotbugsXml.xml') +assert spotbugXml.exists() + + +println '**********************************' +println "Checking Spotbugs Native XML file" +println '**********************************' + +path = new XmlSlurper().parse(spotbugXml) + +allNodes = path.depthFirst().collect{ it } +def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size() +println "BugInstance size is ${spotbugsXmlErrors}" + +assert spotbugsXmlErrors == 0