Examples of BeanContextSupport


Examples of java.beans.beancontext.BeanContextSupport

  }
 
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(Object[])");
    BeanContextSupport bcs = new BeanContextSupport();
   
    // try null
    boolean pass = false;
    try
    {
      bcs.toArray(null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try zero length array for zero children
    Object[] array1 = new Object[0];
    Object[] array2 = bcs.toArray(array1);
    harness.check(array2 == array1);
   
    // try array length 1 for zero children
    array1 = new Object[1];
    array2 = bcs.toArray(array1);
    harness.check(array2 == array1);
    harness.check(array2[0], null);
   
    // try array length 0 for 1 child
    BeanContextSupport child1 = new BeanContextSupport();
    bcs.add(child1);
    array1 = new Object[0];
    array2 = bcs.toArray(array1);
    harness.check(array2 != array1);
    harness.check(array2.length, 1);
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

     * Test method setBeanContext() with BeanContext parameter.
     * <p>
     */
    public void testSetBeanContextBeanContext() throws Exception {
        BeanContextChildSupport sup = new BeanContextChildSupport();
        sup.setBeanContext(new BeanContextSupport());

        assertNotNull("BeanContext should not be null", sup.getBeanContext());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

    public void testSetBeanContextBeanContextWithPropertyVetoException()
            throws Exception {
        MyBeanContextChildSupport myBeanContextChildSupport = new MyBeanContextChildSupport();
        VetoableChangeListener vcl = new MyVetoableChangeListener();
        myBeanContextChildSupport.addVetoableChangeListener("beanContext", vcl);
        BeanContext beanContext = new BeanContextSupport();
        try {
            myBeanContextChildSupport.setBeanContext(beanContext);
            fail("should throw PropertyVetoException");
        } catch (PropertyVetoException e) {          
            // expected
        }
        assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
        assertNull(myBeanContextChildSupport.getBeanContext());
       
        myBeanContextChildSupport.setBeanContext(beanContext);
        assertFalse(myBeanContextChildSupport.getRejectedSetBCOnce());
        assertNotNull(myBeanContextChildSupport.getBeanContext());
       
        try {
            myBeanContextChildSupport.setBeanContext(new BeanContextSupport());
            fail("should throw PropertyVetoException");
        } catch (PropertyVetoException e) {
            // expected
        }
       
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

     */
    public void testInstantiateClassLoaderStringBeanContext_Class()
            throws Exception {

        ClassLoader loader = new BinClassLoader();
        BeanContext context = new BeanContextSupport();
        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);

        assertEquals("as_class", (String) bean.getClass().getMethod(
                "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
        assertSame(loader, bean.getClass().getClassLoader());
        assertTrue(context.contains(bean));
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

    }

    public void testInstantiateClassLoaderStringBeanContext_Ser()
            throws Exception {
        ClassLoader loader = new SerClassLoader();
        BeanContext context = new BeanContextSupport();
        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);

        assertEquals("as_object", (String) bean.getClass().getMethod(
                "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
        assertSame(loader, bean.getClass().getClassLoader());
        assertTrue(context.contains(bean));
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

        assertTrue(context.contains(bean));
    }

    public void testInstantiateClassLoaderStringBeanContext_ClassLoaderNull()
            throws Exception {
        BeanContext context = new BeanContextSupport();
        Object bean = Beans.instantiate(null, MockJavaBean.class.getName(),
                context);

        assertEquals(bean.getClass(), MockJavaBean.class);
        assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
                .getClassLoader());
        assertTrue(context.contains(bean));
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

        assertTrue(context.contains(bean));
    }

    public void testInstantiateClassLoaderStringBeanContext_BeanNameNull()
            throws Exception {
        BeanContext context = new BeanContextSupport();
        ClassLoader loader = createSpecificClassLoader();

        try {
            Beans.instantiate(loader, null, context);
            fail("Should throw NullPointerException.");
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

     * AppletInitializer)
     */
    public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Class()
            throws Exception {
        ClassLoader loader = new BinClassLoader();
        BeanContext context = new BeanContextSupport();
        AppletInitializer appInit = new MockAppletInitializer();
        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context,
                appInit);

        assertEquals("as_class", (String) bean.getClass().getMethod(
                "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
        assertSame(loader, bean.getClass().getClassLoader());
        assertTrue(context.contains(bean));
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

    public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Ser()
            throws Exception {

        ClassLoader loader = new SerClassLoader();
        BeanContext context = new BeanContextSupport();
        AppletInitializer appInit = new MockAppletInitializer();
        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context,
                appInit);

        assertEquals("as_object", (String) bean.getClass().getMethod(
                "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
        assertSame(loader, bean.getClass().getClassLoader());
        assertTrue(context.contains(bean));
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextSupport

    }

    public void testInstantiateClassLoaderStringBeanContextAppletInitializer_LoaderNull()
            throws Exception {
        String beanName = "org.apache.harmony.beans.tests.support.mock.MockJavaBean";
        BeanContext context = new BeanContextSupport();
        AppletInitializer appInit = new MockAppletInitializer();

        Object bean = Beans.instantiate(null, beanName, context, appInit);

        assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
                .getClassLoader());
        assertEquals(beanName, bean.getClass().getName());
        assertTrue(context.contains(bean));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.