Skip to content
Permalink
Browse files

[JENKINS-27505] Added a test to reproduce JENKINS-27505. The empty li…

…ne at the beginning will be removed in a textarea.
  • Loading branch information...
ikedam committed Mar 19, 2015
1 parent 097a7c5 commit 979ddba0ced2dabc62851e428a2e03d587892e0d
Showing with 48 additions and 0 deletions.
  1. +48 −0 test/src/test/groovy/lib/form/TextAreaTest.groovy
@@ -14,6 +14,8 @@ import org.kohsuke.stapler.QueryParameter

import javax.inject.Inject

import static org.junit.Assert.*

/**
*
*
@@ -70,4 +72,50 @@ class TextAreaTest {
}

}

@Test
public void testText() {
def TEXT_TO_TEST = "some\nvalue\n";
def p = j.createFreeStyleProject();
p.buildersList.add(new TextareaTestBuilder(TEXT_TO_TEST));
assertEquals(TEXT_TO_TEST, p.getBuildersList().get(TextareaTestBuilder.class).getText());
j.configRoundtrip(p);
assertEquals(TEXT_TO_TEST, p.getBuildersList().get(TextareaTestBuilder.class).getText());
}

@Issue("JENKINS-27505")
@Test
public void testTextBeginningWithEmptyLine() {
def TEXT_TO_TEST = "\nbegin\n\nwith\nempty\nline\n\n";
def p = j.createFreeStyleProject();
p.buildersList.add(new TextareaTestBuilder(TEXT_TO_TEST));
assertEquals(TEXT_TO_TEST, p.getBuildersList().get(TextareaTestBuilder.class).getText());
j.configRoundtrip(p);
assertEquals(TEXT_TO_TEST, p.getBuildersList().get(TextareaTestBuilder.class).getText());
}

public static class TextareaTestBuilder extends Builder {
private text;

@DataBoundConstructor
TextareaTestBuilder(String text) {
this.text = text;
}

public String getText() { return text; }

@TestExtension
public static class DescriptorImpl extends BuildStepDescriptor<Builder> {
@Override
boolean isApplicable(Class<? extends AbstractProject> jobType) {
return true;
}

@Override
String getDisplayName() {
return this.class.name;
}
}

}
}

0 comments on commit 979ddba

Please sign in to comment.
You can’t perform that action at this time.