Package org.apache.myfaces.test.mock.resource

Examples of org.apache.myfaces.test.mock.resource.MockSimpleResource


                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here


                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here

                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here

                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here

    }

    public void testGetResource() throws Exception
    {

        Resource resource = new MockSimpleResource(null, "testlib", null,
                "testfile.js", null, _documentRoot);

        URL resourceUrl = resource.getURL();
        assertNotNull("Could not find resource", resourceUrl);
        assertTrue(resourceUrl.toString().endsWith(
                "org/apache/myfaces/test/mock/resources/testlib/testfile.js"));
    }
View Full Code Here

    }

    public void testGetNotExistingResource() throws Exception
    {

        Resource resource = new MockSimpleResource(null, "testlib", null,
                "notexisting.js", null, _documentRoot);

        assertNull(resource.getURL());
    }
View Full Code Here

        assertNull(resource.getURL());
    }

    public void testGetAsStream() throws Exception
    {
        Resource resource = new MockSimpleResource(null, "testlib", null,
                "testfile.js", null, _documentRoot);
        InputStream stream = resource.getInputStream();
        assertNotNull(stream);
        assertTrue(stream.read() != -1);
    }
View Full Code Here

                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here

                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here

                    .getViewDeclarationLanguage(facesContext, view.getViewId());
       
        // ---- first component test - without any special settings ----------------------------
       
        // configure the Resource needed for this test
        MockSimpleResource resource = new MockSimpleResource(null, "testlib", null, "composite.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // get the BeanInfo metadata
        BeanInfo metadata = vdl.getComponentMetadata(facesContext, resource);
       
        // create the component
        UIComponent component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the first component
        assertTrue("The component has to be an UINamingContainer", component instanceof UINamingContainer);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // ---- second component test - from a script ------------------------------------------
       
        MockSimpleResource scriptResource = new MockSimpleResource(null, "testlib", null,
                "org.apache.myfaces.application.MockResourceComponent.groovy",
                null, new File("src/test/resources/org/apache/myfaces/application"));
       
        // install the script resource to the VDL-mock
        vdl.setScriptComponentResource(resource, scriptResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, resource);
       
        // asserts for the second component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, resource, metadata);
       
        // remove the script resource again
        vdl.setScriptComponentResource(resource, null);
       
        // ---- third component test - from libaryName.resourceName.class -----------------------
       
        MockSimpleResource componentResource = new MockSimpleResource(null, "org.apache.myfaces.application",
                null, "MockResourceComponent.xhtml", null,
                new File("src/test/resources/org/apache/myfaces/application"))
        {

            /* (non-javadoc)
             * We have to overwrite getURL() here, because it has to deliver a valid URL and
             * we can't get that out of the library and the resource name we set on this resource.
             */
            @Override
            public URL getURL()
            {
                MockServletContext servletContext
                        = (MockServletContext) FacesContext.getCurrentInstance()
                                .getExternalContext().getContext();
                servletContext.setDocumentRoot(new File("src/test/resources/org/apache/myfaces/application"));
   
                try
                {
                    return servletContext.getResource("/testlib/composite.xhtml");
                }
                catch (MalformedURLException e)
                {
                    return null;
                }
            }
           
        };
       
        // get the BeanInfo metadata
        BeanInfo metadataComponentResource = vdl.getComponentMetadata(facesContext, componentResource);
       
        // create the component
        component = _testApplication.createComponent(facesContext, componentResource);
       
        // asserts for the third component
        assertTrue("The component has to be a MockResourceComponent", component instanceof MockResourceComponent);
        assertRendererTypeResourceBeanInfo(component, componentResource, metadataComponentResource);
       
        // ---- fourth component test - with a custom componentType ------------------------------
       
        // change the resource
        resource = new MockSimpleResource(null, "testlib", null, "compositeWithComponentType.xhtml",
                null, new File("src/test/resources/org/apache/myfaces/application"));
        // FIXME resource.setResourceName(resourceName) did not work
        // this can be changed in the next release of MyFaces test (1.0.0-beta.NEXT)
       
        // register the new component type
View Full Code Here

TOP

Related Classes of org.apache.myfaces.test.mock.resource.MockSimpleResource

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.