diff options
Diffstat (limited to 'gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java')
-rw-r--r-- | gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java b/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java index 318c6ac3..eeabcee1 100644 --- a/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java +++ b/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java @@ -15,14 +15,15 @@ */
package com.google.gson.functional;
+import static org.junit.Assert.assertFalse;
+
+import com.google.gson.Gson;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
-
-import junit.framework.TestCase;
-
-import com.google.gson.Gson;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for ensuring Gson thread-safety.
@@ -30,12 +31,11 @@ import com.google.gson.Gson; * @author Inderjeet Singh
* @author Joel Leitch
*/
-public class ConcurrencyTest extends TestCase {
+public class ConcurrencyTest {
private Gson gson;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
gson = new Gson();
}
@@ -43,6 +43,7 @@ public class ConcurrencyTest extends TestCase { * Source-code based on
* http://groups.google.com/group/google-gson/browse_thread/thread/563bb51ee2495081
*/
+ @Test
public void testSingleThreadSerialization() {
MyObject myObj = new MyObject();
for (int i = 0; i < 10; i++) {
@@ -54,6 +55,7 @@ public class ConcurrencyTest extends TestCase { * Source-code based on
* http://groups.google.com/group/google-gson/browse_thread/thread/563bb51ee2495081
*/
+ @Test
public void testSingleThreadDeserialization() {
for (int i = 0; i < 10; i++) {
gson.fromJson("{'a':'hello','b':'world','i':1}", MyObject.class);
@@ -64,6 +66,7 @@ public class ConcurrencyTest extends TestCase { * Source-code based on
* http://groups.google.com/group/google-gson/browse_thread/thread/563bb51ee2495081
*/
+ @Test
public void testMultiThreadSerialization() throws InterruptedException {
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishedLatch = new CountDownLatch(10);
@@ -95,6 +98,7 @@ public class ConcurrencyTest extends TestCase { * Source-code based on
* http://groups.google.com/group/google-gson/browse_thread/thread/563bb51ee2495081
*/
+ @Test
public void testMultiThreadDeserialization() throws InterruptedException {
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishedLatch = new CountDownLatch(10);
|