[cdi-dev] Fwd: [weld-dev] @Alternative VS multiproject

Mark Struberg struberg at yahoo.de
Wed Dec 7 12:29:51 EST 2011


@ProjectStageActivated [1] could be the answer.
One of the first things we'll probably add to DeltaSpike.

LieGrue,
strub

[1] https://cwiki.apache.org/confluence/display/EXTCDI/Core+Usage#CoreUsage-@ProjectStageActivated



----- Original Message -----
> From: Pete Muir <pmuir at redhat.com>
> To: cdi-dev <cdi-dev at lists.jboss.org>
> Cc: 
> Sent: Wednesday, December 7, 2011 10:58 AM
> Subject: [cdi-dev] Fwd: [weld-dev] @Alternative VS multiproject
> 
> Moving to cdi-dev.
> 
> Begin forwarded message:
> 
>>  From: Geoffrey De Smet <ge0ffrey.spam at gmail.com>
>>  Subject: [weld-dev] @Alternative VS multiproject
>>  Date: 6 December 2011 15:16:07 GMT
>>  To: weld-dev at lists.jboss.org
>> 
>>  One promise of @Alternative beans is to make it easier to mock out 
>>  things during testing.
>>  In practice there are some problems to make that a reality.
>> 
>>  For example, suppose we have this:
>> 
>>  - foo-database-layer.jar
>>  -- org/.../ProductionDatabaseSetup.class
>>  --- Description: connects to the database on localhost (which is only 
>>  there on production).
>>  -- org/.../TestDatabaseSetup.class
>>  --- @Alternative
>>  --- extends ProductionDatabaseSetup
>>  --- Description: connects to an in-memory database and inserts testdata 
>>  in it.
>>  - CustomerDAO
>>  -- @Inject DatabaseSetup databaseSetup;
>>  -- META-INF/beans.xml
>>  --- Filled with other stuff
>> 
>>  - foo-server.war
>>  -- WEB-INF/lib/foo-database-layer.jar
>>  -- WEB-INF/beans.xml
>>  --- Filled with other stuff
>> 
>> 
>>  Now, during the integrations tests of foo-server.war, we want to
>>  replace ProductionDatabaseSetup with TestDatabaseSetup.
>> 
>>  How?
>>  1) Add a WEB-INF/beans-test.xml (just like logback-test.xml and 
> logback.xml)
>>  => Does not work. It's ignored.
>> 
>>  2) Change WEB-INF/beans.xml for the tests only.
>>  Duplicate everything from the original.
>>  Add declaration: 
> <alternative>...TestDatabaseSetup</alternative>
>>  => Does not work. CustomerDAO still gets ProductionDatabaseSetup instead 
> 
>>  of TestDatabaseSetup.
>> 
>>  3) Change WEB-INF/lib/foo-database-layer.jar!META-INF/beans.xml for the 
>>  tests only.
>>  Duplicate everything from the original.
>>  Add declaration: 
> <alternative>...TestDatabaseSetup</alternative>
>>  => Lots of code and tests are slow because of all the zipping and 
> unzipping.
>> 
>>  -- 
>>  With kind regards,
>>  Geoffrey De Smet
>> 
>> 
>>  _______________________________________________
>>  weld-dev mailing list
>>  weld-dev at lists.jboss.org
>>  https://lists.jboss.org/mailman/listinfo/weld-dev
> 
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> 


More information about the cdi-dev mailing list