Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-13518] Wrong JSON syntax
- Loading branch information
Showing
7 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/resources/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/org/jenkinsci/plugins/scriptler/share/scriptlerweb/UIHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.jenkinsci.plugins.scriptler.share.scriptlerweb; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import junit.framework.TestCase; | ||
import net.sf.json.JSONObject; | ||
import net.sf.json.JSONSerializer; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.jenkinsci.plugins.scriptler.config.Parameter; | ||
import org.jenkinsci.plugins.scriptler.util.UIHelper; | ||
|
||
public class UIHelperTest extends TestCase { | ||
|
||
public void testExtractParameters1() throws Exception { | ||
JSONObject json = getJsonFromFile("/simple1.json"); | ||
final Parameter[] extractParameters = UIHelper.extractParameters(json); | ||
assertNotNull("no parameters extracted", extractParameters); | ||
assertEquals("not all params extracted", 2, extractParameters.length); | ||
} | ||
|
||
public void testExtractParameters2() throws Exception { | ||
JSONObject json = getJsonFromFile("/simple2.json"); | ||
final Parameter[] extractParameters = UIHelper.extractParameters(json); | ||
assertNotNull("no parameters extracted", extractParameters); | ||
assertEquals("not all params extracted", 2, extractParameters.length); | ||
} | ||
|
||
public void testExtractParameters_JENKINS_13518() throws Exception { | ||
JSONObject json = getJsonFromFile("/JENKINS-13518.json"); | ||
final Parameter[] extractParameters = UIHelper.extractParameters(json); | ||
assertNotNull("no parameters extracted", extractParameters); | ||
assertEquals("not all params extracted", 0, extractParameters.length); | ||
} | ||
|
||
private JSONObject getJsonFromFile(String resource) throws IOException { | ||
InputStream is = UIHelperTest.class.getResourceAsStream(resource); | ||
String jsonTxt = IOUtils.toString(is); | ||
JSONObject json = (JSONObject) JSONSerializer.toJSON(jsonTxt); | ||
return json; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"":"","builder":{"backupJobName":"","builderId":"","defineParams":false,"kind":"org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder","parameters":[{"name":"","value":""},{"name":"","value":""}],"scriptlerScriptId":"testOutput.groovy","stapler-class":"org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder"},"core:apply":"","description":"","displayNameOrNull":"","name":"test","properties":{"hudson-model-ParametersDefinitionProperty":{},"org-jenkinsci-plugins-envinject-EnvInjectJobProperty":{},"stapler-class-bag":"true"},"scm":{"value":"0"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"backupJobName":"new","builderId":"1331321162149_1","defineParams":{"parameters":[{"name":"jobName","value":"${JOB}"},{"name":"buildRange","value":"1-10"}]},"kind":"org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder$DescriptorImpl","scriptlerScriptId":"bulkDeleteBuilds.groovy","stapler-class":"org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"backupJobName":"","builderId":"","defineParams":{"parameters":[{"name":"param1","value":"value1"},{"name":"param2","value":"value2"}]},"kind":"org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder$DescriptorImpl","scriptlerScriptId":"bulkDeleteBuilds.groovy","stapler-class":"org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder"} |