1
2
3
4
5
6
7
8
9 package bexee.model.xmltobpel;
10
11 import junit.framework.TestCase;
12
13 import org.xml.sax.Attributes;
14 import org.xml.sax.helpers.AttributesImpl;
15
16 import bexee.model.*;
17
18 /***
19 * @author Pawel Kowalski
20 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:18 $
21 */
22 public class AbstractObjectCreationFactoryTest extends TestCase implements
23 AttributeNames {
24
25 private String name = "client";
26
27 private String yes = "YES";
28
29 public final void testGetStandardAttributes() {
30 ObjectCreationFactoryTestImpl testImpl = new ObjectCreationFactoryTestImpl();
31
32 try {
33 StandardAttributes stdAtts = (StandardAttributes) testImpl
34 .createObject(getValidStandardAtts());
35
36 assertEquals(name, stdAtts.getName());
37 assertEquals(yes, stdAtts.getJoinCondition());
38 assertEquals(yes, stdAtts.getSuppressJoinFailure());
39 } catch (Exception e) {
40 e.printStackTrace();
41 fail("Should not throw an Exception");
42 }
43 }
44
45 public final void testGetEmpyStandardAttributes() {
46 ObjectCreationFactoryTestImpl testImpl = new ObjectCreationFactoryTestImpl();
47
48 try {
49 StandardAttributes stdAtts = (StandardAttributes) testImpl
50 .createObject(getInvalidStandardAtts());
51 assertNull(stdAtts.getName());
52 assertNull(stdAtts.getJoinCondition());
53 assertNull(stdAtts.getSuppressJoinFailure());
54 } catch (Exception e) {
55 e.printStackTrace();
56 fail("Should not throw an Exception");
57 }
58 }
59
60 private Attributes getValidStandardAtts() {
61 AttributesImpl a = new AttributesImpl();
62 a.addAttribute("", "", NAME, "", name);
63 a.addAttribute("", "", JOIN_CONDITION, "", yes);
64 a.addAttribute("", "", SUPPRESS_JOIN_FAILURE, "", yes);
65 return a;
66 }
67
68 private Attributes getInvalidStandardAtts() {
69 AttributesImpl a = new AttributesImpl();
70 return a;
71 }
72
73 /***
74 * This class is only used to test the getStandartAttributes(Attributes)
75 * method.
76 */
77 public class ObjectCreationFactoryTestImpl extends
78 AbstractObjectCreationFactory {
79 public Object createObject(Attributes atts) throws Exception {
80 return getStandardAttributes(atts);
81 }
82 }
83
84 }