diff --git a/pom.xml b/pom.xml index ebf4ccd2..10724a45 100644 --- a/pom.xml +++ b/pom.xml @@ -221,5 +221,10 @@ 1.10.10 test + + io.jenkins.configuration-as-code + test-harness + test + diff --git a/src/test/java/org/jenkinsci/plugins/workflow/libs/JCasCGlobalLibrariesTest.java b/src/test/java/org/jenkinsci/plugins/workflow/libs/JCasCGlobalLibrariesTest.java new file mode 100644 index 00000000..6745bcc7 --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/workflow/libs/JCasCGlobalLibrariesTest.java @@ -0,0 +1,35 @@ +package org.jenkinsci.plugins.workflow.libs; + +import io.jenkins.plugins.casc.misc.ConfiguredWithCode; +import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.RuleChain; +import org.jvnet.hudson.test.LoggerRule; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsIn.in; +import static org.hamcrest.core.IsNot.not; + +public class JCasCGlobalLibrariesTest { + + public JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule(); + public LoggerRule logging = new LoggerRule(); + + @Rule + public RuleChain chain = RuleChain.outerRule(logging.record(Logger.getLogger("io.jenkins.plugins.casc.BaseConfigurator"), Level.INFO) + .capture(2048)) + .around(j); + + @Test + @ConfiguredWithCode("JCasCGlobalLibrariesTest.yml") + public void isBaseConfiguratorComplainingAboutOwner() { + //WARNING i.j.p.casc.BaseConfigurator#createAttribute: Can't handle class jenkins.plugins.git.GitSCMSource#owner: type is abstract but not Describable. + assertThat("Can't handle class jenkins.plugins.git.GitSCMSource#owner: type is abstract but not Describable.", + not(in(logging.getMessages()) + )); + } +} diff --git a/src/test/resources/JCasCGlobalLibrariesTest.yml b/src/test/resources/JCasCGlobalLibrariesTest.yml new file mode 100644 index 00000000..4e39d341 --- /dev/null +++ b/src/test/resources/JCasCGlobalLibrariesTest.yml @@ -0,0 +1,15 @@ +unclassified: + globalLibraries: + libraries: + - defaultVersion: "dev" + includeInChangesets: false + name: "cloudbees-shared-library" + retriever: + modernSCM: + clone: true + scm: + git: + credentialsId: + remote: + traits: + - "gitBranchDiscovery" \ No newline at end of file