Skip to content

Commit

Permalink
WICKET-6993 - Adjust test cases for new format
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Lamby committed Jun 30, 2022
1 parent 7ebb24c commit 7bd0b63
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void decode1()
@Test
void decode1A()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference1?en");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference1?2~ennullnull");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
// assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); // TODO use hamcrest or assertj
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand Down Expand Up @@ -120,7 +120,7 @@ void decode2()
@Test
void decode2A()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference1?-style&p1=v1&p2=v2");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference1?null5~stylenull&p1=v1&p2=v2");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -139,7 +139,7 @@ void decode2A()
@Test
void decode3()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?en_EN");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?5~en_ENnullnull");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
Expand All @@ -158,7 +158,7 @@ void decode3()
@Test
void decode3A()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?en_EN-style");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?5~en_EN5~stylenull");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand Down Expand Up @@ -188,7 +188,7 @@ void decode3B()
void decode4()
{
Url url = Url
.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?en_EN&p1=v1&p2=v2");
.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?5~en_ENnullnull&p1=v1&p2=v2");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -206,7 +206,7 @@ void decode4()
@Test
void decode5()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference3?-style");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference3?null5~stylenull");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -224,7 +224,7 @@ void decode5()
@Test
void decode6()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference3?-style&p1=v1&p2=v2");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference3?null5~stylenull&p1=v1&p2=v2");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -244,7 +244,7 @@ void decode6()
@Test
void decode7()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference4?en-style");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference4?2~en5~stylenull");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -262,7 +262,7 @@ void decode7()
@Test
void decode7A()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference4?sk");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference4?2~sknullnull");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertNull(handler);
}
Expand All @@ -273,7 +273,7 @@ void decode7A()
@Test
void decode8()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference4?en-style&p1=v1&p2=v2");
Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference4?2~en5~stylenull&p1=v1&p2=v2");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -293,7 +293,7 @@ void decode8()
void decode9()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME
+ "/reference5?en--variation&p1=v1&p2=v2");
+ "/reference5?2~ennull9~variation&p1=v1&p2=v2");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand All @@ -313,7 +313,7 @@ void decode9()
void decode10()
{
Url url = Url.parse("wicket/resource/" + CLASS_NAME
+ "/reference6?en-style-variation&p1=v1&p2=v2");
+ "/reference6?2~en5~style9~variation&p1=v1&p2=v2");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class);
ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler;
Expand Down Expand Up @@ -375,7 +375,7 @@ void encode3()
ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(reference2,
null);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference2/name2?en_EN", url.toString());
assertEquals("wicket/resource/" + CLASS_NAME + "/reference2/name2?5~en_ENnullnull", url.toString());
}

