1 30 31 package org.apache.commons.httpclient; 32 33 import junit.framework.*; 34 35 43 public class TestHeaderElement extends TestNVP { 44 45 public TestHeaderElement(String testName) { 47 super(testName); 48 } 49 50 public static void main(String args[]) { 52 String [] testCaseName = { TestHeaderElement.class.getName() }; 53 junit.textui.TestRunner.main(testCaseName); 54 } 55 56 58 public static Test suite() { 59 return new TestSuite(TestHeaderElement.class); 60 } 61 62 64 protected NameValuePair makePair() { 65 return new HeaderElement(); 66 } 67 68 protected NameValuePair makePair(String name, String value) { 69 return new HeaderElement(name,value); 70 } 71 72 73 75 public void testOldMain() throws Exception { 76 String headerValue = "name1 = value1; name2; name3=\"value3\" , name4=value4; " + 78 "name5=value5, name6= ; name7 = value7; name8 = \" value8\""; 79 HeaderElement[] elements = HeaderElement.parse(headerValue); 80 assertEquals(3,elements.length); 82 assertEquals("name1",elements[0].getName()); 84 assertEquals("value1",elements[0].getValue()); 85 assertEquals(2,elements[0].getParameters().length); 87 assertEquals("name2",elements[0].getParameters()[0].getName()); 88 assertTrue(null == elements[0].getParameters()[0].getValue()); 89 assertEquals("name3",elements[0].getParameters()[1].getName()); 90 assertEquals("value3",elements[0].getParameters()[1].getValue()); 91 assertEquals("name4",elements[1].getName()); 93 assertEquals("value4",elements[1].getValue()); 94 assertEquals(1,elements[1].getParameters().length); 96 assertEquals("name5",elements[1].getParameters()[0].getName()); 97 assertEquals("value5",elements[1].getParameters()[0].getValue()); 98 assertEquals("name6",elements[2].getName()); 100 assertTrue(null == elements[2].getValue()); 101 assertEquals(2,elements[2].getParameters().length); 103 assertEquals("name7",elements[2].getParameters()[0].getName()); 104 assertEquals("value7",elements[2].getParameters()[0].getValue()); 105 assertEquals("name8",elements[2].getParameters()[1].getName()); 106 assertEquals(" value8",elements[2].getParameters()[1].getValue()); 107 } 108 } 109 | Popular Tags |