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 2010/02/02 00:05:53 UTC

svn commit: r905440 - in /incubator/shindig/trunk/java: common/src/test/java/org/apache/shindig/auth/ common/src/test/java/org/apache/shindig/protocol/ gadgets/src/test/java/org/apache/shindig/gadgets/encoding/ gadgets/src/test/java/org/apache/shindig/...

Author: lindner
Date: Mon Feb  1 23:05:52 2010
New Revision: 905440

URL: http://svn.apache.org/viewvc?rev=905440&view=rev
Log:
use junit4 expected exceptions annotations

Modified:
    incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/auth/BlobCrypterSecurityTokenTest.java
    incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/ContentTypesTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureResourceLoaderTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthRequestTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/PNGOptimizerTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/MakeRequestHandlerTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/ProxyHandlerTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/FeatureTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/IconTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/OAuthServiceTest.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/UserPrefTest.java

Modified: incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/auth/BlobCrypterSecurityTokenTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/auth/BlobCrypterSecurityTokenTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/auth/BlobCrypterSecurityTokenTest.java (original)
+++ incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/auth/BlobCrypterSecurityTokenTest.java Mon Feb  1 23:05:52 2010
@@ -48,7 +48,7 @@
     crypter.timeSource = timeSource;
   }
 
-  @Test
+  @Test(expected=UnsupportedOperationException.class)
   public void testNullValues() throws Exception {
     BlobCrypterSecurityToken t = new BlobCrypterSecurityToken(crypter, CONTAINER, DOMAIN);
     String token = t.encrypt();
@@ -65,12 +65,9 @@
     assertNull(t2.getTrustedJson(), t2.getTrustedJson());
     assertNull(t2.getUpdatedToken(), t2.getUpdatedToken());
     assertEquals(CONTAINER, t2.getContainer());
-    try {
-      t2.getActiveUrl();
-      fail("Should have thrown");
-    } catch (UnsupportedOperationException e) {
-      // pass
-    }
+
+    // expect an exception
+    t2.getActiveUrl();
   }
 
   @Test
@@ -97,18 +94,15 @@
     assertEquals("active", t2.getActiveUrl());
   }
 
-  @Test
+  @Test(expected=BlobExpiredException.class)
   public void testExpired() throws Exception {
     BlobCrypterSecurityToken t = new BlobCrypterSecurityToken(crypter, CONTAINER, DOMAIN);
     String token = t.encrypt();
     // one hour plus clock skew
     timeSource.incrementSeconds(3600 + 181);
     String[] fields = StringUtils.split(token, ':');
-    try {
-      BlobCrypterSecurityToken.decrypt(crypter, CONTAINER, DOMAIN, fields[1], "active");
-      fail("Token should have expired");
-    } catch (BlobExpiredException e) {
-      // good
-    }
+
+    // expect an exception
+    BlobCrypterSecurityToken.decrypt(crypter, CONTAINER, DOMAIN, fields[1], "active");
   }
 }

Modified: incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/ContentTypesTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/ContentTypesTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/ContentTypesTest.java (original)
+++ incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/protocol/ContentTypesTest.java Mon Feb  1 23:05:52 2010
@@ -56,24 +56,16 @@
         ContentTypes.MULTIPART_FORM_CONTENT_TYPE, true);
   }
 
-  @Test
+  @Test(expected=ContentTypes.InvalidContentTypeException.class)
   public void testForbidden() throws Exception {
-    try {
-      ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES,
-          "application/x-www-form-urlencoded", false);
-      fail("Should fail as form encoded is forbidden");
-    } catch (ContentTypes.InvalidContentTypeException icte) {
-    }
+    ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES,
+        "application/x-www-form-urlencoded", false);
   }
 
