Skip to content

Commit 35493ac

Browse files
committed
Restructured test cases
1 parent 8b3d43d commit 35493ac

6 files changed

Lines changed: 38 additions & 27 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.kohsuke.stapler.html;
2+
3+
import org.kohsuke.stapler.test.JettyTestCase;
4+
5+
public abstract class HtmlTestCase extends JettyTestCase {
6+
7+
protected final String load(String uri) throws Exception {
8+
return createWebClient()
9+
.getPage(url.toURI().resolve(uri).toURL())
10+
.getWebResponse()
11+
.getContentAsString()
12+
.replaceAll("<!--.+?-->", " ")
13+
.replaceAll("\\s+", " ")
14+
.trim()
15+
.replace('"', '\'');
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.kohsuke.stapler.html;
2+
3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.is;
5+
6+
public final class IncludedFromTest extends HtmlTestCase {
7+
8+
public void testIncludedFromJelly() throws Exception {
9+
assertThat(
10+
load("top"),
11+
is("A prologue. <div> Center text includes a <span>special value</span>. </div> An epilogue."));
12+
}
13+
14+
@HtmlView("center")
15+
public Center getCenter() {
16+
return new Center("special value");
17+
}
18+
19+
public record Center(String value) {}
20+
}

html/src/test/java/org/kohsuke/stapler/html/SmokeTest.java renamed to html/src/test/java/org/kohsuke/stapler/html/StructureTest.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
import static org.hamcrest.MatcherAssert.assertThat;
44
import static org.hamcrest.Matchers.allOf;
55
import static org.hamcrest.Matchers.containsString;
6-
import static org.hamcrest.Matchers.is;
76
import static org.hamcrest.Matchers.not;
87

98
import edu.umd.cs.findbugs.annotations.CheckForNull;
109
import java.util.List;
11-
import org.kohsuke.stapler.test.JettyTestCase;
1210

13-
public final class SmokeTest extends JettyTestCase {
11+
public final class StructureTest extends HtmlTestCase {
1412

1513
Status status;
1614

@@ -54,28 +52,4 @@ public record Items(List<Element> elements) {
5452
public record Element(String name, String value) {}
5553
}
5654
}
57-
58-
public void testCalledFromJelly() throws Exception {
59-
assertThat(
60-
load("top"),
61-
is("A prologue. <div> Center text includes a <span>special value</span>. </div> An epilogue."));
62-
}
63-
64-
@HtmlView("center")
65-
public Center getCenter() {
66-
return new Center("special value");
67-
}
68-
69-
public record Center(String value) {}
70-
71-
private String load(String uri) throws Exception {
72-
return createWebClient()
73-
.getPage(url.toURI().resolve(uri).toURL())
74-
.getWebResponse()
75-
.getContentAsString()
76-
.replaceAll("<!--.+?-->", " ")
77-
.replaceAll("\\s+", " ")
78-
.trim()
79-
.replace('"', '\'');
80-
}
8155
}

html/src/test/resources/org/kohsuke/stapler/html/SmokeTest/center.xhtml renamed to html/src/test/resources/org/kohsuke/stapler/html/IncludedFromTest/center.xhtml

File renamed without changes.

html/src/test/resources/org/kohsuke/stapler/html/SmokeTest/top.jelly renamed to html/src/test/resources/org/kohsuke/stapler/html/IncludedFromTest/top.jelly

File renamed without changes.

html/src/test/resources/org/kohsuke/stapler/html/SmokeTest/standalone.xhtml renamed to html/src/test/resources/org/kohsuke/stapler/html/StructureTest/standalone.xhtml

File renamed without changes.

0 commit comments

Comments
 (0)