001 package com.sptci.rwt;
002
003 import java.util.Collection;
004
005 import static junit.framework.Assert.*;
006 import junit.framework.Test;
007 import junit.framework.TestCase;
008 import junit.framework.TestSuite;
009
010 /**
011 * Unit test for the {@link ViewAnalyser} object.
012 *
013 * <p>Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
014 * @author Rakesh Vidyadharan 2007-09-25
015 * @version $Id: ViewAnalyserTest.java 4123 2008-05-25 21:49:01Z rakesh $
016 */
017 public class ViewAnalyserTest extends TestCase
018 {
019 static ViewMetaData metadata;
020
021 public static Test suite()
022 {
023 return new TestSuite( ViewAnalyserTest.class );
024 }
025
026 /**
027 * Test fetching all views from the database connection.
028 */
029 public void testAnalyse() throws Exception
030 {
031 ViewAnalyser analyser = new ViewAnalyser(
032 CreateTestObjects.manager );
033 Collection<ViewMetaData> views =
034 analyser.analyse( SchemaAnalyserTest.metadata );
035
036 for ( ViewMetaData vmd : views )
037 {
038 if ( CreateTestObjects.viewName.equalsIgnoreCase( vmd.getName() ) )
039 {
040 metadata = vmd;
041 break;
042 }
043 }
044
045 assertNotNull( "Ensuring test view was found", metadata );
046 assertTrue( "Checking non-zero views", views.size() > 0 );
047 }
048
049 /**
050 * Test that the {@link ViewMetaData} were added to {@link
051 * SchemaMetaData#views}.
052 */
053 public void testSchemaUpdated()
054 {
055 assertTrue( "Checking views added to SchemaMetaData",
056 SchemaAnalyserTest.metadata.getViews().size() > 0 );
057 }
058 }