-  @Test
+  @Test(expected=ContentTypes.InvalidContentTypeException.class)
   public void testStrictDisallowUnknown() throws Exception {
-    try {
-      ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES,
-          "text/plain", true);
-      fail("Should fail with strict content type checking enabled");
-    } catch (ContentTypes.InvalidContentTypeException icte) {
-    }
+    ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES,
+        "text/plain", true);
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java Mon Feb  1 23:05:52 2010
@@ -113,16 +113,11 @@
     assertEquals("UTF-8", detector.detectEncoding(data).name());
   }
   
-  @Test
+  @Test(expected=NullPointerException.class)
   public void nullCustomDetector() throws Exception {
     byte[] data = "\u4F60\u597D".getBytes("BIG5");
 
-    try {
-      assertEquals("ISO-8859-1", EncodingDetector.detectEncoding(data, false, null).name());
-      fail("Null Custom encoder is not supported");
-    } catch (NullPointerException e) {
-      // Expected!
-    }
+    // expect a NPE
+    assertEquals("ISO-8859-1", EncodingDetector.detectEncoding(data, false, null).name());
   }
-
 }

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java Mon Feb  1 23:05:52 2010
@@ -22,6 +22,7 @@
 import static org.junit.Assert.fail;
 
 import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.GadgetException;
 
 import org.junit.Test;
 
@@ -113,13 +114,9 @@
     assertEquals(0, bundle4.getResources().get(0).getAttribs().size());
   }
   
-  @Test
-  public void parseInvalidXml() {
-    try {
-      new FeatureParser().parse(Uri.parse(""), "This is not valid XML.");
-      fail("Should have failed to parse invalid XML");
-    } catch (Exception e) {
-      // Expected.
-    }
+  @Test(expected=GadgetException.class)
+  public void parseInvalidXml() throws GadgetException {
+    // Should failed to parse invalid XML");
+    new FeatureParser().parse(Uri.parse(""), "This is not valid XML.");
   }
 }

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureResourceLoaderTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureResourceLoaderTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureResourceLoaderTest.java Mon Feb  1 23:05:52 2010
@@ -93,15 +93,11 @@
     assertTrue(resource.isProxyCacheable());
   }
   
-  @Test
+  @Test(expected=IllegalArgumentException.class)
   public void loadFileNothingAvailable() throws Exception {
     Uri nilUri = new UriBuilder().setScheme("file").setPath("/does/not/exist.js").toUri();
-    try {
-      loader.load(nilUri, null);
-      fail("Should have failed indicating could not find: " + nilUri.toString());
-    } catch (IllegalArgumentException e) {
-      // Expected.
-    }
+    loader.load(nilUri, null);
+    fail("Should have failed indicating could not find: " + nilUri.toString());
   }
   
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthRequestTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthRequestTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthRequestTest.java Mon Feb  1 23:05:52 2010
@@ -1293,7 +1293,7 @@
     }
   }
 
-  @Test
+  @Test(expected=RuntimeException.class)
   public void testGetTamperedFormContent() throws Exception {
     MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
     // Tamper with the body before it hits the service provider
@@ -1303,16 +1303,12 @@
         return serviceProvider.fetch(request);
       }
     });
-    try {
-      client.sendGetWithBody(FakeOAuthServiceProvider.RESOURCE_URL,
-          OAuth.FORM_ENCODED, "foo=bar".getBytes());
-      fail("Should have thrown with oauth signature mismatch");
-    } catch (RuntimeException e) {
-      // good
-    }
+    client.sendGetWithBody(FakeOAuthServiceProvider.RESOURCE_URL,
+        OAuth.FORM_ENCODED, "foo=bar".getBytes());
+    fail("Should have thrown with oauth signature mismatch");
   }
   
-  @Test
+  @Test(expected=RuntimeException.class)
   public void testGetTamperedRemoveRawContent() throws Exception {
     byte[] raw = { 0, 1, 2, 3, 4, 5 };
     MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
@@ -1324,16 +1320,12 @@
         return serviceProvider.fetch(request);
       }
     });
