Skip to content

Commit

Permalink
Needed to trim the release and purpose string values (fixes JENKINS-8…
Browse files Browse the repository at this point in the history
…613)

Added a test case while I'm at it
  • Loading branch information
Keith Mendoza committed Aug 4, 2011
1 parent ee0845e commit 5210802
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
@@ -1,13 +1,17 @@
package hudson.plugins.synergy.impl;
package hudson.plugins.synergy.impl;

import java.util.Arrays;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CreateProjectBaselineCommand extends Command {
private String name;
private String project;
private String release;
private String purpose;

private static final Logger LOGGER = Logger.getLogger(CreateProjectBaselineCommand.class.getName());

public CreateProjectBaselineCommand(String name, String project, String release, String purpose) {
this.name = name;
Expand All @@ -18,12 +22,12 @@ public CreateProjectBaselineCommand(String name, String project, String release,
@Override
public String[] buildCommand(String ccmExe) {
Vector<String> commands = new Vector<String>(Arrays.asList(new String[]{ccmExe, "baseline", "-create", name, "-p", project }));
if(this.release != "") {
if(this.release.trim() != "") {
commands.add("-r");
commands.add(release);
}

if(this.purpose != "") {
if(this.purpose.trim() != "") {
commands.add("-purpose");
commands.add(purpose);
}
Expand Down
@@ -0,0 +1,25 @@
package hudson.plugins.synergy.impl;

import java.util.Arrays;
import java.util.Vector;

import org.junit.Test;
import static org.junit.Assert.*;

public class CreateProjectBaselineCommandTest {
@Test
public void testNoReleaseAndPurpose() {
CreateProjectBaselineCommand cmd = new CreateProjectBaselineCommand("Test_baseline", "TestProj", "", "");
String[] cmdList = cmd.buildCommand("/opt/ccm/bin/ccm");
for(int i = 0; i<cmdList.length; i++) {
if(cmdList[i] == "-r")
fail("-r options should not be here");
}

for(int i = 0; i<cmdList.length; i++) {
if(cmdList[i] == "-purpose")
fail("-p option should not be here");
}

}
}

0 comments on commit 5210802

Please sign in to comment.