Package org.geowebcache.layer

Examples of org.geowebcache.layer.TileLayerDispatcher


    public void testInit() throws Exception {
        GWCCatalogListener gwcListener = (GWCCatalogListener) applicationContext.getBean("gwcCatalogListener");
       
        Catalog cat = gwcListener.cat;
       
        TileLayerDispatcher tld = gwcListener.layerDispatcher;
       
        try {
            tld.getTileLayer("");
        } catch (GeoWebCacheException gwce) {
           
        }
       
        List<TileLayer> layerList = gwcListener.getTileLayers(true);
       
        Iterator<TileLayer> tlIter = layerList.iterator();

        assertTrue(tlIter.hasNext());

        // Disabling tests until I have working build
        if (tlIter.hasNext()) {
            return;
        }

        // 1) Check that cite:Lakes
        boolean foundLakes = false;
        while(tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            if(tl.getName().equals("cite:Lakes")) {
                //tl.isInitialized();
                foundLakes = true;
                break;
            }
        }                   
        assertTrue(foundLakes);

        // 2) Check sf:GenerictEntity is present and initialized
        boolean foudAGF = false;
        while(tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            System.out.println(tl.getName());
            if(tl.getName().equals("sf:AggregateGeoFeature")) {
                //tl.isInitialized();
                foudAGF = true;
                GridSubset epsg4326 = tl.getGridSubset(gwcListener.gridSetBroker.WORLD_EPSG4326.getName());
                assertTrue(epsg4326.getGridSetBounds().equals( new BoundingBox(-180.0,-90.0,180.0,90.0)));
                String mime = tl.getMimeTypes().get(1).getMimeType();
                assertTrue(mime.startsWith("image/") || mime.startsWith("application/vnd.google-earth.kml+xml"));
            }
        }
       
        assertTrue(foudAGF);
       
       
        // 3) Basic get
        LayerInfo li = cat.getLayers().get(1);
        String layerName = li.getResource().getPrefixedName();
       
        TileLayer tl = tld.getTileLayer(layerName);
       
        assertEquals(layerName, tl.getName());
       
       
        // 4) Removal of LayerInfo from catalog
        cat.remove(li);
       
        assertTrue(cat.getLayerByName(tl.getName()) == null);
       
        boolean caughtException = false;
        try {
            TileLayer tl2 = tld.getTileLayer(layerName);
        } catch (GeoWebCacheException gwce) {
            caughtException = true;
        }
        assertTrue(caughtException);
       
        // 5) Introducing new LayerInfo
        LayerInfo layerInfo = cat.getFactory().createLayer();
        layerInfo.setName("hithere");
        ResourceInfo resInfo = li.getResource();
        resInfo.setName("hithere");
        resInfo.getNamespace().setPrefix("sf");
        layerInfo.setResource(resInfo);
       
        cat.add(layerInfo);
        TileLayer tl3 = tld.getTileLayer("sf:hithere");
        assertEquals(tl3.getName(),"sf:hithere");
    }
View Full Code Here


        XMLConfiguration xmlConfig = loadXMLConfig();
        xmlConfig.initialize(gridSetBroker);
        LinkedList<Configuration> configList = new LinkedList<Configuration>();
        configList.add(xmlConfig);

        TileLayerDispatcher layerDispatcher = new TileLayerDispatcher(gridSetBroker, configList);

        TileLayerRestlet tlr = new TileLayerRestlet();
        tlr.setXMLConfiguration(xmlConfig);
        tlr.setTileLayerDispatcher(layerDispatcher);
View Full Code Here

        filters.add(parameterFilter);

        WMSLayer wmsLayer = new WMSLayer(TEST_LAYER_NAME, null, null, null, null, null, filters,
                null, null, true);

        TileLayerDispatcher tld = new TileLayerDispatcherMock(wmsLayer);

        GridSetBroker gsb = new GridSetBroker(true, true);

        wmsLayer.initialize(gsb);
View Full Code Here

        XMLConfiguration xmlConfig = loadXMLConfig();
        LinkedList<Configuration> configList = new LinkedList<Configuration>();
        configList.add(xmlConfig);

        layerDispatcher = new TileLayerDispatcher(new GridSetBroker(false, false), configList);

        tilePageCalculator = new TilePageCalculator(layerDispatcher);

        store = new BDBQuotaStore(cacheDirFinder, tilePageCalculator);
        store.afterPropertiesSet();
