// 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,
(PublicIdCode)events.next());
assertEquals("Wrong codec", codec, (Codec)events.next());
// Skip past the StringTable created by the optimiser
assertTrue("StringTable should be next",
events.next() instanceof StringTable);
// Check href
AttributeStartCode aStartCode = (AttributeStartCode)events.next();
assertEquals("Wrong AttributeStartCode integer", 0x4A,
aStartCode.getInteger());
assertEquals("Wrong AttributeStartCode name", "href",
aStartCode.getName());
assertNull("Wrong AttributeStartCode value prefix",
aStartCode.getValuePrefix());
// Check prefix
assertEquals("Wrong url prefix",
new WBSAXString(codec, "http://www.my.com/page.jsp"),
(WBSAXString)events.next());
// Check jsessionid
StringReference stringReference1 = (StringReference)events.next();
assertEquals("Wrong url jsessionid",
new WBSAXString(codec, ";jsessionid=123"),
stringReference1.resolveString());
// Check suffix
assertEquals("Wrong url suffix",
new WBSAXString(codec, "?parm=value#ref"),
(WBSAXString)events.next());
// Check title
aStartCode = (AttributeStartCode)events.next();
assertEquals("Wrong AttributeStartCode integer", 0x36,
aStartCode.getInteger());
assertEquals("Wrong AttributeStartCode name", "title",
aStartCode.getName());
assertNull("Wrong AttributeStartCode value prefix",
aStartCode.getValuePrefix());
// Check title's value
assertEquals("Wrong title",
new WBSAXString(codec, "my title"),
(WBSAXString)events.next());
// Check href
aStartCode = (AttributeStartCode)events.next();
assertEquals("Wrong AttributeStartCode integer", 0x4A,
aStartCode.getInteger());
assertEquals("Wrong AttributeStartCode name", "href",
aStartCode.getName());
assertNull("Wrong AttributeStartCode value prefix",
aStartCode.getValuePrefix());
// Check prefix
assertEquals("Wrong url prefix",
new WBSAXString(codec, "http://www.my.com/page2.jsp"),
(WBSAXString)events.next());