* Test: Cache properties with set all attributes can be found on
* the stack, but cache with those attributes does not exist.
*/
public void testAttributesOK() throws Exception {
DynamicElementRule rule = new CacheBodyRule();
XMLPipeline pipeline = new XMLPipelineProcessImpl(contextMock);
final String cacheName = "cache406";
final String cacheKeyValue = "cacheKey406";
//Create and set attributes for CacheProperties instance
CacheKey cacheKey = new CacheKey();
cacheKey.addKey(cacheKeyValue);
CacheControl cacheControl = new CacheControl();
cacheControl.setTimeToLive(CacheControlRule.calculateTimeToLive("997"));
CacheProperties properties = new CacheProperties();
properties.setCacheControl(cacheControl);
properties.setCacheKey(cacheKey);
properties.setCacheName(cacheName);
// Prepare mocks for startElement method
contextMock.expects.findObject(CacheProperties.class).
returns(properties).any();
final DependencyContextMock dependencyContextMock =
new DependencyContextMock("dependencyContextMock", expectations);
contextMock.expects.getDependencyContext().returns(
dependencyContextMock).any();
// VBM:2006120611 - using Mocks can be fragile. Needed to add new mock
// and expectation to get this test to pass again.
final XMLPipelineConfigurationMock pipelineConfigurationMock =
new XMLPipelineConfigurationMock("pipelineConfigurationMock",
expectations);
pipelineConfigurationMock.expects.retrieveConfiguration(
CacheProcessConfiguration.class).returns(
new CacheProcessConfiguration() {
{
createCache(cacheName, "100", "0");
}
});
contextMock.expects.getPipelineConfiguration()
.returns(pipelineConfigurationMock);
dynamicProcessMock.expects.getPipeline().returns(pipeline);
dynamicProcessMock.fuzzy.addProcess(mockFactory.
expectsInstanceOf(CacheBodyOperationProcess.class));
//startElement
EndElementAction action = (EndElementAction) rule.
startElement(dynamicProcessMock, elementName, attributes);
assertNotNull(action);
assertNotEquals(action, EndElementAction.DO_NOTHING);
//Prepare mocks for endElement method
dynamicProcessMock.expects.removeProcess().
returns(new XMLPipelineProcessImpl(contextMock));
//endElement
rule.endElement(dynamicProcessMock, elementName, action);
}