Package scenic3.apt

Source Code of scenic3.apt.UrlMatcherGeneratorTest

package scenic3.apt;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.SortedMap;
import java.util.TreeMap;

import org.junit.Test;

import scenic3.ActionPath;
import scenic3.test.Resources;

/**
* Test for {@link UrlMatcherGenerator}
* @author shuji.w6e
* @since 0.2.0
*/
public class UrlMatcherGeneratorTest {
   
    @Test
    public void generate_$Index() throws Exception {
        String packageName = "scenic3.tutorial.controller.macher";
        String className = "TestMacher";
        String pageClassName = "scenic3.tutorial.page.FooPage";
        String pagePath = "/foo/";
        SortedMap<ActionPath, String> patterns = new TreeMap<ActionPath, String>();
        UrlMatcherDesc desc = new UrlMatcherDesc(packageName, className, pageClassName, pagePath, patterns, "scenic3.tutorial.controller.$index");
        StringWriter writer = new StringWriter();
        UrlMatcherGenerator generator = new UrlMatcherGenerator(desc, new PrintWriter(writer));
        generator.generate();
        String actual = writer.toString();
        String expected = Resources.load(getClass().getResourceAsStream("TestMacher.txt"));
        assertThat(actual, is(expected));
    }

    @Test
    public void generate_list() throws Exception {
        String packageName = "scenic3.tutorial.controller.macher";
        String className = "ListMacher";
        String pageClassName = "scenic3.tutorial.page.BarPage";
        String pagePath = "/foo/";
        SortedMap<ActionPath, String> patterns = new TreeMap<ActionPath, String>();
        patterns.put(new ActionPath("list", null), "scenic3.tutorial.controller._list");
        UrlMatcherDesc desc = new UrlMatcherDesc(packageName, className, pageClassName, pagePath, patterns, null);
        StringWriter writer = new StringWriter();
        UrlMatcherGenerator generator = new UrlMatcherGenerator(desc, new PrintWriter(writer));
        generator.generate();
        String actual = writer.toString();
        String expected = Resources.load(getClass().getResourceAsStream("ListMacher.txt"));
        assertThat(actual, is(expected));
    }
}
TOP

Related Classes of scenic3.apt.UrlMatcherGeneratorTest

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.