Return-Path: X-Original-To: apmail-deltaspike-users-archive@www.apache.org Delivered-To: apmail-deltaspike-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 322AB10E2E for ; Sun, 7 Dec 2014 23:46:04 +0000 (UTC) Received: (qmail 84614 invoked by uid 500); 7 Dec 2014 23:46:03 -0000 Delivered-To: apmail-deltaspike-users-archive@deltaspike.apache.org Received: (qmail 84572 invoked by uid 500); 7 Dec 2014 23:46:03 -0000 Mailing-List: contact users-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@deltaspike.apache.org Delivered-To: mailing list users@deltaspike.apache.org Received: (qmail 84561 invoked by uid 99); 7 Dec 2014 23:46:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Dec 2014 23:46:02 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cunningham@olsdallas.com designates 74.125.82.42 as permitted sender) Received: from [74.125.82.42] (HELO mail-wg0-f42.google.com) (74.125.82.42) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Dec 2014 23:45:36 +0000 Received: by mail-wg0-f42.google.com with SMTP id z12so5004201wgg.29 for ; Sun, 07 Dec 2014 15:44:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=Gq+ZCw4MLFi3RQCKgXS88p04TKhXH2Uz/uCgT0WlM+Y=; b=G+BA5xDnXx/cCk3+wU5oouqttnAh4ctQaq/jQsozJdqhx/Fw9+C0kxzXiQKXHVr09k 8TTZAbz0P9/mAvtqKBibkG1PUb54MXy9b7LsfvZkLXs156RfZBdPy21MH9+BlV339yve aEwa6GtIq5IE/k4aCcr/jI4ZnGvS7mgxYRm1STVmJgYoh2j3nRDdzZLYfQdsl4NpKSrQ fZkGAV5RKFHBstmGj15HIH0lkF4src1OgJqmMX5vfSd1zhsCE4Sh0DG8kM226O9UX6xj F8yi+iCCa2WMS6VnhDuKMG7wtCmB+AiLFvbBKOwfLNLIQOpfha4D1KhWKWqkc+ka2RKa 2mBg== X-Gm-Message-State: ALoCoQlXrRjuhH3tZqPkRWrzSp4eLXi/7Mlb4ryJMoEG7WGk5uuXNliLMvwUbG5e0nfNFnbyAX9Y MIME-Version: 1.0 X-Received: by 10.194.8.34 with SMTP id o2mr24389931wja.129.1417995891088; Sun, 07 Dec 2014 15:44:51 -0800 (PST) Received: by 10.217.4.136 with HTTP; Sun, 7 Dec 2014 15:44:51 -0800 (PST) In-Reply-To: References: Date: Sun, 7 Dec 2014 17:44:51 -0600 Message-ID: Subject: Re: Test-Control ProjectStage From: Allen Cunningham To: users@deltaspike.apache.org Content-Type: multipart/alternative; boundary=047d7b5d619261b8090509a8e51b X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d619261b8090509a8e51b Content-Type: text/plain; charset=UTF-8 Gerhard, The only difference I could see in your template was the DeltaSpike version. So I downloaded 1.2.0 and my tests work fine now. If anyone else cares, I suspect ProjectStage has a problem in 1.0.3. We're happy to use 1.2.0. Allen On Fri, Dec 5, 2014 at 5:27 PM, Gerhard Petracek wrote: > hi allen, > > the zip-file you provided contains a bit more. > however, if i use the parts you described in your mail (with [1]), > everything works as expected. > > regards, > gerhard > > [1] https://github.com/os890/javase-cdi-ds-project-template > > > > http://www.irian.at > > Your JavaEE powerhouse - > JavaEE Consulting, Development and > Courses in English and German > > Professional Support for Apache > MyFaces, DeltaSpike and OpenWebBeans > > > > 2014-12-05 21:25 GMT+01:00 Allen Cunningham : > > > I'm having trouble with the ProjectStage in Test-Control. My tests run > with > > ProjectStage.Production instead of UnitTest. > > > > I put together a simple project to demonstrate my problem: > > > > Test class: > > > > @RunWith(CdiTestRunner.class) > > @TestControl(startScopes = ApplicationScoped.class) > > public class UnitTest { > > @Inject SampleClient sampleClient; > > > > @Test > > @TestControl(projectStage = ProjectStage.UnitTest.class) > > public void go() { > > sampleClient.init(new StartupEvent()); > > } > > } > > > > SampleClient: > > > > @ApplicationScoped > > public class SampleClient { > > @Inject SampleAPI sampleAPI; > > > > public void init(@Observes @Any StartupEvent event) { > > System.out.println(sampleAPI.doSomething()); > > } > > } > > > > The API: > > > > public interface SampleAPI { > > public String doSomething(); > > } > > > > The production implementation: > > > > @ApplicationScoped > > @Exclude(ifProjectStage = ProjectStage.UnitTest.class) > > public class SampleImpl implements SampleAPI { > > > > @Override > > public String doSomething() { > > return "Greetings from Impl"; > > } > > } > > > > And finally the mock bean: > > > > @ApplicationScoped > > @Exclude(exceptIfProjectStage = ProjectStage.UnitTest.class) > > public class SampleMock implements SampleAPI { > > > > @Override > > public String doSomething() { > > return "Greetings from Mock"; > > } > > } > > > > When I launch the app using CdiContainer, it loads the mock bean > correctly, > > but when I launch it using CdiTestRunner it loads SampleImpl. > > > > Single stepping through OWB I see that the DeltaSpike > ProjectStageProducer > > sees projectStage == null and sets it to Production by default. > > > > Am I missing something in my test config? > > > > I put a zip of the project here: > > https://www.dropbox.com/s/vg76rdapsl4yps9/ProjectStage.zip?dl=0 > > Sorry it isn't Maven! > > "ant" will launch it normally and "ant test" will run the unit test. > > > > Thanks! > > Allen > > > --047d7b5d619261b8090509a8e51b--