View Javadoc
1   package org.melati.poem.test;
2   
3   import java.math.BigDecimal;
4   
5   import org.melati.poem.BigDecimalPoemType;
6   import org.melati.poem.ParsingPoemException;
7   import org.melati.poem.SQLPoemType;
8   import org.melati.poem.SQLSeriousPoemException;
9   
10  /**
11   * @author timp
12   * @since 21 Dec 2006
13   *
14   */
15  public class NotNullableDefaultBigDecimalPoemTypeTest extends SQLPoemTypeSpec<BigDecimal> {
16  
17    public NotNullableDefaultBigDecimalPoemTypeTest() {
18    }
19  
20    public NotNullableDefaultBigDecimalPoemTypeTest(String name) {
21      super(name);
22    }
23  
24    void setObjectUnderTest() {
25      it = new BigDecimalPoemType(false);
26    }
27  
28    public void testRawOfString() {
29      super.testRawOfString();
30      try {
31        it.rawOfString("ggg");
32        fail("Should have blown up");
33      } catch (ParsingPoemException e) {
34        e = null;
35      }
36     
37    }
38  
39    /**
40     * Test method for
41     * {@link org.melati.poem.SQLType#sqlTypeDefinition(org.melati.poem.dbms.Dbms)}.
42     */
43    public void testSqlTypeDefinition() {
44      super.testSqlDefinition();
45      BigDecimalPoemType it2 = new BigDecimalPoemType(true);
46      it2.setPrecision(-999);
47      it2.setScale(-999);
48      try {
49        it2.sqlTypeDefinition(getDb().getDbms());
50        fail("Should have blown up");
51      } catch (SQLSeriousPoemException e) {
52        e = null;
53      }
54    }
55   
56    /**
57     * Test method for {@link org.melati.poem.SQLType#quotedRaw(java.lang.Object)}.
58     */
59    public void testQuotedRaw() {
60      assertEquals(((SQLPoemType<?>)it).sqlDefaultValue(getDb().getDbms()), 
61          ((SQLPoemType<?>)it).quotedRaw(((SQLPoemType<?>)it).rawOfString(
62                  ((SQLPoemType<?>)it).sqlDefaultValue(getDb().getDbms()))));
63  
64    }
65  
66  }