Package com.alibaba.citrus.service.jsp.impl

Examples of com.alibaba.citrus.service.jsp.impl.JspEngineImpl


    public void createEngineDirectly() throws Exception {
        initServlet("webapp/WEB-INF/web.xml");

        // no servletContext
        try {
            new JspEngineImpl(null, null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("servletContext"));
        }

        // no request
        try {
            new JspEngineImpl(servletContext, null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("request"));
        }

        // no response
        try {
            new JspEngineImpl(servletContext, createMock(MockRequestProxy.class), null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("response"));
        }

        // request not a proxy
        try {
            new JspEngineImpl(servletContext, request, response);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("expects a proxy delegating to a real object, but got an object of type "
                    + request.getClass().getName()));
        }

        // response not a proxy
        try {
            new JspEngineImpl(servletContext, createMock(MockRequestProxy.class), response);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("expects a proxy delegating to a real object, but got an object of type "
                    + response.getClass().getName()));

        }

        // no resource loader
        JspEngineImpl engine = new JspEngineImpl(servletContext, createMock(MockRequestProxy.class),
                createMock(MockResponseProxy.class));

        try {
            engine.afterPropertiesSet();
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceLoader"));
        }

        // ok
        engine = new JspEngineImpl(servletContext, createMock(MockRequestProxy.class),
                createMock(MockResponseProxy.class));

        engine.setResourceLoader(createMock(ResourceLoader.class));

        // not inited yet
        try {
            engine.getPathWithinServletContext("/test");
            fail();
        } catch (IllegalStateException e) {
            assertThat(e, exception("has not been initialized yet"));
        }

        engine.afterPropertiesSet();
    }
View Full Code Here


    public void createEngineDirectly() throws Exception {
        initServlet("webapp/WEB-INF/web.xml");

        // no servletContext
        try {
            new JspEngineImpl(null, null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("servletContext"));
        }

        // no request
        try {
            new JspEngineImpl(servletContext, null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("request"));
        }

        // no response
        try {
            new JspEngineImpl(servletContext, createMock(MockRequestProxy.class), null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("response"));
        }

        // request not a proxy
        try {
            new JspEngineImpl(servletContext, request, response);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("expects a proxy delegating to a real object, but got an object of type "
                                    + request.getClass().getName()));
        }

        // response not a proxy
        try {
            new JspEngineImpl(servletContext, createMock(MockRequestProxy.class), response);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("expects a proxy delegating to a real object, but got an object of type "
                                    + response.getClass().getName()));
        }

        // no resource loader
        JspEngineImpl engine = new JspEngineImpl(servletContext, createMock(MockRequestProxy.class),
                                                 createMock(MockResponseProxy.class));

        try {
            engine.afterPropertiesSet();
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceLoader"));
        }

        // ok
        engine = new JspEngineImpl(servletContext, createMock(MockRequestProxy.class),
                                   createMock(MockResponseProxy.class));

        engine.setResourceLoader(createMock(ResourceLoader.class));

        // not inited yet
        try {
            engine.getPathWithinServletContext("/test");
            fail();
        } catch (IllegalStateException e) {
            assertThat(e, exception("has not been initialized yet"));
        }

        engine.afterPropertiesSet();
    }
View Full Code Here

    public void createEngineDirectly() throws Exception {
        initServlet("webapp/WEB-INF/web.xml");

        // no servletContext
        try {
            new JspEngineImpl(null, null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("servletContext"));
        }

        // no request
        try {
            new JspEngineImpl(servletContext, null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("request"));
        }

        // no response
        try {
            new JspEngineImpl(servletContext, createMock(MockRequestProxy.class), null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("response"));
        }

        // request not a proxy
        try {
            new JspEngineImpl(servletContext, request, response);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("expects a proxy delegating to a real object, but got an object of type "
                                    + request.getClass().getName()));
        }

        // response not a proxy
        try {
            new JspEngineImpl(servletContext, createMock(MockRequestProxy.class), response);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("expects a proxy delegating to a real object, but got an object of type "
                                    + response.getClass().getName()));
        }

        // no resource loader
        JspEngineImpl engine = new JspEngineImpl(servletContext, createMock(MockRequestProxy.class),
                                                 createMock(MockResponseProxy.class));

        try {
            engine.afterPropertiesSet();
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceLoader"));
        }

        // ok
        engine = new JspEngineImpl(servletContext, createMock(MockRequestProxy.class),
                                   createMock(MockResponseProxy.class));

        engine.setResourceLoader(createMock(ResourceLoader.class));

        // not inited yet
        try {
            engine.getPathWithinServletContext("/test");
            fail();
        } catch (IllegalStateException e) {
            assertThat(e, exception("has not been initialized yet"));
        }

        engine.afterPropertiesSet();
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.jsp.impl.JspEngineImpl

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.