Re: Tests based on WicketTester: NPE in ConcatBundleResource.readAllResources
On Sat, September 07, 2013, Martin Grigorov wrote: Is there a chance that you create a bundle without any resource(reference) ? Not quite sure I understand this correctly, In YourApplication#init() you something like: getResourceBundles().addXyzBundle(Class, String, resourceReferences*). For some reason some of the references cannot load its resource data. OK, I've now isolated any code dealing with resource bundles for JS and CSS in my Application and created a TestApplication class in which this isolated method is overridden as empty, so that resources are not used at all. Now the test no longer fails. If I should need this piece to work with tests in the future, I guess I will have to go through the configuration (file system paths for the stuff loaded in the resources) to get this working? Thank you again! M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= Die groessten Liebesgeschichten sind die, die nie stattgefunden haben - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Tests based on WicketTester: NPE in ConcatBundleResource.readAllResources
On Fri, Sep 6, 2013 at 8:11 PM, Martin Dietze d...@fh-wedel.de wrote: On Fri, September 06, 2013, Martin Grigorov wrote: Is there a chance that you create a bundle without any resource(reference) ? Not quite sure I understand this correctly, In YourApplication#init() you something like: getResourceBundles().addXyzBundle(Class, String, resourceReferences*). For some reason some of the references cannot load its resource data. I tried avoiding the use of the ConcatBundleResource altogether by overriding the method that creates it in my Application for my test. But this did not make any difference. Cheers, M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= Die Freiheit ist uns ein schoenes Weib. Sie hat einen Ober- und Unterleib. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Tests based on WicketTester: NPE in ConcatBundleResource.readAllResources
I am currently trying to repair some old tests (which I did not even write myself) based on AbstractWicketTest and WicketTester. At the moment all tests derived from AbstractWicketTest or using TestNGWicketTester fail with some exception inside Wicket. Since I am rather unfamiliar with the wicket test infrastructure, I'd like to ask here, if the stuff below rings any bell with anyone of you? This second class of exceptions I get seems to be related to the fact that in our application all CSS and Javascript includes are handled by a ConcatBundeResource. At least that's the one where the test code crashes with an NPE. Again, the test is real simple, it consists of rendering a page and checking for exceptions etc., this is the code: |public void setUp() { |this.tester = new TestNGWicketTester( new MyApplication() ); |} |public void testRender() { |this.tester.startPage( ResetPasswordPage.class ); |this.tester.assertRenderedPage( ResetPasswordPage.class ); |} And the exception I am getting is the following: [testng] Caused by: java.lang.NullPointerException: null [testng] at org.apache.wicket.resource.bundles.ConcatBundleResource.readAllResources(ConcatBundleResource.java:169) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.resource.bundles.ConcatBundleResource.getCacheableResourceStream(ConcatBundleResource.java:226) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.resource.caching.version.LastModifiedResourceVersion.getVersion(LastModifiedResourceVersion.java:41) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion.getVersion(RequestCycleCachedResourceVersion.java:97) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy.decorateUrl(FilenameWithVersionResourceCachingStrategy.java:97) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.core.request.mapper.ResourceMapper.addCachingDecoration(ResourceMapper.java:228) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.core.request.mapper.ResourceMapper.mapHandler(ResourceMapper.java:199) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.mapper.CompoundRequestMapper.mapHandler(CompoundRequestMapper.java:215) ~[wicket-request-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.util.tester.BaseWicketTester$TestRequestMapper.mapHandler(BaseWicketTester.java:2742) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.cycle.RequestCycle.mapUrlFor(RequestCycle.java:429) [wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:529) [wicket-core-6.8.0.jar:6.8.0] The 'offending' code in ConcatResourceBunde looks like this: |private byte[] readAllResources(ListIResourceStream resources) throws IOException, |ResourceStreamNotFoundException |{ |ByteArrayOutputStream output = new ByteArrayOutputStream(); |for (IResourceStream curStream : resources) // This is line 169, where the NPE occurs! |IOUtils.copy(curStream.getInputStream(), output); | |byte[] bytes = output.toByteArray(); | |if (getCompressor() != null) |{ |String nonCompressed = new String(bytes, UTF-8); |bytes = getCompressor().compress(nonCompressed).getBytes(UTF-8); |} | |return bytes; |} Cheers, M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= manche meinen, lechts und rinks kann man nicht velwechsern. werch ein illtum! -- elnst jandr - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Tests based on WicketTester: NPE in ConcatBundleResource.readAllResources
Hi, Is there a chance that you create a bundle without any resource(reference) ? On Fri, Sep 6, 2013 at 3:43 PM, Martin Dietze d...@fh-wedel.de wrote: I am currently trying to repair some old tests (which I did not even write myself) based on AbstractWicketTest and WicketTester. At the moment all tests derived from AbstractWicketTest or using TestNGWicketTester fail with some exception inside Wicket. Since I am rather unfamiliar with the wicket test infrastructure, I'd like to ask here, if the stuff below rings any bell with anyone of you? This second class of exceptions I get seems to be related to the fact that in our application all CSS and Javascript includes are handled by a ConcatBundeResource. At least that's the one where the test code crashes with an NPE. Again, the test is real simple, it consists of rendering a page and checking for exceptions etc., this is the code: |public void setUp() { |this.tester = new TestNGWicketTester( new MyApplication() ); |} |public void testRender() { |this.tester.startPage( ResetPasswordPage.class ); |this.tester.assertRenderedPage( ResetPasswordPage.class ); |} And the exception I am getting is the following: [testng] Caused by: java.lang.NullPointerException: null [testng] at org.apache.wicket.resource.bundles.ConcatBundleResource.readAllResources(ConcatBundleResource.java:169) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.resource.bundles.ConcatBundleResource.getCacheableResourceStream(ConcatBundleResource.java:226) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.resource.caching.version.LastModifiedResourceVersion.getVersion(LastModifiedResourceVersion.java:41) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion.getVersion(RequestCycleCachedResourceVersion.java:97) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy.decorateUrl(FilenameWithVersionResourceCachingStrategy.java:97) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.core.request.mapper.ResourceMapper.addCachingDecoration(ResourceMapper.java:228) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.core.request.mapper.ResourceMapper.mapHandler(ResourceMapper.java:199) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.mapper.CompoundRequestMapper.mapHandler(CompoundRequestMapper.java:215) ~[wicket-request-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.util.tester.BaseWicketTester$TestRequestMapper.mapHandler(BaseWicketTester.java:2742) ~[wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.cycle.RequestCycle.mapUrlFor(RequestCycle.java:429) [wicket-core-6.8.0.jar:6.8.0] [testng] at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:529) [wicket-core-6.8.0.jar:6.8.0] The 'offending' code in ConcatResourceBunde looks like this: |private byte[] readAllResources(ListIResourceStream resources) throws IOException, |ResourceStreamNotFoundException |{ |ByteArrayOutputStream output = new ByteArrayOutputStream(); |for (IResourceStream curStream : resources) // This is line 169, where the NPE occurs! |IOUtils.copy(curStream.getInputStream(), output); | |byte[] bytes = output.toByteArray(); | |if (getCompressor() != null) |{ |String nonCompressed = new String(bytes, UTF-8); |bytes = getCompressor().compress(nonCompressed).getBytes(UTF-8); |} | |return bytes; |} Cheers, M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= manche meinen, lechts und rinks kann man nicht velwechsern. werch ein illtum! -- elnst jandr - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Tests based on WicketTester: NPE in ConcatBundleResource.readAllResources
On Fri, September 06, 2013, Martin Grigorov wrote: Is there a chance that you create a bundle without any resource(reference) ? Not quite sure I understand this correctly, I tried avoiding the use of the ConcatBundleResource altogether by overriding the method that creates it in my Application for my test. But this did not make any difference. Cheers, M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= Die Freiheit ist uns ein schoenes Weib. Sie hat einen Ober- und Unterleib. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org