You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2009/12/16 23:07:46 UTC

svn commit: r891450 [4/4] - in /incubator/shindig/trunk/java: common/src/main/java/org/apache/shindig/expressions/ common/src/test/java/org/apache/shindig/auth/ common/src/test/java/org/apache/shindig/common/ common/src/test/java/org/apache/shindig/com...

Modified: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/UserIdTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/UserIdTest.java?rev=891450&r1=891449&r2=891450&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/UserIdTest.java (original)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/UserIdTest.java Wed Dec 16 22:07:43 2009
@@ -19,10 +19,11 @@
 
 import org.apache.shindig.common.testing.FakeGadgetToken;
 
-import junit.framework.TestCase;
-
-public class UserIdTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Test;
 
+public class UserIdTest extends Assert {
+  @Test
   public void testGetUserId() throws Exception {
     UserId owner = new UserId(UserId.Type.owner, "hello");
     assertEquals("owner", owner.getUserId(new FakeGadgetToken().setOwnerId("owner")));
@@ -37,6 +38,7 @@
     assertEquals("hello", user.getUserId(new FakeGadgetToken()));
   }
 
+  @Test
   public void testFromJson() throws Exception {
     UserId owner = UserId.fromJson("@owner");
     assertEquals(UserId.Type.owner, owner.getType());
@@ -51,5 +53,4 @@
     assertEquals(UserId.Type.userId, user.getType());
     assertEquals("john.doe", user.getUserId());
   }
-
 }
\ No newline at end of file

Modified: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamAtomConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamAtomConverterTest.java?rev=891450&r1=891449&r2=891450&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamAtomConverterTest.java (original)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamAtomConverterTest.java Wed Dec 16 22:07:43 2009
@@ -23,8 +23,6 @@
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-import junit.framework.TestCase;
-
 import org.apache.shindig.common.xml.XmlUtil;
 import org.apache.shindig.social.SocialApiTestsGuiceModule;
 import org.apache.shindig.social.core.model.ActivityImpl;
@@ -43,21 +41,23 @@
 
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import java.util.List;
 import java.util.Map;
 
-public class BeanXStreamAtomConverterTest extends TestCase {
+public class BeanXStreamAtomConverterTest extends Assert {
   private Person johnDoe;
   private Activity activity;
 
   private BeanXStreamAtomConverter beanXmlConverter;
 
-  @Override
+  @Before
   public void setUp() throws Exception {
-    super.setUp();
     Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule());
 
     johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe"));
@@ -99,6 +99,7 @@
     }
   }
 
+  @Test
   public void testToXmlOnSimpleClass() throws Exception {
     // since this doent implement the model, it wont get mapped correctly, hence
     // we cant validate
@@ -112,6 +113,7 @@
     assertEquals("robot", name.getTextContent());
   }
 
+  @Test
   public void testPersonToXml() throws Exception {
     String xml = beanXmlConverter.convertToString(johnDoe);
     Element element = XmlUtil.parse(xml);
@@ -119,6 +121,7 @@
     assertEquals("urn:guid:" + johnDoe.getId(), id.getTextContent());
   }
 
+  @Test
   public void testActivityToXml() throws Exception {
     String xml = beanXmlConverter.convertToString(activity);
 
@@ -127,6 +130,7 @@
     assertEquals(activity.getId(), id.getTextContent());
   }
 
+  @Test
   public void testMapsToXml() throws Exception {
     // This is the structure our app data currently takes
     Map<String, Map<String, String>> map = Maps.newTreeMap();
@@ -157,6 +161,7 @@
 	XMLAssert.assertXMLEqual(expectedXml, xml);
   }
 
+  @Test
   public void testMapToXml() throws Exception {
     Map<String, String> m = Maps.newLinkedHashMap();
     m.put("key1", "value1");
@@ -178,6 +183,7 @@
 	XMLAssert.assertXMLEqual(expectedXml, xml);
   }
 
+  @Test
   public void testEmptyList() throws Exception {
     List<String> empty = Lists.newArrayList();
     String xml = beanXmlConverter.convertToString(empty);
@@ -208,6 +214,7 @@
 	XMLAssert.assertXMLEqual(expectedXml, xml);
   }
 
