Package org.geowebcache.io

Examples of org.geowebcache.io.Resource


    public static final String TEST_BLOB_DIR_NAME = "gwcTestBlobs";

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

        Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes());
        long[] xyz = { 1L, 2L, 3L };
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "ø");
        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);

        Resource resp = fbs.get(to2);

        to2.setBlob(resp);

        assertEquals(to.getBlobFormat(), to2.getBlobFormat());
        InputStream is = to.getBlob().getInputStream();
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);

        Resource resp = fbs.get(to2);

        // to2.setBlob(resp);

        InputStream is = resp.getInputStream();
        InputStream is2 = bytes.getInputStream();
        try {
            assertTrue(IOUtils.contentEquals(is, is2));
        } finally {
            is.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][4];
        int zoomStart = zoomLevel - 1;
        int zoomStop = zoomLevel + 1;

        long[] range = { x, y, x + tos.length - 3, y };
        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);
        InputStream is = fbs.get(firstTO).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);
        is = fbs.get(lastTO).getInputStream();
        is2 = bytes.getInputStream();
        try {
            assertTrue(IOUtils.contentEquals(is, is2));
        } finally {
            is.close();
            is2.close();
        }

        TileObject midTO = TileObject.createQueryTileObject(layerName,
                tos[(tos.length - 1) / 2].xyz, srs.toString(), mime.getFormat(), parameters);
        Resource res = fbs.get(midTO);

        assertNull(res);
    }
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

        final GridSubset gridSubset = getGridSubset(tileProto.getGridSetId());

        final int zoomLevel = (int) gridLoc[2];
        final boolean store = this.getExpireCache(zoomLevel) != GWCVars.CACHE_DISABLE_CACHE;

        Resource resource;
        boolean encode;
        for (int i = 0; i < gridPositions.length; i++) {
            final long[] gridPos = gridPositions[i];
            if (Arrays.equals(gridLoc, gridPos)) {
                // Is this the one we need to save? then don't use the buffer or it'll be overridden
View Full Code Here

        BlobStore blobStore = new FileBlobStore(blobPath);
       
        StorageBroker sb = new StorageBroker(metaStore, blobStore);
       
        //long[] xyz = {1L,2L,3L};
        Resource blob = new ByteArrayResource(new byte[20*1024]);

        System.out.println("Inserting into database, " + TILE_PUT_COUNT + " tiles");
       
        long startInsert = System.currentTimeMillis();
        for(int i=1; i < TILE_PUT_COUNT; i++) {
View Full Code Here

public class MetaStoreTest extends TestCase {
    public static final String TEST_DB_NAME = "gwcTestMetaStore";
   
    public void testTile() throws Exception {
        Resource bytes = null;
        TileObject to2 = null;
       
        try {
            MetaStore ms = setup();

            long[] xyz = { 1L, 2L, 3L };
            bytes = new ByteArrayResource("Test 1 2 3".getBytes());
            Map<String, String> parameters = new HashMap<String, String>();
            parameters.put("a", "x");
            parameters.put("b", "y");
            TileObject to = TileObject.createCompleteTileObject(
                    "test'Layer:æøå;", xyz, "hefty-gridSet:id", "jpeg", parameters, bytes);

            ms.put(to);
            ms.unlock(to);
           
            long[] xyz2 = { 1L, 2L, 3L };
            to2 = TileObject.createQueryTileObject(
                    "test'Layer:æøå;", xyz2, "hefty-gridSet:id", "jpeg", parameters);

            ms.get(to2);

        } catch (StorageException se) {
            System.out.println(se.getMessage());
            throw se;
        }
        assertEquals(bytes.getSize(),to2.getBlobSize());
        assertEquals(true, to2.getCreated() <= System.currentTimeMillis());
    }
View Full Code Here

        assertEquals(bytes.getSize(),to2.getBlobSize());
        assertEquals(true, to2.getCreated() <= System.currentTimeMillis());
    }
   
    public void testTileDelete() throws Exception {
        Resource bytes = null;
        TileObject to2 = null;
        TileObject to3 = null;
        String layerName = "test'Layer:æøå;";
        String format = "jpeg";
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "y");
       
        try {
            MetaStore ms = setup();

            long[] xyz = { 1L, 2L, 3L };
            bytes = new ByteArrayResource("Test 1 2 3".getBytes());
            TileObject to = TileObject.createCompleteTileObject(
                    layerName, xyz, "hefty-gridSet:id", format, parameters, bytes);

            ms.put(to);
            ms.unlock(to);
           
            // Check
            long[] xyz2 = { 1L, 2L, 3L };
            to2 = TileObject.createQueryTileObject(
                    layerName, xyz2, "hefty-gridSet:id", format, parameters);

            assertTrue(ms.get(to2));
            assertEquals(bytes.getSize(),to2.getBlobSize());
           
            // Delete
            assertTrue(ms.delete(to));
           
            // Check
View Full Code Here

        }

    }

    public void testLayerRename() throws Exception {
        Resource bytes = null;
        String layerName = "test'Layer:æøå;";
        String format = "jpeg";
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "y");
View Full Code Here

            LOGGER.finest("GetMap request intercepted, serving cached content: " + request);
        }

        final byte[] tileBytes;
        {
            final Resource mapContents = cachedTile.getBlob();
            if (mapContents instanceof ByteArrayResource) {
                tileBytes = ((ByteArrayResource) mapContents).getContents();
            } else {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                mapContents.transferTo(Channels.newChannel(out));
                tileBytes = out.toByteArray();
            }
        }

        // Handle Etags
View Full Code Here

TOP

Related Classes of org.geowebcache.io.Resource

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.