KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > beanfactory > BeanWithErrorsTest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.config.schema.beanfactory;
5
6 import org.apache.xmlbeans.XmlError;
7
8 import com.tc.config.schema.MockXmlObject;
9 import com.tc.test.TCTestCase;
10
11 /**
12  * Unit test for {@link BeanWithErrors}.
13  */

14 public class BeanWithErrorsTest extends TCTestCase {
15
16   private MockXmlObject xmlObject;
17   private XmlError[] errors;
18   
19   private BeanWithErrors beanWithErrors;
20
21   public void setUp() throws Exception JavaDoc {
22     this.xmlObject = new MockXmlObject();
23     this.errors = new XmlError[] { XmlError.forMessage("foobar"), XmlError.forMessage("bazbar") };
24     
25     this.beanWithErrors = new BeanWithErrors(this.xmlObject, this.errors);
26   }
27
28   public void testConstruction() throws Exception JavaDoc {
29     try {
30       new BeanWithErrors(null, this.errors);
31       fail("Didn't get NPE on no object");
32     } catch (NullPointerException JavaDoc npe) {
33       // ok
34
}
35
36     try {
37       new BeanWithErrors(this.xmlObject, null);
38       fail("Didn't get NPE on no errors");
39     } catch (NullPointerException JavaDoc npe) {
40       // ok
41
}
42
43     try {
44       new BeanWithErrors(this.xmlObject, new XmlError[] { this.errors[0], null, this.errors[1] });
45       fail("Didn't get NPE on null error");
46     } catch (NullPointerException JavaDoc npe) {
47       // ok
48
}
49   }
50   
51   public void testComponents() throws Exception JavaDoc {
52     assertSame(this.xmlObject, this.beanWithErrors.bean());
53     assertSame(this.errors, this.beanWithErrors.errors());
54   }
55
56 }
57
Popular Tags