src/test/java/de/blau/android/resources/TileLayerServerTest.java
/**
     * Test if bing metadata retrieval works
     */
Test if bing metadata retrieval works
Test if bing metadata retrieval works
@Test
    public void bingMeta() {
        MockWebServerPlus mockServer = new MockWebServerPlus();
        Buffer data = new Buffer();
        try {
            String url = mockServer.url("/?key={apikey}");
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            InputStream is = loader.getResourceAsStream("fixtures/bing_metadata.xml");
            data.readFrom(is);
            mockServer.server().enqueue(new MockResponse().setResponseCode(200).setBody(data));
            TileLayerSource bing = new TileLayerSource(ctx, TileLayerSource.LAYER_BING, "Bing meta test", url, TileLayerSource.TYPE_BING, null, false, false,
                    null, null, null, null, null, 0, 20, 0, 256, 256, null, 0, 0, 0, null, null, null, null, false);
            Assert.assertTrue(bing.isMetadataLoaded());
            MapTile mapTile = new MapTile("", 20, 1111, 2222);
            String s = bing.getTileURLString(mapTile); 
            Assert.assertTrue(s.contains(bing.quadTree(mapTile)));
        } catch (IOException e) {
            fail(e.getMessage());
        } finally {
            data.close();
            try {
                mockServer.server().shutdown();
            } catch (IOException e) {
            }
        }
    }
@ Test public void bingMeta ( ) { MockWebServerPlus mockServer = new MockWebServerPlus ( ) ; Buffer data = new Buffer ( ) ; try { String url = mockServer . url ( "/?key={apikey}" ) ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = loader . getResourceAsStream ( "fixtures/bing_metadata.xml" ) ; data . readFrom ( is ) ; mockServer . server ( ) . enqueue ( new MockResponse ( ) . setResponseCode ( 200 ) . setBody ( data ) ) ; TileLayerSource bing = new TileLayerSource ( ctx , TileLayerSource . LAYER_BING , "Bing meta test" , url , TileLayerSource . TYPE_BING , null , false , false , null , null , null , null , null , 0 , 20 , 0 , 256 , 256 , null , 0 , 0 , 0 , null , null , null , null , false ) ; Assert . assertTrue ( bing . isMetadataLoaded ( ) ) ; MapTile mapTile = new MapTile ( "" , 20 , 1111 , 2222 ) ; String s = bing . getTileURLString ( mapTile ) ; Assert . assertTrue ( s . contains ( bing . quadTree ( mapTile ) ) ) ; } catch ( IOException e ) { fail ( e . getMessage ( ) ) ; } finally { data . close ( ) ; try { mockServer . server ( ) . shutdown ( ) ; } catch ( IOException e ) { } } }
Test if bing metadata retrieval works
Test if bing metadata retrieval works
// for whatever reason the fixture mechanism doesn't seem to work here // note this would fail if the metainfo cannot be retrieved // do nothing