Re: Test based on AbstractWicketTest fails with No RequestCycle is currently set

2013-09-09 Thread Martin Dietze
On Sat, September 07, 2013, Martin Grigorov wrote:

  com.mycompany.request.WicketContainerChecker.onInstantiation(WicketContainerChecker.java:48)
 
 
 What is this doing ?
 Does it start a new thread by chance ?
 Or doing something like: ThreadContext.detach() /
 ThreadContext.setRequestCycle(null)

No, nothing of that kind. It's just a helper to make sure noone
uses Ajax on components which are added to the markup as
wicket:container wicket:id=../wicket:container
The code goes like this:

| public class WicketContainerChecker implements 
IComponentInstantiationListener {
| private static final Behavior BEHAVIOR = new Behavior() {
| private static final long serialVersionUID = 1L;
| 
| @Override
| public void onComponentTag( final Component component, final 
ComponentTag tag ) {
| if ( tag instanceof WicketTag  container.equals( 
tag.getName() )  component.getOutputMarkupId() ) {
| throw new IllegalStateException( Component  + component +  
requests a markup id ( + component.getMarkupId() + ) but is attached to  + 
tag
| + ! This will not work in deployment mode! );
| }
| }
| };
| 
| @Override
| public void onInstantiation( Component component ) {
| component.add( BEHAVIOR );
| }
| }

Cheers,

M'bert

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
WE ARE THE BORG - RESISTANCE IS VOLTAGE DIVIDED BY CURRENT!

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Test based on AbstractWicketTest fails with No RequestCycle is currently set

2013-09-09 Thread Martin Dietze
On Mon, September 09, 2013, Martin Dietze wrote:

 No, nothing of that kind. It's just a helper to make sure noone
 uses Ajax on components which are added to the markup as
 wicket:container wicket:id=../wicket:container

OK, that one is solved, too. After replacing the Application
used in this test by the one created to solve the other problem
(related to the resources for JS and CSS), this problem
disappeared. Obviously the problem I saw in the stack trace 
was misleading here.

Cheers,

M'bert

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Ed is the standard text editor.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Test based on AbstractWicketTest fails with No RequestCycle is currently set

2013-09-07 Thread Martin Grigorov
On Fri, Sep 6, 2013 at 7:41 PM, Martin Dietze d...@fh-wedel.de wrote:

 On Fri, September 06, 2013, Martin Grigorov wrote:

  2. #testAddingAndSwitchingFields
 
  you look at the wrong test
  we cannot help you when we have the wrong source given

 Yes, sorry, I picked the wrong stacktrace, however they're all
 identical anyway. The method 'testAddingAndSwitchingFields'
 starts the same way as 'testRender':

 |public void testAddingAndSwitchingFields( final int numberOfFields,
 final ListString switchButtonPaths, final ListString expectedFieldOrder
 ) {
 |final FeedbackFormSpec formSpec =
 FeedbackFormSpecTestFactory.createEmpty();
 |this.tester.startPage( new FeedbackFormSpecEditorTestPage(
 formSpec ) );
 |// ...

 I.e., the stacktrace below is exactly the same from the moment
 I instanciate the test page, and the super constructor is
 called.

 Here's the stacktrace again:

 org.apache.wicket.WicketRuntimeException: No RequestCycle is currently set!
 org.apache.wicket.Component.getRequest(Component.java:1803)
 org.apache.wicket.markup.html.WebPage.dirty(WebPage.java:318)
 org.apache.wicket.Page.dirty(Page.java:249)
 org.apache.wicket.Page.componentStateChanging(Page.java:926)
 org.apache.wicket.Component.addStateChange(Component.java:3527)
 org.apache.wicket.Behaviors.add(Behaviors.java:55)
 org.apache.wicket.Component.add(Component.java:4511)

 com.mycompany.request.WicketContainerChecker.onInstantiation(WicketContainerChecker.java:48)


What is this doing ?
Does it start a new thread by chance ?
Or doing something like: ThreadContext.detach() /
ThreadContext.setRequestCycle(null)



 org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)

 org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)

 org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)

 org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)
 org.apache.wicket.Component.init(Component.java:683)
 org.apache.wicket.MarkupContainer.init(MarkupContainer.java:121)
 org.apache.wicket.Page.init(Page.java:168)
 org.apache.wicket.Page.init(Page.java:132)
 org.apache.wicket.markup.html.WebPage.init(WebPage.java:76)

 com.mycompany.ui.components.types.FeedbackFormSpecEditorTestPage.init(FeedbackFormSpecEditorTestPage.java:38)

 com.mycompany.ui.components.types.FeedbackFormSpecEditorTest.testAddingAndSwitchingFields(FeedbackFormSpecEditorTest.java:80)

 M'bert

 --
 --- / http://herbert.the-little-red-haired-girl.org /
 -
 =+=
 I am not in a hurry. I prefer to cross the town.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Test based on AbstractWicketTest fails with No RequestCycle is currently set

2013-09-06 Thread Martin Grigorov
Hi,


