Package com.sun.faces

Examples of com.sun.faces.TestBean


    }


    public void testValueRefProperty() throws Exception {

        TestBean testBean = new TestBean();
        testBean.setOne("one");
        getFacesContext().getExternalContext().getSessionMap().put(
            "TestRefBean", testBean);

        ManagedBeanInfo.ManagedProperty property =
             new ManagedBeanInfo.ManagedProperty("one",
                                                 null,
                                                 "#{TestRefBean.one}",
                                                 null,
                                                 null);
        List<ManagedBeanInfo.ManagedProperty> list =
             new ArrayList<ManagedBeanInfo.ManagedProperty>(1);
        list.add(property);
        ManagedBeanInfo bean = new ManagedBeanInfo(beanName,
                                                   beanName,
                                                   "session",
                                                   null,
                                                   null,
                                                   list,
                                                   null);
        BeanManager beanManager =
             ApplicationAssociate.getCurrentInstance().getBeanManager();
        beanManager.register(bean);

        //testing with a property set
        assertNotNull(testBean = (TestBean) beanManager.create(beanName,
                                                               getFacesContext()));

        //make sure bean instantiated properly. Get property back from bean.
        assertTrue(testBean.getOne().equals("one"));

    }
View Full Code Here



    public void testValueRefScope() throws Exception {
        //Testing value ref scope

        TestBean testBean = new TestBean();
        testBean.setOne("one");
        boolean exceptionThrown = false;

        //testing with:
        //  valueref in application scope
        //  managed bean in session scope
        getFacesContext().getExternalContext().getApplicationMap().put(
            "TestRefBean", testBean);


        ManagedBeanInfo.ManagedProperty property =
             new ManagedBeanInfo.ManagedProperty("one",
                                                 null,
                                                 "#{TestRefBean.one}",
                                                 null,
                                                 null);
        List<ManagedBeanInfo.ManagedProperty> list =
             new ArrayList<ManagedBeanInfo.ManagedProperty>(1);
        list.add(property);
        ManagedBeanInfo bean = new ManagedBeanInfo(beanName,
                                                   beanName,
                                                   "session",
                                                   null,
                                                   null,
                                                   list,
                                                   null);
        BeanManager beanManager =
             ApplicationAssociate.getCurrentInstance().getBeanManager();
        beanManager.register(bean);

        //testing with a property set
        assertNotNull(testBean = (TestBean) beanManager.create(beanName,
                                                               getFacesContext()));

        //make sure bean instantiated properly. Get property back from bean.
        assertTrue(testBean.getOne().equals("one"));


        //testing with:
        //  valueref in request scope
        //  managed bean in application scope
View Full Code Here

    }
   
    public void testNoneScope() throws Exception {
        //Testing value ref scope
        TestBean testBean = new TestBean();
        testBean.setOne("one");
        boolean exceptionThrown = false;

        //  valueref in request scope
        //  managed bean in none scope
        // this should fail
View Full Code Here

    public void testMixedBean() throws Exception {
        ValueExpression vb =
            ELUtils.createValueExpression(
                "#{mixedBean}");
        TestBean bean = (TestBean) vb.getValue(getFacesContext().getELContext());
        assertEquals("mixed value Bobby \" \\  \\\" Orr", bean.getProp());

        vb =
            ELUtils.createValueExpression(
                "#{mixedBean.prop}");
        assertEquals(bean.getProp(), (String) vb.getValue(getFacesContext().getELContext()));
    }
View Full Code Here

        ValueExpression vb =
            ELUtils.createValueExpression(
                "#{threeBeanSaladNegative}");
  boolean exceptionThrown = false;
  try {
      TestBean bean = (TestBean) vb.getValue(getFacesContext().getELContext());
      assertTrue(false);
  }
  catch (FacesException pnfe) {
      exceptionThrown = true;
  }
View Full Code Here

    public void testMixedBeanPositive() throws Exception {
        ValueExpression vb =
            ELUtils.createValueExpression(
                "#{threeBeanSaladPositive}");
        TestBean bean = (TestBean) vb.getValue(getFacesContext().getELContext());
        assertEquals("request request session session none none",
         bean.getProp());

        vb =
            ELUtils.createValueExpression(
                "#{threeBeanSaladPositive.prop}");
        assertEquals(bean.getProp(), (String) vb.getValue(getFacesContext().getELContext()));
    }
View Full Code Here

//
// General Methods
//

    public void testScopedLookup() {
        TestBean testBean = new TestBean();
        InnerBean newInner, oldInner = new InnerBean();
        testBean.setInner(oldInner);
        VariableResolver variableResolver =
            getFacesContext().getApplication().getVariableResolver();
        Object result = null;
        getFacesContext().getExternalContext().getSessionMap().remove(
            "TestBean");
View Full Code Here


    public void testSet() throws Exception {
        FacesContext facesContext = getFacesContext();
        System.out.println("Testing setValue() with model bean in session ");
        TestBean testBean = new TestBean();
        InnerBean inner = new InnerBean();
        Inner2Bean innerInner = new Inner2Bean();
        Object result = null;

        getFacesContext().getExternalContext().getSessionMap().put("TestBean",
View Full Code Here

    public void testSetNull() throws Exception {
        FacesContext facesContext = getFacesContext();
        System.out.println(
            "Testing setValue() with model bean in session with null rValues");
        TestBean testBean = new TestBean();
        InnerBean inner = new InnerBean();
        Inner2Bean innerInner = new Inner2Bean();

        getFacesContext().getExternalContext().getSessionMap().put("TestBean",
                                                                   testBean);

        // Test one level of nesting
        valueBinding = this.create("TestBean.one");
        valueBinding.setValue(getFacesContext(), null);
        assertTrue(testBean.getOne() == null);

        System.setProperty(TestBean.PROP, TestBean.FALSE);
        valueBinding = this.create("sessionScope.TestBean.inner");
        valueBinding.setValue(getFacesContext(), inner);
        assertTrue(System.getProperty(TestBean.PROP).equals(TestBean.TRUE));

        valueBinding = this.create("sessionScope.TestBean.inner");
        valueBinding.setValue(getFacesContext(), null);
        assertTrue(testBean.getInner() == null);

        // Inner bean does not exist anymore. So this should result in an
        // exception.
        boolean exceptionThrown = false;
        valueBinding = this.create("sessionScope.TestBean.inner.two");
View Full Code Here


    public void testSetWithNoCurlyBraces() throws Exception {
        FacesContext facesContext = getFacesContext();
        System.out.println("Testing setValue() with model bean in request ");
        TestBean testBean = new TestBean();
        InnerBean inner = new InnerBean();
        Inner2Bean innerInner = new Inner2Bean();

        facesContext.getExternalContext().getSessionMap().remove("TestBean");
        facesContext.getExternalContext().getRequestMap().put("TestBean",
View Full Code Here

TOP

Related Classes of com.sun.faces.TestBean

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.