/**
* Test that jsessionids in url are added to the string table
*/
public void testAddAttributeValue() throws Exception {
TestWBSAXContentHandler contentHandler = new TestWBSAXContentHandler();
URLOptimiser optimiser = new URLOptimiser(contentHandler);
// Start the document
VersionCode versionCode = VersionCode.V1_1;
PublicIdCode publicIdCode = PublicIdFactory.WML_1_1;
Codec codec = new Codec(new CharsetCode(4, "iso-8859-1"));
StringFactory strings = new StringFactory(codec);
StringTable stringTable = new StringTable();
optimiser.setPageContext(getPageContext());
optimiser.startDocument(versionCode, publicIdCode, codec, stringTable,
strings);
// Send a href event to optimiser
AttributeStartFactory attributeStartFactory = new AttributeStartFactory();
TokenTable tokenTable = new WMLVersion1_1TokenTable();
tokenTable.registerAttrStarts(attributeStartFactory);
AttributeStartCode hrefStartCode
= attributeStartFactory.create("href", null);
optimiser.addAttribute(hrefStartCode);
// send url to optimiser
optimiser.addAttributeValue(new WBSAXString(codec,
"http://www.my.com/page.jsp;jsessionid=123?parm=value#ref"));
// Send a title event to optimiser
AttributeStartCode titleStartCode
= attributeStartFactory.create("title", null);
optimiser.addAttribute(titleStartCode);
// Send the value of the title to optimiser
optimiser.addAttributeValue(new WBSAXString(codec, "my title"));
// Send another href to optimiser
optimiser.addAttribute(hrefStartCode);
// send url to optimiser
optimiser.addAttributeValue(new WBSAXString(codec,
"http://www.my.com/page2.jsp;jsessionid=123?parm=value#ref2"));
// Get the events
Iterator events = contentHandler.getEvents();
// Check startDocument
assertEquals("Wrong versionCode", versionCode,
(VersionCode)events.next());
assertEquals("Wrong publicIdCode", publicIdCode,