I think that now I got the idea how to solve my problem. It seems that
I have to use controllable injection in this case. The last minutes of
the presentation are crucial and I advice all guys that are interested
on this they must look last minutes carefully. Now let's get back to
the point.
Here are the thoughts that came into my head when I saw the last part
of the presentation. Please let me know if I'm wrong or totally wrong.
Lets say that we have a simple application with login form that
contains two fields: username and password. To may user be log-in into
the system the application have to ask the database where the entered
username and password are matching. (Probably this is not a heavy
scenario, but it's simple). Here comes part where I want to inject a
Fake login controller that will use some a Hashtable to store
information
about few users which I will use for testing. And here is the deal,
the server has to use FakeController on some tests and RealController
on other tests. As I understood this is realized with cookies.
The test case has to send and http request with some cookie value
which probably is holding the Testing Identifier which identifies the
test to may server handle multiple simultaneous tests. After server
receives such request it has to replace the injector class with Fake
implementation and server probably have to do this with any GuiceBerry
classes.After the implementation is changed then test is ran with
configuration that he is using. I saw that GuiceBerry has dependency
to servlet-api-2.4 which means that there is a such servlet that is
doing this job. Hope that anyone can point me to it.
If my assumptions are right then probably this is a simple structure
that I have to use in my project:
invoice-app-with-guiceberry
src/
com.jadm.invoice.client
com.jadm.invoice.server.dao.jdbc
com.jadm.invoice.server.dao.fake --> this should be placed to may
server inject any of the fake classes when new controller injection
request is received
com.jadm.invoice.server.service.fake -> same as fake dao
com.jadm.invoice.server.service.impl
com.jadm.invoice.server.environment
com.jadm.invoice.server.
test/
com.jadm.invoice.client.integrationtests
com.jadm.invoice.client.applicationtests
com.jadm.invoice.server.dao.jdbc (unit and integration tests)
com.jadm.invoice.server.service (unit tests)
war/
index.jsp
index.css
With this structure, when the server code is deployed the server will
have runtime dependency to fake and to the real implementation and may
change any of them.
Regards,
Miroslav
> invoice-app-with-guiceberry.rar
> 4103KViewDownload