/**
Expand All @@ -392,7 +392,7 @@ void encode4()
parameters);

Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference2/name2?en_EN&p1=v1&p2=v2",
assertEquals("wicket/resource/" + CLASS_NAME + "/reference2/name2?5~en_ENnullnull&p1=v1&p2=v2",
url.toString());
}

Expand All @@ -405,7 +405,7 @@ void encode5()
ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(reference3,
null);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference3?-style", url.toString());
assertEquals("wicket/resource/" + CLASS_NAME + "/reference3?null5~stylenull", url.toString());
}

/**
Expand All @@ -422,7 +422,7 @@ void encode6()
parameters);

Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference3?-style&p1=v1&p2=v2",
assertEquals("wicket/resource/" + CLASS_NAME + "/reference3?null5~stylenull&p1=v1&p2=v2",
url.toString());
}

Expand All @@ -435,7 +435,7 @@ void encode7()
ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(reference4,
null);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference4?en-style", url.toString());
assertEquals("wicket/resource/" + CLASS_NAME + "/reference4?2~en5~stylenull", url.toString());
}

/**
Expand All @@ -452,7 +452,7 @@ void encode8()
parameters);

Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference4?en-style&p1=v1&p2=v2",
assertEquals("wicket/resource/" + CLASS_NAME + "/reference4?2~en5~stylenull&p1=v1&p2=v2",
url.toString());
}

Expand All @@ -466,7 +466,7 @@ void encode9()
null);

Url url = encoder.mapHandler(handler);
assertEquals("wicket/resource/" + CLASS_NAME + "/reference5?en--variation", url.toString());
assertEquals("wicket/resource/" + CLASS_NAME + "/reference5?2~ennull9~variation", url.toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ void imageButton() throws Exception
tester.startPage(Home.class);

tester.clickLink("goCanadian");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?en_CA\"");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?5~en_CAnullnull\"");

tester.clickLink("goChinese");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?zh_CN\"");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?5~zh_CNnullnull\"");

tester.clickLink("goDanish");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?da_DK\"");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?5~da_DKnullnull\"");

tester.clickLink("goDutch");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?nl_NL\"");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?5~nl_NLnullnull\"");

tester.clickLink("goGerman");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?de_DE\"");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\\?5~de_DEnullnull\"");

tester.clickLink("goUS");
tester.assertContains("resource/org.apache.wicket.markup.html.form.imagebutton.Home/Beer.gif\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ void test_1() throws Exception
tester.startPage(Home.class);

tester.clickLink("goCanadian");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?en_CA\"");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?5~en_CAnullnull\"");

tester.clickLink("goChinese");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?zh_CN\"");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?5~zh_CNnullnull\"");

tester.clickLink("goDanish");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?da_DK\"");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?5~da_DKnullnull\"");

tester.clickLink("goDutch");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?nl_NL\"");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?5~nl_NLnullnull\"");

tester.clickLink("goGerman");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?de_DE\"");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\\?5~de_DEnullnull\"");

tester.clickLink("goUS");
tester.assertContains("resource/org.apache.wicket.markup.html.image.Home/Beer.gif\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<wicket:link autolink="true">
<a href="./org.apache.wicket.markup.html.link.subdir.Page1">Home</a>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test.css"/>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test2.css?-myStyle"/>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test3.css?de_DE"/>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/$up$/$up$/html/link/test2.css?-myStyle"/>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test2.css?null7~myStylenull"/>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test3.css?5~de_DEnullnull"/>
<link href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/$up$/$up$/html/link/test2.css?null7~myStylenull"/>
<a href="/root/test.html">Home</a>
<a href="./org.apache.wicket.markup.html.link.Page1">Home</a>
<a href="http://www.google.com">Google</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@ class ResourceUtilTest
@Test
void decodeResourceReferenceAttributesWithString() throws Exception
{
String urlParameter = "en_GB-style-variation";
String urlParameter = "5~en_GB5~style9~variation";
UrlAttributes attributes = ResourceUtil.decodeResourceReferenceAttributes(urlParameter);

assertEquals(Locale.UK, attributes.getLocale());
assertEquals("style", attributes.getStyle());
assertEquals("variation", attributes.getVariation());

attributes = ResourceUtil.decodeResourceReferenceAttributes("it_IT");
attributes = ResourceUtil.decodeResourceReferenceAttributes("5~it_ITnullnull");

assertEquals(Locale.ITALY, attributes.getLocale());
assertNull(attributes.getStyle());
assertNull(attributes.getVariation());

attributes = ResourceUtil.decodeResourceReferenceAttributes("-style-variation");
attributes = ResourceUtil.decodeResourceReferenceAttributes("null5~style9~variation");
assertNull(attributes.getLocale());
assertEquals("style", attributes.getStyle());
assertEquals("variation", attributes.getVariation());

attributes = ResourceUtil.decodeResourceReferenceAttributes("--variation");
attributes = ResourceUtil.decodeResourceReferenceAttributes("nullnull9~variation");
assertNull(attributes.getLocale());
assertNull(attributes.getStyle());
assertEquals("variation", attributes.getVariation());

attributes = ResourceUtil.decodeResourceReferenceAttributes("-style");
attributes = ResourceUtil.decodeResourceReferenceAttributes("null5~stylenull");
assertNull(attributes.getLocale());
assertEquals("style", attributes.getStyle());
assertNull(attributes.getVariation());
Expand All @@ -69,13 +69,13 @@ void decodeResourceReferenceAttributesWithUrl() throws Exception

assertEquals(new UrlAttributes(null, null, null), attributes);

url = Url.parse("www.funny.url/?de_DE");
url = Url.parse("www.funny.url/?5~de_DEnullnull");
attributes = ResourceUtil.decodeResourceReferenceAttributes(url);
assertEquals(Locale.GERMANY, attributes.getLocale());
assertNull(attributes.getStyle());
assertNull(attributes.getVariation());

url = Url.parse("www.funny.url/?-style");
url = Url.parse("www.funny.url/?null5~stylenull");
attributes = ResourceUtil.decodeResourceReferenceAttributes(url);
assertNull(attributes.getLocale());
assertEquals("style", attributes.getStyle());
Expand All @@ -90,11 +90,11 @@ void encodeResourceReferenceAttributes() throws Exception

attributes = new UrlAttributes(Locale.CANADA_FRENCH, "style", "variation");

assertEquals("fr_CA-style-variation", ResourceUtil.encodeResourceReferenceAttributes(attributes));
assertEquals("5~fr_CA5~style9~variation", ResourceUtil.encodeResourceReferenceAttributes(attributes));

attributes = new UrlAttributes(null, null, "variation");

assertEquals("--variation", ResourceUtil.encodeResourceReferenceAttributes(attributes));
assertEquals("nullnull9~variation", ResourceUtil.encodeResourceReferenceAttributes(attributes));
}

@Test
Expand Down Expand Up @@ -136,7 +136,7 @@ void encodeResourceReferenceAttributesWithResource() throws Exception
Mockito.when(resourceReference.getUrlAttributes()).thenReturn(attributes);
ResourceUtil.encodeResourceReferenceAttributes(url, resourceReference);

assertEquals(urlString + "?fr_CA-style-variation", url.toString());
assertEquals(urlString + "?5~fr_CA5~style9~variation", url.toString());

Mockito.reset(resourceReference);

Expand All @@ -147,6 +147,6 @@ void encodeResourceReferenceAttributesWithResource() throws Exception
Mockito.when(resourceReference.getUrlAttributes()).thenReturn(attributes);
ResourceUtil.encodeResourceReferenceAttributes(url, resourceReference);

assertEquals(urlString + "?--variation", url.toString());
assertEquals(urlString + "?nullnull9~variation", url.toString());
}
}

0 comments on commit 7bd0b63

Please sign in to comment.