View Full Code Here

        assertEquals(200, response.getStatusCode());
    }

    @Test public void testBasicIntegration() throws Exception {
        Catalog cat = getCatalog();
        TileLayerDispatcher tld = GeoWebCacheExtensions.bean(TileLayerDispatcher.class);
        assertNotNull(tld);

        GridSetBroker gridSetBroker = GeoWebCacheExtensions.bean(GridSetBroker.class);
        assertNotNull(gridSetBroker);

        try {
            tld.getTileLayer("");
        } catch (GeoWebCacheException gwce) {

        }

        // 1) Check that cite:Lakes is present
        boolean foundLakes = false;
        for (TileLayer tl : tld.getLayerList()) {
            if (tl.getName().equals("cite:Lakes")) {
                foundLakes = true;
                break;
            }
        }
        assertTrue(foundLakes);

        // 2) Check sf:GenerictEntity is present and initialized
        boolean foudAGF = false;
        for (TileLayer tl : tld.getLayerList()) {
            if (tl.getName().equals("sf:AggregateGeoFeature")) {
                // tl.isInitialized();
                foudAGF = true;
                GridSubset epsg4326 = tl.getGridSubset(gridSetBroker.WORLD_EPSG4326.getName());
                assertTrue(epsg4326.getGridSetBounds().equals(
                        new BoundingBox(-180.0, -90.0, 180.0, 90.0)));
                String mime = tl.getMimeTypes().get(1).getMimeType();
                assertTrue(mime.startsWith("image/")
                        || mime.startsWith("application/vnd.google-earth.kml+xml"));
            }
        }
        assertTrue(foudAGF);

        // 3) Basic get
        LayerInfo li = cat.getLayerByName(super.getLayerId(MockData.MPOINTS));
        String layerName = tileLayerName(li);

        TileLayer tl = tld.getTileLayer(layerName);

        assertEquals(layerName, tl.getName());

        // 4) Removal of LayerInfo from catalog
        cat.remove(li);

        assertNull(cat.getLayerByName(tl.getName()));

        try {
            tld.getTileLayer(layerName);
            fail("Layer should not exist");
        } catch (GeoWebCacheException gwce) {
            assertTrue(true);
        }
    }
View Full Code Here

    }
   
    @Test
    public void testRemoveLayerAfterReload() throws Exception {
        Catalog cat = getCatalog();
        TileLayerDispatcher tld = GeoWebCacheExtensions.bean(TileLayerDispatcher.class);
       
        LayerInfo li = cat.getLayerByName(super.getLayerId(MockData.MPOINTS));
        String layerName = tileLayerName(li);

        assertNotNull(tld.getTileLayer(layerName));

        // force reload
        getGeoServer().reload();
       
        // now remove the layer and check it has been removed from GWC as well
        cat.remove(li);
        try {
            tld.getTileLayer(layerName);
            fail("Layer should not exist");
        } catch (GeoWebCacheException gwce) {
            // fine
        }
    }
View Full Code Here

        CatalogConfiguration gwcListener = (CatalogConfiguration) applicationContext
                .getBean("gwcCatalogConfiguration");

        Catalog cat = (Catalog) applicationContext.getBean("rawCatalog");

        TileLayerDispatcher tld = (TileLayerDispatcher) applicationContext
                .getBean("gwcTLDispatcher");
       
        GridSetBroker gridSetBroker = (GridSetBroker) applicationContext.getBean("gwcGridSetBroker");

        try {
            tld.getTileLayer("");
        } catch (GeoWebCacheException gwce) {

        }

        List<TileLayer> layerList;
        Iterator<TileLayer> tlIter;

        layerList = gwcListener.getTileLayers(true);
        tlIter = layerList.iterator();

        assertTrue(tlIter.hasNext());

        // Disabling tests until I have working build
        // if (tlIter.hasNext()) {
        // return;
        // }

        // 1) Check that cite:Lakes
        boolean foundLakes = false;
        while (tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            if (tl.getName().equals("cite:Lakes")) {
                // tl.isInitialized();
                foundLakes = true;
                break;
            }
        }
        assertTrue(foundLakes);

        // 2) Check sf:GenerictEntity is present and initialized
        layerList = gwcListener.getTileLayers(true);
        tlIter = layerList.iterator();
        boolean foudAGF = false;
        while (tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            System.out.println(tl.getName());
            if (tl.getName().equals("sf:AggregateGeoFeature")) {
                // tl.isInitialized();
                foudAGF = true;
                GridSubset epsg4326 = tl.getGridSubset(gridSetBroker.WORLD_EPSG4326
                        .getName());
                assertTrue(epsg4326.getGridSetBounds().equals(
                        new BoundingBox(-180.0, -90.0, 180.0, 90.0)));
                String mime = tl.getMimeTypes().get(1).getMimeType();
                assertTrue(mime.startsWith("image/")
                        || mime.startsWith("application/vnd.google-earth.kml+xml"));
            }
        }

        assertTrue(foudAGF);

        // 3) Basic get
        LayerInfo li = cat.getLayers().get(1);
        String layerName = li.getResource().getPrefixedName();

        TileLayer tl = tld.getTileLayer(layerName);

        assertEquals(layerName, tl.getName());

        // 4) Removal of LayerInfo from catalog
        cat.remove(li);

        assertTrue(cat.getLayerByName(tl.getName()) == null);

        boolean caughtException = false;
        try {
            TileLayer tl2 = tld.getTileLayer(layerName);
        } catch (GeoWebCacheException gwce) {
            caughtException = true;
        }
        assertTrue(caughtException);

        // 5) Introducing new LayerInfo
        ResourceInfo resInfo = li.getResource();
       
        //JD: not sure what this next line is really doing, disabling it because it changes the
        // namespace and does not save it... and the catalog does not cascade changes
        //resInfo.getNamespace().setPrefix("sf");
       
        resInfo.setName("hithere");
        cat.save(resInfo);
       
        LayerInfo layerInfo = cat.getFactory().createLayer();
        layerInfo.setResource(resInfo);
        layerInfo.setName(resInfo.getPrefixedName());

        cat.add(layerInfo);
        String newLayerName = layerInfo.getResource().getPrefixedName();
        TileLayer tl3 = tld.getTileLayer(newLayerName);
        assertEquals(newLayerName, tl3.getName());

        // 6) Add new LayerGroupInfo
        LayerGroupInfo lgi = cat.getFactory().createLayerGroup();
        lgi.setName("sf:aLayerGroup");
        lgi.setBounds(new ReferencedEnvelope(-180, 180, -90, 90, CRS.decode("EPSG:4326")));
        lgi.getLayers().add(cat.getLayerByName("hithere"));

        cat.add(lgi);
        TileLayer tl4 = tld.getTileLayer("sf:aLayerGroup");
        assertNotNull(tl4);
        assertEquals(lgi.getName(), tl4.getName());

    }
