From 1e9e8ec6fd3debd9a57628fd5593f25e48ec339c Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sat, 18 Jan 2020 22:16:32 +0000 Subject: [PATCH] Upgrade to use jcasc test harness --- pom.xml | 11 +++++----- .../ConfigurationAsCodeTest.java | 22 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index afd355d..c91f32e 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.jenkins-ci.plugins plugin - 3.29 + 3.56 @@ -54,9 +54,9 @@ - 2.60.3 + 2.138.4 8 - 1.3 + 1.35 @@ -76,7 +76,7 @@ org.jenkins-ci.plugins credentials - 2.1.16 + 2.2.0 @@ -87,7 +87,7 @@ io.jenkins.configuration-as-code - configuration-as-code-support + test-harness ${configuration-as-code-plugin.version} test @@ -102,6 +102,7 @@ FINE + 1.8 diff --git a/src/test/java/org/jenkinsci/plugins/plaincredentials/ConfigurationAsCodeTest.java b/src/test/java/org/jenkinsci/plugins/plaincredentials/ConfigurationAsCodeTest.java index 677d286..b3d3787 100644 --- a/src/test/java/org/jenkinsci/plugins/plaincredentials/ConfigurationAsCodeTest.java +++ b/src/test/java/org/jenkinsci/plugins/plaincredentials/ConfigurationAsCodeTest.java @@ -4,12 +4,14 @@ import com.cloudbees.plugins.credentials.CredentialsProvider; import com.cloudbees.plugins.credentials.domains.DomainRequirement; import hudson.security.ACL; -import io.jenkins.plugins.casc.ConfigurationAsCode; +import io.jenkins.plugins.casc.misc.ConfiguredWithCode; +import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule; import org.apache.commons.io.IOUtils; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; -import org.jvnet.hudson.test.JenkinsRule; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * @author Nicolas De Loof @@ -17,17 +19,17 @@ public class ConfigurationAsCodeTest { @Rule - public JenkinsRule j = new JenkinsRule(); + public JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule(); @Test + @ConfiguredWithCode("ConfigurationAsCode.yaml") public void should_configure_file_credentials() throws Exception { - ConfigurationAsCode.get().configure(getClass().getResource("ConfigurationAsCode.yaml").toString()); - final FileCredentials credentials = CredentialsMatchers.firstOrNull( + FileCredentials credentials = CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials(FileCredentials.class, j.jenkins, ACL.SYSTEM, (DomainRequirement) null), CredentialsMatchers.withId("secret-file")); - Assert.assertNotNull(credentials); - Assert.assertEquals("Some secret file", credentials.getDescription()); - Assert.assertEquals("my-secret-file", credentials.getFileName()); - Assert.assertEquals("FOO_BAR", IOUtils.toString(credentials.getContent())); + assertNotNull(credentials); + assertEquals("Some secret file", credentials.getDescription()); + assertEquals("my-secret-file", credentials.getFileName()); + assertEquals("FOO_BAR", IOUtils.toString(credentials.getContent())); } }