Improve code / xml formatting, closes #54
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package org.oscim.tiling.source.bitmap;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
@@ -13,66 +11,68 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.UrlTileDataSource;
|
||||
import org.oscim.tiling.source.UrlTileSource;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
public class BitmapTileSourceTest {
|
||||
private BitmapTileSource tileSource;
|
||||
private BitmapTileSource tileSource;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tileSource = new BitmapTileSource("http://tile.openstreetmap.org", 0, 18);
|
||||
}
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tileSource = new BitmapTileSource("http://tile.openstreetmap.org", 0, 18);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotBeNull() throws Exception {
|
||||
assertThat(tileSource).isNotNull();
|
||||
}
|
||||
@Test
|
||||
public void shouldNotBeNull() throws Exception {
|
||||
assertThat(tileSource).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseLwHttp() throws Exception {
|
||||
LwHttp lwHttp = Mockito.mock(LwHttp.class);
|
||||
tileSource.setHttpEngine(new TestHttpFactory(lwHttp));
|
||||
ITileDataSource dataSource = tileSource.getDataSource();
|
||||
dataSource.dispose();
|
||||
Mockito.verify(lwHttp).close();
|
||||
}
|
||||
@Test
|
||||
public void shouldUseLwHttp() throws Exception {
|
||||
LwHttp lwHttp = Mockito.mock(LwHttp.class);
|
||||
tileSource.setHttpEngine(new TestHttpFactory(lwHttp));
|
||||
ITileDataSource dataSource = tileSource.getDataSource();
|
||||
dataSource.dispose();
|
||||
Mockito.verify(lwHttp).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseOkHttp() throws Exception {
|
||||
OkHttpEngine okHttp = Mockito.mock(OkHttpEngine.class);
|
||||
tileSource.setHttpEngine(new TestHttpFactory(okHttp));
|
||||
UrlTileDataSource dataSource = (UrlTileDataSource) tileSource.getDataSource();
|
||||
dataSource.dispose();
|
||||
Mockito.verify(okHttp).close();
|
||||
}
|
||||
@Test
|
||||
public void shouldUseOkHttp() throws Exception {
|
||||
OkHttpEngine okHttp = Mockito.mock(OkHttpEngine.class);
|
||||
tileSource.setHttpEngine(new TestHttpFactory(okHttp));
|
||||
UrlTileDataSource dataSource = (UrlTileDataSource) tileSource.getDataSource();
|
||||
dataSource.dispose();
|
||||
Mockito.verify(okHttp).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseBuilderConfig() {
|
||||
BitmapTileSource ts = BitmapTileSource.builder()
|
||||
.url("http://example.com")
|
||||
.zoomMax(42)
|
||||
.zoomMin(23)
|
||||
.fadeSteps(new FadeStep[] { new FadeStep(0, 10, 0.5f, 1.0f) })
|
||||
.build();
|
||||
@Test
|
||||
public void shouldUseBuilderConfig() {
|
||||
BitmapTileSource ts = BitmapTileSource.builder()
|
||||
.url("http://example.com")
|
||||
.zoomMax(42)
|
||||
.zoomMin(23)
|
||||
.fadeSteps(new FadeStep[]{new FadeStep(0, 10, 0.5f, 1.0f)})
|
||||
.build();
|
||||
|
||||
assertThat(ts.getUrl().getHost()).isEqualTo("example.com");
|
||||
assertThat(ts.getZoomLevelMin()).isEqualTo(23);
|
||||
assertThat(ts.getZoomLevelMax()).isEqualTo(42);
|
||||
assertThat(ts.getFadeSteps()).isNotNull();
|
||||
}
|
||||
assertThat(ts.getUrl().getHost()).isEqualTo("example.com");
|
||||
assertThat(ts.getZoomLevelMin()).isEqualTo(23);
|
||||
assertThat(ts.getZoomLevelMax()).isEqualTo(42);
|
||||
assertThat(ts.getFadeSteps()).isNotNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test factory that allows the specific {@link HttpEngine} instance to be
|
||||
* set.
|
||||
*/
|
||||
class TestHttpFactory implements HttpEngine.Factory {
|
||||
final HttpEngine engine;
|
||||
/**
|
||||
* Test factory that allows the specific {@link HttpEngine} instance to be
|
||||
* set.
|
||||
*/
|
||||
class TestHttpFactory implements HttpEngine.Factory {
|
||||
final HttpEngine engine;
|
||||
|
||||
public TestHttpFactory(HttpEngine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
public TestHttpFactory(HttpEngine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpEngine create(UrlTileSource tileSource) {
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public HttpEngine create(UrlTileSource tileSource) {
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user