Hi Martin, thx!

In this case I need to make sure of to set a default locale before
instantiate the tester. But actually I can add this in a @BeforeAll and
still extend from WicketTestCase. Will improve the test next.

Pedro Santos

On Tue, Sep 13, 2016 at 4:19 AM, Martin Grigorov <[email protected]>
wrote:

> Hi Pedro,
>
> On Sun, Sep 11, 2016 at 8:28 AM, <[email protected]> wrote:
>
> > Repository: wicket
> > Updated Branches:
> >   refs/heads/wicket-7.x 6f530a925 -> ec1ff11dd
> >
> >
> > WICKET-6243 testing session's locale on each auto linked resource
> rendering
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/ec1ff11d
> > Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/ec1ff11d
> > Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/ec1ff11d
> >
> > Branch: refs/heads/wicket-7.x
> > Commit: ec1ff11dd625017a932229c43d77c5d3cd3a07dc
> > Parents: 6f530a9
> > Author: Pedro Henrique Oliveira dos Santos <[email protected]>
> > Authored: Sun Sep 11 03:27:40 2016 -0300
> > Committer: Pedro Henrique Oliveira dos Santos <[email protected]>
> > Committed: Sun Sep 11 03:27:40 2016 -0300
> >
> > ----------------------------------------------------------------------
> >  .../markup/resolver/AutoLinkResolver.java       |  3 +-
> >  .../markup/resolver/AutoLinkResolverTest.java   | 44
> ++++++++++++++++++++
> >  .../PageWithAutoLinkedLocalResource.html        |  1 +
> >  .../PageWithAutoLinkedLocalResource.java        | 26 ++++++++++++
> >  .../apache/wicket/markup/resolver/resource.ext  |  0
> >  .../wicket/markup/resolver/resource_en_CA.ext   |  0
> >  .../wicket/markup/resolver/resource_en_US.ext   |  0
> >  7 files changed, 72 insertions(+), 2 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/main/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolver.java
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/
> resolver/AutoLinkResolver.java
> > b/wicket-core/src/main/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolver.java
> > index cbd2f1f..c9c59a3 100644
> > --- a/wicket-core/src/main/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolver.java
> > +++ b/wicket-core/src/main/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolver.java
> > @@ -603,8 +603,7 @@ public final class AutoLinkResolver implements
> > IComponentResolver
> >                         if (PackageResource.exists(clazz, href,
> > getLocale(), getStyle(), getVariation()))
> >                         {
> >                                 // Create the component implementing the
> > link
> > -                               resourceReference = new
> > PackageResourceReference(clazz, href, getLocale(),
> > -                                       getStyle(), getVariation());
> > +                               resourceReference = new
> > PackageResourceReference(clazz, href, null, null, null);
> >                                 }
> >                                 else
> >                                 {
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolverTest.java
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolverTest.java b/wicket-core/src/test/java/
> > org/apache/wicket/markup/resolver/AutoLinkResolverTest.java
> > new file mode 100644
> > index 0000000..32ed85c
> > --- /dev/null
> > +++ b/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/AutoLinkResolverTest.java
> > @@ -0,0 +1,44 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements.  See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version
> 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License.  You may obtain a copy of the License at
> > + *
> > + *      http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +package org.apache.wicket.markup.resolver;
> > +
> > +import static org.junit.Assert.assertThat;
> > +
> > +import java.util.Locale;
> > +
> > +import org.apache.wicket.util.tester.WicketTester;
> > +import org.hamcrest.CoreMatchers;
> > +import org.junit.Test;
> > +
> > +public class AutoLinkResolverTest
> >
>
> Better extend from WicketTestCase.
> This way the "tester" will be #destroy()-ed at the end of the test.
>
>
> > +{
> > +
> > +       @Test
> > +       public void shouldAutoLinkLocalizedResources()
> > +       {
> > +               Locale.setDefault(Locale.US);
> > +
> > +               WicketTester tester = new WicketTester();
> > +
> > +               tester.getSession().setLocale(Locale.CANADA);
> > +
> > +               tester.startPage(PageWithAutoLinkedLocalResource.class);
> > +
> > +               assertThat(tester.getLastResponseAsString(),
> > CoreMatchers.containsString("en_CA"));
> > +       }
> > +
> > +}
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/test/java/org/apache/wicket/markup/resolver/
> > PageWithAutoLinkedLocalResource.html
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/
> resolver/
> > PageWithAutoLinkedLocalResource.html b/wicket-core/src/test/java/
> > org/apache/wicket/markup/resolver/PageWithAutoLinkedLocalResource.html
> > new file mode 100644
> > index 0000000..7e3fe84
> > --- /dev/null
> > +++ b/wicket-core/src/test/java/org/apache/wicket/markup/resolver/
> > PageWithAutoLinkedLocalResource.html
> > @@ -0,0 +1 @@
> > +<html><body><wicket:link><img src="resource.ext"
> > /></wicket:link></body></html>
> > \ No newline at end of file
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/test/java/org/apache/wicket/markup/resolver/
> > PageWithAutoLinkedLocalResource.java
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/
> resolver/
> > PageWithAutoLinkedLocalResource.java b/wicket-core/src/test/java/
> > org/apache/wicket/markup/resolver/PageWithAutoLinkedLocalResource.java
> > new file mode 100644
> > index 0000000..03d6e9b
> > --- /dev/null
> > +++ b/wicket-core/src/test/java/org/apache/wicket/markup/resolver/
> > PageWithAutoLinkedLocalResource.java
> > @@ -0,0 +1,26 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements.  See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version
> 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License.  You may obtain a copy of the License at
> > + *
> > + *      http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +package org.apache.wicket.markup.resolver;
> > +
> > +import org.apache.wicket.markup.html.WebPage;
> > +
> > +public class PageWithAutoLinkedLocalResource extends WebPage
> > +{
> > +       /** */
> > +       private static final long serialVersionUID = 1L;
> > +
> > +}
> > \ No newline at end of file
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/resource.ext
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/
> resolver/resource.ext
> > b/wicket-core/src/test/java/org/apache/wicket/markup/
> resolver/resource.ext
> > new file mode 100644
> > index 0000000..e69de29
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/resource_en_CA.ext
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/
> resolver/resource_en_CA.ext
> > b/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/resource_en_CA.ext
> > new file mode 100644
> > index 0000000..e69de29
> >
> > http://git-wip-us.apache.org/repos/asf/wicket/blob/
> > ec1ff11d/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/resource_en_US.ext
> > ----------------------------------------------------------------------
> > diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/
> resolver/resource_en_US.ext
> > b/wicket-core/src/test/java/org/apache/wicket/markup/
> > resolver/resource_en_US.ext
> > new file mode 100644
> > index 0000000..e69de29
> >
> >
>

Reply via email to