Package org.jolokia.converter.util

Examples of org.jolokia.converter.util.CompositeTypeAndJson


        extractor.setObjectValue(stringToObjectConverter,new File("test"),"executable",Boolean.TRUE);
    }

    @Test
    public void simple() throws OpenDataException, AttributeNotFoundException, MalformedObjectNameException {
        CompositeTypeAndJson ctj = getTestData();
        JSONObject result = (JSONObject) extractJson(ctj.getCompositeData());
        assertEquals(result.size(), 4);
        assertEquals(result.get("verein"),"FCN");
        assertEquals(result.get("platz"),17);
        assertTrue((Boolean) result.get("absteiger"));
    }
View Full Code Here


        assertTrue((Boolean) result.get("absteiger"));
    }

    @Test
    public void withPath() throws MalformedObjectNameException, OpenDataException, AttributeNotFoundException {
        CompositeTypeAndJson ctj = getTestData();
        String result = (String) extractJson(ctj.getCompositeData(),"complex","domain");
        assertEquals(result,"java.lang");
    }
View Full Code Here

        assertEquals(result,"java.lang");
    }

    @Test(expectedExceptions = ValueFaultHandler.AttributeFilteredException.class)
    public void withInvalidPath1() throws MalformedObjectNameException, OpenDataException, AttributeNotFoundException {
        CompositeTypeAndJson ctj = getTestData();
        extractJson(ctj.getCompositeData(),"blub");
    }
View Full Code Here

        extractJson(ctj.getCompositeData(),"blub");
    }

    @Test(expectedExceptions = ValueFaultHandler.AttributeFilteredException.class)
    public void withInvalidPath2() throws MalformedObjectNameException, OpenDataException, AttributeNotFoundException {
        CompositeTypeAndJson ctj = getTestData();
        extractJson(ctj.getCompositeData(),"complex","domain","blub");
    }
View Full Code Here

        extractJson(ctj.getCompositeData(),"complex","domain","blub");
    }

    @Test
    public void withWildCardPath() throws MalformedObjectNameException, OpenDataException, AttributeNotFoundException {
        CompositeTypeAndJson ctj = getTestData();
        JSONObject result = (JSONObject) extractJson(ctj.getCompositeData(),null,"domain");
        assertEquals(result.size(),1);
        assertEquals(result.get("complex"),"java.lang");
    }
View Full Code Here

        assertEquals(result.get("complex"),"java.lang");
    }

    @Test(expectedExceptions = ValueFaultHandler.AttributeFilteredException.class)
    public void withWildCardPathAndInvalidFilter() throws MalformedObjectNameException, OpenDataException, AttributeNotFoundException {
        CompositeTypeAndJson ctj = getTestData();
        extractJson(ctj.getCompositeData(),null,"unknownAttribute");
    }
View Full Code Here

        extractJson(ctj.getCompositeData(),null,"unknownAttribute");
    }


    private CompositeTypeAndJson getTestData() throws OpenDataException, MalformedObjectNameException {
        return new CompositeTypeAndJson(
                    STRING,"verein","FCN",
                    INTEGER,"platz",17,
                    BOOLEAN,"absteiger",Boolean.TRUE,
                    OBJECTNAME,"complex",new ObjectName("java.lang:type=Memory")
            );
View Full Code Here

        converter.convertToObject(new ArrayType(2,STRING),"{ \"hello\": \"world\"}");
    }

    @Test
    public void arrayTypeWithCompositeElementType() throws OpenDataException {
        CompositeTypeAndJson taj = new CompositeTypeAndJson(
                STRING,"verein","FCN"

        );
        CompositeData[] result =
                (CompositeData[]) converter.convertToObject(new ArrayType(2,taj.getType()),"[" + taj.getJsonAsString() + "]");
        assertEquals(result[0].get("verein"), "FCN");
        assertEquals(result.length,1);
    }
View Full Code Here

    @Test(expectedExceptions = UnsupportedOperationException.class,expectedExceptionsMessageRegExp = ".*Unsupported.*")
    public void arrayTypeWithWrongElementType() throws OpenDataException {
        TabularTypeAndJson taj = new TabularTypeAndJson(
                new String[] { "verein" },
                new CompositeTypeAndJson(
                   STRING,"verein","fcn",
                   BOOLEAN,"absteiger",false
                )
        );
        JSONArray array = new JSONArray();
View Full Code Here

        converter.convertToObject(new ArrayType(2, taj.getType()),array);
    }

    @Test
    public void compositeType() throws OpenDataException, AttributeNotFoundException, ParseException {
        CompositeTypeAndJson taj = new CompositeTypeAndJson(
                STRING,"verein","FCN",
                INTEGER,"platz",6,
                STRING,"trainer",null,
                BOOLEAN,"absteiger",false
        );
        for (Object input : new Object[] { taj.getJson(), taj.getJsonAsString() }) {
            CompositeData result = (CompositeData) converter.convertToObject(taj.getType(),input);
            assertEquals(result.get("verein"),"FCN");
            assertEquals(result.get("trainer"),null);
            assertEquals(result.get("platz"),6);
            assertEquals(result.get("absteiger"),false);
            assertEquals(result.values().size(),4);
View Full Code Here

TOP

Related Classes of org.jolokia.converter.util.CompositeTypeAndJson

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.