KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > context > exe > JbpmTypesTest


1 package org.jbpm.context.exe;
2
3 import java.util.*;
4
5 import javax.naming.directory.*;
6
7 import junit.framework.*;
8
9 import org.jbpm.context.exe.converter.*;
10 import org.jbpm.context.exe.variableinstance.*;
11
12 public class JbpmTypesTest extends TestCase {
13
14   public void testString() {
15     VariableInstance variableInstance = VariableInstance.createVariableInstance("hello".getClass());
16     assertEquals(StringInstance.class, variableInstance.getClass());
17     assertNull(variableInstance.converter);
18   }
19
20   public void testDate() {
21     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Date().getClass());
22     assertEquals(DateInstance.class, variableInstance.getClass());
23     assertNull(variableInstance.converter);
24   }
25
26   public void testBoolean() {
27     VariableInstance variableInstance = VariableInstance.createVariableInstance(Boolean.TRUE.getClass());
28     assertEquals(StringInstance.class, variableInstance.getClass());
29     assertEquals(BooleanToStringConverter.class, variableInstance.converter.getClass());
30   }
31
32   public void testCharacter() {
33     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Character JavaDoc(' ').getClass());
34     assertEquals(StringInstance.class, variableInstance.getClass());
35     assertEquals(CharacterToStringConverter.class, variableInstance.converter.getClass());
36   }
37
38   public void testFloat() {
39     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Float JavaDoc(3.3).getClass());
40     assertEquals(DoubleInstance.class, variableInstance.getClass());
41     assertEquals(FloatToDoubleConverter.class, variableInstance.converter.getClass());
42   }
43
44   public void testDouble() {
45     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Double JavaDoc(3.3).getClass());
46     assertEquals(DoubleInstance.class, variableInstance.getClass());
47     assertNull(variableInstance.converter);
48   }
49
50   public void testSerializable() {
51     VariableInstance variableInstance = VariableInstance.createVariableInstance(new BasicAttribute("i am serializable").getClass());
52     assertEquals(ByteArrayInstance.class, variableInstance.getClass());
53     assertEquals(SerializableToByteArrayConverter.class, variableInstance.converter.getClass());
54   }
55
56   public void testLong() {
57     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Long JavaDoc(3).getClass());
58     assertEquals(LongInstance.class, variableInstance.getClass());
59     assertNull(variableInstance.converter);
60   }
61
62   public void testByte() {
63     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Byte JavaDoc("3").getClass());
64     assertEquals(LongInstance.class, variableInstance.getClass());
65     assertEquals(ByteToLongConverter.class, variableInstance.converter.getClass());
66   }
67
68   public void testShort() {
69     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Short JavaDoc("3").getClass());
70     assertEquals(LongInstance.class, variableInstance.getClass());
71     assertEquals(ShortToLongConverter.class, variableInstance.converter.getClass());
72   }
73
74   public void testInteger() {
75     VariableInstance variableInstance = VariableInstance.createVariableInstance(new Integer JavaDoc(3).getClass());
76     assertEquals(LongInstance.class, variableInstance.getClass());
77     assertEquals(IntegerToLongConverter.class, variableInstance.converter.getClass());
78   }
79
80   public void testNonStorableType() {
81     try {
82       VariableInstance.createVariableInstance(new Thread JavaDoc().getClass());
83       fail("expected exception");
84     } catch (RuntimeException JavaDoc e) {
85       // OK
86
}
87   }
88 }
89
Popular Tags