Fwd: [weld-dev] @Alternative VS multiproject

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [weld-dev] @Alternative VS multiproject

Pete Muir
Administrator
Moving to cdi-dev.

Begin forwarded message:

> From: Geoffrey De Smet <[hidden email]>
> Subject: [weld-dev] @Alternative VS multiproject
> Date: 6 December 2011 15:16:07 GMT
> To: [hidden email]
>
> 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
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/weld-dev


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

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

Joseph Bergmark
In part this is another case for the changes in CDI-18, being able to
enable your alternative in one place for the entire module.

Sincerely,

Joe

|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Pete Muir <[hidden email]>                                                                                                                      |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |cdi-dev <[hidden email]>                                                                                                                 |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |12/07/2011 04:59 AM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |[cdi-dev] Fwd: [weld-dev] @Alternative VS multiproject                                                                                            |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Sent by:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |[hidden email]                                                                                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|





Moving to cdi-dev.

Begin forwarded message:

> From: Geoffrey De Smet <[hidden email]>
> Subject: [weld-dev] @Alternative VS multiproject
> Date: 6 December 2011 15:16:07 GMT
> To: [hidden email]
>
> 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
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/weld-dev


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev



_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

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

Mark Struberg
In reply to this post by Pete Muir
@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 <[hidden email]>
> To: cdi-dev <[hidden email]>
> 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 <[hidden email]>
>>  Subject: [weld-dev] @Alternative VS multiproject
>>  Date: 6 December 2011 15:16:07 GMT
>>  To: [hidden email]
>>
>>  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
>>  [hidden email]
>>  https://lists.jboss.org/mailman/listinfo/weld-dev
>
>
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev