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 <[email protected]>: > 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" <[email protected]> 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 > > > > >
