Author: ieb
Date: Thu Aug 28 17:27:37 2008
New Revision: 690057
URL: http://svn.apache.org/viewvc?rev=690057&view=rev
Log:
Added tests to check to invalid keys in post data and SocialSpiExpcetions in
AppDataHandler
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java?rev=690057&r1=690056&r2=690057&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
Thu Aug 28 17:27:37 2008
@@ -174,6 +174,60 @@
verify();
}
+ /**
+ * Test that the handler correctly recognizes null keys in the data.
+ * @throws Exception if the test fails
+ */
+ public void testHandleNullPostDataKeys() throws Exception {
+ String jsonAppData = "{pandas: 'are fuzzy'}";
+
+ Map<String, String> params = Maps.newHashMap();
+ params.put("fields", "pandas");
+ setPathAndParams("/appData/john.doe/@self/appId", params, jsonAppData);
+
+ HashMap<String, String> values = Maps.newHashMap();
+ // create an invalid set of app data and inject
+ values.put("Aokkey", "an ok key");
+ values.put("", "an empty value");
+ EasyMock.expect(converter.convertToObject(jsonAppData,
HashMap.class)).andReturn(values);
+
+ replay();
+ try {
+ handler.handlePost(request).get();
+ fail();
+ } catch ( SocialSpiException spi ) {
+ // was expecting an Exception
+ }
+ verify();
+ }
+ /**
+ * Test that the handler correctly recognizes invalid keys in the data.
+ * @throws Exception if the test fails
+ */
+ public void testHandleInvalidPostDataKeys() throws Exception {
+ String jsonAppData = "{pandas: 'are fuzzy'}";
+
+ Map<String, String> params = Maps.newHashMap();
+ params.put("fields", "pandas");
+ setPathAndParams("/appData/john.doe/@self/appId", params, jsonAppData);
+
+ HashMap<String, String> values = Maps.newHashMap();
+ // create an invalid set of app data and inject
+ values.put("Aokkey", "an ok key");
+ values.put("a bad key", "a good value");
+ EasyMock.expect(converter.convertToObject(jsonAppData,
HashMap.class)).andReturn(values);
+
+ replay();
+ try {
+ handler.handlePost(request).get();
+ fail();
+ } catch ( SocialSpiException spi ) {
+ // was expecting an Exception
+ }
+ verify();
+ }
+
+
public void testHandleDelete() throws Exception {
Map<String, String> params = Maps.newHashMap();
params.put("fields", "pandas");