Package org.apache.myfaces.extensions.cdi.message.api

Examples of org.apache.myfaces.extensions.cdi.message.api.Message


public class MessageSeverityTest extends AbstractTest
{
    @Test
    public void createMessageWithDefaultSeverityTest()
    {
        Message message = this.messageContext.message().text("hello open message").create();

        assertNotNull(message);
        assertTrue(message.getPayload().containsKey(MessageSeverity.class));
        assertTrue(message.getPayload().containsValue(MessageSeverity.INFO));

        assertTrue(message instanceof MessageWithSeverity);
        assertTrue(MessageSeverity.INFO.equals(((MessageWithSeverity) message).getSeverity()));
    }
View Full Code Here


    }

    @Test
    public void createMessageWithSeverityWarnTest()
    {
        Message message = this.messageContext.message().text("hello open message").payload(MessageSeverity.WARN).create();

        assertNotNull(message);
        assertTrue(message.getPayload().containsKey(MessageSeverity.class));
        assertTrue(message.getPayload().containsValue(MessageSeverity.WARN));

        assertTrue(message instanceof MessageWithSeverity);
        assertTrue(MessageSeverity.WARN.equals(((MessageWithSeverity) message).getSeverity()));
    }
View Full Code Here

        this.messageContext.config().change().messageInterpolator(new ELAwareMessageInterpolator(new TestELProvider()));

        Number arg1 = new BigDecimal("123.4567");
        Date arg2 = new Date();
        String text = "#1: {arg1} and #2: {arg2}";
        Message message1 = this.messageContext.message().text(text)
                .namedArgument("arg1", arg1).namedArgument("arg2", arg2).create();

        Message message2 = new DefaultMessage(text, NamedArguments.add("arg1", arg1).add("arg2", arg2).create());
        ((MessageContextConfigAware)message2).setMessageContextConfig(this.messageContext.config());

        assertEquals(message1, message2);
        assertEquals(message1.toString(), message2.toString());
        assertEquals(message1.toString(this.messageContext), message2.toString(this.messageContext));
    }
View Full Code Here

        this.messageContext.config().change().messageInterpolator(new ELAwareMessageInterpolator(new TestELProvider()));

        Number arg1 = new BigDecimal("123.4567");
        Date arg2 = new Date();
        String text = "#1: {arg1} and #2: {arg2}";
        Message message1 = this.messageContext.message().text(text)
                .namedArgument("arg1", arg1).namedArgument("arg2", arg2).create();

        Map<String, Serializable> arguments = new HashMap<String, Serializable>();
        arguments.put("arg1", arg1);
        arguments.put("arg2", arg2);
        Message message2 = new DefaultMessage(text, NamedArguments.convert(arguments));
        ((MessageContextConfigAware)message2).setMessageContextConfig(this.messageContext.config());

        assertEquals(message1, message2);
        assertEquals(message1.toString(), message2.toString());
        assertEquals(message1.toString(this.messageContext), message2.toString(this.messageContext));
    }
View Full Code Here

    {
        this.messageContext.config().change().addMessageHandler(new TestInternalMessageAwareMessageHandler());

        this.messageContext.message().text("test msg 1").add();

        Message internalMessage = new DefaultInternalMessage("test msg 2").setMessageContextConfig(this.messageContext.config());
        this.messageContext.addMessage(internalMessage);

        assertEquals(1, this.messageContext.getMessages().size());
        assertEquals(this.messageContext.message().text("test msg 1").create(),
                this.messageContext.getMessages().iterator().next());
View Full Code Here

        TestPayloadAwareMessageResolver testResolver = new TestPayloadAwareMessageResolver();
        this.messageContext.config().change().messageResolver(testResolver);

        assertFalse(testResolver.isPayloadAvailable());

        Message message = this.messageContext.message().text("test msg").payload(MessageSeverity.WARN).create();
        message.toString(this.messageContext);

        assertTrue(testResolver.isPayloadAvailable());
    }
View Full Code Here

public class SimpleMessageTest extends AbstractTest
{
    @Test
    public void createInlineMessageTest()
    {
        Message message = this.messageContext.message().text("hello open message").create();

        assertEquals("hello open message", message.toString(this.messageContext));
    }
View Full Code Here

    }

    @Test
    public void createInlineMessageViaMessageBuilderTest()
    {
        Message message = SimpleMessageBuilder.message().text("hello open message").create();

        assertEquals("hello open message", message.toString(this.messageContext));
    }
View Full Code Here

    }

    @Test
    public void createInlineMessageViaCustomMessageBuilderTest()
    {
        Message message = TestMessageBuilder.message().text("hello open message").create();

        assertEquals("hello open message", message.toString(this.messageContext));
    }
View Full Code Here

    }

    @Test
    public void resolveMessageTest()
    {
        Message message = this.messageContext.message().text("{hello}").create();

        checkDefaultHelloMessage(message.toString(this.messageContext));
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.extensions.cdi.message.api.Message

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.