3 Replies Latest reply on Feb 24, 2010 11:09 AM by Miloslav Vlach

    SeamTest: @In not works

    Miloslav Vlach Novice

      I have problem with Seam tests. I have created simple test that get the EntityManager - this test works good.
      The second real test is testing the EJB3 Stateful component TemplateProcessor.


      The test file look like that


      @Test
          public void testObchodniPokynyNotifikace() throws Exception {
              new ComponentTest() {
      
                  @Override
                  protected void testComponents() throws Exception {
      
                      I18NTextFinderLocal i18NTextFinder = (I18NTextFinderLocal) getValue("#{i18NTextFinder}");
                      TemplateProcessorLocal templateProcessor = (TemplateProcessorLocal) getValue("#{templateProcessor}");
      
      


      The template processor need to inject the I18NTestFinder.


      TemplateProcessor.java


          @In(create = true)
          I18NTextFinderLocal i18NTextFinder;
      



      But the i18NTextFinder is null. OK, I am trying to create component in code (not for release edition).


      TemplateProcessor.java


              if (i18NTextFinder == null) {
                  i18NTextFinder = (I18NTextFinderLocal) Component.getInstance("i18NTextFinder");
              }
      



      The i18NTextFinder is created fine and I can follow the next code...but


      TemplateProcessor.java


          @Logger
          Log log;
      



      log is still null.
      Only one property which is not null is EntityManager injected throught @PersistenceContenxt...


      It's look like the BijectionInterceptor is not called (or which class works with @In annotation? )


        • 1. Re: SeamTest: @In not works
          Samuel Doyle Apprentice

          You are extending SeamTest I assume?


          You need to set these values in your context as well so that it can be located for injection. e.g.
          ScopeType.EVENT.getContext().set(i18NTextFinder, i18NTextFinder);

          • 2. Re: SeamTest: @In not works
            Samuel Doyle Apprentice

            Actually scratch that, if Component.getInstance is working fine it should be available.

            • 3. Re: SeamTest: @In not works
              Miloslav Vlach Novice

              In all jar which contains EJB with Seam anotation has to be this file:


              /META-INF/ejb-jar.xml


              <?xml version="1.0" encoding="UTF-8"?>
              <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
                   version="3.0">
                   <interceptors>
                        <interceptor>
                             <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
                        </interceptor>
                   </interceptors>
                   <assembly-descriptor>
                        <interceptor-binding>
                             <ejb-name>*</ejb-name>
                             <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
                        </interceptor-binding>
                   </assembly-descriptor>
              </ejb-jar>