-    try {
-      client.sendGetWithBody(FakeOAuthServiceProvider.RESOURCE_URL,
-          "funky-content", raw);
-      fail("Should have thrown with body hash in form encoded request");
-    } catch (RuntimeException e) {
-      // good
-    }
+    client.sendGetWithBody(FakeOAuthServiceProvider.RESOURCE_URL,
+        "funky-content", raw);
+    fail("Should have thrown with body hash in form encoded request");
   }
 
-  @Test
+  @Test(expected=RuntimeException.class)
   public void testPostTamperedRawContent() throws Exception {
     byte[] raw = { 0, 1, 2, 3, 4, 5 };
     MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
@@ -1344,16 +1336,12 @@
         return serviceProvider.fetch(request);
       }
     });
-    try {
-      client.sendRawPost(FakeOAuthServiceProvider.RESOURCE_URL,
-          "funky-content", raw);
-      fail("Should have thrown with oauth_body_hash mismatch");
-    } catch (RuntimeException e) {
-      // good
-    }
+    client.sendRawPost(FakeOAuthServiceProvider.RESOURCE_URL,
+       "funky-content", raw);
+    fail("Should have thrown with oauth_body_hash mismatch");
   }
 
-  @Test
+  @Test(expected=RuntimeException.class)
   public void testPostTamperedFormContent() throws Exception {
     MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
     // Tamper with the body before it hits the service provider
@@ -1363,15 +1351,11 @@
         return serviceProvider.fetch(request);
       }
     });
-    try {
-      client.sendFormPost(FakeOAuthServiceProvider.RESOURCE_URL, "foo=bar");
-      fail("Should have thrown with oauth signature mismatch");
-    } catch (RuntimeException e) {
-      // good
-    }
+    client.sendFormPost(FakeOAuthServiceProvider.RESOURCE_URL, "foo=bar");
+    fail("Should have thrown with oauth signature mismatch");
   }
   
-  @Test
+  @Test(expected=RuntimeException.class)
   public void testPostTamperedRemoveRawContent() throws Exception {
     byte[] raw = { 0, 1, 2, 3, 4, 5 };
     MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
@@ -1383,13 +1367,9 @@
         return serviceProvider.fetch(request);
       }
     });
-    try {
-      client.sendRawPost(FakeOAuthServiceProvider.RESOURCE_URL,
-          "funky-content", raw);
-      fail("Should have thrown with body hash in form encoded request");
-    } catch (RuntimeException e) {
-      // good
-    }
+    client.sendRawPost(FakeOAuthServiceProvider.RESOURCE_URL,
+        "funky-content", raw);
+    fail("Should have thrown with body hash in form encoded request");
   }
   
   @Test
@@ -1866,7 +1846,7 @@
     assertEquals("User data is hello-oauth", response.getResponseAsString());
   }
 
-  @Test
+  @Test(expected=RuntimeException.class)
   public void testAccessTokenData_noDirectRequest() throws Exception {
     serviceProvider.setReturnAccessTokenData(true);
 
@@ -1879,12 +1859,8 @@
     response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
     assertEquals("User data is hello-oauth", response.getResponseAsString());
 
-    try {
-      client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL);
-      fail("Service provider should have rejected bogus request to access token URL");
-    } catch (RuntimeException e) {
-      // good
-    }
+    client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL);
+    fail("Service provider should have rejected bogus request to access token URL");
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java Mon Feb  1 23:05:52 2010
@@ -51,15 +51,11 @@
     assertEquals(0, services.size());
   }
 
-  @Test
+  @Test(expected=Exception.class)
   public void testGetServicesForContainer_Null() throws Exception {
     String container = null;
-    try {
-      svcLookup.getServicesFor(container, host);
-      fail("Should have thrown an exception for an invalid container");
-    } catch (Exception e) {
-      
-    }
+    svcLookup.getServicesFor(container, host);
+    fail("Should have thrown an exception for an invalid container");
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/PNGOptimizerTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/PNGOptimizerTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/PNGOptimizerTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/PNGOptimizerTest.java Mon Feb  1 23:05:52 2010
@@ -48,17 +48,13 @@
     assertEquals("image/png", httpResponse.getHeader("Content-Type"));
   }
 
