Package java.beans

Examples of java.beans.Encoder$DefaultExceptionListener


        // TBD
    }

    public void testInstantiate_Normal() throws Exception {
        Object obj = new int[] { 1, 2, 3 };
        Expression exp = pd.instantiate(obj, new Encoder());
        assertSame(obj, exp.getValue());
        assertSame(Array.class, exp.getTarget());
        assertEquals("newInstance", exp.getMethodName());
        assertEquals(2, exp.getArguments().length);
        assertSame(Integer.TYPE, exp.getArguments()[0]);
View Full Code Here


     * Test instantiate() with null instance.
     */
    public void testInstantiate_NullInstance() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", "prop2" });
        Encoder enc = new Encoder();
        try {
            pd.instantiate(null, enc);
            fail("Should throw NullPointerException!");
        } catch (NullPointerException ex) {
            // expected
View Full Code Here

    public void testInstantiate_NullProperty() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", null });
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        pd.instantiate(b, new Encoder());
       
        pd = new MockPersistenceDelegate(new String[] {
                "prop1", null, "prop2"});
        MockBean b2 = new MockBean();
        b2.setAll("bean1", 2);
        pd.instantiate(b2, new Encoder());
    }
View Full Code Here

     */
    public void testInstantiate_NoProperty() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate();
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Expression e = pd.instantiate(b, new Encoder());
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(0, e.getArguments().length);
    }
View Full Code Here

    public void testInstantiate_NonExistingGetter() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", "non_existing" });
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Encoder enc = new Encoder();
        ExceptionListener el = new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                CallVerificationStack.getInstance().push(e);
            }
        };
        enc.setExceptionListener(el);
        Expression e = pd.instantiate(b, enc);
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
        assertSame(b.getProp1(), e.getArguments()[0]);
        assertSame(null, e.getArguments()[1]);
        assertTrue(CallVerificationStack.getInstance().pop() instanceof Exception);

        enc.setExceptionListener(null);
        assertNotNull(enc.getExceptionListener());
        e = pd.instantiate(b, enc);
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
View Full Code Here

    public void testInstantiate_InvalidGetter() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", "prop4" });
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Expression e = pd.instantiate(b, new Encoder());
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
        assertSame(b.getProp1(), e.getArguments()[0]);
View Full Code Here

    public void testInstantiate_ExceptionalGetter() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", "prop5" });
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Expression e = pd.instantiate(b, new Encoder());
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
        assertSame(b.getProp1(), e.getArguments()[0]);
View Full Code Here

    public void testInstantiate_ErrorGetter() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", "prop7" });
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Expression e = pd.instantiate(b, new Encoder());
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
        assertSame(b.getProp1(), e.getArguments()[0]);
View Full Code Here

    public void testInstantiate_PrivateGetter() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
                "prop1", "prop6" });
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Expression e = pd.instantiate(b, new Encoder());
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
        assertSame(b.getProp1(), e.getArguments()[0]);
View Full Code Here

    public void testInstantiate_InitialUpperCasePropName() throws Exception {
        String[] props = new String[] { "Prop1", "prop2" };
        MockPersistenceDelegate pd = new MockPersistenceDelegate(props);
        MockBean b = new MockBean();
        b.setAll("bean1", 2);
        Expression e = pd.instantiate(b, new Encoder());
        assertSame(b, e.getValue());
        assertSame(MockBean.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(2, e.getArguments().length);
        assertSame(b.getProp1(), e.getArguments()[0]);
View Full Code Here

TOP

Related Classes of java.beans.Encoder$DefaultExceptionListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.