Author: zhoresh
Date: Wed Dec 8 23:35:13 2010
New Revision: 1043770
URL: http://svn.apache.org/viewvc?rev=1043770&view=rev
Log:
Ref http://codereview.appspot.com/3437043/
Expose RequestItem parameters
Modified:
shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/BaseRequestItem.java
shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/BaseRequestItemTest.java
Modified:
shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/BaseRequestItem.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/BaseRequestItem.java?rev=1043770&r1=1043769&r2=1043770&view=diff
==============================================================================
---
shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/BaseRequestItem.java
(original)
+++
shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/BaseRequestItem.java
Wed Dec 8 23:35:13 2010
@@ -239,6 +239,10 @@ public class BaseRequestItem implements
return param;
}
+ public Map<String, Object> getParameters() {
+ return Collections.unmodifiableMap(this.parameters);
+ }
+
public List<String> getListParameter(String paramName) {
Object param = this.parameters.get(paramName);
if (param == null) {
@@ -288,7 +292,7 @@ public class BaseRequestItem implements
this.parameters.put(paramName, paramValue);
}
}
-
+
public FormDataItem getFormMimePart(String partName) {
if (formItems != null) {
return formItems.get(partName);
Modified:
shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/BaseRequestItemTest.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/BaseRequestItemTest.java?rev=1043770&r1=1043769&r2=1043770&view=diff
==============================================================================
---
shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/BaseRequestItemTest.java
(original)
+++
shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/BaseRequestItemTest.java
Wed Dec 8 23:35:13 2010
@@ -33,6 +33,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import java.util.Map;
+
/**
* Test BaseRequestItem
*/
@@ -114,6 +116,20 @@ public class BaseRequestItemTest extends
}
@Test
+ public void testGetParameters() throws Exception {
+ request.setParameter("anykey", "{name: 'Bob', id: '1234'}");
+ Map<String, Object> params = request.getParameters();
+ assertEquals(1, params.size());
+ assertTrue(params.containsKey("anykey"));
+ try {
+ params.put("this", "is bad");
+ fail("Params should be immutable");
+ } catch (UnsupportedOperationException e) {
+ // As expected
+ }
+ }
+
+ @Test
public void testGetInvalidJsonTypedParameter() throws Exception {
request.setParameter("anykey", "{name: 'Bob");
int code = 0;