-  @Test
+  @Test(expected=IOException.class)
   public void testEvil() throws Exception {
     // Metadata length is too long causes OutOfMemory
-    try {
-      HttpResponse resp =
-          createResponse("org/apache/shindig/gadgets/rewrite/image/evil.png", "image/png");
-      rewrite(resp);
-      fail("Should have failed to read image");
-    } catch (IOException ioe) {
-      // Expected
-    }
+    HttpResponse resp =
+        createResponse("org/apache/shindig/gadgets/rewrite/image/evil.png", "image/png");
+    rewrite(resp);
+    fail("Should have failed to read image");
   }
 
   HttpResponse rewrite(HttpResponse original)

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/MakeRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/MakeRequestHandlerTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/MakeRequestHandlerTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/MakeRequestHandlerTest.java Mon Feb  1 23:05:52 2010
@@ -397,7 +397,7 @@
     assertTrue(rewriter.responseWasRewritten());
   }
 
-  @Test
+  @Test(expected=GadgetException.class)
   public void testBadSecurityTokenThrows() throws Exception {
     expect(request.getAttribute(AuthInfo.Attribute.SECURITY_TOKEN.getId()))
         .andReturn(null).atLeastOnce();
@@ -405,12 +405,7 @@
         .andReturn(AuthType.SIGNED.toString()).atLeastOnce();
     replay();
 
-    try {
-      handler.doFetch(request, recorder);
-      fail("Should have thrown");
-    } catch (GadgetException e) {
-      // good.
-    }
+    handler.doFetch(request, recorder);
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/ProxyHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/ProxyHandlerTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/ProxyHandlerTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/ProxyHandlerTest.java Mon Feb  1 23:05:52 2010
@@ -94,18 +94,14 @@
     assertTrue(rewriter.responseWasRewritten());
   }
 
-  @Test
+  @Test(expected=GadgetException.class)
   public void testNoUrl() throws Exception {
     setupProxyRequestMock("www.example.com", null);
     expect(lockedDomainService.isSafeForOpenProxy("www.example.com")).andReturn(true);
     replay();
 
-    try {
-      proxyHandler.doFetch(request, recorder);
-      fail("Proxy should raise exception if there is no url");
-    } catch (GadgetException e) {
-      // Good!
-    }
+    proxyHandler.doFetch(request, recorder);
+    fail("Proxy should raise exception if there is no url");
   }
 
   @Test
@@ -130,17 +126,13 @@
     assertTrue(rewriter.responseWasRewritten());
   }
 
