Package unit.common.reflection

Source Code of unit.common.reflection.ReflectionUtilsTest$DummyTask

package unit.common.reflection;

import org.junit.Test;

import play.test.UnitTest;
import tasks.Task;
import tasks.TaskContext;

import common.reflection.ReflectionUtils;

/**
* Unit tests for {@link ReflectionUtils}
*/
public class ReflectionUtilsTest extends UnitTest {

    public static class DummyTask implements Task {
        @Override
        public void execute(TaskContext context) throws Exception {}
    }
   
    @Test
    public void testNewInstance_negative() throws Exception {
        try {
            ReflectionUtils.newInstance(Task.class, "Foo");
            fail();
        } catch (Exception e) {
            // expected
        }
       
        Task task = ReflectionUtils.newInstance(Task.class, DummyTask.class.getName());
        assertTrue("unexpected Task implementation", task instanceof DummyTask);
    }
   
}
TOP

Related Classes of unit.common.reflection.ReflectionUtilsTest$DummyTask

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.