summaryrefslogtreecommitdiff
path: root/java/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java
blob: 5d002d3fcced12bde4d7ac7eaed951483d12921b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * User: anna
 * Date: 19-Aug-2009
 */
package com.intellij.refactoring;

import com.intellij.psi.PsiType;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;

public class TypeMigrationByThreadLocalRuleTest extends TypeMigrationTestBase{
  @NotNull
  @Override
  protected String getTestRoot() {
    return "/refactoring/typeMigrationByThreadLocal/";
  }


  public void testDirectInt() throws Exception {
    doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.Integer>", null));
  }
  
  public void testDirectByte() throws Exception {
    doTestFieldType("i", PsiType.BYTE, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.Byte>", null));
  }

  public void testDirectString() throws Exception {
    doTestFieldType("myS", PsiType.getJavaLangString(myPsiManager, GlobalSearchScope.allScope(myProject)), myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.String>", null));
  }

  public void testLanguageLevel() throws Exception {
    final LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(getProject());
    final LanguageLevel languageLevel = extension.getLanguageLevel();
    try {
      extension.setLanguageLevel(LanguageLevel.JDK_1_3);
      doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal", null));
    }
    finally {
      extension.setLanguageLevel(languageLevel);
    }
  }
}