Package mireka.address.parser

Source Code of mireka.address.parser.RecipientParserTest

package mireka.address.parser;

import static org.junit.Assert.*;

import mireka.address.parser.ast.DomainPostmasterRecipientAST;
import mireka.address.parser.ast.MailboxRecipientAST;
import mireka.address.parser.ast.RecipientAST;
import mireka.address.parser.ast.SystemPostmasterRecipientAST;

import org.junit.Test;

public class RecipientParserTest {
    @Test
    public void testSystemPostmaster() throws Exception {
        RecipientAST recipientAST = new RecipientParser("<POSTMASTER>").parse();
        assertTrue(recipientAST instanceof SystemPostmasterRecipientAST);
        assertEquals("POSTMASTER",
                ((SystemPostmasterRecipientAST) recipientAST).postmasterSpelling);
    }

    @Test
    public void testDomainPostmaster() throws Exception {
        RecipientAST recipientAST =
                new RecipientParser("<POSTMASTER@example.com>").parse();
        assertTrue(recipientAST instanceof DomainPostmasterRecipientAST);
        assertEquals(
                "POSTMASTER",
                ((DomainPostmasterRecipientAST) recipientAST).mailboxAST.localPartAST.spelling);
    }

    @Test
    public void testAlmostDomainPostmaster() throws Exception {
        RecipientAST recipientAST =
                new RecipientParser("<Postmaster@[192.0.2.0]>").parse();
        assertTrue(recipientAST instanceof MailboxRecipientAST);
        assertEquals("Postmaster",
                ((MailboxRecipientAST) recipientAST).pathAST.mailboxAST.localPartAST.spelling);
    }

    @Test
    public void testMailboxRecipient() throws Exception {
        RecipientAST recipientAST = new RecipientParser("<john@example.com>").parse();
        assertTrue(recipientAST instanceof MailboxRecipientAST);
        assertEquals("john",
                ((MailboxRecipientAST) recipientAST).pathAST.mailboxAST.localPartAST.spelling);
    }
}
TOP

Related Classes of mireka.address.parser.RecipientParserTest

TOP
Copyright © 2018 www.massapi.com. 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.