2015-10-31 17:48:46 +00:00
|
|
|
package bytecode;
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import plugindevelopment.TypeInsertTester;
|
|
|
|
import de.dhbwstuttgart.core.MyCompiler;
|
|
|
|
import de.dhbwstuttgart.core.MyCompilerAPI;
|
|
|
|
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
|
|
|
import de.dhbwstuttgart.logger.Section;
|
|
|
|
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
|
|
|
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
|
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
|
|
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
|
|
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
|
|
|
|
2015-11-10 17:26:29 +00:00
|
|
|
public class NewClassTest extends SourceFileBytecodeTest{
|
2015-10-31 17:48:46 +00:00
|
|
|
@Override
|
|
|
|
protected void init() {
|
|
|
|
testName = "NewClass";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testInit() throws Exception {
|
|
|
|
ClassLoader cl = getClassLoader();
|
|
|
|
|
|
|
|
cl.loadClass(testName).newInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMethod() throws Exception {
|
|
|
|
try{
|
|
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
|
|
|
|
Object obj = cls.newInstance();
|
|
|
|
|
|
|
|
File file = new File(rootDirectory);
|
|
|
|
URL url = file.toURL();
|
|
|
|
URL[] urls = new URL[]{url};
|
|
|
|
|
|
|
|
|
|
|
|
Class[] params = new Class[0];
|
|
|
|
|
|
|
|
Method method = cls.getDeclaredMethod("method", params);
|
|
|
|
Object returnValue = method.invoke(obj);
|
|
|
|
assertTrue(returnValue instanceof String);
|
|
|
|
}catch(Exception e){
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|