summaryrefslogtreecommitdiff
path: root/java/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java')
-rw-r--r--java/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/java/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java b/java/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java
new file mode 100644
index 000000000000..80658077e986
--- /dev/null
+++ b/java/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java
@@ -0,0 +1,100 @@
+/*
+ * User: anna
+ * Date: 19-Aug-2009
+ */
+package com.intellij.refactoring;
+
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.concurrent.atomic.AtomicReferenceArray;
+import java.util.concurrent.atomic.AtomicIntegerArray;
+
+public class TypeMigrationByAtomicRuleTest extends TypeMigrationTestBase{
+ @NotNull
+ @Override
+ protected String getTestRoot() {
+ return "/refactoring/typeMigrationByAtomic/";
+ }
+
+ private void doTestDirectMigration() throws Exception {
+ doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicInteger", null));
+ }
+
+
+ public void testDirectIncrementDecrement() throws Exception {
+ doTestDirectMigration();
+ }
+
+ public void testDirectAssignments() throws Exception {
+ doTestDirectMigration();
+ }
+
+ public void testDirectConditions() throws Exception {
+ doTestFieldType("b", PsiType.BOOLEAN, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicBoolean", null));
+ }
+
+
+ public void testDirectByte() throws Exception {
+ doTestFieldType("b", PsiType.BYTE, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.Byte>", null));
+ }
+
+ public void testDirectString() throws Exception {
+ doTestFieldType("s", myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
+ myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.String>", null));
+ }
+
+ public void testDirectForeach() throws Exception {
+ doTestFieldType("lst", myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null),
+ myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.util.List<java.lang.String>>", null));
+ }
+
+ public void testDirectStringArray() throws Exception {
+ doTestFieldType("s", myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null).createArrayType(),
+ myJavaFacade.getElementFactory().createTypeFromText(AtomicReferenceArray.class.getName() + "<java.lang.String>", null));
+ }
+
+ public void testDirectIntArray() throws Exception {
+ doTestFieldType("a", PsiType.INT.createArrayType(),
+ myJavaFacade.getElementFactory().createTypeFromText(AtomicIntegerArray.class.getName(), null));
+ }
+
+ private void doTestReverseMigration() throws Exception {
+ doTestFieldType("i", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicInteger", null), PsiType.INT);
+ }
+
+
+ public void testReverseIncrementDecrement() throws Exception {
+ doTestReverseMigration();
+ }
+
+ public void testReverseAssignments() throws Exception {
+ doTestReverseMigration();
+ }
+
+ public void testReverseConditions() throws Exception {
+ doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicBoolean", null), PsiType.BOOLEAN);
+ }
+
+ public void testReverseByte() throws Exception {
+ doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.Byte>", null), PsiType.BYTE);
+ }
+
+ public void testReverseString() throws Exception {
+ doTestFieldType("s",
+ myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.String>", null),
+ myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
+ }
+
+ public void testReverseStringArray() throws Exception {
+ doTestFieldType("s",
+ myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String>", null),
+ myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null).createArrayType());
+ }
+
+ public void testReverseIntArray() throws Exception {
+ doTestFieldType("a",
+ myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicIntegerArray", null),
+ PsiType.INT.createArrayType());
+ }
+} \ No newline at end of file