+  @Test
   public void testElementNamesInList() throws Exception {
     List<Activity> activities = Lists.newArrayList();
     activities.add(activity);

Modified: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamConverterTest.java?rev=891450&r1=891449&r2=891450&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamConverterTest.java (original)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/BeanXStreamConverterTest.java Wed Dec 16 22:07:43 2009
@@ -41,7 +41,11 @@
 import com.google.common.collect.Maps;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
-import junit.framework.TestCase;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -51,7 +55,7 @@
 import java.util.List;
 import java.util.Map;
 
-public class BeanXStreamConverterTest extends TestCase {
+public class BeanXStreamConverterTest extends Assert {
   private static final String XMLSCHEMA =
       " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
       + " xsi:schemaLocation=\"http://ns.opensocial.org/2008/opensocial classpath:opensocial.xsd\" ";
@@ -60,9 +64,8 @@
 
   private BeanXStreamConverter beanXmlConverter;
 
-  @Override
+  @Before
   public void setUp() throws Exception {
-    super.setUp();
     Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule());
 
     johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe"));
@@ -105,6 +108,7 @@
     }
   }
 
+  @Test
   public void testToXmlOnSimpleClass() throws Exception {
     // since this doent implement the model, it wont get mapped correctly, hence
     // we cant validate
@@ -118,6 +122,7 @@
     assertEquals("robot", name.getTextContent());
   }
 
+  @Test
   public void testPersonToXml() throws Exception {
     String xml = XSDValidator.validateOpenSocial(beanXmlConverter.convertToString(johnDoe));
     Element element = XmlUtil.parse(xml);
@@ -125,6 +130,7 @@
     assertEquals(johnDoe.getId(), id.getTextContent());
   }
 
+  @Test
   public void testActivityToXml() throws Exception {
     String xml = XSDValidator.validateOpenSocial(beanXmlConverter.convertToString(activity));
 
@@ -133,6 +139,7 @@
     assertEquals(activity.getId(), id.getTextContent());
   }
 
+  @Test
   public void testMapsToXml() throws Exception {
     // This is the structure our app data currently takes
     Map<String, Map<String, String>> map = Maps.newTreeMap();
@@ -157,6 +164,7 @@
         .deleteWhitespace(xml));
   }
 
+  @Test
   public void testMapToXml() throws XmlException {
     Map<String, String> m = Maps.newLinkedHashMap();
     m.put("key1", "value1");
@@ -171,6 +179,7 @@
         .deleteWhitespace(xml));
   }
 
+  @Test
   public void testEmptyList() throws XmlException {
     List<String> empty = Lists.newArrayList();
     String xml = beanXmlConverter.convertToString(empty);
@@ -192,6 +201,7 @@
         .deleteWhitespace(xml));
   }
 
+  @Test
   public void testElementNamesInList() throws Exception {
 
     List<Activity> activities = Lists.newArrayList();
@@ -241,21 +251,26 @@
 	XMLAssert.assertXMLEqual(expectedXml, xml);
   }
 
