view src/test/java/org/msgpack/template/TestTemplateRegistry.java @ 0:cb825acd883a

first commit
author sugi
date Sat, 18 Oct 2014 15:06:15 +0900
parents
children
line wrap: on
line source

package org.msgpack.template;

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.Test;

public class TestTemplateRegistry {

    private static final TemplateRegistry root = new TemplateRegistry(null);

    static class MyArrayList<E> extends ArrayList<E> {
        private static final long serialVersionUID = 1L;
    }

    @Test
    public void testTraverseInterface() throws Exception {
        Template<?> template = root.lookup(List.class);
        assertThat(template, is(instanceOf(ListTemplate.class)));
    }

    @Test
    public void testTraverseDescentInterface() throws Exception {
        Template<?> template = root.lookup(MyArrayList.class);
        assertThat(template, is(instanceOf(ListTemplate.class)));
    }

    @Test
    public void testArraysAsListIsPackable() throws Exception {
        Template<?> template = root.lookup(Arrays.asList().getClass());
        assertThat(template, is(instanceOf(ListTemplate.class)));
    }

}