views:

305

answers:

1

Hi

I've created SEAM component which checks that at least one user with global admin rights exists and creates one if no.

@Name("installer")
@Stateless
public class InstallerBean implements Installer, Serializable{
   @Observer("org.jboss.seam.postInitialization")
   public void install() {
      ...
   }

   public boolean isInstalled() {
      ...
   }
}

Now I need to test that installer works correctly. I need to check that isInstalled() returns true and check that correct users and roles are exists in the database. However SeamTest.ComponentTest.testComponents() is running before my installation compleate. I can see in the log that last messages from my installer appears in the middle of second test execution so my tests randomly fails.

I'm trying to test my installer in the following way:

public class InstallerTests extends SeamTest {
    @Test
    public void isInstalledTest() {
        new ComponentTest() {
            @Override
            protected void testComponents() {
               ...
            }
        }
    }

    ...
}

How can I make my test starting after my installation compleated?

I'm new to SEAM so maybe I'm doing all compleately wrong. Please tell me if there is a better way.

A: 

Maybe you already solved you problem. Do you call some methods asynchronously during the execution of install()? This could randomly delay completing the installation. A very pragmatic yet not the most clean solution is to use Thread.sleep(.) in your test case to wait for the installation to complete.

kraftan
this problem was not solved mainly because we decided to remove installer component from the project and use import.sql file for database initialization. Solution with Tread.sleep() should work but I can't try it now.
VestniK