Skip to content
Permalink
Browse files
Merge pull request #48 from fcojfernandez/JENKINS-49067
[JENKINS-49067] Script error after upgrading config-file-provider
  • Loading branch information
imod committed Jan 26, 2018
2 parents 271e9cb + c8924e0 commit b5b4d0dcdf57127ed636e7b331edc67ada8026e5

This file was deleted.

@@ -1,7 +1,11 @@
package org.jenkinsci.lib.configprovider;

import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import org.jenkinsci.lib.configprovider.model.Config;
import org.jenkinsci.lib.configprovider.model.ContentType;
import org.jenkinsci.plugins.configfiles.GlobalConfigFiles;
import org.jenkinsci.plugins.configfiles.Messages;
import org.jenkinsci.plugins.configfiles.custom.CustomConfig;
import org.jenkinsci.plugins.configfiles.groovy.GroovyScript;
import org.jenkinsci.plugins.configfiles.json.JsonConfig;
@@ -11,7 +15,9 @@
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestExtension;
import org.jvnet.hudson.test.recipes.LocalData;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Created by domi on 17/09/16.
@@ -82,4 +88,78 @@ public void testDynamicCreationOfConfigs2() {
Assert.assertEquals(savedConfig.newParam3, ExtensionPointTestConfig.TEST_PARAM_VALUE);
Assert.assertNotNull(savedConfig.getProviderId());
}

public static class ExtensionPointTestConfig extends Config {
public static final String TEST_PARAM_VALUE = "DEFAULT_VALUE";
public static final String TEST_NAME_VALUE = "ExtensionPointTestConfig";
public static final String TEST_COMMENT_VALUE = "Test comment";
public static final String TEST_CONTENT_VALUE = "Test content";

private static final long serialVersionUID = 1L;

public String newParam1;
public String newParam2;
public String newParam3;

@DataBoundConstructor
public ExtensionPointTestConfig(String id, String name, String comment, String content) {
super(id, name, comment, content);
newParam1 = TEST_PARAM_VALUE;
newParam2 = TEST_PARAM_VALUE;
newParam3 = TEST_PARAM_VALUE;
}

public ExtensionPointTestConfig(String id, String name, String comment, String content, String providerId) {
super(id, name, comment, content, providerId);
newParam1 = TEST_PARAM_VALUE;
newParam2 = TEST_PARAM_VALUE;
newParam3 = TEST_PARAM_VALUE;
}

public ExtensionPointTestConfig(String id, String name, String comment, String content, String providerId, String newParam1, String newParam2, String newParam3) {
super(id, name, comment, content, providerId);
this.newParam1 = newParam1;
this.newParam2 = newParam2;
this.newParam3 = newParam3;
}

@TestExtension("testDynamicCreationOfConfigs2")
public static class ExtensionPointTestConfigProvider extends AbstractConfigProviderImpl {

public ExtensionPointTestConfigProvider() {
load();
}

@Override
public ContentType getContentType() {
return ContentType.DefinedType.GROOVY;
}

@Override
public String getDisplayName() {
return Messages.groovy_provider_name();
}

@NonNull
@Override
public Config newConfig(@NonNull String id) {
return new ExtensionPointTestConfig(id, TEST_NAME_VALUE, TEST_COMMENT_VALUE, TEST_CONTENT_VALUE, getProviderId(), TEST_PARAM_VALUE, TEST_PARAM_VALUE, TEST_PARAM_VALUE);
}

// ======================
// stuff for backward compatibility
protected transient String ID_PREFIX;

@Override
protected String getXmlFileName() {
return "extension-point-test-config-files.xml";
}

static {
Jenkins.XSTREAM.alias("org.jenkinsci.lib.configprovider.ExtensionPointTestConfigProvider", ExtensionPointTestConfigProvider.class);
}
// ======================
}

}
}

0 comments on commit b5b4d0d

Please sign in to comment.