In a review of pull request 568 Kevin asked me to look at making
GeoServerExtensions easier to use with mock objects.
It is currently not too bad to use with an mock ApplicationContext:
GeoServerResourceLoader resourceLoader = new
GeoServerResourceLoader(baseDirectory);
ApplicationContext context =
createNiceMock(ApplicationContext.class);
expect(context.getBean("catalog")).andReturn(cat).anyTimes();
expect(context.getBean("resourceLoader")).andReturn( resourceLoader
);
expect(context.getBeanNamesForType(GeoServerResourceLoader.class)).andReturn(new
String[]{"resourceLoader"}).anyTimes();
expect(context.getBeanNamesForType((Class)anyObject())).andReturn(new
String[]{}).anyTimes();
replay(context);
The downside is hooking it up:
new GeoServerExtensions().setApplicationContext( context );
I have added two static methods on pull request 568:
GeoServerExtensions.mock( context );
GeoServerExtensions.mock("resourceLoader", resourceLoader);
This covers Kevin's request of making this easier for test cases.
These methods set an internal isMock field that is used to suppress
warnings from checkContext - resulting in smaller output from our test
cases. We may also be able to suppress some of the catalog created /
destroyed information messages during testing as they are not adding value.
--
Jody Garnett
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel