Package org.mapfish.print.wrapper.json

Examples of org.mapfish.print.wrapper.json.PJsonObject


    }

    @Test
    public void testWrongType() throws Exception {
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml"));
        PJsonObject requestData = loadJsonRequestData();

        final JSONArray intArray = new JSONArray();
        intArray.add(1);
        intArray.add(2);
        intArray.add(3);
        requestData.getJSONObject("attributes").getInternalObj().put("stringarray", intArray);

        Template template = config.getTemplate("main");
        Values values = new Values(requestData, template, this.parser, config.getDirectory(), httpClientFactory, config.getDirectory());

        String[] array = (String[]) values.getObject("stringarray", Object.class);
View Full Code Here


        configFiles.put("default", getFile(MapPrinterServletSecurityTest.class, "config-security.yaml").getAbsolutePath());
        printerFactory.setConfigurationFiles(configFiles);
    }

    private String loadRequestDataAsString() throws IOException {
        final PJsonObject requestJson = parseJSONObjectFromFile(MapPrinterServletSecurityTest.class, "requestData.json");
        return requestJson.getInternalObj().toString();
    }
View Full Code Here

    @Test
    public void testAssignStyleBasic() throws Exception {
        this.configurationFactory.setDoValidation(false);
        final Configuration config = this.configurationFactory.getConfig(getFile(BASE_DIR + "basic/config.yaml"));
        final Template template = config.getTemplate("main");
        PJsonObject requestData = parseJSONObjectFromFile(SetStyleProcessorTest.class, BASE_DIR + "basic/request.json");
        Values values = new Values(requestData, template, parser, this.folder.getRoot(), this.httpClientFactory, new File("."));
        forkJoinPool.invoke(template.getProcessorGraph().createTask(values));

        final MapAttribute.MapAttributeValues map = values.getObject("mapDef", MapAttribute.MapAttributeValues.class);
        final AbstractFeatureSourceLayer layer = (AbstractFeatureSourceLayer) map.getLayers().get(0);
View Full Code Here

        Map<String, Object> embeddedEmbedded = Maps.newHashMap();
        embeddedEmbedded.put("ee1", 1);
        embedded.put("embeddedAtt2", embeddedEmbedded);
        embedded.put("embeddedAtt3", Lists.newArrayList("one", "two", "three"));
        map.put("att3", embedded);
        final PJsonObject test = new PYamlObject(map, "test").toJSON();

        assertEquals(3, test.size());
        assertEquals(1, test.getInt("att1"));

        PJsonArray array1 = test.getJSONArray("att2");
        assertEquals(2, array1.size());
        assertEquals(1, array1.get(0));
        assertEquals(2, array1.get(1));

        PJsonObject embeddedJson = test.getJSONObject("att3");
        assertEquals(3, embeddedJson.size());
        assertEquals(true, embeddedJson.has("embeddedAtt1"));

        PJsonObject embeddedEmbeddedJson = embeddedJson.getJSONObject("embeddedAtt2");
        assertEquals(1, embeddedEmbeddedJson.size());
        assertEquals(1, embeddedEmbeddedJson.getInt("ee1"));

        PJsonArray array2 = embeddedJson.getJSONArray("embeddedAtt3");
        assertEquals(3, array2.size());
        assertEquals("one", array2.getString(0));
        assertEquals("two", array2.getString(1));
View Full Code Here

                    }
                }
        );
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml"));
        final Template template = config.getTemplate("main");
        PJsonObject requestData = loadJsonRequestData();
        Values values = new Values(requestData, template, this.parser, getTaskDirectory(), this.requestFactory, new File("."));
        this.forkJoinPool.invoke(template.getProcessorGraph().createTask(values));

        @SuppressWarnings("unchecked")
        List<URI> layerGraphics = (List<URI>) values.getObject("layerGraphics", List.class);
View Full Code Here

                }
        );

        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml"));
        final Template template = config.getTemplate("main");
        PJsonObject requestData = loadJsonRequestData();
        Values values = new Values(requestData, template, this.parser, getTaskDirectory(), this.requestFactory, new File("."));
        template.getProcessorGraph().createTask(values).invoke();

        @SuppressWarnings("unchecked")
        List<URI> layerGraphics = (List<URI>) values.getObject("layerGraphics", List.class);
