Opened 8 years ago

Last modified 8 years ago

#15508 closed enhancement

[PATCH] add TileSourceRule, use in MinimapDialogTest — at Initial Version

Reported by: ris Owned by: team
Priority: normal Milestone: 17.11
Component: Unit tests Version: latest
Keywords: wiremock unit tests tile imagery minimap Cc: michael2402

Description

This isn't quite finished (missing some commenting and doc strings for some public methods etc) but I felt I should share a bit of what I'm up to.

The attached patches add a subclass of WireMockRule which will provide a mock tile server for use by tests. It also has the ability to add these as tile sources to the ImageryLayerInfo list.

This rule can either be used on its own on a test if access from the ImageryLayerInfo list isn't needed or can be added to a JOSMTestRules using a new .fakeImagery() method. In the latter case, the rule will automagically replace the ImageryLayerInfo list with its list of sources at the appropriate time in the initialization routine (and also perform a small hack to remove SlippyMapBBoxChooser's helpful-but-also-untestable default fallback osm tile source).

Or if .fakeImagery() call is added without any arguments it will simply add a default selection of useful tile sources.

A slight hack is required to mitigate a possible bug in WireMock (https://github.com/tomakehurst/wiremock/issues/97) which causes belated startup of a WireMock server, resulting in connection errors if this is not accounted for. I've tried to make this less severe by splitting TileSourceRule's apply() method in two, separately callable, apply() methods. This is taken advantage of in JOSMTestRule's apply() method, with the intention of beginning the server startup process early in the initialization routine leaving the test having to wait as long before it can reliably start its work. Even so, I've had to put a 3500ms wait in the test to get it to work reliably on my system, which I'm not that happy about.

As an example use of this rule, I've added a test of SlippyMapBBoxChooser's source-switching functionality (through the MinimapDialog as its host in this case).

I probably have more to say about this but it's 1am.

Will post the patches in a second, but the changes can also be seen through the prettier github interface:

https://github.com/risicle/josm/compare/82656d49c282fa8202af2164e1b0d730ce907f16...ris-tilesourcerule

(patches are against r13064)

Change History (4)

Note: See TracTickets for help on using tickets.