On Fri, Sep 6, 2013 at 3:36 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? Did I forget something fundamental? A missing
 RequestCycle seems rather fundamental to me, i.e. I'd expect
 the testing infrastructure to take care that there is one, or
 am I mistaken here?

 The one based on AbstractWicketTest basically tries to render a
 page and check for some exception etc., it's code is rather
 simplish:

 |public void testRender( final FeedbackFormSpec formSpec ) {


1. #testRender


 |this.tester.startPage( new FeedbackFormSpecEditorTestPage(
 formSpec ) );
 |this.tester.assertRenderedPage(
 FeedbackFormSpecEditorTestPage.class );
 |this.tester.dumpPage();
 |}

 I get this stacktrace:

 org.apache.wicket.WicketRuntimeException: No RequestCycle is currently set!
 org.apache.wicket.Component.getRequest(Component.java:1803)
 org.apache.wicket.markup.html.WebPage.dirty(WebPage.java:318)
 org.apache.wicket.Page.dirty(Page.java:249)
 org.apache.wicket.Page.componentStateChanging(Page.java:926)
 org.apache.wicket.Component.addStateChange(Component.java:3527)
 org.apache.wicket.Behaviors.add(Behaviors.java:55)
 org.apache.wicket.Component.add(Component.java:4511)

 com.mycompany.request.WicketContainerChecker.onInstantiation(WicketContainerChecker.java:48)

 org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)

 org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)

 org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)

 org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)
 org.apache.wicket.Component.init(Component.java:683)
 org.apache.wicket.MarkupContainer.init(MarkupContainer.java:121)
 org.apache.wicket.Page.init(Page.java:168)
 org.apache.wicket.Page.init(Page.java:132)
 org.apache.wicket.markup.html.WebPage.init(WebPage.java:76)

 com.mycompany.ui.components.types.FeedbackFormSpecEditorTestPage.init(FeedbackFormSpecEditorTestPage.java:38)

 com.mycompany.ui.components.types.FeedbackFormSpecEditorTest.testAddingAndSwitchingFields(FeedbackFormSpecEditorTest.java:80)


2. #testAddingAndSwitchingFields

you look at the wrong test
we cannot help you when we have the wrong source given


 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)

 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
 org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
 org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
 org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)

 org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
 org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
 org.testng.TestRunner.privateRun(TestRunner.java:767)
 org.testng.TestRunner.run(TestRunner.java:617)
 org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
 org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
 org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
 org.testng.SuiteRunner.run(SuiteRunner.java:240)
 org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
 org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
 org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
 org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
 org.testng.TestNG.run(TestNG.java:1031)
 org.testng.TestNG.privateMain(TestNG.java:1338)
 org.testng.TestNG.main(TestNG.java:1307)

 Cheers,

 M'bert

 --
 --- / http://herbert.the-little-red-haired-girl.org /
 -
 =+=
 I now declare this bizarre open!

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Test based on AbstractWicketTest fails with No RequestCycle is currently set

2013-09-06 Thread Martin Dietze
On Fri, September 06, 2013, Martin Grigorov wrote:

 2. #testAddingAndSwitchingFields
 
 you look at the wrong test
 we cannot help you when we have the wrong source given

Yes, sorry, I picked the wrong stacktrace, however they're all
identical anyway. The method 'testAddingAndSwitchingFields'
starts the same way as 'testRender':

|public void testAddingAndSwitchingFields( final int numberOfFields, final 
ListString switchButtonPaths, final ListString expectedFieldOrder ) {
|final FeedbackFormSpec formSpec = 
FeedbackFormSpecTestFactory.createEmpty();
|this.tester.startPage( new FeedbackFormSpecEditorTestPage( formSpec ) 
);
|// ...

I.e., the stacktrace below is exactly the same from the moment 
I instanciate the test page, and the super constructor is
called.

Here's the stacktrace again:

org.apache.wicket.WicketRuntimeException: No RequestCycle is currently set!
org.apache.wicket.Component.getRequest(Component.java:1803)
org.apache.wicket.markup.html.WebPage.dirty(WebPage.java:318)
org.apache.wicket.Page.dirty(Page.java:249)
org.apache.wicket.Page.componentStateChanging(Page.java:926)
org.apache.wicket.Component.addStateChange(Component.java:3527)
org.apache.wicket.Behaviors.add(Behaviors.java:55)
org.apache.wicket.Component.add(Component.java:4511)
com.mycompany.request.WicketContainerChecker.onInstantiation(WicketContainerChecker.java:48)
org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)
org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)
org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)
org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)
org.apache.wicket.Component.init(Component.java:683)
org.apache.wicket.MarkupContainer.init(MarkupContainer.java:121)
org.apache.wicket.Page.init(Page.java:168)
org.apache.wicket.Page.init(Page.java:132)
org.apache.wicket.markup.html.WebPage.init(WebPage.java:76)
com.mycompany.ui.components.types.FeedbackFormSpecEditorTestPage.init(FeedbackFormSpecEditorTestPage.java:38)
com.mycompany.ui.components.types.FeedbackFormSpecEditorTest.testAddingAndSwitchingFields(FeedbackFormSpecEditorTest.java:80)

M'bert

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
I am not in a hurry. I prefer to cross the town.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org