Package java.beans

Examples of java.beans.Encoder$DefaultExceptionListener


    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

     */
    public void testInstantiate_NotRegularGetter() throws Exception {
        MockPersistenceDelegate pd = new MockPersistenceDelegate(
                new String[] { "prop" });
        MockFoo2 b = new MockFoo2(2);
        Expression e = pd.instantiate(b, new Encoder());

        assertSame(b, e.getValue());
        assertSame(MockFoo2.class, e.getTarget());
        assertEquals("new", e.getMethodName());
        assertEquals(1, e.getArguments().length);
View Full Code Here

    public void testInstantiate_NPE() {

        try {
            testDefaultPersistenceDelegate obj = new testDefaultPersistenceDelegate();
            obj.initialize(Object.class, null, new Object(), new Encoder());
            fail("NullPointerException should be thrown");
        } catch (NullPointerException e) {
            // expected
        }
    }
View Full Code Here

        bean1.setValueCalled = false;
        bean2.setValueCalled = false;

        MockPersistenceDelegate mockPersistenceDelegate = new MockPersistenceDelegate();
        mockPersistenceDelegate.initialize(MockBean3.class, bean1, bean2,
                new Encoder());
        assertEquals("bean1", bean1.getValue());
        assertEquals("bean2", bean2.getValue());
        assertFalse(bean1.setValueCalled);
        assertFalse(bean2.setValueCalled);
    }
View Full Code Here

    /*
     * Tests initialize() with null class.
     */
    public void testInitialize_NullClass() {
        MockPersistenceDelegate pd = new MockPersistenceDelegate();
        Encoder enc = new Encoder();
        Object o1 = new Object();
        Object o2 = new Object();
        // enc.setPersistenceDelegate(MockFooStop.class,
        // new MockPersistenceDelegate());
        try {
            enc.setExceptionListener(new ExceptionListener() {
                public void exceptionThrown(Exception e) {
                    CallVerificationStack.getInstance().push(e);
                }
            });
            pd.initialize(null, o1, o2, enc);
View Full Code Here

    /*
     * Tests initialize() with null old and new instances.
     */
    public void testInitialize_NullInstances() {
        MockPersistenceDelegate pd = new MockPersistenceDelegate();
        Encoder enc = new Encoder();
        MockFoo b = new MockFoo();
        b.setName("myName");
        // enc.setPersistenceDelegate(MockFooStop.class,
        // new MockPersistenceDelegate());
        enc.setExceptionListener(new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                CallVerificationStack.getInstance().push(e);
            }
        });
        try {
View Full Code Here

    /*
     * Tests array persistence delegate
     */
    public void testArrayPD_Normal() {
        Encoder enc = new MockEncoder();
        int[] ia = new int[] { 1 };
        PersistenceDelegate pd = enc.getPersistenceDelegate(ia.getClass());
        pd.writeObject(ia, enc);
    }
View Full Code Here

        // 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

    public void testInitialize() {
        pd.initialize(null, null, null, null);
    }

    public void testInstantiate_Normal() throws Exception {
        Expression exp = pd.instantiate("str", new Encoder());

        assertSame("str", exp.getValue());
        assertSame(String.class, exp.getTarget());
        assertEquals("new", exp.getMethodName());
        assertEquals(1, exp.getArguments().length);
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.