Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to JUnit 4 #97

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ project("spring-webflow") {
optional("org.apache.tiles:tiles-extras:$tiles3Version") {
exclude group: "org.springframework", module: "spring-web"
}
provided("junit:junit:3.8.2")
provided("junit:junit:4.12")
testCompile("org.springframework:spring-aop:$springVersion")
testCompile("org.springframework:spring-jdbc:$springVersion")
testCompile("org.springframework:spring-test:$springVersion")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package org.springframework.binding.collection;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;

public class MapAccessorTests extends TestCase {
public class MapAccessorTests {
private MapAccessor<String, Object> accessor;

protected void setUp() throws Exception {
@Before
public void setUp() {
Map<String, Object> map = new HashMap<>();
map.put("string", "hello");
map.put("integer", 9);
map.put("null", null);
this.accessor = new MapAccessor<>(map);
}

@Test
public void testAccessNullAttribute() {
assertEquals(null, accessor.get("null"));
assertEquals(null, accessor.get("null", "something else"));
Expand All @@ -28,16 +33,19 @@ public void testAccessNullAttribute() {
assertEquals(null, accessor.getRequiredCollection("null"));
}

@Test
public void testGetString() {
assertEquals("hello", accessor.getString("string"));
assertEquals("hello", accessor.getRequiredString("string"));
}

@Test
public void testGetInteger() {
assertEquals(new Integer(9), accessor.getInteger("integer"));
assertEquals(new Integer(9), accessor.getRequiredInteger("integer"));
}

@Test
public void testGetRequiredMissingKey() {
try {
accessor.getRequired("bogus");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@
*/
package org.springframework.binding.collection;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import junit.framework.TestCase;
import org.junit.Test;

/**
* Unit tests for {@link org.springframework.binding.collection.SharedMapDecorator}.
*/
public class SharedMapDecoratorTests extends TestCase {
public class SharedMapDecoratorTests {

private SharedMapDecorator<String, String> map = new SharedMapDecorator<>(
new HashMap<>());

@Test
public void testGetPutRemove() {
assertTrue(map.size() == 0);
assertTrue(map.isEmpty());
Expand All @@ -47,6 +54,7 @@ public void testGetPutRemove() {
assertNull(map.get("foo"));
}

@Test
public void testPutAll() {
Map<String, String> all = new HashMap<>();
all.put("foo", "bar");
Expand All @@ -55,20 +63,23 @@ public void testPutAll() {
assertTrue(map.size() == 2);
}

@Test
public void testEntrySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set<Map.Entry<String, String>> entrySet = map.entrySet();
assertTrue(entrySet.size() == 2);
}

@Test
public void testKeySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set<String> keySet = map.keySet();
assertTrue(keySet.size() == 2);
}

@Test
public void testValues() {
map.put("foo", "bar");
map.put("bar", "baz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
*/
package org.springframework.binding.collection;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import junit.framework.TestCase;
import org.junit.Test;

/**
* Unit tests for {@link org.springframework.binding.collection.StringKeyedMapAdapter}.
*/
public class StringKeyedMapAdapterTests extends TestCase {
public class StringKeyedMapAdapterTests {

private Map<String, String> contents = new HashMap<>();

Expand All @@ -49,6 +55,7 @@ protected void setAttribute(String key, String value) {
}
};

@Test
public void testGetPutRemove() {
assertTrue(map.size() == 0);
assertTrue(map.isEmpty());
Expand All @@ -66,6 +73,7 @@ public void testGetPutRemove() {
assertNull(map.get("foo"));
}

@Test
public void testPutAll() {
Map<String, String> all = new HashMap<>();
all.put("foo", "bar");
Expand All @@ -74,20 +82,23 @@ public void testPutAll() {
assertTrue(map.size() == 2);
}

@Test
public void testEntrySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set<Map.Entry<String, String>> entrySet = map.entrySet();
assertTrue(entrySet.size() == 2);
}

@Test
public void testKeySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set<String> keySet = map.keySet();
assertTrue(keySet.size() == 2);
}

@Test
public void testValues() {
map.put("foo", "bar");
map.put("bar", "baz");
Expand Down
Loading