You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Rafael Pestano <rm...@gmail.com> on 2015/04/02 16:10:50 UTC

CDI Test control MessageBundle

Hi guys,

i'm having some problems to create a simple test using test control module
in an EE6 app.

Class under test:

@MessageBundle
public interface Messages {

  @MessageTemplate("{label.system-info}")
  String systemInfo();

}


MessagesTest.java

@RunWith(CdiTestRunner.class)
public class MessagesTest {

  @Inject
  Messages messages;

  @Test
  public void deveLerMensagemDoBundle(){
    assertEquals(messages.systemInfo(),"System info");
  }
}


1 - the above dependencies were not sufficient:

<dependency>
    <groupId>org.apache.deltaspike.modules</groupId>
    <artifactId>deltaspike-test-control-module-api</artifactId>
    <version>${ds.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.apache.deltaspike.modules</groupId>
    <artifactId>deltaspike-test-control-module-impl</artifactId>
    <version>${ds.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.apache.deltaspike.cdictrl</groupId>
    <artifactId>deltaspike-cdictrl-weld</artifactId>
    <version>${ds.version}</version>
    <scope>test</scope>
</dependency>


needed to add

<dependency>
    <groupId>org.jboss.weld.se</groupId>
    <artifactId>weld-se-core</artifactId>
    <version>2.2.6.Final</version>
    <scope>test</scope>
</dependency>


otherwise i get: java.lang.NoClassDefFoundError:
org/jboss/weld/environment/se/Weld

2 - beans.xml in test/resources/META-INF was not suffcient

needed to add beans.xml to src/main/resources/META-INF

otherwise i get:

 WELD-001408: Unsatisfied dependencies for type Messages with qualifiers
@Default
  at injection point [BackedAnnotatedField] @Inject
com.procergs.apm.it.MessagesTest.messages

3 - In the test the line: *messages.systemInfo() *return
"???label.system-info???" meaning taht the key was not found in the message
bundle although when running the application the message is found.

My messages.properties is located at *src/main/resources*.


Any help is appreciated.

Thanks in advance.



-- 
<http://www.advancedit.com.br/>Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
http://rpestano.wordpress.com/
@realpestano <https://twitter.com/realpestano>

Re: CDI Test control MessageBundle

Posted by Rafael Pestano <rm...@gmail.com>.
Hi,

"(or in case of a jsf-application via a message-bundle config-entry - see
[1])" yes, that was the case and why it worked in the app but failled
during tests.

To make it work in both cases I had to use
@MessageContextConfig(messageSource = "messages")

thanks again.


2015-04-02 15:19 GMT-03:00 Gerhard Petracek <ge...@gmail.com>:

> hi rafael,
>
> without (the same) package and name it should just be possible via
> @MessageContextConfig#messageSource
> (or in case of a jsf-application via a message-bundle config-entry - see
> [1]).
>
> regards,
> gerhard
>
> [1]
>
> http://deltaspike.apache.org/documentation/jsf.html#_integration_with_deltaspike_type_safe_messages
>
> 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-04-02 20:01 GMT+02:00 Rafael Pestano <rm...@gmail.com>:
>
> > Thanks for the clarifications Ron but I still dont get why it is working
> > when i run the application and fails during the tests.
> >
> > I will play a bit more soon and tell you the results.
> > Em 02/04/2015 14:56, "Ron Smeral" <rs...@redhat.com> escreveu:
> >
> > > Hi Rafael,
> > >
> > > On 2.4.2015 16:10, Rafael Pestano wrote:
> > >
> > >> Hi guys,
> > >>
> > >> i'm having some problems to create a simple test using test control
> > module
> > >> in an EE6 app.
> > >>
> > >> Class under test:
> > >>
> > >> @MessageBundle
> > >> public interface Messages {
> > >>
> > >>    @MessageTemplate("{label.system-info}")
> > >>    String systemInfo();
> > >>
> > >> }
> > >>
> > >>
> > >> MessagesTest.java
> > >>
> > >> @RunWith(CdiTestRunner.class)
> > >> public class MessagesTest {
> > >>
> > >>    @Inject
> > >>    Messages messages;
> > >>
> > >>    @Test
> > >>    public void deveLerMensagemDoBundle(){
> > >>      assertEquals(messages.systemInfo(),"System info");
> > >>    }
> > >> }
> > >>
> > >>
> > >> 1 - the above dependencies were not sufficient:
> > >>
> > >> <dependency>
> > >>      <groupId>org.apache.deltaspike.modules</groupId>
> > >>      <artifactId>deltaspike-test-control-module-api</artifactId>
> > >>      <version>${ds.version}</version>
> > >>      <scope>test</scope>
> > >> </dependency>
> > >> <dependency>
> > >>      <groupId>org.apache.deltaspike.modules</groupId>
> > >>      <artifactId>deltaspike-test-control-module-impl</artifactId>
> > >>      <version>${ds.version}</version>
> > >>      <scope>test</scope>
> > >> </dependency>
> > >> <dependency>
> > >>      <groupId>org.apache.deltaspike.cdictrl</groupId>
> > >>      <artifactId>deltaspike-cdictrl-weld</artifactId>
> > >>      <version>${ds.version}</version>
> > >>      <scope>test</scope>
> > >> </dependency>
> > >>
> > >>
> > >> needed to add
> > >>
> > >> <dependency>
> > >>      <groupId>org.jboss.weld.se</groupId>
> > >>      <artifactId>weld-se-core</artifactId>
> > >>      <version>2.2.6.Final</version>
> > >>      <scope>test</scope>
> > >> </dependency>
> > >>
> > >>
> > >> otherwise i get: java.lang.NoClassDefFoundError:
> > >> org/jboss/weld/environment/se/Weld
> > >>
> > >
> > > The deltaspike-cdictrl-weld project needs a Weld impl on the classpath.
> > It
> > > has a provided-scoped dependency on weld-se-core. It is provided and
> not
> > > compile scoped so that cdictrl can work also in an EE container, where
> a
> > > CDI impl is already present.
> > >
> > > I made a clarification in the docs: https://github.com/apache/
> > > deltaspike/pull/25
> > >
> > >  2 - beans.xml in test/resources/META-INF was not suffcient
> > >>
> > >> needed to add beans.xml to src/main/resources/META-INF
> > >>
> > >> otherwise i get:
> > >>
> > >>   WELD-001408: Unsatisfied dependencies for type Messages with
> > qualifiers
> > >> @Default
> > >>    at injection point [BackedAnnotatedField] @Inject
> > >> com.procergs.apm.it.MessagesTest.messages
> > >>
> > >
> > > Yes, well, beans.xml needs to be where the tested beans are. I suppose
> > > that "target/classes" and "target/test-classes" are treated as two
> > > different BDAs.
> > >
> > >  3 - In the test the line: *messages.systemInfo() *return
> > >> "???label.system-info???" meaning taht the key was not found in the
> > >> message
> > >> bundle although when running the application the message is found.
> > >>
> > >> My messages.properties is located at *src/main/resources*.
> > >>
> > >
> > > The file with messages must be named the same as the message-bundle
> bean,
> > > including the package. So if your message-bundle bean is
> > > "com.example.Messages" then you need to have src/main/resources/com/
> > > example/Messages.properties.
> > >
> > >
> > >> Any help is appreciated.
> > >>
> > >> Thanks in advance.
> > >>
> > >>
> > >>
> > >>
> > > HTH,
> > >
> > > Ron
> > >
> > > --
> > > Ron Smeral
> > > JBoss Quality Engineer
> > > Brno
> > >
> > >
> >
>



-- 
<http://www.advancedit.com.br/>Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
http://rpestano.wordpress.com/
@realpestano <https://twitter.com/realpestano>

Re: CDI Test control MessageBundle

Posted by Gerhard Petracek <ge...@gmail.com>.
hi rafael,

without (the same) package and name it should just be possible via
@MessageContextConfig#messageSource
(or in case of a jsf-application via a message-bundle config-entry - see
[1]).

regards,
gerhard

[1]
http://deltaspike.apache.org/documentation/jsf.html#_integration_with_deltaspike_type_safe_messages

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-04-02 20:01 GMT+02:00 Rafael Pestano <rm...@gmail.com>:

> Thanks for the clarifications Ron but I still dont get why it is working
> when i run the application and fails during the tests.
>
> I will play a bit more soon and tell you the results.
> Em 02/04/2015 14:56, "Ron Smeral" <rs...@redhat.com> escreveu:
>
> > Hi Rafael,
> >
> > On 2.4.2015 16:10, Rafael Pestano wrote:
> >
> >> Hi guys,
> >>
> >> i'm having some problems to create a simple test using test control
> module
> >> in an EE6 app.
> >>
> >> Class under test:
> >>
> >> @MessageBundle
> >> public interface Messages {
> >>
> >>    @MessageTemplate("{label.system-info}")
> >>    String systemInfo();
> >>
> >> }
> >>
> >>
> >> MessagesTest.java
> >>
> >> @RunWith(CdiTestRunner.class)
> >> public class MessagesTest {
> >>
> >>    @Inject
> >>    Messages messages;
> >>
> >>    @Test
> >>    public void deveLerMensagemDoBundle(){
> >>      assertEquals(messages.systemInfo(),"System info");
> >>    }
> >> }
> >>
> >>
> >> 1 - the above dependencies were not sufficient:
> >>
> >> <dependency>
> >>      <groupId>org.apache.deltaspike.modules</groupId>
> >>      <artifactId>deltaspike-test-control-module-api</artifactId>
> >>      <version>${ds.version}</version>
> >>      <scope>test</scope>
> >> </dependency>
> >> <dependency>
> >>      <groupId>org.apache.deltaspike.modules</groupId>
> >>      <artifactId>deltaspike-test-control-module-impl</artifactId>
> >>      <version>${ds.version}</version>
> >>      <scope>test</scope>
> >> </dependency>
> >> <dependency>
> >>      <groupId>org.apache.deltaspike.cdictrl</groupId>
> >>      <artifactId>deltaspike-cdictrl-weld</artifactId>
> >>      <version>${ds.version}</version>
> >>      <scope>test</scope>
> >> </dependency>
> >>
> >>
> >> needed to add
> >>
> >> <dependency>
> >>      <groupId>org.jboss.weld.se</groupId>
> >>      <artifactId>weld-se-core</artifactId>
> >>      <version>2.2.6.Final</version>
> >>      <scope>test</scope>
> >> </dependency>
> >>
> >>
> >> otherwise i get: java.lang.NoClassDefFoundError:
> >> org/jboss/weld/environment/se/Weld
> >>
> >
> > The deltaspike-cdictrl-weld project needs a Weld impl on the classpath.
> It
> > has a provided-scoped dependency on weld-se-core. It is provided and not
> > compile scoped so that cdictrl can work also in an EE container, where a
> > CDI impl is already present.
> >
> > I made a clarification in the docs: https://github.com/apache/
> > deltaspike/pull/25
> >
> >  2 - beans.xml in test/resources/META-INF was not suffcient
> >>
> >> needed to add beans.xml to src/main/resources/META-INF
> >>
> >> otherwise i get:
> >>
> >>   WELD-001408: Unsatisfied dependencies for type Messages with
> qualifiers
> >> @Default
> >>    at injection point [BackedAnnotatedField] @Inject
> >> com.procergs.apm.it.MessagesTest.messages
> >>
> >
> > Yes, well, beans.xml needs to be where the tested beans are. I suppose
> > that "target/classes" and "target/test-classes" are treated as two
> > different BDAs.
> >
> >  3 - In the test the line: *messages.systemInfo() *return
> >> "???label.system-info???" meaning taht the key was not found in the
> >> message
> >> bundle although when running the application the message is found.
> >>
> >> My messages.properties is located at *src/main/resources*.
> >>
> >
> > The file with messages must be named the same as the message-bundle bean,
> > including the package. So if your message-bundle bean is
> > "com.example.Messages" then you need to have src/main/resources/com/
> > example/Messages.properties.
> >
> >
> >> Any help is appreciated.
> >>
> >> Thanks in advance.
> >>
> >>
> >>
> >>
> > HTH,
> >
> > Ron
> >
> > --
> > Ron Smeral
> > JBoss Quality Engineer
> > Brno
> >
> >
>

Re: CDI Test control MessageBundle

Posted by Rafael Pestano <rm...@gmail.com>.
Thanks for the clarifications Ron but I still dont get why it is working
when i run the application and fails during the tests.

I will play a bit more soon and tell you the results.
Em 02/04/2015 14:56, "Ron Smeral" <rs...@redhat.com> escreveu:

> Hi Rafael,
>
> On 2.4.2015 16:10, Rafael Pestano wrote:
>
>> Hi guys,
>>
>> i'm having some problems to create a simple test using test control module
>> in an EE6 app.
>>
>> Class under test:
>>
>> @MessageBundle
>> public interface Messages {
>>
>>    @MessageTemplate("{label.system-info}")
>>    String systemInfo();
>>
>> }
>>
>>
>> MessagesTest.java
>>
>> @RunWith(CdiTestRunner.class)
>> public class MessagesTest {
>>
>>    @Inject
>>    Messages messages;
>>
>>    @Test
>>    public void deveLerMensagemDoBundle(){
>>      assertEquals(messages.systemInfo(),"System info");
>>    }
>> }
>>
>>
>> 1 - the above dependencies were not sufficient:
>>
>> <dependency>
>>      <groupId>org.apache.deltaspike.modules</groupId>
>>      <artifactId>deltaspike-test-control-module-api</artifactId>
>>      <version>${ds.version}</version>
>>      <scope>test</scope>
>> </dependency>
>> <dependency>
>>      <groupId>org.apache.deltaspike.modules</groupId>
>>      <artifactId>deltaspike-test-control-module-impl</artifactId>
>>      <version>${ds.version}</version>
>>      <scope>test</scope>
>> </dependency>
>> <dependency>
>>      <groupId>org.apache.deltaspike.cdictrl</groupId>
>>      <artifactId>deltaspike-cdictrl-weld</artifactId>
>>      <version>${ds.version}</version>
>>      <scope>test</scope>
>> </dependency>
>>
>>
>> needed to add
>>
>> <dependency>
>>      <groupId>org.jboss.weld.se</groupId>
>>      <artifactId>weld-se-core</artifactId>
>>      <version>2.2.6.Final</version>
>>      <scope>test</scope>
>> </dependency>
>>
>>
>> otherwise i get: java.lang.NoClassDefFoundError:
>> org/jboss/weld/environment/se/Weld
>>
>
> The deltaspike-cdictrl-weld project needs a Weld impl on the classpath. It
> has a provided-scoped dependency on weld-se-core. It is provided and not
> compile scoped so that cdictrl can work also in an EE container, where a
> CDI impl is already present.
>
> I made a clarification in the docs: https://github.com/apache/
> deltaspike/pull/25
>
>  2 - beans.xml in test/resources/META-INF was not suffcient
>>
>> needed to add beans.xml to src/main/resources/META-INF
>>
>> otherwise i get:
>>
>>   WELD-001408: Unsatisfied dependencies for type Messages with qualifiers
>> @Default
>>    at injection point [BackedAnnotatedField] @Inject
>> com.procergs.apm.it.MessagesTest.messages
>>
>
> Yes, well, beans.xml needs to be where the tested beans are. I suppose
> that "target/classes" and "target/test-classes" are treated as two
> different BDAs.
>
>  3 - In the test the line: *messages.systemInfo() *return
>> "???label.system-info???" meaning taht the key was not found in the
>> message
>> bundle although when running the application the message is found.
>>
>> My messages.properties is located at *src/main/resources*.
>>
>
> The file with messages must be named the same as the message-bundle bean,
> including the package. So if your message-bundle bean is
> "com.example.Messages" then you need to have src/main/resources/com/
> example/Messages.properties.
>
>
>> Any help is appreciated.
>>
>> Thanks in advance.
>>
>>
>>
>>
> HTH,
>
> Ron
>
> --
> Ron Smeral
> JBoss Quality Engineer
> Brno
>
>

Re: CDI Test control MessageBundle

Posted by Ron Smeral <rs...@redhat.com>.
Hi Rafael,

On 2.4.2015 16:10, Rafael Pestano wrote:
> Hi guys,
>
> i'm having some problems to create a simple test using test control module
> in an EE6 app.
>
> Class under test:
>
> @MessageBundle
> public interface Messages {
>
>    @MessageTemplate("{label.system-info}")
>    String systemInfo();
>
> }
>
>
> MessagesTest.java
>
> @RunWith(CdiTestRunner.class)
> public class MessagesTest {
>
>    @Inject
>    Messages messages;
>
>    @Test
>    public void deveLerMensagemDoBundle(){
>      assertEquals(messages.systemInfo(),"System info");
>    }
> }
>
>
> 1 - the above dependencies were not sufficient:
>
> <dependency>
>      <groupId>org.apache.deltaspike.modules</groupId>
>      <artifactId>deltaspike-test-control-module-api</artifactId>
>      <version>${ds.version}</version>
>      <scope>test</scope>
> </dependency>
> <dependency>
>      <groupId>org.apache.deltaspike.modules</groupId>
>      <artifactId>deltaspike-test-control-module-impl</artifactId>
>      <version>${ds.version}</version>
>      <scope>test</scope>
> </dependency>
> <dependency>
>      <groupId>org.apache.deltaspike.cdictrl</groupId>
>      <artifactId>deltaspike-cdictrl-weld</artifactId>
>      <version>${ds.version}</version>
>      <scope>test</scope>
> </dependency>
>
>
> needed to add
>
> <dependency>
>      <groupId>org.jboss.weld.se</groupId>
>      <artifactId>weld-se-core</artifactId>
>      <version>2.2.6.Final</version>
>      <scope>test</scope>
> </dependency>
>
>
> otherwise i get: java.lang.NoClassDefFoundError:
> org/jboss/weld/environment/se/Weld

The deltaspike-cdictrl-weld project needs a Weld impl on the classpath. 
It has a provided-scoped dependency on weld-se-core. It is provided and 
not compile scoped so that cdictrl can work also in an EE container, 
where a CDI impl is already present.

I made a clarification in the docs: 
https://github.com/apache/deltaspike/pull/25

> 2 - beans.xml in test/resources/META-INF was not suffcient
>
> needed to add beans.xml to src/main/resources/META-INF
>
> otherwise i get:
>
>   WELD-001408: Unsatisfied dependencies for type Messages with qualifiers
> @Default
>    at injection point [BackedAnnotatedField] @Inject
> com.procergs.apm.it.MessagesTest.messages

Yes, well, beans.xml needs to be where the tested beans are. I suppose 
that "target/classes" and "target/test-classes" are treated as two 
different BDAs.

> 3 - In the test the line: *messages.systemInfo() *return
> "???label.system-info???" meaning taht the key was not found in the message
> bundle although when running the application the message is found.
>
> My messages.properties is located at *src/main/resources*.

The file with messages must be named the same as the message-bundle 
bean, including the package. So if your message-bundle bean is 
"com.example.Messages" then you need to have 
src/main/resources/com/example/Messages.properties.

>
> Any help is appreciated.
>
> Thanks in advance.
>
>
>

HTH,

Ron

-- 
Ron Smeral
JBoss Quality Engineer
Brno


Re: CDI Test control MessageBundle

Posted by Rafael Pestano <rm...@gmail.com>.
Hi Gerhard,
"#3 per default the bundle needs to be in the same package as the
interface."

O do not have MessageContextConfig and it works with bundle in default
resources package (src/main/resources/messages.properties).

It shouldnt work?

The only problem is with tests.

2015-04-02 13:26 GMT-03:00 Gerhard Petracek <ge...@gmail.com>:
>
> hi rafael,
>
> #1 and #2 is the normal setup - there is nothing unexpected here.
> #3 per default the bundle needs to be in the same package as the
interface.
> (you can specify a different location via
> @MessageContextConfig#messageSource.)
>
> 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-04-02 16:10 GMT+02:00 Rafael Pestano <rm...@gmail.com>:
>
> > Hi guys,
> >
> > i'm having some problems to create a simple test using test control
module
> > in an EE6 app.
> >
> > Class under test:
> >
> > @MessageBundle
> > public interface Messages {
> >
> >   @MessageTemplate("{label.system-info}")
> >   String systemInfo();
> >
> > }
> >
> >
> > MessagesTest.java
> >
> > @RunWith(CdiTestRunner.class)
> > public class MessagesTest {
> >
> >   @Inject
> >   Messages messages;
> >
> >   @Test
> >   public void deveLerMensagemDoBundle(){
> >     assertEquals(messages.systemInfo(),"System info");
> >   }
> > }
> >
> >
> > 1 - the above dependencies were not sufficient:
> >
> > <dependency>
> >     <groupId>org.apache.deltaspike.modules</groupId>
> >     <artifactId>deltaspike-test-control-module-api</artifactId>
> >     <version>${ds.version}</version>
> >     <scope>test</scope>
> > </dependency>
> > <dependency>
> >     <groupId>org.apache.deltaspike.modules</groupId>
> >     <artifactId>deltaspike-test-control-module-impl</artifactId>
> >     <version>${ds.version}</version>
> >     <scope>test</scope>
> > </dependency>
> > <dependency>
> >     <groupId>org.apache.deltaspike.cdictrl</groupId>
> >     <artifactId>deltaspike-cdictrl-weld</artifactId>
> >     <version>${ds.version}</version>
> >     <scope>test</scope>
> > </dependency>
> >
> >
> > needed to add
> >
> > <dependency>
> >     <groupId>org.jboss.weld.se</groupId>
> >     <artifactId>weld-se-core</artifactId>
> >     <version>2.2.6.Final</version>
> >     <scope>test</scope>
> > </dependency>
> >
> >
> > otherwise i get: java.lang.NoClassDefFoundError:
> > org/jboss/weld/environment/se/Weld
> >
> > 2 - beans.xml in test/resources/META-INF was not suffcient
> >
> > needed to add beans.xml to src/main/resources/META-INF
> >
> > otherwise i get:
> >
> >  WELD-001408: Unsatisfied dependencies for type Messages with qualifiers
> > @Default
> >   at injection point [BackedAnnotatedField] @Inject
> > com.procergs.apm.it.MessagesTest.messages
> >
> > 3 - In the test the line: *messages.systemInfo() *return
> > "???label.system-info???" meaning taht the key was not found in the
message
> > bundle although when running the application the message is found.
> >
> > My messages.properties is located at *src/main/resources*.
> >
> >
> > Any help is appreciated.
> >
> > Thanks in advance.
> >
> >
> >
> > --
> > <http://www.advancedit.com.br/>Att,
> >
> > Rafael M. Pestano
> >
> > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> > http://rpestano.wordpress.com/
> > @realpestano <https://twitter.com/realpestano>
> >


-- 
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
http://rpestano.wordpress.com/
@realpestano

Re: CDI Test control MessageBundle

Posted by Gerhard Petracek <ge...@gmail.com>.
hi rafael,

#1 and #2 is the normal setup - there is nothing unexpected here.
#3 per default the bundle needs to be in the same package as the interface.
(you can specify a different location via
@MessageContextConfig#messageSource.)

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-04-02 16:10 GMT+02:00 Rafael Pestano <rm...@gmail.com>:

> Hi guys,
>
> i'm having some problems to create a simple test using test control module
> in an EE6 app.
>
> Class under test:
>
> @MessageBundle
> public interface Messages {
>
>   @MessageTemplate("{label.system-info}")
>   String systemInfo();
>
> }
>
>
> MessagesTest.java
>
> @RunWith(CdiTestRunner.class)
> public class MessagesTest {
>
>   @Inject
>   Messages messages;
>
>   @Test
>   public void deveLerMensagemDoBundle(){
>     assertEquals(messages.systemInfo(),"System info");
>   }
> }
>
>
> 1 - the above dependencies were not sufficient:
>
> <dependency>
>     <groupId>org.apache.deltaspike.modules</groupId>
>     <artifactId>deltaspike-test-control-module-api</artifactId>
>     <version>${ds.version}</version>
>     <scope>test</scope>
> </dependency>
> <dependency>
>     <groupId>org.apache.deltaspike.modules</groupId>
>     <artifactId>deltaspike-test-control-module-impl</artifactId>
>     <version>${ds.version}</version>
>     <scope>test</scope>
> </dependency>
> <dependency>
>     <groupId>org.apache.deltaspike.cdictrl</groupId>
>     <artifactId>deltaspike-cdictrl-weld</artifactId>
>     <version>${ds.version}</version>
>     <scope>test</scope>
> </dependency>
>
>
> needed to add
>
> <dependency>
>     <groupId>org.jboss.weld.se</groupId>
>     <artifactId>weld-se-core</artifactId>
>     <version>2.2.6.Final</version>
>     <scope>test</scope>
> </dependency>
>
>
> otherwise i get: java.lang.NoClassDefFoundError:
> org/jboss/weld/environment/se/Weld
>
> 2 - beans.xml in test/resources/META-INF was not suffcient
>
> needed to add beans.xml to src/main/resources/META-INF
>
> otherwise i get:
>
>  WELD-001408: Unsatisfied dependencies for type Messages with qualifiers
> @Default
>   at injection point [BackedAnnotatedField] @Inject
> com.procergs.apm.it.MessagesTest.messages
>
> 3 - In the test the line: *messages.systemInfo() *return
> "???label.system-info???" meaning taht the key was not found in the message
> bundle although when running the application the message is found.
>
> My messages.properties is located at *src/main/resources*.
>
>
> Any help is appreciated.
>
> Thanks in advance.
>
>
>
> --
> <http://www.advancedit.com.br/>Att,
>
> Rafael M. Pestano
>
> Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> http://rpestano.wordpress.com/
> @realpestano <https://twitter.com/realpestano>
>