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 ColumnAnalyser} 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: ColumnAnalyserTest.java 4123 2008-05-25 21:49:01Z rakesh $
017     */
018    public class ColumnAnalyserTest extends TestCase
019    {
020      public static Test suite()
021      {
022        return new TestSuite( ColumnAnalyserTest.class );
023      }
024    
025      /**
026       * Test fetching all columns from the database connection.
027       */
028      public void testTableAnalyse() throws Exception
029      {
030        ColumnAnalyser analyser = new ColumnAnalyser(
031            CreateTestObjects.manager );
032        Collection<ColumnMetaData> columns = analyser.analyse(
033            SchemaAnalyserTest.metadata, TableAnalyserTest.metadata );
034    
035        assertTrue( "Checking non-zero columns", columns.size() > 0 );
036      }
037    
038      /**
039       * Test to ensure that the {@link TableMetaData} field {@link
040       * TableMetaData#columns} was updated with {@link ColumnMetaData} information.
041       */
042      public void testTableUpdated()
043      {
044        assertTrue( "Checking columns added to table metadata",
045            TableAnalyserTest.metadata.getColumns().size() > 0 );
046      }
047    
048      /**
049       * Test fetching all columns from the database connection.
050       */
051      public void testViewAnalyse() throws Exception
052      {
053        ColumnAnalyser analyser = new ColumnAnalyser(
054            CreateTestObjects.manager );
055        Collection<ColumnMetaData> columns = analyser.analyse(
056            SchemaAnalyserTest.metadata, ViewAnalyserTest.metadata );
057    
058        assertTrue( "Checking non-zero columns", columns.size() > 0 );
059      }
060    
061      /**
062       * Test to ensure that the {@link ViewMetaData} field {@link
063       * ViewMetaData#columns} was updated with {@link ColumnMetaData} information.
064       */
065      public void testViewUpdated()
066      {
067        assertTrue( "Checking columns added to view metadata",
068            ViewAnalyserTest.metadata.getColumns().size() > 0 );
069      }
070    }