Package org.auraframework.util.json

Examples of org.auraframework.util.json.Json$JsonException


     * Verify registered components are serialized in alphabetical order
     */
    public void testSerializeAsPart() throws Exception {
        InstanceStack iStack = new InstanceStack();

        Json jsonMock = Mockito.mock(Json.class);
        BaseComponent<?, ?> a = getComponentWithPath("a");
        BaseComponent<?, ?> b = getComponentWithPath("b");
        BaseComponent<?, ?> c = getComponentWithPath("c");
        iStack.registerComponent(b);
        iStack.registerComponent(c);
View Full Code Here


    /**
     * Verify nothing serialized if no registered components
     */
    public void testSerializeAsPartNoComponents() throws Exception {
        InstanceStack iStack = new InstanceStack();
        Json jsonMock = Mockito.mock(Json.class);
        iStack.serializeAsPart(jsonMock);
        assertEquals("Components should empty when no registered components", 0, iStack.getComponents().size());
        verifyZeroInteractions(jsonMock);
    }
View Full Code Here

        LoggingService loggingService = Aura.getLoggingService();
        if (message == null) {
            return;
        }
        List<Action> actions = message.getActions();
        Json json = Json.createJsonStream(out, context.getJsonSerializationContext());
        try {
            json.writeMapBegin();
            if (extras != null && extras.size() > 0) {
                for (Map.Entry<?, ?> entry : extras.entrySet()) {
                    json.writeMapEntry(entry.getKey(), entry.getValue());
                }
            }
            json.writeMapKey("actions");
            json.writeArrayBegin();
            run(actions, json);
            json.writeArrayEnd();

            loggingService.startTimer(LoggingService.TIMER_SERIALIZATION);
            loggingService.startTimer(LoggingService.TIMER_SERIALIZATION_AURA);
            try {
                json.writeMapEntry("context", context);
                List<Event> clientEvents = Aura.getContextService().getCurrentContext().getClientEvents();
                if (clientEvents != null && !clientEvents.isEmpty()) {
                    json.writeMapEntry("events", clientEvents);
                }
                json.writeMapEnd();
            } finally {
                loggingService.stopTimer(LoggingService.TIMER_SERIALIZATION_AURA);
                loggingService.stopTimer(LoggingService.TIMER_SERIALIZATION);
            }
        } finally {
            json.close();
        }
    }
View Full Code Here

    public void testSerialization() throws Exception {
        LibraryDef libDef = Aura.getDefinitionService().getDefinition("test:test_Library", LibraryDef.class);
        assertNotNull(libDef);

        ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
        Json json = Json.createJsonStream(baos, false, false, false);
        libDef.serialize(json);
        json.close();

        String actual = new String(baos.toByteArray(), Charsets.UTF_8).replaceAll("\\s", "");
        goldFileJson(actual);
    }
