Package org.vfny.geoserver.wms

Examples of org.vfny.geoserver.wms.GetMapProducer


    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testFindMapProducers() {
        GetMapProducer mockProducer1 = createMock(GetMapProducer.class);
        GetMapProducer mockProducer2 = createMock(GetMapProducer.class);

        ApplicationContext mockContext = EasyMock.createMock(ApplicationContext.class);
        // I'm not so pleasant with this block of code as it implies knowing how
        // the internals of GeoServerExtensions work
        expect(mockContext.getBeanNamesForType(ExtensionFilter.class)).andReturn(new String[0]);
View Full Code Here


        assertNotNull(mapProducers);
        assertEquals(0, mapProducers.size());
    }

    public void testFindMapProducer() {
        GetMapProducer mockProducer = createMock(GetMapProducer.class);

        ApplicationContext mockContext = EasyMock.createMock(ApplicationContext.class);
        // I'm not so pleasant with this block of code as it implies knowing how
        // the internals of GeoServerExtensions work
        expect(mockContext.getBeanNamesForType(ExtensionFilter.class)).andReturn(new String[0]);
        expect(mockContext.getBeanNamesForType(GetMapProducer.class)).andReturn(
                new String[] { "producer1" }); // call#1
        expect(mockContext.getBean("producer1")).andReturn(mockProducer); // call#1

        expect(mockContext.getBeanNamesForType(ExtensionFilter.class)).andReturn(new String[0]);
        expect(mockContext.getBeanNamesForType(GetMapProducer.class)).andReturn(
                new String[] { "producer1" }); // call#2
        expect(mockContext.getBean("producer1")).andReturn(mockProducer); // call#2

        // end of unpleasant block

        Set<String> testFormatNames = new HashSet<String>();
        testFormatNames.add("image/fakeformat");
        testFormatNames.add("image/dummy");

        expect(mockProducer.getOutputFormatNames()).andReturn(testFormatNames);// call#1
        expect(mockProducer.getOutputFormatNames()).andReturn(testFormatNames);// call#2

        replay(mockContext);
        replay(mockProducer);

        // note the lookup shall be case insensitive..
        GetMapProducer producer;
        producer = WMSExtensions.findMapProducer("ImaGe/FaKeForMat", mockContext);// call#1
        assertSame(mockProducer, producer);

        producer = WMSExtensions.findMapProducer("notARegisteredFormat", mockContext);// call#2
        assertNull(producer);
View Full Code Here

     *             if no specialization is configured for the output format
     *             specified in <code>request</code> or if it can't be
     *             instantiated
     */
    private GetMapProducer getDelegate(final String outputFormat) throws WmsException {
        final GetMapProducer producer = WMSExtensions.findMapProducer(outputFormat,
                availableProducers);
        if (producer == null) {
            WmsException e = new WmsException("There is no support for creating maps in "
                    + outputFormat + " format", "InvalidFormat");
            e.setCode("InvalidFormat");
            throw e;
        }
        // Tell the producer which of its output format names the
        // request
        // was made for, the producer may need it for its logic.
        // For example, result is different if requested image/png8
        // instead of image/png
        // I'm not so glad with this, but found a lot of producers were
        // made that way
        producer.setOutputFormat(outputFormat);
        return producer;
    }
View Full Code Here

    /**
     * Test method for {@link GetMapResponse#execute(org.vfny.geoserver.Request)}.
     */
    public void testDelegateLookup() {
        GetMapProducer producer = new WMSMockData.DummyRasterMapProducer();
        response = new GetMapResponse(Collections.singleton(producer));
        request.setFormat(WMSMockData.DummyRasterMapProducer.MIME_TYPE);

        response.execute(request);

        GetMapProducer delegate = response.getDelegate();
        assertSame(producer, delegate);
    }
View Full Code Here

            fail("Expected failure");
        } catch (RuntimeException e) {
            // let execute crash, we're only interested in the delegate
            assertTrue(true);
        }
        GetMapProducer delegate = response.getDelegate();
        assertTrue(delegate instanceof MetatileMapProducer);
    }
View Full Code Here

            throw new WmsException("There is no support for creating maps in "
                + outputFormat + " format", "InvalidFormat");
        }

       
        GetMapProducer producer = mpf.createMapProducer(outputFormat,config);

        return producer;
    }
View Full Code Here

    /**
     * DOCUMENT ME!
     */
    public void testExecute() throws Exception{
        GetMapProducer producer;
      producer = GetMapResponse.getDelegate(TestMapProducerFactory.TESTING_MIME_TYPE,null);
      assertEquals(TestMapProducerFactory.class, producer.getClass());
    }
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.wms.GetMapProducer

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.