Package org.apache.velocity.context

Examples of org.apache.velocity.context.InternalContextAdapter


     */
    @Test
    public void testEnd() {
        HttpServletRequest request = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        InternalContextAdapter velocityContext = createMock(InternalContextAdapter.class);
        Writer writer = createMock(Writer.class);
        ServletContext servletContext = createMock(ServletContext.class);
        Map<String, Object> params = createParams();
        MutableTilesContainer container = createMock(MutableTilesContainer.class);
        ArrayStack<Object> composeStack = new ArrayStack<Object>();
View Full Code Here


     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRenderAttribute() throws IOException {
        TilesContainer container = createMock(TilesContainer.class);
        InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        StringWriter writer = new StringWriter();
        Attribute attribute = new Attribute("myValue");

        Map<String, Object> requestScope = new HashMap<String, Object>();
View Full Code Here

     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRenderDefinition() throws IOException {
        TilesContainer container = createMock(TilesContainer.class);
        InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        StringWriter writer = new StringWriter();

        Map<String, Object> requestScope = new HashMap<String, Object>();
        Map<String, Object> applicationScope = new HashMap<String, Object>();
View Full Code Here

     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRenderAttributeContext() throws IOException {
        TilesContainer container = createMock(TilesContainer.class);
        InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        StringWriter writer = new StringWriter();

        Map<String, Object> requestScope = new HashMap<String, Object>();
        Map<String, Object> applicationScope = new HashMap<String, Object>();
View Full Code Here

import org.junit.Test;

public class VelocityAutotagRuntimeTest {
    @Test
    public void testCreateRequest() {
        InternalContextAdapter context = createMock(InternalContextAdapter.class);
        Writer writer = createMock(Writer.class);
        Node node = createMock(Node.class);
        ViewToolContext viewContext = createMock(ViewToolContext.class);
        HttpServletRequest request = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        ServletContext servletContext = createMock(ServletContext.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        expect(context.getInternalUserContext()).andReturn(viewContext);
        expect(viewContext.getRequest()).andReturn(request);
        expect(viewContext.getResponse()).andReturn(response);
        expect(viewContext.getServletContext()).andReturn(servletContext);
        expect(servletContext.getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(applicationContext);
View Full Code Here

        verify(context, writer, node, viewContext, request, response, servletContext, applicationContext);
    }

    @Test
    public void testCreateModelBody() {
        InternalContextAdapter context = createMock(InternalContextAdapter.class);
        Writer writer = createMock(Writer.class);
        Node node = createMock(Node.class);
        ASTBlock block = createMock(ASTBlock.class);
        expect(node.jjtGetChild(1)).andReturn(block);
        replay(context, writer, node, block);
View Full Code Here

        verify(context, writer, node, block);
    }

    @Test
    public void testGetParameter() {
        InternalContextAdapter context = createMock(InternalContextAdapter.class);
        Writer writer = createMock(Writer.class);
        Node node = createMock(Node.class);
        ASTMap astMap = createMock(ASTMap.class);
        @SuppressWarnings("unchecked")
        Map<String, Object> params = createMock(Map.class);
View Full Code Here

                    /*
                     *  init.  be a good citizen and give it an ICA
                     */

                    InternalContextAdapter ica
                            = new InternalContextAdapterImpl(new VelocityContext());

                    ica.pushCurrentTemplateName("VMProxyArg : "
                            + ParserTreeConstants.jjtNodeName[type]);

                    nodeTree.init(ica, rsvc);
                }
                catch ( Exception e )
View Full Code Here

         * to prevent any changes to the current context.
         */
       
        if (nodeTree != null)
        {
            InternalContextAdapter ica = new EvaluateContext(context, rsvc);

            ica.pushCurrentTemplateName( templateName );

            try
            {
                try
                {
                    nodeTree.init( ica, rsvc );
                }
                catch (TemplateInitException pex)
                {
                    Info info = new Info( templateName, node.getLine(), node.getColumn() );
                    throw  new ParseErrorException( pex.getMessage(), info );
                }

                try
                {
                    preRender(ica);

                    /*
                     *  now render, and let any exceptions fly
                     */
                    nodeTree.render( ica, writer );
                }
                catch (StopCommand stop)
                {
                    if (!stop.isFor(this))
                    {
                        throw stop;
                    }
                    else if (Logger.isDebugEnabled(this.getClass()))
                    {
                        Logger.debug(this,stop.getMessage());
                    }
                }
                catch (ParseErrorException pex)
                {
                    // convert any parsing errors to the correct line/col
                    Info info = new Info( templateName, node.getLine(), node.getColumn() );
                    throw  new ParseErrorException( pex.getMessage(), info );
                }
            }
            finally
            {
                ica.popCurrentTemplateName();
                postRender(ica);
            }
            return true;
        }

View Full Code Here

   
   
    private static void velocityLogError(Class cl){
      if(velocityCtx.get() != null){
        Context ctx =  velocityCtx.get();
        InternalContextAdapter ica =  new InternalContextAdapterImpl(ctx);
        com.dotcms.repackage.org.apache.log4j.Logger logger = map.get(VelocityServlet.class);
        logger.error("#--------------------------------------------------------------------------------------");
        logger.error("#");
        if(ica.getCurrentMacroName() != null){
          logger.error("# Velocity Error");
        }

        if(ctx.get("VTLSERVLET_URI") != null && ctx.get("host") != null ){
          logger.error("# on url      : " + ((Host) ctx.get("host")).getHostname()  + ctx.get("VTLSERVLET_URI") );
        }
        else if(ctx.get("VTLSERVLET_URI") != null ){
          logger.error("# on uri      : " + ctx.get("VTLSERVLET_URI") );
        }
        else if(ctx.get("host") != null){
          logger.error("# on host     : " + ((Host) ctx.get("host")).getHostname() );
        }
        if(ctx.get("request") != null){
          HttpServletRequest req  = (HttpServletRequest)ctx.get("request");
          if(req.getAttribute("javax.servlet.forward.request_uri") != null){
            logger.error("# on req      : " + req.getAttribute("javax.servlet.forward.request_uri") );
          }
         
         }
        if(ica.getCurrentMacroName() != null){
          logger.error("# with macro  : #" + ica.getCurrentMacroName());
        }
        if(ica.getCurrentTemplateName() != null){
          logger.error("# on template : " + normalizeTemplate(ica.getCurrentTemplateName()));
        }
        logger.error("#    stack:");
        for(Object obj : ica.getTemplateNameStack()){
        logger.error("#    -- " + normalizeTemplate(obj));
        }
        logger.error("#");
        logger.error("#--------------------------------------------------------------------------------------");
      }
View Full Code Here

TOP

Related Classes of org.apache.velocity.context.InternalContextAdapter

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.