assertNotNull(mapProducers);
assertEquals(0, mapProducers.size());
}
public void testFindMapProducer() {
GetMapProducer mockProducer = createMock(GetMapProducer.class);
ApplicationContext mockContext = EasyMock.createMock(ApplicationContext.class);
// I'm not so pleasant with this block of code as it implies knowing how
// the internals of GeoServerExtensions work
expect(mockContext.getBeanNamesForType(ExtensionFilter.class)).andReturn(new String[0]);
expect(mockContext.getBeanNamesForType(GetMapProducer.class)).andReturn(
new String[] { "producer1" }); // call#1
expect(mockContext.getBean("producer1")).andReturn(mockProducer); // call#1
expect(mockContext.getBeanNamesForType(ExtensionFilter.class)).andReturn(new String[0]);
expect(mockContext.getBeanNamesForType(GetMapProducer.class)).andReturn(
new String[] { "producer1" }); // call#2
expect(mockContext.getBean("producer1")).andReturn(mockProducer); // call#2
// end of unpleasant block
Set<String> testFormatNames = new HashSet<String>();
testFormatNames.add("image/fakeformat");
testFormatNames.add("image/dummy");
expect(mockProducer.getOutputFormatNames()).andReturn(testFormatNames);// call#1
expect(mockProducer.getOutputFormatNames()).andReturn(testFormatNames);// call#2
replay(mockContext);
replay(mockProducer);
// note the lookup shall be case insensitive..
GetMapProducer producer;
producer = WMSExtensions.findMapProducer("ImaGe/FaKeForMat", mockContext);// call#1
assertSame(mockProducer, producer);
producer = WMSExtensions.findMapProducer("notARegisteredFormat", mockContext);// call#2
assertNull(producer);