On Tue, Apr 22, 2014 at 9:25 AM, Jody Garnett <[email protected]>wrote:

> 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);
>

I'm against having testing code creep into the normal API so explicitly.
Can we have a helper object that resides in testing packages that does
that, without pulluting GeoServerExtension
directly?

Cheers
Andrea


-- 
==
Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.
==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39  339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------
------------------------------------------------------------------------------
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

Reply via email to