java-tests module introduced

This commit is contained in:
Dmitry Jemerov
2009-09-10 17:59:25 +04:00
parent 9b7434e19f
commit fcc49cb61c
7 changed files with 48 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="testFramework-java" />
<orderEntry type="module" module-name="java-impl" />
</component>
</module>
@@ -0,0 +1,18 @@
import java.util.*;
class A<K, V> {
public Iterator<Map.Entry<K, V>> iterator(long revision) {
return new <caret>Iterator<Map.Entry<K, V>>() {
public boolean hasNext() {
return false;
}
public Map.Entry<K, V> next() {
return null;
}
public void remove() {
}
};
}
}
@@ -0,0 +1,20 @@
import java.util.*;
class A<K, V> {
public Iterator<Map.Entry<K, V>> iterator(long revision) {
return new MyIterator<K, V>();
}
private static class MyIterator<K, V> implements Iterator<Map.Entry<K, V>> {
public boolean hasNext() {
return false;
}
public Map.Entry<K, V> next() {
return null;
}
public void remove() {
}
}
}
@@ -0,0 +1,22 @@
package com.intellij;
import com.intellij.openapi.application.PathManager;
import org.jetbrains.annotations.NonNls;
import java.io.File;
/**
* @author yole
*/
public class JavaTestUtil {
@NonNls private static final String JAVA_TEST_DATA = "java/java-tests/testData";
public static String getJavaTestDataPath() {
final String homePath = PathManager.getHomePath();
File dir = new File(homePath, "community/" + JAVA_TEST_DATA);
if (dir.exists()) {
return dir.getPath();
}
return new File(homePath, JAVA_TEST_DATA).getPath();
}
}
@@ -0,0 +1,44 @@
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightTestCase;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.refactoring.anonymousToInner.AnonymousToInnerHandler;
/**
* @author yole
*/
public class AnonymousToInnerTest extends CodeInsightTestCase {
private static final String TEST_ROOT = "/refactoring/anonymousToInner/";
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
@Override
protected Sdk getTestProjectJdk() {
return JavaSdkImpl.getMockJdk15("java 1.5");
}
public void testGenericTypeParameters() throws Exception { // IDEADEV-29446
doTest("MyIterator", true);
}
private void doTest(final String newClassName, final boolean makeStatic) throws Exception {
configureByFile(TEST_ROOT + getTestName(true) + ".java");
AnonymousToInnerHandler handler = new AnonymousToInnerHandler() {
@Override
protected boolean showRefactoringDialog() {
myNewClassName = newClassName;
myMakeStatic = makeStatic;
return true;
}
};
handler.invoke(myProject, myEditor, myFile, null);
checkResultByFile(TEST_ROOT + getTestName(true) + "_after.java");
}
}