1 2 Previous Next 22 Replies Latest reply on Nov 12, 2007 10:11 AM by pmuir

    Question about SeamTest

    gavin.king

      Are people actually using Seam's integration testing stuff? I've seen very few questions about this, which allows various possible explanations:

      (1) Everyone is using it and it Just Works
      (2) No-one understands it or no-one knows it exists
      (3) No-one does integration testing
      (4) There is some fundamental limitation which means people can't use it on their projects (eg. they are required to use JUnit instead of TestNG)

      Any feedback on this would be very useful.

      Thanks

        • 1. Re: Question about SeamTest
          mirko27

          We have used it, but it just isn`t neccessary usually. Because monitoring is enough.
          Btw. our debug page does not work anymore. Client-id is duplicated in faces tree. Upgraded facelets & myfaces but no use. Do you have any suggestions Gavin?

          • 2. Re: Question about SeamTest
            mirko27

            I found a workaround for this problem.
            UIViewRoot had same ID then first component. So I did following:
            Changed start of debug.xhtml as follows:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <ui:component xmlns:ui="http://java.sun.com/jsf/facelets">
            <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html">
            <f:view>

            Added to the end:
            </ui:component>

            • 3. Error message need to be improved
              liudan2005

              Here are some points I think seamtest need to be improved:
              1. Error message/report need to be improved.
              2. Configuration need to simplified.
              3. Need to more fault tolerant.

              Here is what happend to us when using SeamTest:
              We copied everything from seam booking example to our project and added in our code. Everything worked fine in jboss app server but not in seamtest. The error message it gave didn't make any sense to us. we had to use cvs diff to compare every single file to make sure our project is exactly same as seam booking example. we finally got it working after a couple of hours code analysing. We thought that was the end of the trouble but it's not.

              After a few days, we've added in some of our code. SeamTest stopped working again. The error message was "comp is not bound". The generated xml report didn't have any useful information. We had to revert our project to the initial state and repeat our changes one by one. It took us 2 days to find out the problem was caused by one of the jboss config xml under embedded-ejb/conf folder.

              It worked fine for a few days and it stopped working again one day morning. This didn't make any sense to us because it worked on the previous day. The error message was still "Comp is not bound". We spent another 2 days to get it working again. Still don't know what the problem was, but at least it worked.

              After a few days, it stopped working again("Comp is not bound"). we spent another 2 days to find out it was caused by a incorret annotation used in one of our entities.

              It's so much trouble to use SeamTest and we finally had to stop using seamtest. We now use junit for small unit test and manually test our app in browser for integration test.

              I guess the first thing seamtest need to improve is the error message. the most common error we got is "comp not bound", or "NullPointerException". It would save us a lot of time if the error was something like "ABC component is not bound, please check your jboss-xxx.xml".

              BTW: by the time I'm writting on this thread, tried to run seamtest which i stopped using it for a month. still get "comp not bound".

              • 4. Re: Question about SeamTest

                I'll be using SeamTest for integration testing of each main line use case scenario at least. I've opted not to use the EJB bootstrap component though, & boot the EJB3 standalone using a beforeSuite @Configuration. Speed is the issue for me, though I think the EJB component will be very handy for some. I temporarily disable hsql referential integrity & use dbunit to delete all table data, for setup/teardown where needed. I prefer to use object mothers to set up test data rather than sql.

                Typically I find I have some pan-conversational final Entities outside the scripts (maybe persisted), which I can check against from within any script, and Script scoped initializer blocks/variables can handle needs at the pan-Script level. I could use Seam itself for test data handling too I guess.

                I like the Seam testability actually, although I've only really used it in a trial capacity so far. Classically, I make most mistakes at the integration level, and I really appreciate having testability as a core feature

                • 5. Re: Question about SeamTest
                  gavin.king

                  The "comp not bound" problem is a name not found exception coming from JNDI when there is no java:/comp namespace in JNDI.

                  • 6. Re: Question about SeamTest
                    lcoetzee

                    We started off using it (and it worked quite nicely). But as always the development continued without the test cases being kept in sync (or not even writing integration tests for stuff that needs to be developed). As a result our integrations tests are completely useless (for that matter also our unit tests).

                    It basically needs to be reimplemented.

                    • 7. Re: Question about SeamTest
                      mk74

                      I am trying to get a SeamTest running which uses a JBPM process,
                      but I get an exception when I try to retrieve a SEAM component with:

                      @Override
                      protected void invokeApplication() {
                      Register c = (Register) Component.getInstance("register", true);
                      }

                      The component appears in the ApplicationContext and all init messages
                      look ok. Once I try to work with it I get:

                      org.jboss.seam.InstantiationException: Could not instantiate Seam component
                      ...
                      Caused by: javax.naming.NamingException: Local server is not initialized
                      at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
                      at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
                      at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
                      at javax.naming.InitialContext.init(Unknown Source)
                      at javax.naming.InitialContext.(Unknown Source)
                      at org.jboss.seam.util.NamingHelper.getInitialContext(NamingHelper.java:25)


                      When I comment out the JBPM init parameters from "initServletContext" then the SEAM components can be used again, but then I cannot test methods annotated with @CreateProcess. Hmm, would be nice to hear some comments...
                      My initialization routine is:

                      @Override
                      public void initServletContext(Map initParams) {

                      initParams.put(Init.COMPONENT_CLASSES, "org.jboss.seam.core.Ejb");
                      initParams.put(Init.JNDI_PATTERN, "#{ejbName}/local");

                      initParams.put(Init.COMPONENT_CLASSES, "org.jboss.seam.core.Jbpm");
                      initParams.put(Jbpm.PROCESS_DEFINITIONS,
                      "register.par/processdefinition.xml");
                      }



                      • 8. Re: Question about SeamTest

                        I am pleased that the test functionality exists and we'll certainly be implementing tests further into development. Ideally we would have been implementing tests up front but this is hard when we're still learning Seam, JSF, EJB3, etc. I would imagine that any subsequent projects will involve using the test framework earlier in the process.

                        I'm also keen on embedding Seam & JBoss EJB3 as I think I'll end up writing scripts in BSH to do disposable script stuff (maintenance).

                        • 9. Re: Question about SeamTest
                          gavin.king

                           

                          "mk74" wrote:
                          I am trying to get a SeamTest running which uses a JBPM process,


                          Yes, I didn't get this working yet :-(

                          • 10. Re: Question about SeamTest
                            gavin.king

                             

                            "d1g" wrote:
                            I'm also keen on embedding Seam & JBoss EJB3 as I think I'll end up writing scripts in BSH to do disposable script stuff (maintenance).


                            Actually I was thinking of shipping Seam with beanshell integration so you can dynamically call Seam components from the console. Would make a really fun demo.

                            • 11. Re: Question about SeamTest
                              mk74

                               

                              I am trying to get a SeamTest running which uses a JBPM process,

                              Yes, I didn't get this working yet :-(


                              a partial solution is to test the JBPM separately, but it fails if there are dependencies on SEAM components in the process definition.
                              For that I use a MockVariableResolver for expressions like #{actor.id}, e.g.

                              public class MockVariableResolver implements VariableResolver {

                              public Object resolveVariable(String name) throws ELException {
                              if (name.equals("actor")) {
                              Actor actor = new Actor();
                              actor.setId("hans-peter");
                              return actor;
                              }
                              return null;
                              }
                              }

                              another limitation of SeamTest is that no beans with EJB security annotations can be loaded because jaas is not yet supported in the embedded EJB container. Is there any workaround for that, for example
                              couldn't the security annotations just be ignored for testing?


                              • 12. Re: Question about SeamTest
                                gavin.king

                                You'll have to ask bill about JAAS support.

                                • 13. Re: Question about SeamTest
                                  ranik

                                  SeamTest is one of the reasons we switched from @EJB to @In ;-)
                                  I have been able to get EJB3 & hibernate work with testNG based on the examples. But, I am unable to get Hibernate & EJB3 working in the same test. The errors include datasource not defined even though it is defined in jboss-beans.xml and is found by EJB3 components. I hope this is not a limitation of the micro container?

                                  • 14. Re: Question about SeamTest
                                    joris77

                                    Hi,

                                    We would like to use the seamtest but, we use junit already and are not planning to switch test framework. Not because I like junit or testng better but I just like to stick with one testing framework.

                                    Joris wijlens

                                    1 2 Previous Next