GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / web / org / codehaus / groovy / grails / web / taglib / GroovyCollectTagTests.java
blob35697d04a1e3512ea4fcceb5e7d566f770a52f77
1 /**
2 *
3 */
4 package org.codehaus.groovy.grails.web.taglib;
6 import java.io.PrintWriter;
7 import java.io.StringWriter;
8 import java.util.HashMap;
9 import java.util.Map;
11 import org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException;
13 import junit.framework.TestCase;
15 /**
16 * @author graemerocher
19 public class GroovyCollectTagTests extends TestCase {
21 private GroovyCollectTag tag;
22 private StringWriter sw;
24 /* (non-Javadoc)
25 * @see junit.framework.TestCase#setUp()
27 protected void setUp() throws Exception {
28 super.setUp();
29 sw = new StringWriter();
30 tag = new GroovyCollectTag();
31 tag.setWriter(new PrintWriter(sw));
35 protected void tearDown() throws Exception
37 tag = null;
38 sw = null;
39 super.tearDown();
42 /**
43 * Test method for {@link org.codehaus.groovy.grails.web.taglib.GroovyCollectTag#isBufferWhiteSpace()}.
45 public void testIsBufferWhiteSpace() {
46 assertFalse(tag.isBufferWhiteSpace());
49 /**
50 * Test method for {@link org.codehaus.groovy.grails.web.taglib.GroovyCollectTag#hasPrecedingContent()}.
52 public void testHasPrecedingContent() {
53 assertTrue(tag.hasPrecedingContent());
56 /**
57 * Test method for {@link org.codehaus.groovy.grails.web.taglib.GroovyCollectTag#doStartTag()}.
59 public void testDoStartTag() {
60 Map attrs = new HashMap();
62 try {
63 tag.doStartTag();
64 fail("can't create this tag with no [in] and [expr] attributes");
65 } catch (GrailsTagException e) {
66 // expected
68 attrs.put("\"in\"", "myObj");
69 attrs.put("\"expr\"", " ${ it.name }");
70 tag.setAttributes(attrs);
71 assertFalse(tag.attributes.isEmpty());
72 tag.doStartTag();
73 assertEquals("myObj.collect {it.name}.each { " + System.getProperty("line.separator"),sw.toString());