Package org.apache.myfaces.config.impl.digester.elements

Examples of org.apache.myfaces.config.impl.digester.elements.ManagedBeanImpl


    protected void setUp() throws Exception
    {
        super.setUp();
        managedBeanBuilder  = new ManagedBeanBuilder();
       
        beanConfiguration = new ManagedBeanImpl();       
        beanConfiguration.setBeanClass(AnnotatedManagedBean2.class.getName());
        beanConfiguration.setName("managed");
        beanConfiguration.setScope("request");
       
        ManagedPropertyImpl managedProperty = new ManagedPropertyImpl();
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    public void testCustomScope()
    {
        // create the custom scope
        ManagedBeanImpl scopeBean = new ManagedBeanImpl();
        scopeBean.setBeanClass(HashMap.class.getName());
        scopeBean.setName("scopeBean");
        scopeBean.setScope("application");
        runtimeConfig.addManagedBean("scopeBean", scopeBean);
       
        // create the managed bean
        ManagedBeanImpl beanInCustomScope = new ManagedBeanImpl();
        beanInCustomScope.setBeanClass(ArrayList.class.getName());
        beanInCustomScope.setName("beanInCustomScope");
        beanInCustomScope.setScope("#{scopeBean}");
        runtimeConfig.addManagedBean("beanInCustomScope", beanInCustomScope);
       
        // resolve the managed bean
        Object resolvedBeanInCustomScope = new MockValueExpression("#{beanInCustomScope}", List.class)
                                                   .getValue(facesContext.getELContext());
View Full Code Here

     * of the value, and the type of the value.
     */
    public void testCustomScopeNoMap()
    {
        // create the custom scope
        ManagedBeanImpl scopeBean = new ManagedBeanImpl();
        // Scope is ArrayList instead of HashMap
        scopeBean.setBeanClass(ArrayList.class.getName());
        scopeBean.setName("scopeBean");
        scopeBean.setScope("application");
        runtimeConfig.addManagedBean("scopeBean", scopeBean);
       
        // create the managed bean
        ManagedBeanImpl beanInCustomScope = new ManagedBeanImpl();
        beanInCustomScope.setBeanClass(ArrayList.class.getName());
        beanInCustomScope.setName("beanInCustomScope");
        beanInCustomScope.setScope("#{scopeBean}");
        runtimeConfig.addManagedBean("beanInCustomScope", beanInCustomScope);
       
        // resolve the managed bean
        try
        {
            new MockValueExpression("#{beanInCustomScope}", List.class)
                    .getValue(facesContext.getELContext());
        }
        catch (FacesException fe)
        {
            // the message must contain ...
            final String message = fe.getMessage();
            // ... the expression string
            assertTrue(message.contains(beanInCustomScope.getManagedBeanScope()));
            Object resolvedScopeBean = new MockValueExpression("#{scopeBean}", List.class)
                                               .getValue(facesContext.getELContext());
            // ... the toString() of the value
            assertTrue(message.contains(resolvedScopeBean.toString()));
            // ... and the type of the value
View Full Code Here

     * The ManagedBeanResolver only tries to detect cyclic references if ProjectStage != Production.
     */
    public void testCustomScopeCyclicReferences()
    {
        // create m1
        ManagedBeanImpl m1 = new ManagedBeanImpl();
        m1.setBeanClass(TestBean.class.getName());
        m1.setName("m1");
        m1.setScope("#{m2.scope}");
        runtimeConfig.addManagedBean("m1", m1);
       
        // create m2
        ManagedBeanImpl m2 = new ManagedBeanImpl();
        m2.setBeanClass(TestBean.class.getName());
        m2.setName("m2");
        m2.setScope("#{m1.scope}");
        runtimeConfig.addManagedBean("m2", m2);
       
        // try to resolve m1
        try
        {
View Full Code Here

     * Tests the view scope, which was introduced in jsf 2.0
     */
    public void testViewScope()
    {
        // create the managed bean
        ManagedBeanImpl beanInViewScope = new ManagedBeanImpl();
        beanInViewScope.setBeanClass(ArrayList.class.getName());
        beanInViewScope.setName("beanInViewScope");
        beanInViewScope.setScope("view");
        runtimeConfig.addManagedBean("beanInViewScope", beanInViewScope);
       
        // resolve the managed bean
        Object resolvedBeanInCustomScope = new MockValueExpression("#{beanInViewScope}", List.class)
                                                   .getValue(facesContext.getELContext());
View Full Code Here

   
    protected void setUp() throws Exception
  {
        super.setUp();
        ManagedBeanBuilder managedBeanBuilder = new ManagedBeanBuilder();
        ManagedBeanImpl managedBean = new ManagedBeanImpl();
       
        managedBean.setBeanClass(MangedBeanExample.class.getName());
        managedBean.setName("managed");
        managedBean.setScope("request");
       
        // test methods of children will want to make sure these values come
        // out on the other end of this.
        MANAGED_LIST.add("0");
        MANAGED_LIST.add("1");
        MANAGED_LIST.add("2");
        MANAGED_MAP.put("0", "0");
        MANAGED_MAP.put("1", "1");
        MANAGED_MAP.put("2", "2");
       
        ManagedPropertyImpl managedProperty = new ManagedPropertyImpl();
        managedProperty.setPropertyName("managedProperty");
        managedProperty.setValue(INJECTED_VALUE);
       
        ManagedPropertyImpl managedList = new ManagedPropertyImpl();
        managedList.setPropertyName("managedList");
        ListEntriesImpl listEntries = makeListEntries();
        managedList.setListEntries(listEntries);
       
        ManagedPropertyImpl writeOnlyList = new ManagedPropertyImpl();
        writeOnlyList.setPropertyName("writeOnlyList");
        ListEntriesImpl writeOnlyListEntries = makeListEntries();
        writeOnlyList.setListEntries(writeOnlyListEntries);
       
        ManagedPropertyImpl managedMap = new ManagedPropertyImpl();
        managedMap.setPropertyName("managedMap");
        MapEntriesImpl mapEntries = makeMapEntries();
        managedMap.setMapEntries(mapEntries);
       
        ManagedPropertyImpl writeOnlyMap = new ManagedPropertyImpl();
        writeOnlyMap.setPropertyName("writeOnlyMap");
        MapEntriesImpl writeOnlyMapEntries = makeMapEntries();
        writeOnlyMap.setMapEntries(writeOnlyMapEntries);       
       
        managedBean.addProperty(managedProperty);
        managedBean.addProperty(managedList);
        managedBean.addProperty(writeOnlyList);
        managedBean.addProperty(managedMap);
        managedBean.addProperty(writeOnlyMap);

        // simulate a managed bean creation
        example = (MangedBeanExample) managedBeanBuilder
            .buildManagedBean(facesContext, managedBean);
    }
View Full Code Here

        Injector injector = Guice.createInjector(new ShoppingModule());
        servletContext.setAttribute(GuiceResolver.KEY, injector);
       
        // simulate Myfaces starting up
        RuntimeConfig rc = RuntimeConfig.getCurrentInstance(externalContext);
        ManagedBeanImpl bean = new ManagedBeanImpl();
        bean.setBeanClass(ShoppingCart.class.getName());
        bean.setScope("request");
        rc.addManagedBean("shoppingCart", bean);
       
    }
View Full Code Here

     * the session, the application and the none scope.
     */
    public void testIsInValidScope()
    {
        // create sessionBean referencing requestBean
        ManagedBeanImpl sessionBean = new ManagedBeanImpl();
        sessionBean.setBeanClass(TestBean.class.getName());
        sessionBean.setName("sessionBean");
        sessionBean.setScope("session");
        ManagedPropertyImpl anotherBeanProperty = new ManagedPropertyImpl();
        anotherBeanProperty.setPropertyName("anotherBean");
        anotherBeanProperty.setValue("#{requestBean}");
        sessionBean.addProperty(anotherBeanProperty);
        runtimeConfig.addManagedBean("sessionBean", sessionBean);
       
        // create requestBean
        ManagedBeanImpl requestBean = new ManagedBeanImpl();
        requestBean.setBeanClass(TestBean.class.getName());
        requestBean.setName("requestBean");
        requestBean.setScope("request");
        runtimeConfig.addManagedBean("requestBean", requestBean);
       
        try
        {
            new MockValueExpression("#{sessionBean}", TestBean.class).getValue(facesContext.getELContext());
View Full Code Here

     * references if the ProjectStage is not Production.
     */
    public void testIsInValidScopeWithCustomScopes()
    {
        // create scopeBean
        ManagedBeanImpl scopeBean = new ManagedBeanImpl();
        scopeBean.setBeanClass(TestBean.class.getName());
        scopeBean.setName("scopeBean");
        scopeBean.setScope("session");
        runtimeConfig.addManagedBean("scopeBean", scopeBean);
       
        // create sessionBean referencing requestBean
        ManagedBeanImpl sessionBean = new ManagedBeanImpl();
        sessionBean.setBeanClass(TestBean.class.getName());
        sessionBean.setName("sessionBean");
        sessionBean.setScope("#{scopeBean.scope}");
        ManagedPropertyImpl anotherBeanProperty = new ManagedPropertyImpl();
        anotherBeanProperty.setPropertyName("anotherBean");
        anotherBeanProperty.setValue("#{requestBean}");
        sessionBean.addProperty(anotherBeanProperty);
        runtimeConfig.addManagedBean("sessionBean", sessionBean);
       
        // create requestBean
        ManagedBeanImpl requestBean = new ManagedBeanImpl();
        requestBean.setBeanClass(TestBean.class.getName());
        requestBean.setName("requestBean");
        requestBean.setScope("request");
        runtimeConfig.addManagedBean("requestBean", requestBean);
       
        try
        {
            new MockValueExpression("#{sessionBean}", TestBean.class).getValue(facesContext.getELContext());
View Full Code Here

     * This test is to test the view scope, introduced in jsf 2.0.
     */
    public void testIsInValidScopeViewScope()
    {
        // create viewBean referencing requestBean
        ManagedBeanImpl viewBean = new ManagedBeanImpl();
        viewBean.setBeanClass(TestBean.class.getName());
        viewBean.setName("viewBean");
        viewBean.setScope("view");
        ManagedPropertyImpl anotherBeanProperty = new ManagedPropertyImpl();
        anotherBeanProperty.setPropertyName("anotherBean");
        anotherBeanProperty.setValue("#{requestBean}");
        viewBean.addProperty(anotherBeanProperty);
        runtimeConfig.addManagedBean("viewBean", viewBean);
       
        // create requestBean
        ManagedBeanImpl requestBean = new ManagedBeanImpl();
        requestBean.setBeanClass(TestBean.class.getName());
        requestBean.setName("requestBean");
        requestBean.setScope("request");
        runtimeConfig.addManagedBean("requestBean", requestBean);
       
        try
        {
            new MockValueExpression("#{viewBean}", TestBean.class).getValue(facesContext.getELContext());
View Full Code Here

TOP

Related Classes of org.apache.myfaces.config.impl.digester.elements.ManagedBeanImpl

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.