move tests to separate project

This commit is contained in:
Hannes Janetzek
2014-03-29 12:54:12 +01:00
parent f75702a575
commit 2bf5313c2b
7 changed files with 24 additions and 13 deletions

View File

@@ -0,0 +1,58 @@
package org.oscim.tiling.source;
import com.squareup.okhttp.OkHttpClient;
import org.junit.Before;
import org.junit.Test;
import org.oscim.tiling.ITileDataSource;
import static org.fest.assertions.api.Assertions.assertThat;
public class UrlTileSourceTest {
private UrlTileSource tileSource;
@Before
public void setUp() throws Exception {
tileSource = new TestTileSource("http://example.org/tiles/vtm");
}
@Test
public void shouldNotBeNull() throws Exception {
assertThat(tileSource).isNotNull();
}
@Test
public void shouldUseDefaultHttpEngine() throws Exception {
TestTileDataSource dataSource = (TestTileDataSource) tileSource.getDataSource();
assertThat(dataSource.getConnection()).isInstanceOf(LwHttp.class);
}
@Test
public void shouldUseCustomHttpEngine() throws Exception {
tileSource.setHttpEngine(new OkHttpEngine(tileSource.getUrl()));
TestTileDataSource dataSource = (TestTileDataSource) tileSource.getDataSource();
assertThat(dataSource.getConnection()).isInstanceOf(OkHttpEngine.class);
}
class TestTileSource extends UrlTileSource {
public TestTileSource(String urlString) {
super(urlString);
}
@Override
public ITileDataSource getDataSource() {
return new TestTileDataSource(this, null, getHttpEngine());
}
}
class TestTileDataSource extends UrlTileDataSource {
public TestTileDataSource(UrlTileSource tileSource, ITileDecoder tileDecoder,
HttpEngine conn) {
super(tileSource, tileDecoder, conn);
}
public HttpEngine getConnection() {
return mConn;
}
}
}