Package org.geowebcache.io

Examples of org.geowebcache.io.ByteArrayResource


    }

    public ConveyorTile doNonMetatilingRequest(ConveyorTile tile) throws GeoWebCacheException {
        tile.setTileLayer(this);

        ByteArrayResource buffer = getImageBuffer(WMS_BUFFER);
        sourceHelper.makeRequest(tile, buffer);

        if (tile.getError() || buffer.getSize() == 0) {
            throw new GeoWebCacheException("Empty tile, error message: " + tile.getErrorMessage());
        }

        tile.setBlob(buffer);
        return tile;
View Full Code Here


        // Should we do mime type checks?

        // note: not using getImageBuffer() here cause this method is not called during seeding, so
        // there's no gain
        Resource buffer = new ByteArrayResource(2048);
        sourceHelper.makeRequest(tile, buffer);
        tile.setBlob(buffer);

        return tile;
    }
View Full Code Here

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
       
        return new ByteArrayResource(green);
    }
View Full Code Here

        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "ø");

        Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes());
        long[] xyz = { 5L, 6L, 7L };
        TileObject to = TileObject.createCompleteTileObject("test:123123 112", xyz, "EPSG:4326",
                "image/jpeg", parameters, bytes);
        to.setId(11231231);

        fbs.put(to);

        TileObject to2 = TileObject.createQueryTileObject("test:123123 112", xyz, "EPSG:4326",
                "image/jpeg", parameters);
        to2.setId(11231231);
        fbs.get(to2);

        InputStream is = to2.getBlob().getInputStream();
        InputStream is2 = bytes.getInputStream();
        try {
            assertTrue(IOUtils.contentEquals(is, is2));
        } finally {
            is.close();
            is2.close();
View Full Code Here

    }

    public void testTilRangeDelete() throws Exception {
        FileBlobStore fbs = setup();

        Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes());
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "ø");
        MimeType mime = ImageMime.png;
        SRS srs = SRS.getEPSG4326();
        String layerName = "test:123123 112";

        int zoomLevel = 7;
        int x = 25;
        int y = 6;

        // long[] origXYZ = {x,y,zoomLevel};

        TileObject[] tos = new TileObject[6];

        for (int i = 0; i < tos.length; i++) {
            long[] xyz = { x + i - 1, y, zoomLevel };
            tos[i] = TileObject.createCompleteTileObject(layerName, xyz, srs.toString(),
                    mime.getFormat(), parameters, bytes);
            fbs.put(tos[i]);
        }

        long[][] rangeBounds = new long[zoomLevel + 2][5];
        int zoomStart = zoomLevel - 1;
        int zoomStop = zoomLevel + 1;

        long[] range = { x, y, x + tos.length - 3, y, zoomLevel};
        rangeBounds[zoomLevel] = range;

        TileRange trObj = new TileRange(layerName, srs.toString(), zoomStart, zoomStop,
                rangeBounds, mime, parameters);

        fbs.delete(trObj);

        // starting x and x + tos.length should have data, the remaining should not
        TileObject firstTO = TileObject.createQueryTileObject(layerName, tos[0].xyz,
                srs.toString(), mime.getFormat(), parameters);
        fbs.get(firstTO);
        InputStream is = firstTO.getBlob().getInputStream();
        InputStream is2 = bytes.getInputStream();
        try {
            assertTrue(IOUtils.contentEquals(is, is2));
        } finally {
            is.close();
            is2.close();
        }

        TileObject lastTO = TileObject.createQueryTileObject(layerName, tos[tos.length - 1].xyz,
                srs.toString(), mime.getFormat(), parameters);
        fbs.get(lastTO);
        is = lastTO.getBlob().getInputStream();
        is2 = bytes.getInputStream();
        try {
            assertTrue(IOUtils.contentEquals(is, is2));
        } finally {
            is.close();
            is2.close();
View Full Code Here

        assertNull(res);
    }

    public void testRenameLayer() throws Exception {
        FileBlobStore fbs = setup();
        Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes());
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "ø");
        MimeType mime = ImageMime.png;
        SRS srs = SRS.getEPSG4326();
View Full Code Here

        transCache.setTicker(ticker);
    }
   
    @Test
    public void testHit() throws Exception {
        Resource r = new ByteArrayResource(new byte[]{1,2,3});
       
        transCache.put("foo", r);
       
        ticker.advanceMilli(EXPIRE_TIME-1);
        Resource result = transCache.get("foo");
        assertThat(result, notNullValue());
        assertThat(r.getLastModified(), equalTo(r.getLastModified()));
        try (InputStream is = result.getInputStream();){
            assertThat(is.read(), equalTo(1));
            assertThat(is.read(), equalTo(2));
            assertThat(is.read(), equalTo(3));
            assertThat(is.read(), equalTo(-1));
View Full Code Here

        }
    }
   
    @Test
    public void testRemoveOnHit() throws Exception {
        Resource r = new ByteArrayResource(new byte[]{1,2,3});
       
        transCache.put("foo", r);
       
        ticker.advanceMilli(EXPIRE_TIME-1);
       
View Full Code Here

        assertThat(result, nullValue()); // Should have been cleared
    }
   
    @Test
    public void testRemoveOnExpire() throws Exception {
        Resource r = new ByteArrayResource(new byte[]{1,2,3});
       
        transCache.put("foo", r);
       
        ticker.advanceMilli(EXPIRE_TIME+1);
       
View Full Code Here

   
    @Test
    public void testRemoveWhenMaxTiles() throws Exception {
       
        for (byte i = 0; i<MAX_TILES; i++) {
           Resource r = new ByteArrayResource(new byte[]{(byte)(i+1),(byte)(i+2),(byte)(i+3)});
           transCache.put("foo"+i, r);
           assertThat(transCache.size(), is(i+1));
        }
        assertThat(transCache.storageSize(), is((long)MAX_TILES*3));
        Resource r = new ByteArrayResource(new byte[]{(byte)(MAX_TILES+1),(byte)(MAX_TILES+2)});
        transCache.put("foo"+MAX_TILES, r);
        assertThat(transCache.size(), is(MAX_TILES));
        assertThat(transCache.storageSize(), is((long)MAX_TILES*3-1)); // remove a 3 byte  and add a 2 byte
       
        ticker.advanceMilli(1);
View Full Code Here

TOP

Related Classes of org.geowebcache.io.ByteArrayResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.