@Test public void testNVParseUsingCursor(){
  HeaderValueParser parser=BasicHeaderValueParser.DEFAULT;
  String s="test";
  CharArrayBuffer buffer=new CharArrayBuffer(16);
  buffer.append(s);
  ParserCursor cursor=new ParserCursor(0,s.length());
  NameValuePair param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals(null,param.getValue());
  Assert.assertEquals(s.length(),cursor.getPos());
  Assert.assertTrue(cursor.atEnd());
  s="test;";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals(null,param.getValue());
  Assert.assertEquals(s.length(),cursor.getPos());
  Assert.assertTrue(cursor.atEnd());
  s="test  ,12";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals(null,param.getValue());
  Assert.assertEquals(s.length() - 2,cursor.getPos());
  Assert.assertFalse(cursor.atEnd());
  s="test=stuff";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals("stuff",param.getValue());
  Assert.assertEquals(s.length(),cursor.getPos());
  Assert.assertTrue(cursor.atEnd());
  s="   test  =   stuff ";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals("stuff",param.getValue());
  Assert.assertEquals(s.length(),cursor.getPos());
  Assert.assertTrue(cursor.atEnd());
  s="   test  =   stuff ;1234";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals("stuff",param.getValue());
  Assert.assertEquals(s.length() - 4,cursor.getPos());
  Assert.assertFalse(cursor.atEnd());
  s="test  = \"stuff\"";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals("stuff",param.getValue());
  s="test  = \"  stuff\\\"\"";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals("  stuff\\\"",param.getValue());
  s="  test";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("test",param.getName());
  Assert.assertEquals(null,param.getValue());
  s="  ";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("",param.getName());
  Assert.assertEquals(null,param.getValue());
  s=" = stuff ";
  buffer=new CharArrayBuffer(16);
  buffer.append(s);
  cursor=new ParserCursor(0,s.length());
  param=parser.parseNameValuePair(buffer,cursor);
  Assert.assertEquals("",param.getName());
  Assert.assertEquals("stuff",param.getValue());
}
