Author |
Message |
25/10/2010 09:29:24
|
hilka
Power User
Joined: 23/11/2007 09:00:08
Messages: 191
Offline
|
Hello,
I tried to implement some simple beans containing a FixGrid using the Test-Driven-Development approach. Unfortunately, there are some static references deep down in the Enterprise Client code which fail the test.
Here is a simple example:
FIXGRIDListBinding<FIXGRIDItem> list = new FIXGRIDListBinding<FIXGRIDItem>();
list.getItems().add(new FIXGRIDItem());
list.selectAndFocusItem(list.getItems().get(0));
This test fails with the following stacktrace:
java.lang.NullPointerException
at org.eclnt.jsfserver.session.SessionInfo.getCurrentHttpSession(SessionInfo.java:146)
at org.eclnt.jsfserver.session.SessionInfo.getSessionInstance(SessionInfo.java:112)
at org.eclnt.jsfserver.session.RequestFocusManager.getNewRequestFocusCounter(RequestFocusManager.java:63)
at org.eclnt.jsfserver.elements.impl.FIXGRIDItem.requestFocus(FIXGRIDItem.java:121)
at org.eclnt.jsfserver.elements.impl.FIXGRIDBinding.selectAndFocusItem(FIXGRIDBinding.java:1747)
...
Would it be possible to have some kind of test-mode or a more forgiving code which ignores the fact, that we are currently not in an HTTPSession?
The same problem occurred when testing some methods with StatusBar output. For the statusbar we take the approach of mocking the "real" statusbar implementation for tests.
Tobias
|
|
|
25/10/2010 10:55:14
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5555
Offline
|
Hi,
yessss - you are right...: some functions (e.g. selectAndFocus) require the "logic FIXGRIDBinding" object to be connected with the "FIXGRID server side Component".
Concrete, in this example: for calculating the scroll position, the number of items needs to be known. This number of items (SBVISIBLEAMOUNT) is coming from the FIXGRID Component...
We will encapsulate these methods by corresponding Exception-catchers - maybe they need to be made active by setting a certain "global flag", that the system is running in test mode.
Thanks + regards! Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
11/12/2010 11:54:35
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5555
Offline
|
Hi,
we now started to tackle this...
and introduced a new class UsageWithoutSessionContext, with a static method "initUsageWithoutSessionContext" - which you need to call from your test program.
Critical areas will be wrapped accordingly, so that at least a dummy behaviour will survive during testing + testing will not run into the types of errors you are talking about.
Unfortunately, this is some "trial and error", so we have to expect some phase of running from one error to the next, until having wrapped "all" critical areas...
Regards, Björn
PS: available with next update
|
Björn Müller, CaptainCasa GmbH |
|
|
13/12/2010 14:18:36
|
hilka
Power User
Joined: 23/11/2007 09:00:08
Messages: 191
Offline
|
Hello Captain,
glad to hear that it is available with the next update. In some scenarios, we found a workaround for testing, but for more complex situations, the workaround would be just senseless.
Will keep you up to date about the testing-behaviour.
|
|
|
|