Author: ieb
Date: Mon Sep 1 15:42:40 2008
New Revision: 691078
URL: http://svn.apache.org/viewvc?rev=691078&view=rev
Log:
Stye cleanup, mainly whitespace but some lines too long.
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/config/SocialApiGuiceModule.java
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ActivityImpl.java
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/OrganizationImpl.java
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/oauth/SampleContainerOAuthLookupService.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataCollectionTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/ApiValidatorTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanJsonConverterTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonConverterPerformancePerf.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonObjectToMapMorpherTest.java
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/config/SocialApiGuiceModule.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/config/SocialApiGuiceModule.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/config/SocialApiGuiceModule.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/config/SocialApiGuiceModule.java
Mon Sep 1 15:42:40 2008
@@ -36,10 +36,10 @@
import java.util.List;
/**
- * Provides social api component injection. Implementor may want to replace
this module if they
- * need to replace some of the internals of the Social API, like for instance
the JSON to Bean to JSON
- * converter Beans, however in general this should not be required, as most
default implementations have
- * been specified with the Guice @ImplementedBy annotation.
+ * Provides social api component injection. Implementor may want to replace
this module if they need
+ * to replace some of the internals of the Social API, like for instance the
JSON to Bean to JSON
+ * converter Beans, however in general this should not be required, as most
default implementations
+ * have been specified with the Guice @ImplementedBy annotation.
*/
public class SocialApiGuiceModule extends AbstractModule {
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ActivityImpl.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ActivityImpl.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ActivityImpl.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ActivityImpl.java
Mon Sep 1 15:42:40 2008
@@ -94,14 +94,14 @@
}
public Date getUpdated() {
- if ( updated == null ) {
+ if (updated == null) {
return null;
}
return new Date(updated.getTime());
}
public void setUpdated(Date updated) {
- if ( updated == null ) {
+ if (updated == null) {
this.updated = null;
} else {
this.updated = new Date(updated.getTime());
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/OrganizationImpl.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/OrganizationImpl.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/OrganizationImpl.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/OrganizationImpl.java
Mon Sep 1 15:42:40 2008
@@ -53,14 +53,14 @@
}
public Date getEndDate() {
- if ( endDate == null ) {
+ if (endDate == null) {
return null;
}
return new Date(endDate.getTime());
}
public void setEndDate(Date endDate) {
- if ( endDate == null ) {
+ if (endDate == null) {
this.endDate = null;
} else {
this.endDate = new Date(endDate.getTime());
@@ -92,14 +92,14 @@
}
public Date getStartDate() {
- if ( startDate == null ) {
+ if (startDate == null) {
return null;
- }
+ }
return new Date(startDate.getTime());
}
public void setStartDate(Date startDate) {
- if ( startDate == null ) {
+ if (startDate == null) {
this.startDate = null;
} else {
this.startDate = new Date(startDate.getTime());
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java
Mon Sep 1 15:42:40 2008
@@ -186,14 +186,14 @@
}
public Date getBirthday() {
- if ( birthday == null ) {
+ if (birthday == null) {
return null;
- }
+ }
return new Date(birthday.getTime());
}
public void setBirthday(Date birthday) {
- if ( birthday == null ) {
+ if (birthday == null) {
this.birthday = null;
} else {
this.birthday = new Date(birthday.getTime());
@@ -321,14 +321,14 @@
}
public Date getUpdated() {
- if ( updated == null ) {
+ if (updated == null) {
return null;
}
return new Date(updated.getTime());
}
public void setUpdated(Date updated) {
- if ( updated == null ) {
+ if (updated == null) {
this.updated = updated;
} else {
this.updated = new Date(updated.getTime());
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
Mon Sep 1 15:42:40 2008
@@ -103,7 +103,7 @@
} else if (val instanceof Map) {
JSONObject map = new JSONObject();
- Map<?, ?> originalMap = (Map<?,?>) val;
+ Map<?, ?> originalMap = (Map<?, ?>) val;
for (Entry<?, ?> item : originalMap.entrySet()) {
map.put(item.getKey().toString(),
translateObjectToJson(item.getValue()));
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/oauth/SampleContainerOAuthLookupService.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/oauth/SampleContainerOAuthLookupService.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/oauth/SampleContainerOAuthLookupService.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/oauth/SampleContainerOAuthLookupService.java
Mon Sep 1 15:42:40 2008
@@ -48,7 +48,7 @@
// If we were a real social network we would probably be keeping track of
this in a db somewhere
private static Map<String, ArrayList<String>> sampleContainerAppInstalls =
Maps.immutableMap(
- "john.doe", Lists.newArrayList( "7810", "8355")
+ "john.doe", Lists.newArrayList("7810", "8355")
);
// If we were a real social network we would establish shared secrets with
each of our gadgets
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java
Mon Sep 1 15:42:40 2008
@@ -147,8 +147,8 @@
canonical.setNetworkPresence(new
EnumImpl<Enum.NetworkPresence>(Enum.NetworkPresence.ONLINE));
canonical.setNickname("diggy");
canonical.setPets("dog,cat");
- canonical.setPhoneNumbers(Lists.<ListField>newArrayList(new
ListFieldImpl("work", "111-111-111"),
- new ListFieldImpl("mobile", "999-999-999")));
+ canonical.setPhoneNumbers(Lists.<ListField> newArrayList(new
ListFieldImpl("work",
+ "111-111-111"), new ListFieldImpl("mobile", "999-999-999")));
canonical.setPoliticalViews("open leaning");
canonical.setProfileSong(new
UrlImpl("http://www.example.org/songs/OnlyTheLonely.mp3",
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=691078&r1=691077&r2=691078&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
Mon Sep 1 15:42:40 2008
@@ -195,7 +195,7 @@
try {
handler.handlePost(request).get();
fail();
- } catch ( SocialSpiException spi ) {
+ } catch (SocialSpiException spi) {
// was expecting an Exception
}
verify();
@@ -221,7 +221,7 @@
try {
handler.handlePost(request).get();
fail();
- } catch ( SocialSpiException spi ) {
+ } catch (SocialSpiException spi) {
// was expecting an Exception
}
verify();
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java
Mon Sep 1 15:42:40 2008
@@ -121,7 +121,8 @@
/**
- * Tests a data handler that returns a failed Future
+ * Tests a data handler that returns a failed Future.
+ * @throws Exception on failure
*/
public void testFailedRequest() throws Exception {
setupRequest("{id:id,method:appdata.get}");
@@ -189,8 +190,7 @@
EasyMock.expect(jsonConverter.convertToJson(resultObject))
.andStubReturn(new JSONObject(Maps.immutableMap("foo", "bar")));
- JSONArray result = new JSONArray("[{id:'1',data:{foo:'bar'}}," +
- "{id:'2',data:{foo:'bar'}}]");
+ JSONArray result = new JSONArray("[{id:'1',data:{foo:'bar'}}," +
"{id:'2',data:{foo:'bar'}}]");
PrintWriter writerMock = EasyMock.createMock(PrintWriter.class);
EasyMock.expect(res.getWriter()).andReturn(writerMock);
writerMock.write(EasyMock.eq(result.toString()));
@@ -204,7 +204,7 @@
public void testGetExecution() throws Exception {
EasyMock.expect(req.getParameterMap()).andStubReturn(
- Maps.immutableMap("method",new String[]{"people.get"},"id", new
String[]{"1"}));
+ Maps.immutableMap("method", new String[]{"people.get"}, "id", new
String[]{"1"}));
EasyMock.expect(req.getMethod()).andStubReturn("GET");
EasyMock.expect(req.getAttribute(EasyMock.isA(String.class))).andReturn(FAKE_GADGET_TOKEN);
setupInjector();
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java
Mon Sep 1 15:42:40 2008
@@ -142,7 +142,7 @@
request.setListParameter("fields", Collections.<String>emptyList());
assertEquals(Sets.<String>newHashSet(), request.getFields());
- request.setListParameter("fields",
Lists.newArrayList("happy","sad","grumpy"));
+ request.setListParameter("fields", Lists.newArrayList("happy", "sad",
"grumpy"));
assertEquals(Sets.newHashSet("happy", "sad", "grumpy"),
request.getFields());
}
}
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataCollectionTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataCollectionTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataCollectionTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataCollectionTest.java
Mon Sep 1 15:42:40 2008
@@ -27,7 +27,7 @@
public class DataCollectionTest extends TestCase {
public void testBasicMethods() throws Exception {
- Map<String, Map<String,String>> entry = Maps.newHashMap();
+ Map<String, Map<String, String>> entry = Maps.newHashMap();
DataCollection collection = new DataCollection(entry);
assertEquals(entry, collection.getEntry());
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/ApiValidatorTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/ApiValidatorTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/ApiValidatorTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/ApiValidatorTest.java
Mon Sep 1 15:42:40 2008
@@ -35,8 +35,8 @@
/**
* A definition of the test json used in this unit test.
*/
- private static final String TEST_DEFINITION =
- "var TestDef = {}; TestDef.Field = { FIELD1 : \"json\", FIELD2 : \"xyz\",
FIELD3 : \"shouldBeMissing\" };";
+ private static final String TEST_DEFINITION = "var TestDef = {}; "
+ + "TestDef.Field = { FIELD1 : \"json\", FIELD2 : \"xyz\", FIELD3 :
\"shouldBeMissing\" };";
private static final String[] TEST_DEFINITION_FIELDS = {
"json",
"xyz",
@@ -44,72 +44,77 @@
};
/**
- * test the validator for successful validation
+ * test the validator for successful validation.
* @throws ApiValidatorExpcetion
* @throws IOException
* @throws ParserConfigurationException
* @throws SAXException
*/
@Test
- public void testValidator() throws ApiValidatorExpcetion, IOException,
ParserConfigurationException, SAXException {
+ public void testValidator() throws ApiValidatorExpcetion, IOException,
+ ParserConfigurationException, SAXException {
ApiValidator apiVal = new ApiValidator();
apiVal.addScript(TEST_DEFINITION);
- String[] optional = {"shouldBeMissing"};
+ String[] optional = { "shouldBeMissing" };
String[] nullfields = {};
- Map<String, Object> result = apiVal.validate("{ json: \"A Test JSON\",
xyz : 123 }", "TestDef.Field", optional, nullfields );
- Assert.assertNotNull(result);
- Assert.assertNotNull(result.get("json"));
- Assert.assertNotNull(result.get("xyz"));
- Assert.assertEquals(String.class,result.get("json").getClass());
- Assert.assertEquals(Integer.class,result.get("xyz").getClass());
- Assert.assertEquals("A Test JSON",result.get("json"));
- Assert.assertEquals(123,((Integer)result.get("xyz")).intValue());
-
-
+ Map<String, Object> result = apiVal.validate("{ json: \"A Test JSON\", xyz
: 123 }",
+ "TestDef.Field", optional, nullfields);
+ Assert.assertNotNull(result);
+ Assert.assertNotNull(result.get("json"));
+ Assert.assertNotNull(result.get("xyz"));
+ Assert.assertEquals(String.class, result.get("json").getClass());
+ Assert.assertEquals(Integer.class, result.get("xyz").getClass());
+ Assert.assertEquals("A Test JSON", result.get("json"));
+ Assert.assertEquals(123, ((Integer) result.get("xyz")).intValue());
}
-
+
/**
* Test for a failing validation
+ *
* @throws ApiValidatorExpcetion
* @throws IOException
* @throws ParserConfigurationException
* @throws SAXException
*/
@Test
- public void testValidatorFail() throws ApiValidatorExpcetion, IOException,
ParserConfigurationException, SAXException {
+ public void testValidatorFail() throws ApiValidatorExpcetion, IOException,
+ ParserConfigurationException, SAXException {
ApiValidator apiVal = new ApiValidator();
apiVal.addScript(TEST_DEFINITION);
String[] optional = {};
String[] nullfields = {};
try {
- apiVal.validate("{ jsonIsMissing: \"A Test JSON\", xyz : 123 }",
"TestDef.Field", optional, nullfields );
+ apiVal.validate("{ jsonIsMissing: \"A Test JSON\", xyz : 123 }",
"TestDef.Field", optional,
+ nullfields);
Assert.fail("Should have Generated an APIValidatorException ");
- } catch ( ApiValidatorExpcetion ex ) {
-
+ } catch (ApiValidatorExpcetion ex) {
+
}
}
/**
* test the validator for successful validation
+ *
* @throws ApiValidatorExpcetion
* @throws IOException
* @throws ParserConfigurationException
* @throws SAXException
*/
@Test
- public void testFieldsValidator() throws ApiValidatorExpcetion, IOException,
ParserConfigurationException, SAXException {
+ public void testFieldsValidator() throws ApiValidatorExpcetion, IOException,
+ ParserConfigurationException, SAXException {
ApiValidator apiVal = new ApiValidator();
- String[] optional = {"shouldBeMissing"};
+ String[] optional = { "shouldBeMissing" };
String[] nullfields = {};
- Map<String, Object> result = apiVal.validate("{ json: \"A Test JSON\",
xyz : 123 }", TEST_DEFINITION_FIELDS, optional, nullfields );
- Assert.assertNotNull(result);
- Assert.assertNotNull(result.get("json"));
- Assert.assertNotNull(result.get("xyz"));
- Assert.assertEquals(String.class,result.get("json").getClass());
- Assert.assertEquals(Integer.class,result.get("xyz").getClass());
- Assert.assertEquals("A Test JSON",result.get("json"));
- Assert.assertEquals(123,((Integer)result.get("xyz")).intValue());
-
-
+ Map<String, Object> result = apiVal.validate("{ json: \"A Test JSON\", xyz
: 123 }",
+ TEST_DEFINITION_FIELDS, optional, nullfields);
+ Assert.assertNotNull(result);
+ Assert.assertNotNull(result.get("json"));
+ Assert.assertNotNull(result.get("xyz"));
+ Assert.assertEquals(String.class, result.get("json").getClass());
+ Assert.assertEquals(Integer.class, result.get("xyz").getClass());
+ Assert.assertEquals("A Test JSON", result.get("json"));
+ Assert.assertEquals(123, ((Integer) result.get("xyz")).intValue());
+
}
/**
@@ -120,15 +125,17 @@
* @throws SAXException
*/
@Test
- public void testFieldsValidatorFail() throws ApiValidatorExpcetion,
IOException, ParserConfigurationException, SAXException {
+ public void testFieldsValidatorFail() throws ApiValidatorExpcetion,
IOException,
+ ParserConfigurationException, SAXException {
ApiValidator apiVal = new ApiValidator();
String[] optional = {};
String[] nullfields = {};
try {
- apiVal.validate("{ jsonIsMissing: \"A Test JSON\", xyz : 123 }",
TEST_DEFINITION_FIELDS, optional, nullfields );
+ apiVal.validate("{ jsonIsMissing: \"A Test JSON\", xyz : 123 }",
TEST_DEFINITION_FIELDS,
+ optional, nullfields);
Assert.fail("Should have Generated an APIValidatorException ");
- } catch ( ApiValidatorExpcetion ex ) {
-
+ } catch (ApiValidatorExpcetion ex) {
+ // was expcting this
}
}
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanJsonConverterTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanJsonConverterTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanJsonConverterTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanJsonConverterTest.java
Mon Sep 1 15:42:40 2008
@@ -186,9 +186,9 @@
}
public void testJsonToActivity() throws Exception {
- String jsonActivity = "{userId : 5, id : 6, mediaItems : [" +
- "{url : 'hello', mimeType : 'mimey', type : 'video'}" +
- "]}";
+ String jsonActivity = "{userId : 5, id : 6, mediaItems : ["
+ + "{url : 'hello', mimeType : 'mimey', type : 'video'}"
+ + "]}";
// TODO: rename the enums to be lowercase
Activity result = beanJsonConverter.convertToObject(jsonActivity,
Activity.class);
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonConverterPerformancePerf.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonConverterPerformancePerf.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonConverterPerformancePerf.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonConverterPerformancePerf.java
Mon Sep 1 15:42:40 2008
@@ -43,8 +43,7 @@
public class JsonConverterPerformancePerf extends TestCase {
- private static final Log log = LogFactory
- .getLog(JsonConverterPerformancePerf.class);
+ private static final Log log =
LogFactory.getLog(JsonConverterPerformancePerf.class);
private static final int TEST_SIZE = 10000;
private Person johnDoe;
private Activity activity;
@@ -56,28 +55,26 @@
public void setUp() throws Exception {
super.setUp();
johnDoe = new PersonImpl("johnDoeId", new NameImpl("John Doe"));
- johnDoe.setPhoneNumbers(Lists.<ListField>newArrayList(
- new ListFieldImpl("home", "+33H000000000"),
- new ListFieldImpl("mobile", "+33M000000000"),
- new ListFieldImpl("work", "+33W000000000")));
-
- johnDoe.setAddresses(Lists.<Address>newArrayList(
- new AddressImpl("My home address")));
-
- johnDoe.setEmails(Lists.<ListField>newArrayList(
- new ListFieldImpl("work", "[EMAIL PROTECTED]"),
- new ListFieldImpl("home", "[EMAIL PROTECTED]")));
+ johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new
ListFieldImpl("home",
+ "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new
ListFieldImpl("work",
+ "+33W000000000")));
+
+ johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl("My home
address")));
+
+ johnDoe.setEmails(Lists.<ListField> newArrayList(
+ new ListFieldImpl("work", "[EMAIL PROTECTED]"), new
ListFieldImpl("home",
+ "[EMAIL PROTECTED]")));
activity = new ActivityImpl("activityId", johnDoe.getId());
- activity.setMediaItems(Lists.<MediaItem> newArrayList(new MediaItemImpl(
- "image/jpg", MediaItem.Type.IMAGE, "http://foo.bar")));
+ activity.setMediaItems(Lists.<MediaItem> newArrayList(new
MediaItemImpl("image/jpg",
+ MediaItem.Type.IMAGE, "http://foo.bar")));
Injector injector = Guice.createInjector(new JsonLibTestsGuiceModule());
beanJsonLibConverter = injector.getInstance(BeanJsonLibConverter.class);
- beanJsonConverter = new BeanJsonConverter(Guice
- .createInjector(new SocialApiTestsGuiceModule()));
+ beanJsonConverter = new BeanJsonConverter(
+ Guice.createInjector(new SocialApiTestsGuiceModule()));
}
@@ -110,24 +107,24 @@
}
Runtime r = Runtime.getRuntime();
r.gc();
- long memstart = r.totalMemory()-r.freeMemory();
+ long memstart = r.totalMemory() - r.freeMemory();
long startOutput = System.currentTimeMillis();
String[] output = new String[TEST_SIZE];
for (int i = 0; i < TEST_SIZE; i++) {
output[i] = beanJsonLibConverter.convertToString(spa[i]);
}
long endOutput = System.currentTimeMillis();
- long memend = r.totalMemory()-r.freeMemory();
+ long memend = r.totalMemory() - r.freeMemory();
String[] serializeOutput = new String[TEST_SIZE];
char[] source = output[0].toCharArray();
r.gc();
- long stringsizeStart = r.totalMemory()-r.freeMemory();
+ long stringsizeStart = r.totalMemory() - r.freeMemory();
for (int i = 0; i < TEST_SIZE; i++) {
serializeOutput[i] = new String(source);
}
- long stringsizeEnd = r.totalMemory()-r.freeMemory();
+ long stringsizeEnd = r.totalMemory() - r.freeMemory();
/*
* Output the time per conversion and the memory usage - the output per
@@ -135,13 +132,15 @@
*
*/
- log.info("SF JSON Lib Output "
- + average(startOutput, endOutput, TEST_SIZE)
- + " ms/conversion, "
- + (average(memstart, memend, TEST_SIZE)-average(stringsizeStart,
stringsizeEnd, TEST_SIZE))
- + " heap bytes/conversion, output packet consumed on average "
- + average(stringsizeStart, stringsizeEnd, TEST_SIZE)+" for a string
length of "+output[0].length());
- log.info("Output Was ["+output[0]+"]");
+ log
+ .info("SF JSON Lib Output "
+ + average(startOutput, endOutput, TEST_SIZE)
+ + " ms/conversion, "
+ + (average(memstart, memend, TEST_SIZE) - average(stringsizeStart,
stringsizeEnd,
+ TEST_SIZE)) + " heap bytes/conversion, output packet consumed
on average "
+ + average(stringsizeStart, stringsizeEnd, TEST_SIZE) + " for a
string length of "
+ + output[0].length());
+ log.info("Output Was [" + output[0] + "]");
}
public void testToJsonLibOnInheritedClassInput() throws Exception {
@@ -149,11 +148,11 @@
SpecialPerson[] sparesult = new SpecialPerson[TEST_SIZE];
Runtime r = Runtime.getRuntime();
r.gc();
- long personStart = r.totalMemory()-r.freeMemory();
+ long personStart = r.totalMemory() - r.freeMemory();
for (int i = 0; i < TEST_SIZE; i++) {
spa[i] = new SpecialPerson(String.valueOf(i), "robot", "nonsense");
}
- long personEnd = r.totalMemory()-r.freeMemory();
+ long personEnd = r.totalMemory() - r.freeMemory();
String[] serializeOutput = new String[TEST_SIZE];
r.gc();
@@ -163,19 +162,16 @@
}
r.gc();
- long memstart = r.totalMemory()-r.freeMemory();
+ long memstart = r.totalMemory() - r.freeMemory();
long startInput = System.currentTimeMillis();
for (int i = 0; i < TEST_SIZE; i++) {
- sparesult[i] = beanJsonLibConverter.convertToObject(
- serializeOutput[i], SpecialPerson.class);
+ sparesult[i] = beanJsonLibConverter.convertToObject(serializeOutput[i],
SpecialPerson.class);
}
long endInput = System.currentTimeMillis();
- long memend = r.totalMemory()-r.freeMemory();
+ long memend = r.totalMemory() - r.freeMemory();
- log.info("SF JSON Lib Input "
- + average(startInput, endInput, TEST_SIZE)
- + " ms/conversion, "
- + (average(memstart, memend, TEST_SIZE)-average(personStart,
personEnd, TEST_SIZE))
+ log.info("SF JSON Lib Input " + average(startInput, endInput, TEST_SIZE) +
" ms/conversion, "
+ + (average(memstart, memend, TEST_SIZE) - average(personStart,
personEnd, TEST_SIZE))
+ " heap bytes/conversion, person object consumed on average "
+ average(personStart, personEnd, TEST_SIZE));
}
@@ -188,31 +184,33 @@
Runtime r = Runtime.getRuntime();
String[] output = new String[TEST_SIZE];
r.gc();
- long memstart = r.totalMemory()-r.freeMemory();
+ long memstart = r.totalMemory() - r.freeMemory();
long startOutput = System.currentTimeMillis();
for (int i = 0; i < TEST_SIZE; i++) {
- output[i] = ((JSONObject)
beanJsonConverter.convertToJson(spa[i])).toString();
+ output[i] = ((JSONObject)
beanJsonConverter.convertToJson(spa[i])).toString();
}
long endOutput = System.currentTimeMillis();
- long memend = r.totalMemory()-r.freeMemory();
+ long memend = r.totalMemory() - r.freeMemory();
String[] serializeOutput = new String[TEST_SIZE];
char[] source = output[0].toCharArray();
r.gc();
- long stringsizeStart = r.totalMemory()-r.freeMemory();
+ long stringsizeStart = r.totalMemory() - r.freeMemory();
for (int i = 0; i < TEST_SIZE; i++) {
serializeOutput[i] = new String(source);
}
- long stringsizeEnd = r.totalMemory()-r.freeMemory();
+ long stringsizeEnd = r.totalMemory() - r.freeMemory();
- log.info("ORG JSON Lib Output "
- + average(startOutput, endOutput, TEST_SIZE)
- + " ms/conversion, "
- + (average(memstart, memend, TEST_SIZE)-average(stringsizeStart,
stringsizeEnd, TEST_SIZE))
- + " heap bytes/conversion, output packet consumed on average "
- + average(stringsizeStart, stringsizeEnd, TEST_SIZE)+" for a string
length of "+output[0].length());
- log.info("Output Was ["+output[0]+"]");
+ log
+ .info("ORG JSON Lib Output "
+ + average(startOutput, endOutput, TEST_SIZE)
+ + " ms/conversion, "
+ + (average(memstart, memend, TEST_SIZE) - average(stringsizeStart,
stringsizeEnd,
+ TEST_SIZE)) + " heap bytes/conversion, output packet consumed
on average "
+ + average(stringsizeStart, stringsizeEnd, TEST_SIZE) + " for a
string length of "
+ + output[0].length());
+ log.info("Output Was [" + output[0] + "]");
}
/**
@@ -232,11 +230,11 @@
SpecialPerson[] sparesult = new SpecialPerson[TEST_SIZE];
Runtime r = Runtime.getRuntime();
r.gc();
- long personStart = r.totalMemory()-r.freeMemory();
+ long personStart = r.totalMemory() - r.freeMemory();
for (int i = 0; i < TEST_SIZE; i++) {
spa[i] = new SpecialPerson(String.valueOf(i), "robot", "nonsense");
}
- long personEnd = r.totalMemory()-r.freeMemory();
+ long personEnd = r.totalMemory() - r.freeMemory();
String[] serializeOutput = new String[TEST_SIZE];
r.gc();
@@ -246,20 +244,17 @@
}
r.gc();
- long memstart = r.totalMemory()-r.freeMemory();
+ long memstart = r.totalMemory() - r.freeMemory();
long startInput = System.currentTimeMillis();
for (int i = 0; i < TEST_SIZE; i++) {
- sparesult[i] = beanJsonConverter.convertToObject(
- serializeOutput[i], SpecialPerson.class);
+ sparesult[i] = beanJsonConverter.convertToObject(serializeOutput[i],
SpecialPerson.class);
}
long endInput = System.currentTimeMillis();
- long memend = r.totalMemory()-r.freeMemory();
+ long memend = r.totalMemory() - r.freeMemory();
- log.info("SF JSON Lib Input "
- + average(startInput, endInput, TEST_SIZE)
- + " ms/conversion, "
- + (average(memstart, memend, TEST_SIZE)-average(personStart,
personEnd, TEST_SIZE))
+ log.info("SF JSON Lib Input " + average(startInput, endInput, TEST_SIZE) +
" ms/conversion, "
+ + (average(memstart, memend, TEST_SIZE) - average(personStart,
personEnd, TEST_SIZE))
+ " heap bytes/conversion, person object consumed on average "
+ average(personStart, personEnd, TEST_SIZE));
}
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonObjectToMapMorpherTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonObjectToMapMorpherTest.java?rev=691078&r1=691077&r2=691078&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonObjectToMapMorpherTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/JsonObjectToMapMorpherTest.java
Mon Sep 1 15:42:40 2008
@@ -70,16 +70,16 @@
testObj.put("1", "z");
Object o = om.morph(testObj);
assertNotSame(testObj, o);
- if ( o instanceof Map ) {
+ if (o instanceof Map) {
Map<?, ?> fm = (Map<?, ?>) o;
- assertEquals("y",fm.get("x"));
- assertEquals("z",fm.get("1"));
+ assertEquals("y", fm.get("x"));
+ assertEquals("z", fm.get("1"));
assertNull(fm.get("xyz"));
}
try {
om.morph(o);
fail();
- } catch ( ClassCastException cce ) {
+ } catch (ClassCastException cce) {
assertTrue(true);
}
}