Skip to content

Commit

Permalink
fix for GRAILS-6532 "JSONObject.containsKey() is broken"
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Jul 26, 2010
1 parent 09bd010 commit b1fc5d7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/java/org/codehaus/groovy/grails/web/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1157,11 +1157,11 @@ public boolean isEmpty() {
}

public boolean containsKey(Object o) {
return false;
return myHashMap.containsKey(o);
}

public boolean containsValue(Object o) {
return this.myHashMap.containsKey(o);
return this.myHashMap.containsValue(o);
}

public Object get(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.codehaus.groovy.grails.web.json

/**
* @author Graeme Rocher
* @since 1.0
*/
class JSONObjectTests extends GroovyTestCase {


void testContainsKey() {
JSONObject j = new JSONObject();
j.put('test', 1)
assert j.containsKey('test')
}

void testContainsValue() {
JSONObject j = new JSONObject();
j.put('test', 1)
assert j.containsValue(1)

}
}

0 comments on commit b1fc5d7

Please sign in to comment.