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 8903217305 for ; Tue, 3 Feb 2015 23:14:39 +0000 (UTC) Received: (qmail 42513 invoked by uid 500); 3 Feb 2015 23:14:40 -0000 Delivered-To: apmail-deltaspike-users-archive@deltaspike.apache.org Received: (qmail 42479 invoked by uid 500); 3 Feb 2015 23:14:40 -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 42467 invoked by uid 99); 3 Feb 2015 23:14:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2015 23:14:39 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,LOTS_OF_MONEY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gerhard.petracek@gmail.com designates 209.85.214.169 as permitted sender) Received: from [209.85.214.169] (HELO mail-ob0-f169.google.com) (209.85.214.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2015 23:14:14 +0000 Received: by mail-ob0-f169.google.com with SMTP id wp4so10959644obc.0 for ; Tue, 03 Feb 2015 15:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=F7ar4E4db9/3lCVF8dPKeKB47cJiJQWwb7kmfPm6bw0=; b=GxOIJtxXd93HrAgJz/T6wnlm+i5r6/AnTERV1tZ2IpJYognxiYb5lpVaJdXdnJOVB3 c1Ws0t8E5n9LmQltVrjGFuG3XgYZOQ8dYfkOYg3T3e5EZHhFbT8oGcKInDo9FTApRvtF wONEaWmP5UhN09Y+Z6UpbYYboM7ZNpv+3k9VsQVh4OGDKQfJ4hXw8l+b9lh/ngDxicTD vHqihwXPF32bDP7HZuu6KHkhIhXaQLN/qwzTjUaGCJrwmjISVFawQ3jirCPk9Xn2eu2d anlgNjgIw4xTcxb3sO1Bro8VeGDRsffXjfnQpcPV0Uq/PZ7PBuaEGCSU5PjOK49lMQcM zIOA== X-Received: by 10.202.108.137 with SMTP id h131mr16205828oic.90.1423005207184; Tue, 03 Feb 2015 15:13:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.202.230.9 with HTTP; Tue, 3 Feb 2015 15:13:06 -0800 (PST) In-Reply-To: References: From: Gerhard Petracek Date: Wed, 4 Feb 2015 00:13:06 +0100 Message-ID: Subject: Re: JerseyTest mock support To: users@deltaspike.apache.org Content-Type: multipart/alternative; boundary=001a1142d8cce34d64050e373750 X-Virus-Checked: Checked by ClamAV on apache.org --001a1142d8cce34d64050e373750 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable hi jc, it doesn't work because jetty uses an own thread to answer the request and therefore the cdi-container needs to be integrated properly (the request-context needs to be active for every request answered by jetty). just fyi: CdiTestRunner just manages the current (test-)thread. 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 2015-02-03 19:54 GMT+01:00 Gerhard Petracek : > hi jc, > > ok - i'll have a look at it soon. > > 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 > > > > 2015-02-03 19:27 GMT+01:00 Jean-Christophe Counio < > jean-christophe.counio@oracle.com>: > >> Hi, >> >> Here=E2=80=99s the link : >> https://github.com/couniojc/jerseytest-cdi >> >> If you set >> "deltaspike.testcontrol.mock-support.allow_mocked_beans=3Dfalse=E2=80=9D= , you can run >> PingResourceSimpleTest (no mocks in this one) >> As soon as you set it to true, it throws the exception. >> >> Thanks >> >> JC >> >> >> On Feb 3, 2015, at 12:29 AM, Gerhard Petracek >> wrote: >> >> > hi jc, >> > >> > please provide a link to a demo which illustrates the issue. >> > >> > 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 >> > >> > >> > >> > 2015-02-03 2:18 GMT+01:00 Jean-Christophe Counio < >> > jean-christophe.counio@oracle.com>: >> > >> >> Hi, >> >> >> >> Anyone successfully integrated JerseyTest with mocks using deltaspike= ? >> >> When I activate >> >> deltaspike.testcontrol.mock-support.allow_mocked_beans=3Dtrue, I have= the >> >> following error : >> >> >> >> org.jboss.weld.context.ContextNotActiveException: WELD-001303: No >> active >> >> contexts for scope type javax.enterprise.context.RequestScoped >> >> at >> >> >> org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:6= 87) >> >> at >> >> >> org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanIns= tance.java:79) >> >> at >> >> >> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.j= ava:99) >> >> at >> >> >> org.jboss.weld.proxies.DynamicMockManager$1777947725$Proxy$_$$_WeldClien= tProxy.getMock(Unknown >> >> Source) >> >> at >> >> >> org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrap= per.produce(MockAwareInjectionTargetWrapper.java:59) >> >> at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:149= ) >> >> at >> >> org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96) >> >> at >> >> >> org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanIns= tance.java:98) >> >> at >> >> >> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.j= ava:78) >> >> at >> >> com.test.simplerest.PingResource$Proxy$_$$_WeldClientProxy.ping(Unkno= wn >> >> Source) >> >> >> >> The test is like this : >> >> @RunWith(CdiTestRunner.class) >> >> public class PingResourceTest extends JerseyTest { >> >> >> >> @Inject >> >> ApplicationMockManager applicationMockManager; >> >> >> >> MyInj injMock =3D EasyMock.createMock(MockType.NICE, MyInj.class); >> >> >> >> @Override >> >> protected Application configure() { >> >> return new MyApp(); >> >> } >> >> >> >> @Test >> >> public void testPing() { >> >> applicationMockManager.addMock(injMock); //no behavior set so = it >> >> should return null >> >> String resp =3D target("/ping").request().get(String.class); >> >> Assert.assertEquals("Ping", =E2=80=9Cnull", resp); >> >> } >> >> } >> >> >> >> I tried to play with @TestControl but there=E2=80=99s no changes. >> >> >> >> Thanks >> >> >> >> JC >> >> >> >> >> >> > --001a1142d8cce34d64050e373750--