Skip to content

Minor fixes to close json resources, prevent malformed URLs, and correct index.xhtml values #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public static WebArchive deploy() {
@Test
public void checkRenderedPage() throws Exception {
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(base + "/faces/myflow/index.xhtml");
HtmlPage page = webClient.getPage((base + "/faces/myflow/index.xhtml").replace("//faces", "/faces"));
assertNotNull(page);
assert (page.asText().contains("Hello there!"));
}
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ public static WebArchive createDeployment() {
@Before
public void setup() throws IOException {
webClient = new WebClient();
page = webClient.getPage(base + "/faces/index.xhtml");
page = webClient.getPage((base + "/faces/index.xhtml").replace("//faces", "/faces"));
nameInputText = (HtmlTextInput) page.getElementById("nameInputText");
ageInputText = (HtmlTextInput) page.getElementById("ageInputText");
zipInputText = (HtmlTextInput) page.getElementById("zipInputText");
@@ -68,7 +68,7 @@ public void testNameLessCharacters() throws IOException {
zipInputText.setText("12345");
HtmlPage result = button.click();
HtmlSpan span = (HtmlSpan) result.getElementById("nameMessage");
assertEquals("At least 3 characters", span.asText());
assertEquals("nameInputText: At least 3 characters", span.asText());
}

@Test
@@ -88,7 +88,7 @@ public void testAgeLessThan() throws IOException {
zipInputText.setText("12345");
HtmlPage result = button.click();
HtmlSpan span = (HtmlSpan) result.getElementById("ageMessage");
assertEquals("must be greater than or equal to 18", span.asText());
assertEquals("ageInputText: must be greater than or equal to 18", span.asText());
}

@Test
@@ -118,7 +118,7 @@ public void testAgeGreaterThan() throws IOException {
zipInputText.setText("12345");
HtmlPage result = button.click();
HtmlSpan span = (HtmlSpan) result.getElementById("ageMessage");
assertEquals("must be less than or equal to 25", span.asText());
assertEquals("ageInputText: must be less than or equal to 25", span.asText());
}

@Test
@@ -128,7 +128,7 @@ public void testZipAlphabets() throws IOException {
zipInputText.setText("abcde");
HtmlPage result = button.click();
HtmlSpan span = (HtmlSpan) result.getElementById("zipMessage");
assertEquals("must match \"[0-9]{5}\"", span.asText());
assertEquals("zipInputText: must match the following regular expression: [0-9]{5}", span.asText());
}

@Test
@@ -138,7 +138,7 @@ public void testZipLessNumbers() throws IOException {
zipInputText.setText("1234");
HtmlPage result = button.click();
HtmlSpan span = (HtmlSpan) result.getElementById("zipMessage");
assertEquals("must match \"[0-9]{5}\"", span.asText());
assertEquals("zipInputText: must match the following regular expression: [0-9]{5}", span.asText());
}

@Test
@@ -148,7 +148,7 @@ public void testZipMoreNumbers() throws IOException {
zipInputText.setText("123456");
HtmlPage result = button.click();
HtmlSpan span = (HtmlSpan) result.getElementById("zipMessage");
assertEquals("must match \"[0-9]{5}\"", span.asText());
assertEquals("zipInputText: must match the following regular expression: [0-9]{5}", span.asText());
}

@Test
8 changes: 4 additions & 4 deletions jsf/components/src/main/webapp/index.xhtml
Original file line number Diff line number Diff line change
@@ -111,20 +111,20 @@
</h:selectManyCheckbox>

<p/><b>selectManyListbox</b><br/>
<h:selectManyListbox value="#{myBean.selectBooleanCheckbox}" size="2">
<h:selectManyListbox value="#{myBean.selectManyCheckbox}" size="2">
<f:selectItem itemValue="red" itemLabel="Red"/>
<f:selectItem itemValue="green" itemLabel="Green"/>
<f:selectItem itemValue="blue" itemLabel="Blue"/>
<f:selectItem itemValue="yellow" itemLabel="yellow"/>
<f:selectItem itemValue="yellow" itemLabel="Yellow"/>
<f:selectItem itemValue="orange" itemLabel="Orange"/>
</h:selectManyListbox>

<p/><b>selectManyMenu</b><br/>
<h:selectManyMenu value="#{myBean.selectBooleanCheckbox}">
<h:selectManyMenu value="#{myBean.selectManyCheckbox}">
<f:selectItem itemValue="red" itemLabel="Red"/>
<f:selectItem itemValue="green" itemLabel="Green"/>
<f:selectItem itemValue="blue" itemLabel="Blue"/>
<f:selectItem itemValue="yellow" itemLabel="yellow"/>
<f:selectItem itemValue="yellow" itemLabel="Yellow"/>
<f:selectItem itemValue="orange" itemLabel="Orange"/>
</h:selectManyMenu>
</h:form>
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public static WebArchive createDeployment() {
@Before
public void setup() throws IOException {
webClient = new WebClient();
page = webClient.getPage(base + "/faces/index.xhtml");
page = webClient.getPage((base + "/faces/index.xhtml").replace("//faces", "/faces"));
}

@Test
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ public void testEmptyObject() throws JSONException {

assertNotNull(json);
assertTrue(json.isEmpty());
jsonReader.close();
}

@Test
@@ -58,6 +59,7 @@ public void testSimpleObjectWithTwoElements() throws JSONException {
assertEquals("red", json.getString("apple"));
assertTrue(json.containsKey("banana"));
assertEquals("yellow", json.getString("banana"));
jsonReader.close();
}

@Test
@@ -72,6 +74,7 @@ public void testArray() throws JSONException {

JSONAssert.assertEquals("{\"apple\":\"red\"}", jsonArr.get(0).toString(), JSONCompareMode.STRICT);
JSONAssert.assertEquals("{\"banana\":\"yellow\"}", jsonArr.get(1).toString(), JSONCompareMode.STRICT);
jsonReader.close();
}

@Test
@@ -103,5 +106,6 @@ public void testNestedStructure() throws JSONException {
+ " \"Laurence Fishburne\","
+ " \"Carrie-Anne Moss\""
+ " ]", jsonArr.toString(), JSONCompareMode.STRICT);
jsonReader.close();
}
}
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ public void testEmptyObject() throws JSONException {

assertNotNull(json);
assertTrue(json.isEmpty());
jsonReader.close();
}

@Test
@@ -64,6 +65,7 @@ public void testSimpleObjectWithTwoElements() throws JSONException {
assertEquals("red", json.getString("apple"));
assertTrue(json.containsKey("banana"));
assertEquals("yellow", json.getString("banana"));
jsonReader.close();
}

@Test
@@ -78,6 +80,7 @@ public void testArray() throws JSONException {

JSONAssert.assertEquals("{\"apple\":\"red\"}", jsonArr.get(0).toString(), JSONCompareMode.STRICT);
JSONAssert.assertEquals("{\"banana\":\"yellow\"}", jsonArr.get(1).toString(), JSONCompareMode.STRICT);
jsonReader.close();
}

@Test
@@ -104,5 +107,6 @@ public void testNestedStructure() throws JSONException {
+ " \"Laurence Fishburne\","
+ " \"Carrie-Anne Moss\""
+ " ]", jsonArr.toString(), JSONCompareMode.STRICT);
jsonReader.close();
}
}
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ public void testEmptyObject() throws JSONException {
JsonParser parser = Json.createParser(new StringReader(json));
assertEquals(JsonParser.Event.START_OBJECT, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
parser.close();
}

@Test
@@ -52,6 +53,7 @@ public void testSimpleObject() throws JSONException {
assertEquals(JsonParser.Event.KEY_NAME, parser.next());
assertEquals(JsonParser.Event.VALUE_STRING, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
parser.close();
}

@Test
@@ -68,6 +70,7 @@ public void testArray() throws JSONException {
assertEquals(JsonParser.Event.VALUE_STRING, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
assertEquals(JsonParser.Event.END_ARRAY, parser.next());
parser.close();
}

@Test
@@ -86,5 +89,6 @@ public void testNestedStructure() throws JSONException {
assertEquals(JsonParser.Event.VALUE_STRING, parser.next());
assertEquals(JsonParser.Event.END_ARRAY, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
parser.close();
}
}
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ public void testEmptyObject() throws JSONException {

assertEquals(JsonParser.Event.START_OBJECT, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
parser.close();
}

@Test
@@ -60,6 +61,7 @@ public void testSimpleObject() throws JSONException {
assertEquals(JsonParser.Event.KEY_NAME, parser.next());
assertEquals(JsonParser.Event.VALUE_STRING, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
parser.close();
}

@Test
@@ -79,6 +81,7 @@ public void testArray() throws JSONException {
assertEquals(JsonParser.Event.VALUE_STRING, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
assertEquals(JsonParser.Event.END_ARRAY, parser.next());
parser.close();
}

@Test
@@ -100,6 +103,7 @@ public void testNestedStructure() throws JSONException {
assertEquals(JsonParser.Event.VALUE_STRING, parser.next());
assertEquals(JsonParser.Event.END_ARRAY, parser.next());
assertEquals(JsonParser.Event.END_OBJECT, parser.next());
parser.close();
}

}