﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
15508	[PATCH] add TileSourceRule, use in MinimapDialogTest	ris	team	"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 when applied to a junit test will provide a (limited) mock tile server. 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 hardcoded 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)"	enhancement	new	minor		Unit tests	latest		wiremock unit tests tile imagery minimap	