View Full Code Here

        XMLConfiguration xmlConfig = loadXMLConfig();
        LinkedList<Configuration> configList = new LinkedList<Configuration>();
        configList.add(xmlConfig);

        layerDispatcher = new TileLayerDispatcher(new GridSetBroker(true, true), configList);

        tilePageCalculator = new TilePageCalculator(layerDispatcher);

        // prepare a connection pool for tests against a H2 database
        dataSource = getDataSource();
View Full Code Here

public class WMSGetCapabilitiesTest {
   

    @Test
    public void testEscapeXMLChars() throws Exception {
        TileLayerDispatcher tld = createMock(TileLayerDispatcher.class);
        HttpServletRequest servReq = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        String baseUrl = "http://example.com/geowebcache/";
        String contextPath = "service/";
        URLMangler urlMangler = new NullURLMangler();
        ServiceInformation servInfo = createMock(ServiceInformation.class);
       
        Map<String, String[]> parameterMap = new HashMap<>();
        parameterMap.put("SERVICE", new String[]{"WMS"});
        parameterMap.put("VERSION", new String[]{"1.1.1"});
        parameterMap.put("REQUEST", new String[]{"getcapabilities"});
        parameterMap.put("TILED", new String[]{"true"});
       
        expect(servReq.getParameterMap()).andStubReturn(Collections.unmodifiableMap(parameterMap));
        expect(servReq.getCharacterEncoding()).andStubReturn("UTF-8");
       
        expect(servInfo.getTitle()).andStubReturn("Title & \"stuff\"");
        expect(servInfo.getDescription()).andStubReturn("This \"description\" contains <characters> which & should be \'escaped\'.");
        expect(servInfo.getKeywords()).andStubReturn(null);
        expect(servInfo.getServiceProvider()).andStubReturn(null);
        expect(servInfo.getFees()).andStubReturn("NONE");
        expect(servInfo.getAccessConstraints()).andStubReturn("NONE");
        expect(tld.getServiceInformation()).andStubReturn(servInfo);
       
        expect(tld.getLayerList()).andStubReturn(Collections.<TileLayer>emptyList());

        replay(tld, servReq, response, servInfo);
       
        WMSGetCapabilities capabilities = new WMSGetCapabilities(tld, servReq, baseUrl, contextPath, urlMangler);
       
View Full Code Here

        layer.getGridSubset(layer.getGridSubsets().iterator().next());
        File temp = File.createTempFile("gwc", "wms");
        temp.delete();
        temp.mkdirs();
        try {
          TileLayerDispatcher dispatcher = new TileLayerDispatcher(gridSetBroker) {

        @Override
        public TileLayer getTileLayer(String layerName)
            throws GeoWebCacheException {
          return layer;
View Full Code Here

TOP

Related Classes of org.geowebcache.layer.TileLayerDispatcher

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.