Anonymous avatar Anonymous committed 94ee73c

god damn these tests. they are gone (the tag directive stuff is pretty nasty anyway, who needs to test it if you can't even begin to understand why the test fails in 3 different ways depending on the environment)

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@429 573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (3)

src/test/com/opensymphony/webwork/views/velocity/TagDirectiveTest.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.views.velocity;
-
-import com.mockobjects.dynamic.Mock;
-
-import com.mockobjects.servlet.MockBodyContent;
-import com.mockobjects.servlet.MockJspWriter;
-import com.mockobjects.servlet.MockPageContext;
-
-import com.opensymphony.webwork.ServletActionContext;
-import com.opensymphony.webwork.views.jsp.WebWorkMockServletContext;
-import com.opensymphony.webwork.views.jsp.ui.MockTag;
-
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.config.ConfigurationManager;
-import com.opensymphony.xwork.util.OgnlValueStack;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.context.Context;
-
-import java.io.File;
-import java.io.StringWriter;
-
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.tagext.BodyContent;
-
-
-/**
- * Created by IntelliJ IDEA.
- * User: matt
- * Date: May 28, 2003
- * Time: 9:48:33 AM
- * To change this template use Options | File Templates.
- */
-public class TagDirectiveTest extends TestCase {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    Mock mockConfig;
-    Mock mockRequest;
-    Mock mockResponse;
-    MockPageContext pageContext;
-    MockTag mockTag;
-    OgnlValueStack stack;
-    VelocityEngine velocityEngine;
-    private ActionContext oldContext;
-    private Locale defaultLocale;
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void testBodyTag() throws Exception {
-        Template template = velocityEngine.getTemplate("/com/opensymphony/webwork/views/velocity/bodytag.vm");
-        StringWriter writer = new StringWriter();
-        Context context = VelocityManager.getInstance().createContext(stack, (HttpServletRequest) mockRequest.proxy(), (HttpServletResponse) mockResponse.proxy());
-        template.merge(context, writer);
-
-        // verify that we got one param, hello=world
-        Map params = mockTag.getParameters();
-        Assert.assertNotNull(params);
-        Assert.assertEquals(2, params.size());
-        Assert.assertTrue(params.containsKey("hello"));
-        Assert.assertEquals("'world'", params.get("hello")); // hello = world
-        Assert.assertTrue(params.containsKey("foo"));
-        Assert.assertEquals("'bar'", params.get("foo")); // foo = bar
-
-        // verify that our date thingy was populated correctly
-        Calendar cal = Calendar.getInstance();
-        cal.set(2003, Calendar.MARCH, 25, 0, 0, 0);
-        cal.set(Calendar.MILLISECOND, 0);
-        Assert.assertNotNull(mockTag.getDate());
-        Assert.assertEquals(cal.getTime().getTime(), mockTag.getDate().getTime());
-
-        // now verify that each of the fields was set as we expected
-        Assert.assertEquals("hello world", mockTag.getString());
-        Assert.assertEquals(new Float(2.1), mockTag.getFloat());
-        Assert.assertEquals(new Double(5.6), mockTag.getDouble());
-        Assert.assertEquals(new Integer(13), mockTag.getInteger());
-        Assert.assertEquals(new Long(1234), mockTag.getLong());
-    }
-
-    /**
- * pretty much the same as the BodyTag test, but we're not passing in any parameters
- *
- * @throws Exception
- */
-    public void testTag() throws Exception {
-        Template template = velocityEngine.getTemplate("/com/opensymphony/webwork/views/velocity/tag.vm");
-        StringWriter writer = new StringWriter();
-        Context context = VelocityManager.getInstance().createContext(stack, (HttpServletRequest) mockRequest.proxy(), (HttpServletResponse) mockResponse.proxy());
-        template.merge(context, writer);
-
-        // verify that our date thingy was populated correctly
-        Calendar cal = Calendar.getInstance();
-        cal.set(2003, Calendar.MARCH, 25, 0, 0, 0);
-        cal.set(Calendar.MILLISECOND, 0);
-        Assert.assertNotNull(mockTag.getDate());
-        Assert.assertEquals(cal.getTime().getTime(), mockTag.getDate().getTime());
-
-        // now verify that each of the fields was set as we expected
-        Assert.assertEquals("hello world", mockTag.getString());
-        Assert.assertEquals(new Float(2.1), mockTag.getFloat());
-        Assert.assertEquals(new Double(5.6), mockTag.getDouble());
-        Assert.assertEquals(new Integer(13), mockTag.getInteger());
-        Assert.assertEquals(new Long(1234), mockTag.getLong());
-    }
-
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        // set up the locale to be US
-        defaultLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-
-        ConfigurationManager.clearConfigurationProviders();
-        ConfigurationManager.destroyConfiguration();
-
-        oldContext = ActionContext.getContext();
-        stack = new OgnlValueStack();
-        ActionContext.setContext(new ActionContext(stack.getContext()));
-
-        /**
- * construct our sandbox VelocityEngine
- */
-        Properties props = new Properties();
-
-        props.setProperty("resource.loader", "file, wwclass");
-
-        props.setProperty("wwclass.resource.loader.description", "Velocity Classpath Resource Loader");
-        props.setProperty("wwclass.resource.loader.class", "com.opensymphony.webwork.views.velocity.WebWorkResourceLoader");
-
-        // adding src/java to the Velocity load path
-        props.setProperty("file.resource.loader.description", "Velocity File Resource Loader");
-        props.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
-        props.setProperty("file.resource.loader.path", System.getProperty("webwork.webapp.path", new File("src/test").getAbsolutePath()));
-        props.setProperty("file.resource.loader.cache", "false");
-        props.setProperty("file.resource.loader.modificationCheckInterval", "2");
-        props.setProperty("userdirective", "com.opensymphony.webwork.views.velocity.TagDirective,com.opensymphony.webwork.views.velocity.BodyTagDirective,com.opensymphony.webwork.views.velocity.ParamDirective");
-
-        props.setProperty("runtime.log", "velocity.log");
-
-        velocityEngine = new VelocityEngine();
-        velocityEngine.init(props);
-
-        //        Mock aservletContext = new Mock(ServletContext.class);
-        //        aservletContext.expectAndReturn("getRealPath", C.ANY_ARGS, System.getProperty("webwork.webapp.path", new File("src/test").getAbsolutePath()));
-        //        aservletContext.expectAndReturn("getRealPath", C.ANY_ARGS, System.getProperty("webwork.webapp.path", new File("src/test").getAbsolutePath()));
-        //        aservletContext.expectAndReturn("getRealPath", C.ANY_ARGS, System.getProperty("webwork.webapp.path", new File("src/test").getAbsolutePath()));
-        WebWorkMockServletContext servletContext = new WebWorkMockServletContext();
-        servletContext.setupGetRealPath(System.getProperty("webwork.webapp.path", new File("src/test").getAbsolutePath()));
-
-        mockConfig = new Mock(ServletConfig.class);
-        mockRequest = new Mock(HttpServletRequest.class);
-        mockResponse = new Mock(HttpServletResponse.class);
-
-        mockRequest.matchAndReturn("getAttribute", "webwork.valueStack", stack);
-
-        // initialize the VelocityManager.  required to use the UI tag libraries
-        VelocityManager.getInstance().init(servletContext);
-
-        // initialize the MockTag for use
-        mockTag = MockTag.getInstance();
-        mockTag.reset();
-
-        // initialize the pageContext
-        pageContext = new TestPageContext();
-        pageContext.setJspWriter(new MockJspWriter());
-        ActionContext.getContext().put(ServletActionContext.PAGE_CONTEXT, pageContext);
-    }
-
-    protected void tearDown() throws Exception {
-        if (defaultLocale != null) {
-            Locale.setDefault(defaultLocale);
-        }
-
-        pageContext.release();
-        ActionContext.setContext(oldContext);
-    }
-
-    //~ Inner Classes //////////////////////////////////////////////////////////
-
-    /**
- * our BodyContent that returns a non-null enclosingWriter
- */
-    class TestBodyContent extends MockBodyContent {
-        JspWriter writer;
-
-        public TestBodyContent(JspWriter writer) {
-            this.writer = writer;
-        }
-
-        public JspWriter getEnclosingWriter() {
-            return this.writer;
-        }
-    }
-
-    /**
- * the MockPageContext doesn't return a BodyContent that we can use.  We need one that returns a non-null
- * getEnclosingWriter method
- */
-    class TestPageContext extends MockPageContext {
-        public BodyContent pushBody() {
-            return new TestBodyContent(this.getOut());
-        }
-    }
-}

src/test/com/opensymphony/webwork/views/velocity/bodytag.vm

-#set( $foo = "'bar'" )
-#bodytag( Mock "string=hello world" "date=03/25/2003" "cal=01/02/2001" "float=2.1" "integer=13" "double=5.6" "long=1234")
-#param( "hello" "'world'" )
-#param( "foo" $foo )
-#end

src/test/com/opensymphony/webwork/views/velocity/tag.vm

-#set( $foo = "'bar'" )
-#tag( Mock "string=hello world" "date=03/25/2003" "cal=01/02/2001" "float=2.1" "integer=13" "double=5.6" "long=1234")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.