001    package com.sptci.rwt;
002    
003    import java.sql.Connection;
004    import java.util.Collection;
005    
006    import static junit.framework.Assert.*;
007    import junit.framework.Test;
008    import junit.framework.TestCase;
009    import junit.framework.TestSuite;
010    
011    /**
012     * Unit test for the {@link ForeignKeyAnalyser} object.
013     *
014     * <p>Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
015     * @author Rakesh Vidyadharan 2007-09-25
016     * @version $Id: ForeignKeyAnalyserTest.java 4123 2008-05-25 21:49:01Z rakesh $
017     */
018    public class ForeignKeyAnalyserTest extends TestCase
019    {
020      public static Test suite()
021      {
022        return new TestSuite( ForeignKeyAnalyserTest.class );
023      }
024    
025      /**
026       * Test fetching all columns from the database connection.
027       */
028      public void testAnalyse() throws Exception
029      {
030        ForeignKeyAnalyser analyser = new ForeignKeyAnalyser(
031            CreateTestObjects.manager );
032        Collection<ForeignKeyMetaData> metadata = analyser.analyse(
033            SchemaAnalyserTest.metadata, TableAnalyserTest.metadata );
034    
035        assertTrue( "Checking non-zero foreign keys", metadata.size() > 0 );
036      }
037    
038      /**
039       * Test to ensure that the {@link TableMetaData#foreignKeys} field was
040       * updated with {@link ForeignKeyMetaData} information.
041       */
042      public void testTableUpdated()
043      {
044        assertTrue( "Checking foreign keys added to table metadata",
045            TableAnalyserTest.metadata.getForeignKeys().size() > 0 );
046      }
047    }