1   package uba.db.column;
2   
3   import junit.framework.TestCase;
4   import uba.db.table.TableSchema;
5   import uba.db.testhelpers.TestUtils;
6   
7   /***
8    * Test de unidad para {@linkk CharColumnSpecification}.
9    * 
10   * @version $Revision: 1.2 $
11   */
12  public class CharColumnSpecificationTest extends TestCase {
13      private CharColumnSpecification columnSpec;
14      private CharColumnSpecification sameColumnSpec;
15      private CharColumnSpecification otherColumnSpec;
16      private TableSchema mockSchema;
17  
18      /***
19       * @see junit.framework.TestCase#setUp()
20       */
21      protected void setUp() throws Exception {
22          super.setUp();
23  
24          columnSpec = new CharColumnSpecification("id", 10, ColumnConstraint.NOT_NULL);
25          sameColumnSpec = new CharColumnSpecification("id", 10, ColumnConstraint.NOT_NULL);
26          otherColumnSpec = new CharColumnSpecification("other", 20);
27  
28      }
29  
30      /***
31       * Test de igualdad entre dos instancias
32       */
33      public void testEquals() throws Exception {
34          TestUtils.assertEqualsImplementation(columnSpec, sameColumnSpec, otherColumnSpec);
35      }
36  
37      /***
38       * Test del metodo notNull
39       */
40      public void testNotNull() throws Exception {
41          assertTrue(columnSpec.notNull());
42          assertFalse(otherColumnSpec.notNull());
43      }
44  
45      /***
46       * Test para acceder a la longitud de una columna char.
47       */
48      public void testLength() {
49          assertEquals(10, columnSpec.maxChars());
50          assertEquals(20, otherColumnSpec.maxChars());
51      }
52  
53      /***
54       * Test: retornar un string que describe el tipo de datos de la especificación de
55       * columna.
56       */
57      public void testDataTypeDisplayString() throws Exception {
58          assertEquals(CharColumnSpecification.DATATYPE_DISPLAY_STRING, columnSpec
59                  .dataTypeDisplayString());
60      }
61  }