View Full Code Here

    @Test
    public void testConvertTableInConfigNotInRequest() throws IOException, JSONException, NoSuchAppException, URISyntaxException {
        setUpConfigFiles();
        Configuration configuration = printerFactory.create("default").getConfiguration();
        final PJsonObject v2ApiRequest = loadRequestDataAsJson("requestData-old-api-no-table-data.json");
        JSONObject request = OldAPIRequestConverter.convert(v2ApiRequest, configuration).getInternalObj();

        assertTrue(request.has("attributes"));
        JSONObject attributes = request.getJSONObject("attributes");
View Full Code Here

        final MockHttpServletResponse infoResponse = new MockHttpServletResponse();
        this.servlet.getInfo(null, null, infoRequest, infoResponse);
        assertEquals(HttpStatus.OK.value(), infoResponse.getStatus());
       
        final String result = infoResponse.getContentAsString();
        final PJsonObject info = parseJSONObjectFromString(result);
       
        assertTrue(info.has("scales"));
        assertTrue(info.has("dpis"));
        assertTrue(info.has("outputFormats"));
        assertTrue(info.has("layouts"));
        assertTrue(info.has("printURL"));
        assertTrue(info.has("createURL"));

        assertEquals(10, info.getArray("scales").size());
        final PObject firstScale = info.getArray("scales").getObject(0);
        assertEquals("1:5000", firstScale.getString("name"));
        assertEquals("5000", firstScale.getString("value"));

        assertEquals(5, info.getArray("dpis").size());
       
        assertTrue(info.getArray("outputFormats").size() > 0);
        assertTrue(info.getArray("outputFormats").getObject(0).has("name"));

        assertTrue(info.getArray("layouts").size() > 0);
        PObject layout = info.getArray("layouts").getObject(0);
        assertEquals("A4 Portrait", layout.getString("name"));
        assertTrue(layout.getBool("rotation"));
        assertEquals(802, layout.getObject("map").getInt("width"));
        assertEquals(210, layout.getObject("map").getInt("height"));
       
        assertEquals("/print-old/dep/print.pdf", info.getString("printURL"));
        assertEquals("/print-old/dep/create.json", info.getString("createURL"));
    }
View Full Code Here

        final MockHttpServletResponse infoResponse = new MockHttpServletResponse();
        this.servlet.getInfo(null, null, infoRequest, infoResponse);
        assertEquals(HttpStatus.OK.value(), infoResponse.getStatus());
       
        final String result = infoResponse.getContentAsString();
        final PJsonObject info = parseJSONObjectFromString(result);
       
        assertTrue(info.has("dpis"));
        assertEquals(4, info.getArray("dpis").size());
        final PObject firstDpi = info.getArray("dpis").getObject(0);
        assertEquals("90", firstDpi.getString("name"));
        assertEquals("90", firstDpi.getString("value"));
        final PObject lastDpi = info.getArray("dpis").getObject(3);
        assertEquals("400", lastDpi.getString("name"));
        assertEquals("400", lastDpi.getString("value"));
    }
View Full Code Here

       
        final String result = infoResponse.getContentAsString();
        assertTrue(result.startsWith("var printConfig="));
        assertTrue(result.endsWith(";"));
       
        final PJsonObject info = parseJSONObjectFromString(
                result.replace("var printConfig=", "").replace(";", ""));
       
        assertTrue(info.has("scales"));
        assertTrue(info.has("dpis"));
        assertTrue(info.has("outputFormats"));
        assertTrue(info.has("layouts"));
        assertTrue(info.has("printURL"));
        assertTrue(info.has("createURL"));
       
        assertEquals("http://demo.mapfish.org/2.2/print/dep/print.pdf", info.getString("printURL"));
        assertEquals("http://demo.mapfish.org/2.2/print/dep/create.json", info.getString("createURL"));
    }
View Full Code Here

TOP

Related Classes of org.mapfish.print.wrapper.json.PJsonObject

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.