Groovy: mock groovy-2.1 in tests

This commit is contained in:
Max Medvedev
2013-01-27 17:33:32 +04:00
parent 5069553135
commit 019fc2fa57
4 changed files with 16 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,8 @@ import com.intellij.openapi.vfs.JarFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
import static org.jetbrains.plugins.groovy.util.TestUtils.getMockGroovy1_8LibraryName
import static org.jetbrains.plugins.groovy.util.TestUtils.getMockGroovy2_1LibraryName
/**
* @author Max Medvedev
*/
@@ -36,7 +37,7 @@ class GroovyLightProjectDescriptor extends DefaultLightProjectDescriptor {
@Override
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
final Library.ModifiableModel modifiableModel = model.moduleLibraryTable.createLibrary("GROOVY").modifiableModel;
final VirtualFile groovyJar = JarFileSystem.instance.refreshAndFindFileByPath("$mockGroovy1_8LibraryName!/");
final VirtualFile groovyJar = JarFileSystem.instance.refreshAndFindFileByPath("$mockGroovy2_1LibraryName!/");
assert groovyJar != null;
modifiableModel.addRoot(groovyJar, OrderRootType.CLASSES);
modifiableModel.commit();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -788,7 +788,7 @@ new A().pro<caret>p''')
assertInstanceOf(resolved, GrGdkMethod)
def method = resolved.staticMethod as PsiMethod
assertEquals(method.parameterList.parameters[0].type.canonicalText, CommonClassNames.JAVA_LANG_STRING)
assertEquals(method.parameterList.parameters[0].type.canonicalText, 'java.lang.CharSequence')
}
void testLocalVarNotAvailableInClass() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ public abstract class TestUtils {
public static final String GROOVY_JAR = "groovy-all.jar";
public static final String GROOVY_JAR_17 = "groovy-all-1.7.jar";
public static final String GROOVY_JAR_18 = "groovy-1.8.0-beta-2.jar";
public static final String GROOVY_JAR_21 = "groovy-all-2.1.0-beta-1.jar";
public static String getMockJdkHome() {
return getAbsoluteTestDataPath() + "/mockJDK";
@@ -82,10 +83,18 @@ public abstract class TestUtils {
return getAbsoluteTestDataPath() + "/mockGroovyLib1.8";
}
public static String getMockGroovy2_1LibraryHome() {
return getAbsoluteTestDataPath() + "/mockGroovyLib2.1";
}
public static String getMockGroovy1_8LibraryName() {
return getMockGroovy1_8LibraryHome()+"/"+GROOVY_JAR_18;
}
public static String getMockGroovy2_1LibraryName() {
return getMockGroovy2_1LibraryHome() + "/" + GROOVY_JAR_21;
}
public static PsiFile createPseudoPhysicalGroovyFile(final Project project, final String text) throws IncorrectOperationException {
return createPseudoPhysicalFile(project, TEMP_FILE, text);
}