-  @Test
+  @Test(expected=GadgetException.class)
   public void testLockedDomainFailedEmbed() throws Exception {
     setupFailedProxyRequestMock("www.example.com", URL_ONE);
     expect(lockedDomainService.isSafeForOpenProxy("www.example.com")).andReturn(false);
     replay();
-    try {
-      proxyHandler.doFetch(request, response);
-      fail("Should have thrown");
-    } catch (GadgetException e) {
-      // good
-    }
+
+    proxyHandler.doFetch(request, response);
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/FeatureTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/FeatureTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/FeatureTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/FeatureTest.java Mon Feb  1 23:05:52 2010
@@ -81,25 +81,15 @@
     assertNull(feature.getParam("foobar"));
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testDoesNotLikeUnnamedFeatures() throws Exception {
     String xml = "<Require/>";
-    try {
-      new Feature(XmlUtil.parse(xml));
-      fail("No exception thrown when an unnamed feature is passed.");
-    } catch (SpecParserException e) {
-      // Ok
-    }
+    new Feature(XmlUtil.parse(xml));
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testEnforceParamNames() throws Exception {
     String xml = "<Require feature=\"foo\"><Param>Test</Param></Require>";
-    try {
-      new Feature(XmlUtil.parse(xml));
-      fail("No exception thrown when an unnamed parameter is passed.");
-    } catch (SpecParserException e) {
-      // OK.
-    }
+    new Feature(XmlUtil.parse(xml));
   }
 }

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java Mon Feb  1 23:05:52 2010
@@ -75,32 +75,22 @@
     assertEquals("test", spec.getView("test").getContent());
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testMissingModulePrefs() throws Exception {
     String xml = "<Module>" +
                  "<Content type=\"html\"/>" +
                  "</Module>";
-    try {
-      new GadgetSpec(SPEC_URL, xml);
-      fail("No exception thrown when ModulePrefs is missing.");
-    } catch (SpecParserException e) {
-      // OK
-    }
+    new GadgetSpec(SPEC_URL, xml);
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testEnforceOneModulePrefs() throws Exception {
     String xml = "<Module>" +
                  "<ModulePrefs title=\"hello\"/>" +
                  "<ModulePrefs title=\"world\"/>" +
                  "<Content type=\"html\"/>" +
                  "</Module>";
-    try {
-      new GadgetSpec(SPEC_URL, xml);
-      fail("No exception thrown when more than 1 ModulePrefs is specified.");
-    } catch (SpecParserException e) {
-      // OK
-    }
+    new GadgetSpec(SPEC_URL, xml);
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/IconTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/IconTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/IconTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/IconTest.java Mon Feb  1 23:05:52 2010
@@ -35,15 +35,10 @@
     assertEquals("helloWorld", icon.getContent());
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testInvalidMode() throws Exception {
     String xml = "<Icon type=\"foo\" mode=\"broken\"/>";
-    try {
-      new Icon(XmlUtil.parse(xml));
-      fail("No exception thrown when an invalid mode attribute is passed.");
-    } catch (SpecParserException e) {
-      // OK
-    }
+    new Icon(XmlUtil.parse(xml));
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/OAuthServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/OAuthServiceTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/OAuthServiceTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/OAuthServiceTest.java Mon Feb  1 23:05:52 2010
@@ -44,15 +44,10 @@
     assertEquals("http://azn.example.com", url.toString());
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testParseAuthorizeUrl_nourl() throws Exception {
     String xml = "<Authorization/>";
-    try {
-      service.parseAuthorizationUrl(XmlUtil.parse(xml), SPEC_URL);
-      fail("Should have rejected malformed Authorization element");
-    } catch (SpecParserException e) {
-      assertEquals("OAuth/Service/Authorization @url is not valid: ", e.getMessage());
-    }
+    service.parseAuthorizationUrl(XmlUtil.parse(xml), SPEC_URL);
   }
 
   @Test

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/UserPrefTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/UserPrefTest.java?rev=905440&r1=905439&r2=905440&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/UserPrefTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/UserPrefTest.java Mon Feb  1 23:05:52 2010
@@ -77,15 +77,10 @@
     assertEquals(displayValue, userPref.getEnumValues().get("0"));
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testMissingName() throws Exception {
     String xml = "<UserPref datatype=\"string\"/>";
-    try {
-      new UserPref(XmlUtil.parse(xml));
-      fail("No exception thrown when name is missing");
-    } catch (SpecParserException e) {
-      // OK
-    }
+    new UserPref(XmlUtil.parse(xml));
   }
 
   @Test
@@ -95,17 +90,12 @@
     assertEquals(UserPref.DataType.STRING, pref.getDataType());
   }
 
-  @Test
+  @Test(expected=SpecParserException.class)
   public void testMissingEnumValue() throws Exception {
     String xml = "<UserPref name=\"foo\" datatype=\"enum\">" +
                  " <EnumValue/>" +
                  "</UserPref>";
-    try {
-      new UserPref(XmlUtil.parse(xml));
-      fail("No exception thrown when EnumValue@value is missing");
-    } catch (SpecParserException e) {
-      // OK
-    }
+    new UserPref(XmlUtil.parse(xml));
   }
 
   @Test