1 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 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"), XmlError.forMessage("bazbar") }; 24 25 this.beanWithErrors = new BeanWithErrors(this.xmlObject, this.errors); 26 } 27 28 public void testConstruction() throws Exception { 29 try { 30 new BeanWithErrors(null, this.errors); 31 fail("Didn't get NPE on no object"); 32 } catch (NullPointerException npe) { 33 } 35 36 try { 37 new BeanWithErrors(this.xmlObject, null); 38 fail("Didn't get NPE on no errors"); 39 } catch (NullPointerException npe) { 40 } 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 npe) { 47 } 49 } 50 51 public void testComponents() throws Exception { 52 assertSame(this.xmlObject, this.beanWithErrors.bean()); 53 assertSame(this.errors, this.beanWithErrors.errors()); 54 } 55 56 } 57 | Popular Tags |