Skip to content

Commit

Permalink
[JENKINS-53399] Add deserialization test for FolderConfigFileProperty
Browse files Browse the repository at this point in the history
The config files for the new test have been set up as similar as
possible to the existing one, only ids differ. The existing test
was cleaned a bit.
  • Loading branch information
darxriggs committed Sep 3, 2019
1 parent bb125d8 commit 8b8a1b0
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.jvnet.hudson.test.recipes.LocalData;

/**
* Test for GlobalConfigFiles to ensure reading data.<br>
* Test for {@link GlobalConfigFiles} to ensure reading data.
*/
public class GlobalConfigFilesTest {

Expand All @@ -28,9 +28,8 @@ public class GlobalConfigFilesTest {
@LocalData
@Test
public void verifyLoadWithAnonymousInnerClassComparatorVar1() {
GlobalConfigFiles store = j.getInstance().getExtensionList(GlobalConfigFiles.class).get(GlobalConfigFiles.class);
ConfigFileStore store = j.getInstance().getExtensionList(GlobalConfigFiles.class).get(GlobalConfigFiles.class);
Collection<Config> configs = store.getConfigs();
assertThat(configs, hasSize(2));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.jenkinsci.plugins.configfiles.folder;

import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;

import java.util.Collection;

import com.cloudbees.hudson.plugins.folder.Folder;
import org.jenkinsci.lib.configprovider.model.Config;
import org.jenkinsci.plugins.configfiles.ConfigFileStore;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;

/**
* Test for {@link FolderConfigFileProperty} to ensure reading data.
*/
public class FolderConfigFilesTest {

@Rule
public JenkinsRule j = new JenkinsRule();

/**
* Read data produced by Jenkins ver. 2.141 and plugin version 2.18.<br>
* The only change I made is to downgrade XML version to 1.0 because of this:<br>
*
* XML version of descriptor are upgraded from 1.0 to 1.1 in 2.105 https://jenkins.io/changelog/#v2.105 (JENKINS-48463)
*/
@LocalData
@Test
public void verifyLoadWithAnonymousInnerClassComparatorVar1() {
ConfigFileStore store = ((Folder) j.jenkins.getItemByFullName("test-folder")).getAction(FolderConfigFileAction.class).getStore();
Collection<Config> configs = store.getConfigs();
assertThat(configs, hasSize(2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<comparator class="org.jenkinsci.plugins.configfiles.GlobalConfigFiles$1"/>
<org.jenkinsci.plugins.configfiles.custom.CustomConfig>
<id>e61a40f3-9d03-4448-bca1-e874f3fb1c45</id>
<name>dummyCustomConfig1</name>
<comment>Dummy Custom Config 1</comment>
<name>custom-config</name>
<comment>Dummy Custom Config</comment>
<content>dummy content</content>
<providerId>org.jenkinsci.plugins.configfiles.custom.CustomConfig</providerId>
</org.jenkinsci.plugins.configfiles.custom.CustomConfig>
Expand All @@ -17,21 +17,10 @@
&lt;settings&gt;
&lt;interactiveMode&gt;false&lt;/interactiveMode&gt;
&lt;localRepository&gt;${env.WORKSPACE}/.repository&lt;/localRepository&gt;
&lt;!--
&lt;proxies&gt;
&lt;proxy&gt;
&lt;id&gt;dummy-proxy&lt;/id&gt;
&lt;active&gt;true&lt;/active&gt;
&lt;protocol&gt;http&lt;/protocol&gt;
&lt;port&gt;8888&lt;/port&gt;
&lt;nonProxyHosts&gt;localhost&lt;/nonProxyHosts&gt;
&lt;/proxy&gt;
&lt;/proxies&gt;
--&gt;
&lt;/settings&gt;</content>
<providerId>org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig</providerId>
<serverCredentialMappings/>
<isReplaceAll>true</isReplaceAll>
</org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig>
</configs>
</org.jenkinsci.plugins.configfiles.GlobalConfigFiles>
</org.jenkinsci.plugins.configfiles.GlobalConfigFiles>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version='1.0' encoding='UTF-8'?>
<com.cloudbees.hudson.plugins.folder.Folder plugin="cloudbees-folder@5.12">
<actions/>
<description/>
<properties>
<org.jenkinsci.plugins.configfiles.folder.FolderConfigFileProperty plugin="config-file-provider@2.18">
<configs class="sorted-set">
<comparator class="org.jenkinsci.plugins.configfiles.folder.FolderConfigFileProperty$1"/>
<org.jenkinsci.plugins.configfiles.custom.CustomConfig>
<id>e47beadf-b379-4d8a-9db9-ea373600d8eb</id>
<name>custom-config</name>
<comment>Dummy Custom Config</comment>
<content>dummy content</content>
<providerId>org.jenkinsci.plugins.configfiles.custom.CustomConfig</providerId>
</org.jenkinsci.plugins.configfiles.custom.CustomConfig>
<org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig>
<id>de351ee6-bf92-43e1-b0af-0c31f5819b68</id>
<name>global-maven-settings</name>
<comment>Dummy global Maven settings</comment>
<content>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;settings&gt;
&lt;interactiveMode&gt;false&lt;/interactiveMode&gt;
&lt;localRepository&gt;${env.WORKSPACE}/.repository&lt;/localRepository&gt;
&lt;/settings&gt;</content>
<providerId>org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig</providerId>
<serverCredentialMappings/>
<isReplaceAll>true</isReplaceAll>
</org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig>
</configs>
</org.jenkinsci.plugins.configfiles.folder.FolderConfigFileProperty>
</properties>
<views>
<hudson.model.AllView>
<owner class="com.cloudbees.hudson.plugins.folder.Folder" reference="../../.."/>
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<healthMetrics/>
<icon class="com.cloudbees.hudson.plugins.folder.icons.StockFolderIcon"/>
</com.cloudbees.hudson.plugins.folder.Folder>

0 comments on commit 8b8a1b0

Please sign in to comment.