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 2013/10/18 04:33:25 UTC

svn commit: r1533314 - in /shindig/trunk/java: common/src/test/java/org/apache/shindig/common/xml/DomUtilTest.java gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/OAuth2ArgumentsTest.java

Author: lindner
Date: Fri Oct 18 02:33:25 2013
New Revision: 1533314

URL: http://svn.apache.org/r1533314
Log:
fix some non-threadsafe tests to get ready for the latest surefire maven plugin

Modified:
    shindig/trunk/java/common/src/test/java/org/apache/shindig/common/xml/DomUtilTest.java
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/OAuth2ArgumentsTest.java

Modified: shindig/trunk/java/common/src/test/java/org/apache/shindig/common/xml/DomUtilTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/xml/DomUtilTest.java?rev=1533314&r1=1533313&r2=1533314&view=diff
==============================================================================
--- shindig/trunk/java/common/src/test/java/org/apache/shindig/common/xml/DomUtilTest.java (original)
+++ shindig/trunk/java/common/src/test/java/org/apache/shindig/common/xml/DomUtilTest.java Fri Oct 18 02:33:25 2013
@@ -19,6 +19,7 @@
 package org.apache.shindig.common.xml;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNull;
 
 import org.apache.shindig.common.xml.DomUtil;
@@ -27,6 +28,7 @@ import org.apache.shindig.common.xml.Xml
 
 import com.google.common.collect.ImmutableSet;
 
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.w3c.dom.Document;
@@ -44,15 +46,9 @@ public class DomUtilTest {
       "  <other>not real</other>" +
       "</root>";
 
-  private static Element root;
-
-  @BeforeClass
-  public static void createRoot() throws XmlException {
-    root = XmlUtil.parse(XML);
-  }
-
   @Test
-  public void getFirstNamedChildNode() {
+  public void getFirstNamedChildNode() throws Exception {
+    Element root = XmlUtil.parse(XML);
     assertEquals("zero", DomUtil.getFirstNamedChildNode(root, "element").getTextContent());
     assertEquals("whatever", DomUtil.getFirstNamedChildNode(root, "other").getTextContent());
     assertNull("Did not return null for missing element.",
@@ -60,7 +56,9 @@ public class DomUtilTest {
   }
 
   @Test
-  public void getLastNamedChildNode() {
+  public void getLastNamedChildNode() throws Exception {
+    Element root = XmlUtil.parse(XML);
+    assertTrue(DomUtil.getLastNamedChildNode(root, "element") != null);
     assertEquals("two", DomUtil.getLastNamedChildNode(root, "element").getTextContent());
     assertEquals("not real", DomUtil.getLastNamedChildNode(root, "other").getTextContent());
     assertNull("Did not return null for missing element.",
@@ -68,7 +66,8 @@ public class DomUtilTest {
   }
 
   @Test
-  public void getElementsByTagNameCaseInsensitive() {
+  public void getElementsByTagNameCaseInsensitive() throws Exception {
+    Element root = XmlUtil.parse(XML);
     Document doc = root.getOwnerDocument();
     List<Element> elements
         = DomUtil.getElementsByTagNameCaseInsensitive(doc, ImmutableSet.of("element"));

Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/OAuth2ArgumentsTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/OAuth2ArgumentsTest.java?rev=1533314&r1=1533313&r2=1533314&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/OAuth2ArgumentsTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/OAuth2ArgumentsTest.java Fri Oct 18 02:33:25 2013
@@ -34,31 +34,30 @@ import org.junit.Test;
 import com.google.common.collect.Maps;
 
 public class OAuth2ArgumentsTest extends MockUtils {
-  private static HttpServletRequest requestMock;
-  private static Map<String, String> attrs;
+  private HttpServletRequest requestMock;
+  private Map<String, String> attrs;
 
   @Before
   public void setUp() throws Exception {
-    OAuth2ArgumentsTest.attrs = Maps.newHashMap();
-    OAuth2ArgumentsTest.attrs.put("OAUTH_SCOPE", MockUtils.SCOPE);
-    OAuth2ArgumentsTest.attrs.put("OAUTH_SERVICE_NAME", MockUtils.SERVICE_NAME);
-    OAuth2ArgumentsTest.attrs.put("bypassSpecCache", "1");
-    OAuth2ArgumentsTest.attrs.put("extraParam", "extraValue");
-    OAuth2ArgumentsTest.requestMock = EasyMock.createNiceMock(HttpServletRequest.class);
-    EasyMock.expect(OAuth2ArgumentsTest.requestMock.getParameterNames()).andReturn(
-        Collections.enumeration(OAuth2ArgumentsTest.attrs.keySet()));
-    EasyMock.expect(OAuth2ArgumentsTest.requestMock.getParameterMap()).andReturn(
-        OAuth2ArgumentsTest.attrs);
-    for (final Entry<String, String> entry : OAuth2ArgumentsTest.attrs.entrySet()) {
-      EasyMock.expect(OAuth2ArgumentsTest.requestMock.getParameter(entry.getKey())).andReturn(
+    attrs = Maps.newHashMap();
+    attrs.put("OAUTH_SCOPE", MockUtils.SCOPE);
+    attrs.put("OAUTH_SERVICE_NAME", MockUtils.SERVICE_NAME);
+    attrs.put("bypassSpecCache", "1");
+    attrs.put("extraParam", "extraValue");
+    requestMock = EasyMock.createNiceMock(HttpServletRequest.class);
+    EasyMock.expect(requestMock.getParameterNames()).andReturn(
+        Collections.enumeration(attrs.keySet()));
+    EasyMock.expect(requestMock.getParameterMap()).andReturn(attrs);
+    for (final Entry<String, String> entry : attrs.entrySet()) {
+      EasyMock.expect(requestMock.getParameter(entry.getKey())).andReturn(
           entry.getValue());
     }
-    EasyMock.replay(OAuth2ArgumentsTest.requestMock);
+    EasyMock.replay(requestMock);
   }
 
   @Test
   public void testOAuth2Arguments_1() throws Exception {
-    final OAuth2Arguments result = new OAuth2Arguments(OAuth2ArgumentsTest.requestMock);
+    final OAuth2Arguments result = new OAuth2Arguments(requestMock);
 
     Assert.assertNotNull(result);
     Assert.assertTrue(result.getBypassSpecCache());
@@ -95,7 +94,7 @@ public class OAuth2ArgumentsTest extends
   public void testOAuth2Arguments_3() throws Exception {
     final RequestAuthenticationInfo info = EasyMock.createNiceMock(RequestAuthenticationInfo.class);
     EasyMock.expect(info.getAuthType()).andReturn(AuthType.OAUTH2);
-    EasyMock.expect(info.getAttributes()).andReturn(OAuth2ArgumentsTest.attrs);
+    EasyMock.expect(info.getAttributes()).andReturn(attrs);
     EasyMock.replay(info);
 
     final OAuth2Arguments result = new OAuth2Arguments(info);
@@ -108,7 +107,7 @@ public class OAuth2ArgumentsTest extends
 
   @Test
   public void testOAuth2Arguments_4() throws Exception {
-    final OAuth2Arguments result = new OAuth2Arguments(AuthType.OAUTH2, OAuth2ArgumentsTest.attrs);
+    final OAuth2Arguments result = new OAuth2Arguments(AuthType.OAUTH2, attrs);
 
     Assert.assertNotNull(result);
     Assert.assertTrue(result.getBypassSpecCache());
@@ -118,9 +117,9 @@ public class OAuth2ArgumentsTest extends
 
   @Test
   public void testEquals_1() throws Exception {
-    final OAuth2Arguments fixture = new OAuth2Arguments(AuthType.OAUTH2, OAuth2ArgumentsTest.attrs);
+    final OAuth2Arguments fixture = new OAuth2Arguments(AuthType.OAUTH2, attrs);
 
-    final Object obj = new OAuth2Arguments(OAuth2ArgumentsTest.requestMock);
+    final Object obj = new OAuth2Arguments(requestMock);
 
     final boolean result = fixture.equals(obj);
 
@@ -131,14 +130,14 @@ public class OAuth2ArgumentsTest extends
   public void testEquals_2() throws Exception {
     final Object obj = new Object();
 
-    final boolean result = OAuth2ArgumentsTest.requestMock.equals(obj);
+    final boolean result = requestMock.equals(obj);
 
     Assert.assertFalse(result);
   }
 
   @Test
   public void testEquals_3() throws Exception {
-    final boolean result = OAuth2ArgumentsTest.requestMock.equals(null);
+    final boolean result = requestMock.equals(null);
 
     Assert.assertFalse(result);
   }
@@ -160,14 +159,14 @@ public class OAuth2ArgumentsTest extends
 
     final OAuth2Arguments obj = new OAuth2Arguments(request);
 
-    final boolean result = OAuth2ArgumentsTest.requestMock.equals(obj);
+    final boolean result = requestMock.equals(obj);
 
     Assert.assertFalse(result);
   }
 
   @Test
   public void testGetBypassSpecCache_1() throws Exception {
-    final OAuth2Arguments fixture = new OAuth2Arguments(OAuth2ArgumentsTest.requestMock);
+    final OAuth2Arguments fixture = new OAuth2Arguments(requestMock);
 
     final boolean result = fixture.getBypassSpecCache();
 
@@ -176,7 +175,7 @@ public class OAuth2ArgumentsTest extends
 
   @Test
   public void testGetScope_1() throws Exception {
-    final OAuth2Arguments fixture = new OAuth2Arguments(OAuth2ArgumentsTest.requestMock);
+    final OAuth2Arguments fixture = new OAuth2Arguments(requestMock);
 
     final String result = fixture.getScope();
 
@@ -186,7 +185,7 @@ public class OAuth2ArgumentsTest extends
 
   @Test
   public void testGetServiceName_1() throws Exception {
-    final OAuth2Arguments fixture = new OAuth2Arguments(OAuth2ArgumentsTest.requestMock);
+    final OAuth2Arguments fixture = new OAuth2Arguments(requestMock);
 
     final String result = fixture.getServiceName();
 
@@ -196,7 +195,7 @@ public class OAuth2ArgumentsTest extends
 
   @Test
   public void testHashCode_1() throws Exception {
-    final OAuth2Arguments fixture = new OAuth2Arguments(OAuth2ArgumentsTest.requestMock);
+    final OAuth2Arguments fixture = new OAuth2Arguments(requestMock);
 
     final int result = fixture.hashCode();