Author: lindner
Date: Wed Jun 24 22:20:35 2009
New Revision: 788197
URL: http://svn.apache.org/viewvc?rev=788197&view=rev
Log:
Update tests to use Immutable Collections
Modified:
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingLinkRewriterTest.java
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/HttpRequestHandlerTest.java
incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/spi/SpiTestUtil.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.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/MessageHandlerTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/sample/spi/JsonDbOpensocialServiceTest.java
Modified:
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingLinkRewriterTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingLinkRewriterTest.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingLinkRewriterTest.java
(original)
+++
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingLinkRewriterTest.java
Wed Jun 24 22:20:35 2009
@@ -21,7 +21,7 @@
import org.junit.Test;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
/**
* Test of proxying rewriter
@@ -64,7 +64,7 @@
public void testWithRefresh() throws Exception {
ContentRewriterFeature contentRewriterFeature = new ContentRewriterFeature(
createSpecWithoutRewrite(), ".*", "", "86400",
- Sets.newHashSet("embed", "img", "script", "link", "style"));
+ ImmutableSet.of("embed", "img", "script", "link", "style"));
ProxyingLinkRewriter rewriter = new ProxyingLinkRewriter(
SPEC_URL,
contentRewriterFeature,
Modified:
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/HttpRequestHandlerTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/HttpRequestHandlerTest.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/HttpRequestHandlerTest.java
(original)
+++
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/HttpRequestHandlerTest.java
Wed Jun 24 22:20:35 2009
@@ -56,6 +56,7 @@
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.inject.Guice;
import com.google.inject.Injector;
@@ -93,7 +94,7 @@
HttpRequestHandler handler = new HttpRequestHandler(pipeline,
rewriterRegistry);
registry = new DefaultHandlerRegistry(injector, converter,
new HandlerExecutionListener.NoOpHandler());
- registry.addHandlers(Sets.<Object>newHashSet(handler));
+ registry.addHandlers(ImmutableSet.<Object>of(handler));
builder = new HttpResponseBuilder().setResponseString("CONTENT");
emptyFormItems = Collections.emptyMap();
}
Modified:
incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/spi/SpiTestUtil.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/spi/SpiTestUtil.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/spi/SpiTestUtil.java
(original)
+++
incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/spi/SpiTestUtil.java
Wed Jun 24 22:20:35 2009
@@ -208,7 +208,7 @@
*/
public static Set<UserId> buildUserIds(String... userIds) {
// Set user id list
- Set<UserId> userIdSet = new HashSet<UserId>();
+ Set<UserId> userIdSet = Sets.newHashSet();
for (String userId: userIds) {
userIdSet.add(new UserId(Type.userId, userId));
}
@@ -389,7 +389,7 @@
}
public static Set<String> asSet(String... items) {
- return new HashSet<String>(Arrays.asList(items));
+ return new Sets.newHashSet(Arrays.asList(items));
}
}
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.java
Wed Jun 24 22:20:35 2009
@@ -38,6 +38,7 @@
import org.apache.shindig.social.opensocial.spi.UserId;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -60,8 +61,8 @@
private FakeGadgetToken token;
- private static final Set<UserId> JOHN_DOE = Sets
- .newHashSet(new UserId(UserId.Type.userId, "john.doe"));
+ private static final Set<UserId> JOHN_DOE =
+ ImmutableSet.of(new UserId(UserId.Type.userId, "john.doe"));
protected HandlerRegistry registry;
protected ContainerConfig containerConfig;
@@ -84,7 +85,7 @@
handler = new ActivityHandler(activityService, containerConfig);
registry = new DefaultHandlerRegistry(null, converter,
new HandlerExecutionListener.NoOpHandler());
- registry.addHandlers(Sets.<Object>newHashSet(handler));
+ registry.addHandlers(ImmutableSet.<Object>of(handler));
}
private void assertHandleGetForGroup(GroupId.Type group) throws Exception {
@@ -94,7 +95,7 @@
List<Activity> activityList = ImmutableList.of();
RestfulCollection<Activity> data = new
RestfulCollection<Activity>(activityList);
org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE),
- eq(new GroupId(group, null)), (String)isNull(),
eq(Sets.<String>newHashSet()),
+ eq(new GroupId(group, null)), (String)isNull(),
eq(ImmutableSet.<String>of()),
org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))).
andReturn(ImmediateFuture.newInstance(data));
@@ -126,7 +127,7 @@
Set<UserId> userIdSet = Sets.newLinkedHashSet(JOHN_DOE);
userIdSet.add(new UserId(UserId.Type.userId, "jane.doe"));
org.easymock.EasyMock.expect(activityService.getActivities(eq(userIdSet),
- eq(new GroupId(GroupId.Type.self, null)),
eq("appId"),eq(Sets.<String>newHashSet()),
+ eq(new GroupId(GroupId.Type.self, null)),
eq("appId"),eq(ImmutableSet.<String>of()),
org.easymock.EasyMock.isA((CollectionOptions.class)),
eq(token))).andReturn(
ImmediateFuture.newInstance(data));
@@ -144,7 +145,7 @@
Activity activity = new ActivityImpl();
org.easymock.EasyMock.expect(activityService.getActivity(eq(JOHN_DOE.iterator().next()),
eq(new GroupId(GroupId.Type.friends, null)),
- eq("appId"), eq(Sets.<String>newHashSet()), eq("1"),
eq(token))).andReturn(
+ eq("appId"), eq(ImmutableSet.<String>of()), eq("1"),
eq(token))).andReturn(
ImmediateFuture.newInstance(activity));
replay();
@@ -165,7 +166,7 @@
.andReturn(activity);
org.easymock.EasyMock.expect(activityService.createActivity(eq(JOHN_DOE.iterator().next()),
- eq(new GroupId(GroupId.Type.self, null)), eq("appId"),
eq(Sets.<String>newHashSet()),
+ eq(new GroupId(GroupId.Type.self, null)), eq("appId"),
eq(ImmutableSet.<String>of()),
eq(activity), eq(token))).andReturn(ImmediateFuture.newInstance((Void)
null));
replay();
@@ -193,7 +194,7 @@
org.easymock.EasyMock.expect(activityService.deleteActivities(eq(JOHN_DOE.iterator().next()),
- eq(new GroupId(GroupId.Type.self, null)), eq("appId"),
eq(Sets.newHashSet("1")),
+ eq(new GroupId(GroupId.Type.self, null)), eq("appId"),
eq(ImmutableSet.of("1")),
eq(token))).andReturn(ImmediateFuture.newInstance((Void) null));
replay();
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=788197&r1=788196&r2=788197&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
Wed Jun 24 22:20:35 2009
@@ -44,8 +44,9 @@
import javax.servlet.http.HttpServletResponse;
-import com.google.common.collect.Maps;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import com.google.common.collect.Maps;
public class AppDataHandlerTest extends EasyMockTestCase {
@@ -58,8 +59,8 @@
protected HandlerRegistry registry;
- private static final Set<UserId> JOHN_DOE = Collections.unmodifiableSet(Sets
- .newHashSet(new UserId(UserId.Type.userId, "john.doe")));
+ private static final Set<UserId> JOHN_DOE = Collections.unmodifiableSet(
+ ImmutableSet.of(new UserId(UserId.Type.userId, "john.doe")));
@Override
@@ -71,7 +72,7 @@
AppDataHandler handler = new AppDataHandler(appDataService);
registry = new DefaultHandlerRegistry(null, converter,
new HandlerExecutionListener.NoOpHandler());
- registry.addHandlers(Sets.<Object>newHashSet(handler));
+ registry.addHandlers(ImmutableSet.<Object>of(handler));
}
private void assertHandleGetForGroup(GroupId.Type group) throws Exception {
@@ -81,7 +82,7 @@
DataCollection data = new DataCollection(null);
org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE),
eq(new GroupId(group, null)),
- eq("appId"), eq(Sets.<String>newHashSet()), eq(token)))
+ eq("appId"), eq(ImmutableSet.<String>of()), eq(token)))
.andReturn(ImmediateFuture.newInstance(data));
replay();
@@ -111,7 +112,7 @@
userIdSet.add(new UserId(UserId.Type.userId, "jane.doe"));
org.easymock.EasyMock.expect(appDataService.getPersonData(eq(userIdSet),
eq(new GroupId(GroupId.Type.self, null)),
- eq("appId"), eq(Sets.<String>newHashSet()), eq(token)))
+ eq("appId"), eq(ImmutableSet.<String>of()), eq(token)))
.andReturn(ImmediateFuture.newInstance(data));
replay();
@@ -130,7 +131,7 @@
DataCollection data = new DataCollection(null);
org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE),
eq(new GroupId(GroupId.Type.friends, null)),
- eq("appId"), eq(Sets.newHashSet("pandas")), eq(token)))
+ eq("appId"), eq(ImmutableSet.of("pandas")), eq(token)))
.andReturn(ImmediateFuture.newInstance(data));
replay();
@@ -153,7 +154,7 @@
org.easymock.EasyMock.expect(appDataService.updatePersonData(eq(JOHN_DOE.iterator().next()),
eq(new GroupId(GroupId.Type.self, null)),
- eq("appId"), eq(Sets.newHashSet("pandas")), eq(values), eq(token)))
+ eq("appId"), eq(ImmutableSet.of("pandas")), eq(values), eq(token)))
.andReturn(ImmediateFuture.newInstance((Void) null));
replay();
return operation.execute(params, new StringReader(jsonAppData), token,
converter);
@@ -238,7 +239,7 @@
EasyMock.expect(appDataService.deletePersonData(eq(JOHN_DOE.iterator().next()),
eq(new GroupId(GroupId.Type.self, null)),
- eq("appId"), eq(Sets.newHashSet("pandas")), eq(token)))
+ eq("appId"), eq(ImmutableSet.of("pandas")), eq(token)))
.andReturn(ImmediateFuture.newInstance((Void) null));
replay();
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/MessageHandlerTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/MessageHandlerTest.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/MessageHandlerTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/MessageHandlerTest.java
Wed Jun 24 22:20:35 2009
@@ -40,7 +40,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
public class MessageHandlerTest extends TestCase {
@@ -65,7 +65,7 @@
handler = new MessageHandler(messageService);
registry = new DefaultHandlerRegistry(null, converter,
new HandlerExecutionListener.NoOpHandler());
- registry.addHandlers(Sets.<Object>newHashSet(handler));
+ registry.addHandlers(ImmutableSet.<Object>of(handler));
}
public void testPostMessage()
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java
Wed Jun 24 22:20:35 2009
@@ -39,6 +39,7 @@
import org.apache.shindig.social.opensocial.spi.UserId;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -59,12 +60,12 @@
protected HandlerRegistry registry;
private BeanJsonConverter converter;
- private static final Set<String> DEFAULT_FIELDS =
Sets.newHashSet(Person.Field.ID.toString(),
+ private static final Set<String> DEFAULT_FIELDS =
ImmutableSet.of(Person.Field.ID.toString(),
Person.Field.NAME.toString(),
Person.Field.THUMBNAIL_URL.toString());
- private static final Set<UserId> JOHN_DOE = Sets
- .newHashSet(new UserId(UserId.Type.userId, "john.doe"));
+ private static final Set<UserId> JOHN_DOE =
+ ImmutableSet.of(new UserId(UserId.Type.userId, "john.doe"));
private static CollectionOptions DEFAULT_OPTIONS = new CollectionOptions();
protected ContainerConfig containerConfig;
@@ -93,7 +94,7 @@
handler = new PersonHandler(personService, containerConfig);
registry = new DefaultHandlerRegistry(null, converter,
new HandlerExecutionListener.NoOpHandler());
- registry.addHandlers(Sets.<Object>newHashSet(handler));
+ registry.addHandlers(ImmutableSet.<Object>of(handler));
}
public void testHandleGetAllNoParams() throws Exception {
@@ -183,7 +184,7 @@
RestfulCollection<Person> data = new RestfulCollection<Person>(people);
// TODO: We aren't passing john.doe to the service yet.
expect(personService.getPeople(
- eq(Sets.newHashSet(new UserId(UserId.Type.userId, "jane.doe"))),
+ eq(ImmutableSet.of(new UserId(UserId.Type.userId, "jane.doe"))),
eq(new GroupId(GroupId.Type.self, null)), eq(DEFAULT_OPTIONS),
eq(DEFAULT_FIELDS), eq(token)))
.andReturn(ImmediateFuture.newInstance(data));
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/sample/spi/JsonDbOpensocialServiceTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/sample/spi/JsonDbOpensocialServiceTest.java?rev=788197&r1=788196&r2=788197&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/sample/spi/JsonDbOpensocialServiceTest.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/sample/spi/JsonDbOpensocialServiceTest.java
Wed Jun 24 22:20:35 2009
@@ -128,7 +128,7 @@
options.setMax(20);
RestfulCollection<Person> responseItem = db.getPeople(
- Sets.newHashSet(CANON_USER), new GroupId(GroupId.Type.friends, null),
+ ImmutableSet.of(CANON_USER), new GroupId(GroupId.Type.friends, null),
options, Collections.<String>emptySet(), token).get();
assertNotNull(responseItem);
assertEquals(4, responseItem.getTotalResults());
@@ -159,14 +159,14 @@
public void testGetExpectedActivities() throws Exception {
RestfulCollection<Activity> responseItem = db.getActivities(
- Sets.newHashSet(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(), null,
+ ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(), null,
new FakeGadgetToken()).get();
assertSame(2, responseItem.getTotalResults());
}
public void testGetExpectedActivitiesForPlural() throws Exception {
RestfulCollection<Activity> responseItem = db.getActivities(
- Sets.newHashSet(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID,
Collections.<String>emptySet(), null,
+ ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID,
Collections.<String>emptySet(), null,
new FakeGadgetToken()).get();
assertSame(3, responseItem.getTotalResults());
}
@@ -174,7 +174,7 @@
public void testGetExpectedActivity() throws Exception {
Activity activity = db.getActivity(
CANON_USER, SELF_GROUP, APP_ID,
- Sets.newHashSet("appId", "body", "mediaItems"), APP_ID, new
FakeGadgetToken()).get();
+ ImmutableSet.of("appId", "body", "mediaItems"), APP_ID, new
FakeGadgetToken()).get();
assertNotNull(activity);
// Check that some fields are fetched and others are not
assertNotNull(activity.getBody());
@@ -182,14 +182,14 @@
}
public void testDeleteExpectedActivity() throws Exception {
- db.deleteActivities(CANON_USER, SELF_GROUP, APP_ID,
Sets.newHashSet(APP_ID),
+ db.deleteActivities(CANON_USER, SELF_GROUP, APP_ID,
ImmutableSet.of(APP_ID),
new FakeGadgetToken());
// Try to fetch the activity
try {
db.getActivity(
CANON_USER, SELF_GROUP, APP_ID,
- Sets.newHashSet("appId", "body", "mediaItems"), APP_ID, new
FakeGadgetToken()).get();
+ ImmutableSet.of("appId", "body", "mediaItems"), APP_ID, new
FakeGadgetToken()).get();
fail();
} catch (ProtocolException sse) {
assertEquals(HttpServletResponse.SC_BAD_REQUEST, sse.getCode());
@@ -198,7 +198,7 @@
public void testGetExpectedAppData() throws Exception {
DataCollection responseItem = db.getPersonData(
- Sets.newHashSet(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
+ ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
new FakeGadgetToken()).get();
assertFalse(responseItem.getEntry().isEmpty());
assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());
@@ -210,7 +210,7 @@
public void testGetExpectedAppDataForPlural() throws Exception {
DataCollection responseItem = db.getPersonData(
- Sets.newHashSet(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
+ ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
new FakeGadgetToken()).get();
assertFalse(responseItem.getEntry().isEmpty());
assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());
@@ -227,11 +227,11 @@
public void testDeleteExpectedAppData() throws Exception {
// Delete the data
db.deletePersonData(CANON_USER, SELF_GROUP, APP_ID,
- Sets.newHashSet("count"), new FakeGadgetToken());
+ ImmutableSet.of("count"), new FakeGadgetToken());
// Fetch the remaining and test
DataCollection responseItem = db.getPersonData(
- Sets.newHashSet(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
+ ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
new FakeGadgetToken()).get();
assertFalse(responseItem.getEntry().isEmpty());
assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());
@@ -248,7 +248,7 @@
// Fetch the remaining and test
DataCollection responseItem = db.getPersonData(
- Sets.newHashSet(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
+ ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID,
Collections.<String>emptySet(),
new FakeGadgetToken()).get();
assertFalse(responseItem.getEntry().isEmpty());