View Full Code Here

                IncludeDef.class, libDesc);
        Mockito.doReturn(includeDesc.getName()).when(descriptor).getName();
        addSourceAutoCleanup(includeDesc, "function(){}");

        StringBuffer buffer = new StringBuffer();
        Json json = Json.createJsonStream(buffer, Aura.getContextService().getCurrentContext()
                .getJsonSerializationContext());

        builder.setDescriptor(descriptor);
        builder.setIncludeDescriptor(includeDesc);
        IncludeDefRef def = builder.build();

        def.validateDefinition();
        json.writeMapBegin();
        def.serialize(json);
        json.writeMapEnd();
        json.close();

        assertEquals(
                String.format("{\n" +
                        "\n" +
                        "function(define) {define(\"%s:%s\", function(){}\n" +
View Full Code Here

        Mockito.doReturn(includeDesc.getName()).when(descriptor).getName();
        addSourceAutoCleanup(includeDesc,
                "//this doc should be helpful\nfunction(){\n//fix later\nreturn this;}//last word");

        StringBuffer buffer = new StringBuffer();
        Json json = Json.createJsonStream(buffer, Aura.getContextService().getCurrentContext()
                .getJsonSerializationContext());

        builder.setDescriptor(descriptor);
        builder.setIncludeDescriptor(includeDesc);
        IncludeDefRef def = builder.build();

        def.validateDefinition();
        json.writeMapBegin();
        def.serialize(json);
        json.writeMapEnd();
        json.close();

        assertEquals(
                String.format("{\n" +
                        "\n" +
                        "function(define) {define(\"%s:%s\", \n" +
View Full Code Here

        Mockito.doReturn(includeDesc.getName()).when(descriptor).getName();
        addSourceAutoCleanup(includeDesc,
                "/*this doc should be helpful*/function(){/*fix later*/return this;}/*last word*/");

        StringBuffer buffer = new StringBuffer();
        Json json = Json.createJsonStream(buffer, Aura.getContextService().getCurrentContext()
                .getJsonSerializationContext());

        builder.setDescriptor(descriptor);
        builder.setIncludeDescriptor(includeDesc);
        IncludeDefRef def = builder.build();

        def.validateDefinition();
        json.writeMapBegin();
        def.serialize(json);
        json.writeMapEnd();
        json.close();

        assertEquals(
                String.format("{\n" +
                        "\n" +
                        "function(define) {define(\"%s:%s\", \n" +
View Full Code Here

                IncludeDef.class, libDesc);
        Mockito.doReturn(includeDesc.getName()).when(descriptor).getName();
        addSourceAutoCleanup(includeDesc, "function(){}");

        StringBuffer buffer = new StringBuffer();
        Json json = Json.createJsonStream(buffer, Aura.getContextService().getCurrentContext()
                .getJsonSerializationContext());

        builder.setDescriptor(descriptor);
        builder.setIncludeDescriptor(includeDesc);
        builder.setImports(ImmutableList.of(importDesc));
        IncludeDefRef def = builder.build();

        def.validateDefinition();
        json.writeMapBegin();
        def.serialize(json);
        json.writeMapEnd();
        json.close();

        assertEquals(
                String.format("{\n" +
                        "\n" +
                        "function(define) {define(\"%s:%s\", \"%s\", function(){}\n" +
View Full Code Here

                IncludeDef.class, libDesc);
        Mockito.doReturn(includeDesc.getName()).when(descriptor).getName();
        addSourceAutoCleanup(includeDesc, "function(){}");

        StringBuffer buffer = new StringBuffer();
        Json json = Json.createJsonStream(buffer, Aura.getContextService().getCurrentContext()
                .getJsonSerializationContext());

        builder.setDescriptor(descriptor);
        builder.setIncludeDescriptor(includeDesc);
        builder.setImports(ImmutableList.of(import1Desc, import2Desc, import3Desc));
        IncludeDefRef def = builder.build();

        def.validateDefinition();
        json.writeMapBegin();
        def.serialize(json);
        json.writeMapEnd();
        json.close();

        assertEquals(
                String.format("{\n" +
                        "\n" +
                        "function(define) {define(\"%s:%s\", \"%s\", \"%s\", \"%s\", function(){}\n" +
View Full Code Here

                IncludeDef.class, libDesc);
        Mockito.doReturn(includeDesc.getName()).when(descriptor).getName();
        addSourceAutoCleanup(includeDesc, "var myexpt=function(){return 'something'}");

        StringBuffer buffer = new StringBuffer();
        Json json = Json.createJsonStream(buffer, Aura.getContextService().getCurrentContext()
                .getJsonSerializationContext());

        builder.setDescriptor(descriptor);
        builder.setIncludeDescriptor(includeDesc);
        builder.setExport("myexpt");
        IncludeDefRef def = builder.build();

        def.validateDefinition();
        json.writeMapBegin();
        def.serialize(json);
        json.writeMapEnd();
        json.close();

        assertEquals(
                String.format("{\n" +
                        "\n" +
                        "function(define) {define(\"%s:%s\", \n" +
View Full Code Here

TOP

Related Classes of org.auraframework.util.json.Json$JsonException

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.