4 Replies Latest reply on Sep 3, 2009 7:40 AM by Christian Bauer

    SeamDBTest doesn't work in 2.2.0.GA

    Daniel Hinojosa Master

      Last night I upgraded an app for a customer to 2.2.0.GA from 2.1.2.  By doing to so all integration test using SeamDBTest failed.  The issue it looks like is that it is unable to read the db unit xml flat files, so tests were failing because the data wasn't in there.  Has anyone come across this issue?  I verified this is the case by reverting to 2.1.2. with my version control, and the integration tests worked fine.

        • 1. Re: SeamDBTest doesn't work in 2.2.0.GA
          Christian Bauer Master

          Code, log traces, exceptions, etc.

          • 2. Re: SeamDBTest doesn't work in 2.2.0.GA
            Daniel Hinojosa Master

            Nothing out of the ordinary stack traces.  The bootstrap loads fine, everything works fine.


            The only failure were the tests because it didn't load the data into the the memory based HSQLDB from my new DataSetOperation.
            Here is a sample of my setup.  Again this works great in 2.1.2, but not in 2.2.0.GA



            TestNG IntegrationTest.xml


            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
            <suite name="integration" verbose="1">
                <parameter name="datasourceJndiName" value="java:/DefaultDS"/>
                <test name="integration">
                    <groups>
                        <run>
                            <include name="integration"/>
                            <exclude name="unit"/>
                            <exclude name="broken"/>
                        </run>
                    </groups>
                    <packages>
                        <package name="com.datacell.*"/>
                    </packages>
                </test>
            </suite>
            
            



            Example Test: com.datacell.office.OfficeUniquenessServiceBeanIntegrationTest


            public class OfficeUniquenessServiceBeanIntegrationTest extends IntegrationTest {
            
                @Test(groups = "integration")
                public void integrationTestAbbreviationUniqueWithoutIds() throws Exception {
                    new ComponentTest() {
                        @SuppressWarnings({"unchecked"})
                        protected void testComponents() throws Exception {
                            assertFalse((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('IL')}"));
                            assertFalse((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('PA')}"));
                            assertFalse((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('NB')}"));
                            assertTrue((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('GA')}"));
                        }
                    }.run();
                }
            
                @Test(groups = "integration")
                public void integrationTestAbbreviationUniqueWithIds() throws Exception {
                    new ComponentTest() {
                        @SuppressWarnings({"unchecked"})
                        protected void testComponents() throws Exception {
                            assertTrue((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('IL', 1)}"));
                            assertTrue((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('PA', 2)}"));
                            assertTrue((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('NB', 3)}"));
                            assertFalse((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('IL', 4)}"));
                            assertFalse((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('PA', 5)}"));
                            assertFalse((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('NB', 6)}"));
                            assertTrue((Boolean) invokeMethod("#{officeUniquenessServiceBean.isAbbreviationUnique('GA', 7)}"));
                        }
                    }.run();
                }
            
            
                protected void prepareDBUnitOperations() {
                    beforeTestOperations.add(
                            new DataSetOperation("datasets/officedata.xml")
                    );
                }
            }
            



            com.datacell.IntegrationTest. I created this class so that I can put my integration tests into TestNG groups. This is a super-class to all my integration tests.


            @Test(groups = "integration")
            public class IntegrationTest extends DBUnitSeamTest {
            
                @BeforeClass
                @Parameters("datasourceJndiName")
                @Override
                public void setDatasourceJndiName(String datasourceJndiName) {
                    super.setDatasourceJndiName(datasourceJndiName);
                }
            
                @BeforeSuite
                @Override
                public void startSeam() throws Exception {
                    super.startSeam();
                    System.out.println("db.int.startSeam");
                }
            
                @BeforeMethod
                @Override
                public void begin() {
                    super.begin();
                    System.out.println("db.int.begin");
                }
            
                @AfterMethod
                @Override
                public void end() {
                    super.end();
                    System.out.println("db.int.end");
                }
            
                protected void prepareDBUnitOperations() {
            
                }
            
            
                @Override
                @BeforeClass
                public void setupClass() throws Exception {
                    super.setupClass();
                    System.out.println("db.int.setupClass");
                }
            
                @Override
                @AfterClass
                public void cleanupClass() throws Exception {
                    super.cleanupClass();
                    System.out.println("db.int.cleanupClass");
                }
            
                @AfterSuite
                @Override
                public void stopSeam() throws Exception {
                    super.stopSeam();
                    System.out.println("db.int.stopSeam");
                }
            }
            
            



            datasets/officedata.xml


            <dataset>
            
            
                <datacell_office id="1" name="Chicago" updatedDate="2009-09-12 12:00:00" abbreviation="IL"
                                 createdDate="2009-10-22 23:00:00" addressID="1"
                                 managerID="2"/>
            
                <datacell_office id="2" name="Philadelphia" updatedDate="2009-10-12 12:00:00" abbreviation="PA"
                                 createdDate="2009-10-24 23:00:00" addressID="2"
                                 managerID="3"/>
            
                <datacell_office id="3" name="Omaha" updatedDate="2009-10-12 12:00:00" abbreviation="NB"
                                 createdDate="2009-10-24 23:00:00" addressID="3"
                                 managerID="4"/>
            
                <datacell_address id="1" state="IL" type="Work" line1="123 Lakeshore Blvd." Line2="Suite 2"
                                  city="Chicago" postalCode="22222"/>
            
                <datacell_address id="2" state="PA" type="Work" line1="1701 John F. Kennedy Blvd."
                                  city="Philadelphia" postalCode="19103"/>
            
                <datacell_address id="3" state="NB" type="Work" line1="1601 Dodge Street"
                                  city="Omaha" postalCode="68102"/>
            
                <datacell_address id="4" state="NM" type="Site" line1="222 James Rd."
                                  city="Bernalillo" postalCode="86662"/>
            
                <datacell_user id="1" password="pass" status="0"
                               updatedDate="2009-02-02 13:00:00"
                               createdDate="2009-02-13 15:00:00"
                               firstName="George"
                               lastName="Washington"
                               middleName=""
                               email="gwashington@gmail.com"
                               officeID="1"/>
            
                <datacell_user id="2" password="pass" status="0"
                               updatedDate="2009-02-02 13:00:00"
                               createdDate="2009-02-13 15:00:00"
                               firstName="John"
                               lastName="Adams"
                               middleName=""
                               email="jadams@gmail.com"
                               officeID="2"/>
            
                <datacell_user id="3" password="pass" status="0"
                               updatedDate="2009-02-02 13:00:00"
                               createdDate="2009-02-13 15:00:00"
                               firstName="Thomas"
                               lastName="Jefferson"
                               middleName=""
                               email="tjefferson@gmail.com"
                               officeID="3"/>
            
                <datacell_user id="4" password="pass" status="0"
                               updatedDate="2009-02-02 13:00:00"
                               createdDate="2009-02-13 15:00:00"
                               firstName="James"
                               lastName="Monroe"
                               middleName=""
                               email="tmonroe@gmail.com"
                               officeID="3"/>
            
            </dataset>
            

            • 3. Re: SeamDBTest doesn't work in 2.2.0.GA
              Arbi Sookazian Master

              You should be able to pinpoint the root-cause by stepping thru public DataSetOperation(String dataSetLocation, String dtdLocation, DatabaseOperation operation) in org.jboss.seam.mock.DBUnitSeamTest.


              I'm guessing in this method:


              public DataSetOperation(String dataSetLocation, String dtdLocation, DatabaseOperation operation)
                    {
                       log.debug(">>> Preparing dataset: " + dataSetLocation + " <<<");
              
                       // Load the base dataset file
                       InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(dataSetLocation);
                       try
                       {
                          InputStream dtdInput = null;
                          if (dtdLocation != null)
                          {
                             dtdInput = Thread.currentThread().getContextClassLoader().getResourceAsStream(dtdLocation);
                          }
                          if (dtdInput == null)
                          {
                             this.dataSet = new ReplacementDataSet(new FlatXmlDataSet(input));
                          }
                          else
                          {
                             this.dataSet = new ReplacementDataSet(new FlatXmlDataSet(input, dtdInput));
                          }
                       }
                       catch (Exception ex)
                       {
                          throw new RuntimeException(ex);
                       }
                       this.dataSet.addReplacementObject("[NULL]", null);
                       if (binaryDir != null)
                       {
                          this.dataSet.addReplacementSubstring("[BINARY_DIR]", getBinaryDirFullpath().toString());
                       }
                       this.operation = operation;
                       this.dataSetLocation = dataSetLocation;
                    }



              If it's not loading, something erroneous is happening in this method, right?

              • 4. Re: SeamDBTest doesn't work in 2.2.0.GA
                Christian Bauer Master

                Daniel, I've just fixed a rather serious bug in DBUnitSeamTest for release in 2.2.1CR1. This most likely will also solve your problem. Can you please test it: http://fisheye.jboss.org/changelog/Seam?cs=11461&csize=1