Package mireka.address.parser

Source Code of mireka.address.parser.PathParserTest

package mireka.address.parser;

import static org.junit.Assert.*;

import mireka.address.parser.ast.PathAST;

import org.junit.Test;

public class PathParserTest {
    @Test
    public void testSimplePath() throws Exception {
        PathAST pathAST = new PathParser("<john@example.com>").parse();
        assertNull(pathAST.sourceRouteAST);
        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
        assertEquals("example.com", pathAST.mailboxAST.remotePartAST.spelling);
    }

    @Test
    public void testSourceRoute1() throws Exception {
        PathAST pathAST = new PathParser("<@example.org:john@example.com>").parse();
        assertEquals(1, pathAST.sourceRouteAST.domainASTs.size());
        assertEquals("example.org", pathAST.sourceRouteAST.domainASTs.get(0).spelling);
        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
    }

    @Test
    public void testSourceRoute2() throws Exception {
        PathAST pathAST =
                new PathParser("<@example.org@example.net:john@example.com>")
                        .parse();
        assertEquals(2, pathAST.sourceRouteAST.domainASTs.size());
        assertEquals("example.org", pathAST.sourceRouteAST.domainASTs.get(0).spelling);
        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
    }
}
TOP

Related Classes of mireka.address.parser.PathParserTest

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.