54 lines
1.2 KiB
Java
54 lines
1.2 KiB
Java
package bytecode.operators;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import java.io.File;
|
|
import java.lang.reflect.Method;
|
|
import java.net.URL;
|
|
import java.net.URLClassLoader;
|
|
import java.util.Vector;
|
|
|
|
import org.junit.Ignore;
|
|
import org.junit.Test;
|
|
|
|
import bytecode.SourceFileBytecodeTest;
|
|
|
|
public class ModuloOperatorTest extends SourceFileBytecodeTest{
|
|
@Override
|
|
protected void init() {
|
|
testName = "ModuloOperator";
|
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
|
}
|
|
|
|
@Test
|
|
public void testConstruct() throws Exception{
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
Object obj = cls.newInstance();
|
|
assertTrue(true);
|
|
}
|
|
|
|
@Test
|
|
public void testTwoIntegers() throws Exception{
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
Object obj = cls.newInstance();
|
|
|
|
Integer x = new Integer(1);
|
|
Integer y = new Integer(2);
|
|
|
|
Class[] params = new Class[]{
|
|
x.getClass(),
|
|
y.getClass(),
|
|
};
|
|
|
|
Method method = cls.getDeclaredMethod("method", params);
|
|
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
|
assertEquals(new Integer(1), returnValue);
|
|
}
|
|
}
|