5 Replies Latest reply on Oct 17, 2009 11:41 PM by Wolfgang Bergbauer

    seam test and transaction ovservers

    Wolfgang Bergbauer Newbie

      Hi all,

      we have some component tests setup to create a simple organizational hierarchy:


      This hierarchy is displayed in a tree.
      To ensure the tree is up to date, the setupOrgTree method is annotated with the TransactionSuccess event:

           public void setupOrgTree()

      From a test case, we create hundrets of organizations. The problem is this test takes really long, because each insert into the databasse will raise a org.jboss.seam.afterTransactionSuccess.Organization event and the tree will be rebuild many times.
      Here is the test method:

           @Test //(dependsOnMethods = { "test_check_organization" })
           public void test_create_orgainization() throws Exception {
                new FacesRequest(){     
                    protected void invokeApplication() throws Exception {
                          //create root org
                          OrganizationHome organizationHome =  (OrganizationHome) Component.getInstance("organizationHome", true);
                          Organization parentOrg = organizationHome.getInstance();
                          for (int i=0; i<3; i++) {
                               organizationHome.getInstance().setName("Level1-" + i);
                               Organization level1org = organizationHome.getInstance();
                               for (int n=0; n<3; n++) {
                                    organizationHome.getInstance().setName("Level2-" + n);
                                    Organization level2org = organizationHome.getInstance();
                                    for (int m=0; m<=3; m++) {
                                         organizationHome.getInstance().setName("Level3-" + m);

      What would be the best way to supress the setupOrgTree when running a test?
      Of course I could raise my own event whenever an organization is updated/deleted/modified, but it has quite some charme to use the TransactionSuccess Events, since this is raised always (when using the home object to manage organizations).

      Thanks for any suggestions.