01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.config.schema.beanfactory;
05:
06: import org.apache.xmlbeans.XmlError;
07:
08: import com.tc.config.schema.MockXmlObject;
09: 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 {
22: this .xmlObject = new MockXmlObject();
23: this .errors = new XmlError[] { XmlError.forMessage("foobar"),
24: XmlError.forMessage("bazbar") };
25:
26: this .beanWithErrors = new BeanWithErrors(this .xmlObject,
27: this .errors);
28: }
29:
30: public void testConstruction() throws Exception {
31: try {
32: new BeanWithErrors(null, this .errors);
33: fail("Didn't get NPE on no object");
34: } catch (NullPointerException npe) {
35: // ok
36: }
37:
38: try {
39: new BeanWithErrors(this .xmlObject, null);
40: fail("Didn't get NPE on no errors");
41: } catch (NullPointerException npe) {
42: // ok
43: }
44:
45: try {
46: new BeanWithErrors(this .xmlObject, new XmlError[] {
47: this .errors[0], null, this .errors[1] });
48: fail("Didn't get NPE on null error");
49: } catch (NullPointerException npe) {
50: // ok
51: }
52: }
53:
54: public void testComponents() throws Exception {
55: assertSame(this.xmlObject, this.beanWithErrors.bean());
56: assertSame(this.errors, this.beanWithErrors.errors());
57: }
58:
59: }
|