1
2
3
4 package org.melati.poem.test;
5
6 import java.sql.Timestamp;
7 import java.sql.Types;
8 import java.text.DateFormat;
9
10 import org.melati.poem.ParsingPoemException;
11 import org.melati.poem.PoemLocale;
12 import org.melati.poem.SQLPoemType;
13 import org.melati.poem.TimestampPoemType;
14
15
16
17
18
19
20 public class NotNullableTimestampPoemTypeTest extends SQLPoemTypeSpec<Timestamp> {
21
22 public NotNullableTimestampPoemTypeTest() {
23 }
24
25 public NotNullableTimestampPoemTypeTest(String name) {
26 super(name);
27 }
28
29
30
31
32
33 void setObjectUnderTest() {
34 it = new TimestampPoemType(false);
35 }
36
37 public void testStringOfCooked() {
38 super.testStringOfCooked();
39 long now = System.currentTimeMillis();
40 Timestamp nowStamp = new Timestamp(now);
41 String result = it.stringOfCooked(nowStamp, PoemLocale.HERE, DateFormat.MEDIUM);
42 int expected = 20;
43 if (System.getProperty("java.version").startsWith("11")) {
44 expected = 21;
45 }
46 assertEquals(result,expected, result.length());
47 }
48
49
50
51
52 public void testQuotedRaw() {
53 long now = System.currentTimeMillis();
54 Timestamp nowStamp = new Timestamp(now);
55 assertEquals("'" + TimestampPoemType.format.format(nowStamp) + "'",
56 ((SQLPoemType<?>)it).quotedRaw(nowStamp));
57
58 }
59
60 public void testAssertValidCooked() {
61 super.testAssertValidCooked();
62 }
63
64 public void testPossibleRaws() {
65 super.testPossibleRaws();
66
67 }
68 public void testRawOfString() {
69 super.testRawOfString();
70 try{
71 it.rawOfString("kk");
72 fail("Should have blown up");
73 } catch (ParsingPoemException e) {
74 e = null;
75 }
76
77 }
78
79 public void testRawOfCooked() {
80 super.testRawOfCooked();
81 }
82
83
84
85
86 public void testFullConstructor() {
87 TimestampPoemType it2 = new MyTimestampPoemType(it.getNullable());
88 assertEquals(it.getNullable(),it2.getNullable());
89 }
90 class MyTimestampPoemType extends TimestampPoemType {
91
92 public MyTimestampPoemType(boolean nullable) {
93 super(Types.TIMESTAMP, "TIMESTAMP", nullable);
94 }
95
96 }
97 }