Package org.geowebcache.io

Examples of org.geowebcache.io.ByteArrayResource


   
    @Test
    public void testRemoveWhenMaxSpace() throws Exception {
       
        for (long i = 0; i<MAX_SPACE_KiB; i++) {
           Resource r = new ByteArrayResource(new byte[i==0?1023:1024]); // make the first one 1 byte less than a KiB
           transCache.put("foo"+i, r);
           assertThat(transCache.storageSize(), is((i+1)*1024-1)); // 1 KiB per resource, less a byte for the first
           ticker.advanceMilli(1);
        }
        assertThat(transCache.storageSize(), is((long)MAX_SPACE_KiB*1024-1)); // 1 KiB per resource, less a byte for the first
        assertThat(transCache.size(), is(MAX_SPACE_KiB));
        Resource r = new ByteArrayResource(new byte[2]); // 2 bytes will go over the maximum
        transCache.put("foo"+MAX_SPACE_KiB, r);
        assertThat(transCache.storageSize(), is((long)(MAX_SPACE_KiB-1)*1024+2)); // 1 KiB for each of the resources except the first should be removed, and the last is only 2 bytes.
        assertThat(transCache.size(), is(MAX_SPACE_KiB));
       
        ticker.advanceMilli(1);
View Full Code Here


        TransientCache transCache = new TransientCache(100, 1024, 2000);
       
        StorageBroker sb = new DefaultStorageBroker(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

            is = GeoWebCacheDispatcher.class.getResourceAsStream("blank.png");
            byte[] blankTile = new byte[425];
            int ret = is.read(blankTile);
            log.info("Read " + ret + " from blank PNG file (expected 425).");
           
            return new ByteArrayResource(blankTile);
        } catch (IOException ioe) {
            log.error(ioe.getMessage());
        } finally {
            try {
                if(is != null)
View Full Code Here

        try {
            r.getInputStream().read(buf);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        CachedResource blob = new CachedResource(new ByteArrayResource(buf));
        currentStorage += r.getSize();
        cache.put(key, blob);
    }
View Full Code Here

            }))).andReturn(true).anyTimes();
            expect(storageBroker.get((TileObject) anyObject())).andAnswer(new IAnswer<Boolean>() {
                public Boolean answer() throws Throwable {
                    TileObject tile = (TileObject) EasyMock.getCurrentArguments()[0];
                    if (puts.contains(TransientCache.computeTransientKey(tile))) {
                        tile.setBlob(new ByteArrayResource(fakeWMSResponse));
                        storageGetCounter.incrementAndGet();
                        return true;
                    } else {
                        return false;
                    }
View Full Code Here

    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",
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.