Update of 
/var/cvs/speeltuin/ernst/tagfileparser/test/nl/vpro/tagfileparser/parser
In directory 
james.mmbase.org:/tmp/cvs-serv7886/test/nl/vpro/tagfileparser/parser

Modified Files:
        DirectiveParserTest.java 
Log Message:



See also: 
http://cvs.mmbase.org/viewcvs/speeltuin/ernst/tagfileparser/test/nl/vpro/tagfileparser/parser


Index: DirectiveParserTest.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/test/nl/vpro/tagfileparser/parser/DirectiveParserTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- DirectiveParserTest.java    15 Jul 2008 06:54:23 -0000      1.2
+++ DirectiveParserTest.java    30 Sep 2008 11:37:13 -0000      1.3
@@ -1,6 +1,7 @@
 package nl.vpro.tagfileparser.parser;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import nl.vpro.tagfileparser.model.TagInfo;
@@ -10,20 +11,20 @@
 
 public class DirectiveParserTest extends TestCase {
        
-       public void testParser(){
-               String line ="<%@   test foo =    \"bar\"  name= \"disco\" 
hi=\"ho      \" empty=\"\" %>";
+       public void testParser() {
+               String line = "<%@   test foo =    \"bar\"  name= \"disco\" 
hi=\"ho     \" empty=\"\" %>";
                final List<Attribute> attributes = new ArrayList<Attribute>();
                
-               //this is a bit weird, but the boolean has to be 
-               //final, and it is not mutable, so this is a workaround.
-               final Boolean[] found = new Boolean[] {false};
+               // this is a bit weird, but the boolean has to be
+               // final, and it is not mutable, so this is a workaround.
+               final Boolean[] found = new Boolean[] { false };
                DirectiveParser tdp = createParser(attributes, found);
                
-               //now parse the test line
-               List<String>l = new ArrayList<String>();
+               // now parse the test line
+               List<String> l = new ArrayList<String>();
                l.add(line);
-               tdp.parse(l.iterator() , new TagInfo("test"));
-               assertEquals( Boolean.TRUE, found[0]);
+               tdp.parse(l.iterator(), new TagInfo("test"));
+               assertEquals(Boolean.TRUE, found[0]);
                assertEquals(4, attributes.size());
                assertEquals("foo", attributes.get(0).getName());
                assertEquals("name", attributes.get(1).getName());
@@ -37,18 +38,15 @@
        }
        
        /**
-        * This method tests the bug where dash (-) characters are not
-        * valid as part of attribute names
+        * This method tests the bug where dash (-) characters are not valid as 
part
+        * of attribute names
         */
-       public void testDashBug(){
-               String line ="<[EMAIL PROTECTED] name-dash=\"value\" %>";
+       public void testDashBug() {
                final List<Attribute> attributes = new ArrayList<Attribute>();
-               final Boolean[] found = new Boolean[] {false};
+               final Boolean[] found = new Boolean[] { false };
                DirectiveParser tdp = createParser(attributes, found);
-               List<String>l = new ArrayList<String>();
                
-               l.add(line);
-               tdp.parse(l.iterator() , new TagInfo("test"));
+               tdp.parse(Arrays.asList(new String[] { "<[EMAIL PROTECTED] 
name-dash=\"value\" %>" }).iterator(), new TagInfo("test"));
                
                assertEquals(1, attributes.size());
                assertEquals("name-dash", attributes.get(0).getName());
@@ -56,12 +54,27 @@
                
        }
 
-       private DirectiveParser createParser(final List<Attribute> attributes,
-                       final Boolean[] found) {
-               DirectiveParser tdp = new DirectiveParser("test"){
+       /**
+        * When the value of an attribute is has newlines (consists of more 
than one
+        * line, the lines are joined, and the newlines disappear.
+        */
+       public void testNewlineInAttributeBug() {
+               final List<Attribute> attributes = new ArrayList<Attribute>();
+               final Boolean[] found = new Boolean[] { false };
+               DirectiveParser tdp = createParser(attributes, found);
+
+               tdp.parse(Arrays.asList(new String[] { "<[EMAIL PROTECTED] 
name=\"regel een\nregeltwee\" %>" }).iterator(), new TagInfo("test"));
+
+               assertEquals(1, attributes.size());
+               assertEquals("regel een\nregeltwee", 
attributes.get(0).getValue());
+       }
+
+       private DirectiveParser createParser(final List<Attribute> attributes, 
final Boolean[] found) {
+               DirectiveParser tdp = new DirectiveParser("test") {
                        protected void attributeFound(Attribute attribute) {
                                attributes.add(attribute);
                        }
+
                        protected void directiveFound() {
                                found[0] = Boolean.TRUE;
                        }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to