Package name.pehl.taoki.paging.parser

Source Code of name.pehl.taoki.paging.parser.HeaderPageInfoParserTest

package name.pehl.taoki.paging.parser;

import static org.junit.Assert.fail;
import name.pehl.taoki.paging.PageInfo;

import org.junit.Before;
import org.junit.Test;

/**
* @author $Author: harald.pehl $
* @version $Date: 2012-03-02 08:50:20 -0600 (Fri, 02 Mar 2012) $ $Revision: 219 $
*/
public class HeaderPageInfoParserTest extends AbstractPageInfoParserTest
{
    @Before
    public void setUp() throws Exception
    {
        underTest = new HeaderPageInfoParser();
    }


    @Test
    public void parseInvalid()
    {
        try
        {
            underTest.parse(FOO);
            fail(PAGE_INFO_PARSE_EXCEPTION_EXPECTED);
        }
        catch (PageInfoParseException e)
        {
            // nop
        }

        try
        {
            underTest.parse("items=0-");
            fail(PAGE_INFO_PARSE_EXCEPTION_EXPECTED);
        }
        catch (PageInfoParseException e)
        {
            // nop
        }

        try
        {
            underTest.parse("items=0-x");
            fail(PAGE_INFO_PARSE_EXCEPTION_EXPECTED);
        }
        catch (PageInfoParseException e)
        {
            // nop
        }
        try
        {
            underTest.parse("items=0-9;");
            fail(PAGE_INFO_PARSE_EXCEPTION_EXPECTED);
        }
        catch (PageInfoParseException e)
        {
            // nop
        }

        try
        {
            underTest.parse("items=0-9;foo:");
            fail(PAGE_INFO_PARSE_EXCEPTION_EXPECTED);
        }
        catch (PageInfoParseException e)
        {
            // nop
        }

        try
        {
            underTest.parse("items=0-9;foo:bar");
            fail(PAGE_INFO_PARSE_EXCEPTION_EXPECTED);
        }
        catch (PageInfoParseException e)
        {
            // nop
        }
    }


    @Test
    public void parseValid() throws PageInfoParseException
    {
        PageInfo pageInfo = null;

        pageInfo = underTest.parse("items=0-9");
        assertPageInfo(pageInfo, 0, 10);
    }
}
TOP

Related Classes of name.pehl.taoki.paging.parser.HeaderPageInfoParserTest

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.