My bad for copy paste, I did not see that I had DefaultTestService
instantiated in each producer. -Fixed ( BAD stephen )
I removed qualifiers.

I think my apache-deltaspike.properties is configure properly - is it ?
I think my Alternate Producers are now correct - are they ?

I still think there is something that I am not comprehending because the
tests are still failing.




On Mon, Apr 16, 2018 at 12:15 PM, Gerhard Petracek <
gerhard.petra...@gmail.com> wrote:

> hi stephen,
>
> @#1:
> (by design) ds-test-control always uses/tests the whole
> application(/module+deps.) and the test-classpath the test is located in.
> you added a constellation in the test-classpath which violates the rules of
> cdi -> as you can see (in the logs), you caused an
> AmbiguousResolutionException because [1] and [2] lead to 2 beans of the
> same type (and qualifiers).
> that are std./plain cdi-rules and isn't related to any kind of alternative
> bean/s.
> since the test-classpath isn't isolated per test (because you test your
> application as a whole), all tests will fail in case you violate rules
> defined by cdi.
>
> in this case you sometimes see diff. exceptions (as the last exception),
> because in our test-suite (to test ds-test-control itself) we have some
> consistency checks e.g. in @AfterClass callbacks.
> due to that you see e.g. an IllegalStateException instead of an
> AmbiguousResolutionException at the very end (but the first issue was
> always an AmbiguousResolutionException).
> in your own application it would/should be always just one exception in
> case you violate cdi-rules (in this case the AmbiguousResolutionException).
>
> @#2:
> i answered that already (following the std. cdi-rule/s you need to replace
> the producer-class and not the beans created by the producer).
>
> @"#3":
> you don't need 3 qualifiers for 3 producers for the test you shared.
> you need
>  - @Exclude (or @Vetoed or @Typed() or nothing with cdi 1.1+ and
> bean-discovery-mode="annotated") for DefaultTestService, because you have
> DefaultTestServiceProducer which creates beans of type TestService020 (=
> std. cdi rules)
>  - @Alternative for your alternative producer (which should replace
> DefaultTestServiceProducer) (= std. cdi rules)
>  - a label to bind alternative-producer-x to test-x (+ the config for it in
> an active config-source like apache-deltaspike.properties)
>
> most is std. cdi and really easier than you (might) think.
>
> regards,
> gerhard
>
> [1]
> https://github.com/mores/deltaspike/blob/altProduces/
> deltaspike/modules/test-control/impl/src/test/java/
> org/apache/deltaspike/test/testcontrol/uc020/DefaultTestServiceProducer.
> java
> [2]
> https://github.com/mores/deltaspike/blob/altProduces/
> deltaspike/modules/test-control/impl/src/test/java/
> org/apache/deltaspike/test/testcontrol/uc020/DefaultTestService.java
>
>
>
> 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-16 16:21 GMT+02:00 Stephen More <stephen.m...@gmail.com>:
>
> > Ok, I updated my code, I had to add 3 Qualifiers to fix all other tests.
> >
> > I now have 3 producers.
> >
> > I think it should be working as is but I still see:
> >
> >   TestServiceLabelBTest.resultB:44 expected:<[result-b]> but
> > was:<[default-result]>
> >   TestServiceTestLabelATest.resultA:44 expected:<[result-a]> but
> > was:<[default-result]>
> >
> >
> >
> > On Mon, Apr 16, 2018 at 8:22 AM, Stephen More <stephen.m...@gmail.com>
> > wrote:
> >
> > > Usually I work on multiple tasks at a time, and I might not communicate
> > as
> > > well as I should. I will try to be a little more verbose.
> > >
> > > Before I added DefaultTestServiceProducer to uc020, mvn clean install
> > > was working as expected "Tests run: 65, Failures: 0, Errors: 0,
> Skipped:
> > 0"
> > >
> > > By simply adding DefaultTestServiceProducer to uc020 I did not expect
> to
> > > get "Tests run: 53, Failures: 6, Errors: 22, Skipped: 0"
> > >
> > > 1. At this point I am no longer focusing on getting my uc020 to pass,
> but
> > > rather what the heck did I just do.....what caused this ? Is something
> > else
> > > bigger going on that will cause my use case to fail anyway ?
> > >
> > > 2. In parallel I am also working on a private branch to get  Alternate
> > > Producers working....( again not working as expected ).
> > >
> > > I am at a loss to explain what is going on in 1, and 2 I think should
> be
> > > working, but is not.
> > >
> > >
> > > Why did my DefaultTestServiceProducer create all this havoc ?
> > >
> > >
> > >
> > >
> > > Failed tests:
> > >   InterceptedBeanTest.classLevelInterception:52
> > >   InterceptedBeanTest.methodLevelInterception:60
> > >   TestServiceLabelYTest.resultY:44 expected:<[result-y]> but
> > > was:<[default-result]>
> > >   TestServiceTestLabelXTest.resultX:44 expected:<[result-x]> but
> > > was:<[default-result]>
> > >   LabeledServiceTest.resultLbl:45 expected:<[result-lbl]> but
> > > was:<[alternative-result]>
> > >   TestServiceLabelXTest.resultX:43 expected:<result-[x]> but
> > > was:<result-[y]>
> > > Tests in error:
> > >   MockedRequestScopedBeanTest.org.apache.deltaspike.test.
> > > testcontrol.mock.uc001.MockedRequestScopedBeanTest » Deployment
> > >   MockedSessionScopedBeanAcrossMethodsTest.org.apache.
> > > deltaspike.test.testcontrol.mock.uc003.MockedSessionScopedBeanAcrossM
> > ethodsTest
> > > » Deployment
> > >   MockedProducedBeanTest.org.apache.deltaspike.test.
> > > testcontrol.mock.uc005.MockedProducedBeanTest » Deployment
> > >   MockedTypedBeanTest.org.apache.deltaspike.test.
> testcontrol.mock.uc008.
> > MockedTypedBeanTest
> > > » Deployment
> > >   MockedTypedProducedBeanTest.org.apache.deltaspike.test.
> > > testcontrol.mock.uc009.MockedTypedProducedBeanTest » Deployment
> > >   MockedRequestScopedBeanWithInjectionTest.org.apache.
> > > deltaspike.test.testcontrol.mock.uc012.MockedRequestScopedBeanWithInj
> > ectionTest
> > > » Deployment
> > >   MockedTypedProducedBeanTest.org.apache.deltaspike.test.
> > > testcontrol.mock.uc013.MockedTypedProducedBeanTest » Deployment
> > >   MockedTypedProducedBeanTest.org.apache.deltaspike.test.
> > > testcontrol.mock.uc014.MockedTypedProducedBeanTest » Deployment
> > > org.apache.deltaspike.test.testcontrol.uc001.
> > > RequestAndSessionScopePerTestMethodTest.org.apache.
> > > deltaspike.test.testcontrol.uc001.RequestAndSessionScopePerTestM
> > ethodTest
> > >   Run 1: RequestAndSessionScopePerTestMethodTest.org.apache.
> > > deltaspike.test.testcontrol.uc001.RequestAndSessionScopePerTestM
> > ethodTest
> > > » Deployment
> > >   Run 2: RequestAndSessionScopePerTestMethodTest.
> finalCheckAndCleanup:99
> > > IllegalState u...
> > >
> > > org.apache.deltaspike.test.testcontrol.uc002.
> > SessionScopePerTestClassTest.
> > > org.apache.deltaspike.test.testcontrol.uc002.
> > SessionScopePerTestClassTest
> > >   Run 1: SessionScopePerTestClassTest.org.apache.deltaspike.test.
> > > testcontrol.uc002.SessionScopePerTestClassTest » Deployment
> > >   Run 2: SessionScopePerTestClassTest.finalCheckAndCleanup:93
> > > IllegalState unexpected i...
> > >
> > >   SessionScopePerTestClassTest.org.apache.deltaspike.test.
> > > testcontrol.uc003.SessionScopePerTestClassTest » Deployment
> > > org.apache.deltaspike.test.testcontrol.uc004.
> > ProjectStageTestControlTest.
> > > org.apache.deltaspike.test.testcontrol.uc004.
> ProjectStageTestControlTest
> > >   Run 1: ProjectStageTestControlTest.org.apache.deltaspike.test.
> > > testcontrol.uc004.ProjectStageTestControlTest » Deployment
> > >   Run 2: ProjectStageTestControlTest>RequestAndSessionScopePerTestM
> > > ethodTest.finalCheckAndCleanup:99 » IllegalState
> > >
> > >   SkipExternalContainerTest.org.apache.deltaspike.test.
> > testcontrol.uc006.SkipExternalContainerTest
> > > » Deployment
> > >   ExtendedTest.org.apache.deltaspike.test.testcontrol.
> uc007.ExtendedTest
> > > » Deployment
> > >   JsfContainerPerTestMethodTest.org.apache.deltaspike.test.
> > > testcontrol.uc010.JsfContainerPerTestMethodTest » Deployment
> > >   InterceptedBeanTest.org.apache.deltaspike.test.testcontrol.uc011.
> > InterceptedBeanTest
> > > » Deployment
> > >   TestServiceNoLabelTest.org.apache.deltaspike.test.testcontrol.uc014.
> > TestServiceNoLabelTest
> > > » Deployment
> > >   AlternativeServiceTest.org.apache.deltaspike.test.testcontrol.uc015.
> > AlternativeServiceTest
> > > » Deployment
> > >   TestServiceLabelYTest.org.apache.deltaspike.test.testcontrol.uc016.
> > TestServiceLabelYTest
> > > » Deployment
> > >   TestServiceLabelBTest.resultB » AmbiguousResolution There is more
> than
> > > one Bea...
> > >   TestServiceNoLabelTest.org.apache.deltaspike.test.testcontrol.uc020.
> > TestServiceNoLabelTest
> > > » Deployment
> > >   TestServiceTestLabelATest.org.apache.deltaspike.test.
> > testcontrol.uc020.TestServiceTestLabelATest
> > > » Deployment
> > >
> > >
> > >
> > > On Mon, Apr 16, 2018 at 1:33 AM, Gerhard Petracek <
> > > gerhard.petra...@gmail.com> wrote:
> > >
> > >> hi stephen,
> > >>
> > >> you only have one producer-class:
> > >> https://github.com/mores/deltaspike/blob/altProduces/deltasp
> > >> ike/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/deltasp
> > >> ike/modules/test-control/impl/src/test/java/org/apache/
> > >> deltaspike/test/testcontrol/uc020/TestServiceLabelA.java#L24
> > >> and
> > >> https://github.com/mores/deltaspike/blob/altProduces/deltasp
> > >> ike/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