// =====================================================================
// Create Mocks
// =====================================================================
WebRequestCookie cookie = new WebRequestCookie();
HTTPMessageEntities entities = new SimpleHTTPMessageEntities();
// =====================================================================
// Set Expectations
// =====================================================================
expectAddSimpleElementProcess(cookie);
entityFactoryMock.expects.createCookie().returns(cookie);
contextMock.expects.getProperty(WebRequestCookie.class)
.returns(entities);
// =====================================================================
// Test Expectations
// =====================================================================
addAttribute("name", name);
addAttribute("value", value);
addAttribute("from", from);
addAttribute("comment", comment);
addAttribute("domain", domain);
addAttribute("maxAge", Integer.toString(maxAge));
addAttribute("path", path);
addAttribute("secure", "" + secure);
addAttribute("version", version.getName());
DynamicElementRule rule = new CookieRule(entityFactoryMock);
XMLProcess process = (XMLProcess) rule.startElement(dynamicProcessMock,
elementName, attributes);
dynamicProcessMock.expects.removeProcess(process);
rule.endElement(dynamicProcessMock, elementName, process);
assertNotNull(cookie);
assertEquals("Name should match", name,
cookie.getName());
assertEquals("Value should match", value,
cookie.getValue());
assertEquals("From should match", from,
cookie.getFrom());
assertEquals("Comment should match", comment,
cookie.getComment());
assertEquals("Domain should match", domain,
cookie.getDomain());
assertEquals("MaxAge should match", maxAge,
cookie.getMaxAge());
assertEquals("Path should match", path,
cookie.getPath());
assertEquals("Secure should match", secure,
cookie.isSecure());
// returns an int
assertEquals("Version should match", version,
cookie.getVersion());
}