make IG test light and add some test cases
authorBas Leijdekkers <basleijdekkers@gmail.com>
Thu, 29 Sep 2016 17:30:13 +0000 (19:30 +0200)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Fri, 30 Sep 2016 07:21:23 +0000 (09:21 +0200)
plugins/InspectionGadgets/test/com/siyeh/igtest/threading/WaitNotInSynchronizedContextInspection.java [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/Test.java [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/WaitNotInSynchronizedContext.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/expected.xml [deleted file]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/WaitNotInSynchronizedContextInspectionTest.java

diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/WaitNotInSynchronizedContextInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/WaitNotInSynchronizedContextInspection.java
deleted file mode 100644 (file)
index c213b87..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.siyeh.igtest.threading;
-
-public class WaitNotInSynchronizedContextInspection
-{
-    private final Object lock = new Object();
-
-    public  void foo()
-    {
-        try
-        {
-            lock.wait();
-        }
-        catch(InterruptedException e)
-        {
-        }
-    }
-    public  synchronized void bar()
-    {
-        try
-        {
-            lock.wait();
-        }
-        catch(InterruptedException e)
-        {
-        }
-    }
-
-    public  void barzoomb() throws InterruptedException {
-        synchronized (lock) {
-            lock.wait();
-        }
-    }
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/Test.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/Test.java
deleted file mode 100644 (file)
index a3fe87b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.siyeh.igtest.threading.wait_not_in_synchronized_context;
-
-public class Test {
-       private final Object lock = new Object();
-       private final Object otherLock = new Object();
-
-       void foo() throws InterruptedException {
-        otherLock.wait();
-               synchronized (this) {
-                       lock.wait();
-               }
-        synchronized (lock) {
-            wait();
-        }
-       }
-
-    synchronized void bar() throws InterruptedException {
-        wait();
-    }
-
-       public static void main(String[] args) throws InterruptedException {
-               new Test().foo();
-       }
-
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/WaitNotInSynchronizedContext.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/WaitNotInSynchronizedContext.java
new file mode 100644 (file)
index 0000000..c321508
--- /dev/null
@@ -0,0 +1,40 @@
+package com.siyeh.igtest.threading.wait_not_in_synchronized_context;
+
+public class WaitNotInSynchronizedContext {
+  private final Object lock = new Object();
+  private final Object otherLock = new Object();
+
+  void foo() throws InterruptedException {
+    <warning descr="Call to 'otherLock.wait()' while not synchronized on 'otherLock'">otherLock.wait()</warning>;
+    synchronized (this) {
+      <warning descr="Call to 'lock.wait()' while not synchronized on 'lock'">lock.wait()</warning>;
+    }
+    synchronized (lock) {
+      <warning descr="Call to 'wait()' while not synchronized on 'this'">wait()</warning>;
+    }
+  }
+
+  synchronized void bar() throws InterruptedException {
+    wait();
+  }
+
+  public static void main(String[] args) throws InterruptedException {
+    new WaitNotInSynchronizedContext().foo();
+  }
+
+}
+class More {
+  private final Object lock = new Object();
+
+  public  synchronized void bar() {
+    try {
+      <warning descr="Call to 'lock.wait()' while not synchronized on 'lock'">lock.wait()</warning>;
+    } catch(InterruptedException e) {}
+  }
+
+  public  void barzoomb() throws InterruptedException {
+    synchronized (lock) {
+      lock.wait();
+    }
+  }
+}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/wait_not_in_synchronized_context/expected.xml
deleted file mode 100644 (file)
index 58b571c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<problems>
-  <problem>
-    <file>Test.java</file>
-    <line>8</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'wait()' while not synchronized</problem_class>
-    <description>Call to &lt;code&gt;otherLock.wait()&lt;/code&gt; while not synchronized on 'otherLock' #loc</description>
-  </problem>
-  
-  <problem>
-    <file>Test.java</file>
-    <line>10</line>
-    <problem_class>'wait()' while not synced</problem_class>
-    <description>Call to &lt;code&gt;lock.wait()()&lt;/code&gt; while not synchronized on 'lock' #loc</description>
-  </problem>
-
-  <problem>
-    <file>Test.java</file>
-    <line>13</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'wait()' while not synced</problem_class>
-    <description>Call to &lt;code&gt;wait()&lt;/code&gt; while not synchronized on 'this' #loc</description>
-  </problem>
-  
-</problems>
\ No newline at end of file
index 53624d6f7dc9022fa8aeebd8820703342775e073..4c229dba3ffce8ab1eadc7d747b765832efb215c 100644 (file)
@@ -1,12 +1,33 @@
+/*
+ * Copyright 2000-2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.siyeh.ig.threading;
 
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
 
-public class WaitNotInSynchronizedContextInspectionTest
-  extends IGInspectionTestCase {
+public class WaitNotInSynchronizedContextInspectionTest extends LightInspectionTestCase {
 
-  public void test() throws Exception {
-    doTest("com/siyeh/igtest/threading/wait_not_in_synchronized_context",
-           new WaitNotInSynchronizedContextInspection());
+  public void testWaitNotInSynchronizedContext() {
+    doTest();
+  }
+
+  @Nullable
+  @Override
+  protected InspectionProfileEntry getInspection() {
+    return new WaitNotInSynchronizedContextInspection();
   }
 }
\ No newline at end of file