hi stephen,

you only have one producer-class:
https://github.com/mores/deltaspike/blob/altProduces/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc020/DefaultTestServiceProducer.java

and @Alternative is only present at:
https://github.com/mores/deltaspike/blob/altProduces/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc020/TestServiceLabelA.java#L24
and
https://github.com/mores/deltaspike/blob/altProduces/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc020/TestServiceLabelB.java#L24

instead you need an alternative producer-class (to replace
DefaultTestServiceProducer in your case).

regards,
gerhard

http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans

2018-04-15 21:02 GMT+02:00 Stephen More <stephen.m...@gmail.com>:

> Correct. I have a default producer and 1 alternate producer. I can enable
> the alternate producer by updating beans.xml.
> I am trying to do the same thing using labeledAlternatives....
>
> what changes should be made to META-INF/apache-deltaspike.properties when
> using multiple alternate producers ?
>
>
> labeledAlternatives[testLabelX].org.apache.deltaspike.test.testcontrol.
> uc014.TestService=org.apache.deltaspike.test.testcontrol.uc014.
> TestServiceLabelXProducer
> labeledAlternatives[y].org.apache.deltaspike.test.
> testcontrol.uc014.TestService=org.apache.deltaspike.test.
> testcontrol.uc014.TestServiceLabelYProducer
>
>
> ?
>
>
>
>
> On Sun, Apr 15, 2018 at 1:22 PM, Gerhard Petracek <
> gerhard.petra...@gmail.com> wrote:
>
> > hi stephen,
> >
> > as usual with cdi, you need to create an alternative-producer (= the
> > producer-bean itself needs to be replaced).
> >
> > regards,
> > gerhard
> >
> > http://www.irian.at
> >
> > Your JavaEE powerhouse -
> > JavaEE Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache
> > MyFaces, DeltaSpike and OpenWebBeans
> >
> >
> >
> > 2018-04-15 14:41 GMT+02:00 Stephen More <stephen.m...@gmail.com>:
> >
> > > "alternative-bean-x1 (instead of bean-x) in test1
> > > and alternative-bean-x2  (instead of bean-x) in test2"
> > >
> > > Yes, this is exactly what I am going after, unfortunately I have not
> > gotten
> > > it to work yet. In my case bean-x comes from a producer.
> > >
> > > Not sure if that is my problem so I started working on a use case, I
> > made a
> > > clone of uc014 -> uc020 ( fixed name collisions in
> > > apache-deltaspike.properties ) but many other test cases started to
> fail
> > > outside of uc020.  ( https://github.com/mores/
> > deltaspike/tree/altProduces
> > > )
> > >
> > > Is this a possible bug ?
> > > -Thanks
> > >
> > >
> > > p.s. when a typo is made in apache-deltaspike.properties no warning or
> > > error was thrown that I could easily see
> > >
> > >
> > >
> > > On Sat, Apr 14, 2018 at 12:18 PM, Gerhard Petracek <
> > > gerhard.petra...@gmail.com> wrote:
> > >
> > > > hi stephen,
> > > >
> > > > if your alternative-instance/behavior should be different for "every"
> > > test
> > > > and you can't use a mock-manager, you need to use a producer (for the
> > > > original bean) and @Specializes it in the test-classpath.
> > > > in your test you change the state of the test-producer with static
> > > methods
> > > > (e.g. set a flag or a whole instance which should be returned by the
> > > > test-producer).
> > > > -> it's std. cdi and/or java - no special concept is needed.
> > > >
> > > > if you would like to use alternative-bean-x1 (instead of bean-x) in
> > test1
> > > > and alternative-bean-x2  (instead of bean-x) in test2, you can use
> > > labeled
> > > > alternatives (provided by ds > v1.8.1) - see e.g. [1] and [2].
> > > > it's based on the new AlternativeBeanClassProvider spi (which you
> could
> > > use
> > > > as well to implement your own concepts) - see e.g. [3].
> > > >
> > > > regards,
> > > > gerhard
> > > >
> > > > [1]
> > > > https://github.com/apache/deltaspike/tree/master/
> > > deltaspike/modules/test-
> > > > control/impl/src/test/java/org/apache/deltaspike/test/
> > testcontrol/uc014
> > > > [2]
> > > > https://github.com/apache/deltaspike/tree/master/
> > > deltaspike/modules/test-
> > > > control/impl/src/test/java/org/apache/deltaspike/test/
> > testcontrol/uc015
> > > > [3]
> > > > https://github.com/apache/deltaspike/tree/master/
> > > deltaspike/modules/test-
> > > > control/impl/src/test/java/org/apache/deltaspike/test/
> > testcontrol/uc016
> > > >
> > > >
> > > >
> > > > http://www.irian.at
> > > >
> > > > Your JavaEE powerhouse -
> > > > JavaEE Consulting, Development and
> > > > Courses in English and German
> > > >
> > > > Professional Support for Apache
> > > > MyFaces, DeltaSpike and OpenWebBeans
> > > >
> > > > 2018-04-14 15:24 GMT+02:00 Stephen More <stephen.m...@gmail.com>:
> > > >
> > > > > I have a need to run some unit tests with @Alternative -
> > mockedVersionA
> > > > > and other tests with @Alternative - mockedVersionB
> > > > > and other tests with @Alternative - mockedVersionC
> > > > >
> > > > > It looks like Arquillian can handle this utilizing ShrinkWrap and
> > > > > @Deployment....
> > > > > addAsManifestResource( "mockedVersionA.xml","beans.xml");
> > > > > addAsManifestResource( "mockedVersionB.xml","beans.xml");
> > > > >
> > > > > Can I achieve the same functionality using CdiTestRunner ?
> > > > > -Thanks
> > > > >
> > > >
> > >
> >
>

Reply via email to