-  public void testPerson1() throws XmlException, IOException {
+  @Test
+  public void testPerson1() throws Exception {
     String xml = loadXML("testxml/person1.xml");
     beanXmlConverter.convertToObject(xml, Person.class);
   }
 
-  public void testActivity1() throws XmlException, IOException {
+  @Test
+  public void testActivity1() throws Exception {
     String xml = loadXML("testxml/activity1.xml");
     beanXmlConverter.convertToObject(xml, Activity.class);
   }
 
-  public void testAppdata1() throws XmlException, IOException {
+  @Test
+  public void testAppdata1() throws Exception {
     String xml = loadXML("testxml/appdata1.xml");
     beanXmlConverter.convertToObject(xml, Map.class);
   }
 
+  @Test
+  @Ignore("TODO")
   public void testGroup1() throws XmlException {
     // TODO
   }

Modified: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/XSDValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/XSDValidatorTest.java?rev=891450&r1=891449&r2=891450&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/XSDValidatorTest.java (original)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/XSDValidatorTest.java Wed Dec 16 22:07:43 2009
@@ -17,35 +17,42 @@
  */
 package org.apache.shindig.social.opensocial.util;
 
-import junit.framework.TestCase;
-
 import org.apache.shindig.common.xml.XmlException;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests the XSDValidator
  */
-public class XSDValidatorTest extends TestCase {
+public class XSDValidatorTest extends Assert {
 
   /**
    * Check that the XSDValidator is working correctly by testing for pass and fail
    * @throws XmlException
    */
+  @Test
   public void testValidator() throws XmlException {
     assertEquals("", XSDValidator.validate(this.getClass().getResourceAsStream("testschema1.xml"),this.getClass().getResourceAsStream("opensocial.xsd")));
     assertNotSame("", XSDValidator.validate(this.getClass().getResourceAsStream("testschema1bad.xml"),this.getClass().getResourceAsStream("opensocial.xsd")));
   }
-  
+
+  @Test
   public void testPerson1() throws XmlException {
     assertEquals("", XSDValidator.validate(this.getClass().getResourceAsStream("testxml/person1.xml"),this.getClass().getResourceAsStream("opensocial.xsd")));
   }
+
+  @Test
   public void testActivity1() throws XmlException {
     assertEquals("", XSDValidator.validate(this.getClass().getResourceAsStream("testxml/activity1.xml"),this.getClass().getResourceAsStream("opensocial.xsd")));
   }
+
+  @Test
   public void testAppdata1() throws XmlException {
     assertEquals("", XSDValidator.validate(this.getClass().getResourceAsStream("testxml/appdata1.xml"),this.getClass().getResourceAsStream("opensocial.xsd")));
   }
+
+  @Test
   public void testGroup1() throws XmlException {
     assertEquals("", XSDValidator.validate(this.getClass().getResourceAsStream("testxml/group1.xml"),this.getClass().getResourceAsStream("opensocial.xsd")));
   }
-
-}
+}
\ No newline at end of file

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=891450&r1=891449&r2=891450&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 Dec 16 22:07:43 2009
@@ -37,18 +37,18 @@
 
 import javax.servlet.http.HttpServletResponse;
 
-import junit.framework.TestCase;
-
 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;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Test the JSONOpensocialService
  */
-public class JsonDbOpensocialServiceTest extends TestCase {
+public class JsonDbOpensocialServiceTest extends Assert {
   private JsonDbOpensocialService db;
 
   private static final UserId CANON_USER = new UserId(UserId.Type.userId, "canonical");
@@ -61,13 +61,13 @@
 
   private SecurityToken token = new FakeGadgetToken();
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUp() throws Exception {
     Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule());
     db = injector.getInstance(JsonDbOpensocialService.class);
   }
 
+  @Test
   public void testGetPersonDefaultFields() throws Exception {
     Person person = db
         .getPerson(CANON_USER, Person.Field.DEFAULT_FIELDS, token).get();
@@ -79,12 +79,14 @@
         person.getThumbnailUrl());
   }
 
+  @Test
   public void testGetPersonAllFields() throws Exception {
     Person person = db
         .getPerson(CANON_USER, Person.Field.ALL_FIELDS, token).get();
     assertNotNull("Canonical user not found", person);
   }
 
+  @Test
   public void testGetPersonAllAppData() throws Exception {
     Person person = db
         .getPerson(CANON_USER, ImmutableSet.of("id", "appData"), token).get();
@@ -95,6 +97,7 @@
         ImmutableMap.of("count", "2", "size", "100"), person.getAppData());
   }
 
+  @Test
   public void testGetPersonOneAppDataField() throws Exception {
     Person person = db
         .getPerson(CANON_USER, ImmutableSet.of("id", "appData.size"), token).get();
@@ -105,6 +108,7 @@
         ImmutableMap.of("size", "100"), person.getAppData());
   }
 
+  @Test
   public void testGetPersonMultipleAppDataFields() throws Exception {
     Person person = db
         .getPerson(CANON_USER,
@@ -117,6 +121,7 @@
         ImmutableMap.of("count", "2", "size", "100"), person.getAppData());
   }
 
+  @Test
   public void testGetExpectedFriends() throws Exception {
     CollectionOptions options = new CollectionOptions();
     options.setSortBy(PersonService.TOP_FRIENDS_SORT);
@@ -137,6 +142,7 @@
     assertEquals("jane.doe", responseItem.getEntry().get(1).getId());
   }
 
+  @Test
   public void testGetExpectedUsersForPlural() throws Exception {
     CollectionOptions options = new CollectionOptions();
     options.setSortBy(PersonService.TOP_FRIENDS_SORT);
@@ -157,6 +163,7 @@
     assertEquals("jane.doe", responseItem.getEntry().get(1).getId());
   }
 
+  @Test
   public void testGetExpectedActivities() throws Exception {
     RestfulCollection<Activity> responseItem = db.getActivities(
         ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(), null,
@@ -164,6 +171,7 @@
     assertSame(2, responseItem.getTotalResults());
   }
 
+  @Test
   public void testGetExpectedActivitiesForPlural() throws Exception {
     RestfulCollection<Activity> responseItem = db.getActivities(
         ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(), null,
@@ -171,6 +179,7 @@
     assertSame(3, responseItem.getTotalResults());
   }
 
+  @Test
   public void testGetExpectedActivity() throws Exception {
     Activity activity = db.getActivity(
         CANON_USER, SELF_GROUP, APP_ID,
@@ -181,6 +190,7 @@
     assertNull(activity.getBodyId());
   }
 
+  @Test
   public void testDeleteExpectedActivity() throws Exception {
     db.deleteActivities(CANON_USER, SELF_GROUP, APP_ID, ImmutableSet.of(APP_ID),
         new FakeGadgetToken());
@@ -196,6 +206,7 @@
     }
   }
 
+  @Test
   public void testGetExpectedAppData() throws Exception {
     DataCollection responseItem = db.getPersonData(
         ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(),
@@ -208,6 +219,7 @@
     assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));
   }
 
+  @Test
   public void testGetExpectedAppDataForPlural() throws Exception {
     DataCollection responseItem = db.getPersonData(
         ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(),
@@ -224,6 +236,7 @@
     assertTrue(responseItem.getEntry().get(JOHN_DOE.getUserId()).containsKey("count"));
   }
 
+  @Test
   public void testDeleteExpectedAppData() throws Exception {
     // Delete the data
     db.deletePersonData(CANON_USER, SELF_GROUP, APP_ID,
@@ -241,6 +254,7 @@
     assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));
   }
 
+  @Test
   public void testUpdateExpectedAppData() throws Exception {
     // Delete the data
     db.updatePersonData(CANON_USER, SELF_GROUP, APP_ID,