You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/01/22 09:05:57 UTC

svn commit: r1234460 [16/30] - in /incubator/isis/trunk/framework/viewer: bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/ bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/components/ bdd/common/src/main/java/org/apache/isis/viewer...

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestDomainModelTest_parser.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestDomainModelTest_parser.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestDomainModelTest_parser.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestDomainModelTest_parser.java Sun Jan 22 08:05:17 2012
@@ -16,24 +16,24 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib;
-
-import static org.junit.Assert.assertSame;
-
-import org.apache.isis.viewer.json.applib.RestfulRequest.DomainModel;
+package org.apache.isis.viewer.json.applib;
+
+import static org.junit.Assert.assertSame;
+
+import org.apache.isis.viewer.json.applib.RestfulRequest.DomainModel;
 import org.apache.isis.viewer.json.applib.util.Parser;
-import org.junit.Test;
-
-public class RestfulRequestDomainModelTest_parser {
-
-    @Test
-    public void parser_roundtrips() {
-        final Parser<DomainModel> parser = RestfulRequest.DomainModel.parser();
-        for (DomainModel domainModel : DomainModel.values()) {
-            final String asString = parser.asString(domainModel);
-            final DomainModel roundtripped = parser.valueOf(asString);
-            assertSame(roundtripped, domainModel);
-        }
-    }
-
-}
+import org.junit.Test;
+
+public class RestfulRequestDomainModelTest_parser {
+
+    @Test
+    public void parser_roundtrips() {
+        final Parser<DomainModel> parser = RestfulRequest.DomainModel.parser();
+        for (final DomainModel domainModel : DomainModel.values()) {
+            final String asString = parser.asString(domainModel);
+            final DomainModel roundtripped = parser.valueOf(asString);
+            assertSame(roundtripped, domainModel);
+        }
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestRequestParameterTest_valueOf.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestRequestParameterTest_valueOf.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestRequestParameterTest_valueOf.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulRequestRequestParameterTest_valueOf.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib;
-
+package org.apache.isis.viewer.json.applib;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
@@ -26,65 +26,65 @@ import java.util.List;
 import org.apache.isis.viewer.json.applib.RestfulRequest.RequestParameter;
 import org.junit.Before;
 import org.junit.Test;
-
-public class RestfulRequestRequestParameterTest_valueOf {
-
+
+public class RestfulRequestRequestParameterTest_valueOf {
+
     private final RequestParameter<List<List<String>>> requestParameter = RestfulRequest.RequestParameter.FOLLOW_LINKS;
-    
-    private JsonRepresentation repr;
-
-    @Before
-    public void setUp() throws Exception {
-        repr = JsonRepresentation.newMap();
-    }
-    
-    @Test
-    public void mapContainsList() {
-        repr.mapPut("x-ro-follow-links", "a,b.c");
-        List<List<String>> valueOf = requestParameter.valueOf(repr);
-        
-        assertThat(valueOf.size(), is(2));
-        assertThat(valueOf.get(0).size(), is(1));
-        assertThat(valueOf.get(0).get(0), is("a"));
-        assertThat(valueOf.get(1).size(), is(2));
-        assertThat(valueOf.get(1).get(0), is("b"));
-        assertThat(valueOf.get(1).get(1), is("c"));
-    }
-
-    @Test
-    public void mapHasNoKey() {
-        repr.mapPut("something-else", "a,b.c");
-        List<List<String>> valueOf = requestParameter.valueOf(repr);
-        
-        assertThat(valueOf.size(), is(0));
-    }
-
-    @Test
-    public void mapIsEmpty() {
-        List<List<String>> valueOf = requestParameter.valueOf(repr);
-        
-        assertThat(valueOf.size(), is(0));
-    }
-
-    @Test
-    public void mapIsNull() {
-        List<List<String>> valueOf = requestParameter.valueOf(null);
-        
-        assertThat(valueOf.size(), is(0));
-    }
-
-    @Test
-    public void mapContainsCommaSeparatedList() {
-        
-        repr.mapPut("x-ro-follow-links", "a,b.c");
-        List<List<String>> valueOf = requestParameter.valueOf(repr);
-        
-        assertThat(valueOf.size(), is(2));
-        assertThat(valueOf.get(0).size(), is(1));
-        assertThat(valueOf.get(0).get(0), is("a"));
-        assertThat(valueOf.get(1).size(), is(2));
-        assertThat(valueOf.get(1).get(0), is("b"));
-        assertThat(valueOf.get(1).get(1), is("c"));
-    }
-
-}
+
+    private JsonRepresentation repr;
+
+    @Before
+    public void setUp() throws Exception {
+        repr = JsonRepresentation.newMap();
+    }
+
+    @Test
+    public void mapContainsList() {
+        repr.mapPut("x-ro-follow-links", "a,b.c");
+        final List<List<String>> valueOf = requestParameter.valueOf(repr);
+
+        assertThat(valueOf.size(), is(2));
+        assertThat(valueOf.get(0).size(), is(1));
+        assertThat(valueOf.get(0).get(0), is("a"));
+        assertThat(valueOf.get(1).size(), is(2));
+        assertThat(valueOf.get(1).get(0), is("b"));
+        assertThat(valueOf.get(1).get(1), is("c"));
+    }
+
+    @Test
+    public void mapHasNoKey() {
+        repr.mapPut("something-else", "a,b.c");
+        final List<List<String>> valueOf = requestParameter.valueOf(repr);
+
+        assertThat(valueOf.size(), is(0));
+    }
+
+    @Test
+    public void mapIsEmpty() {
+        final List<List<String>> valueOf = requestParameter.valueOf(repr);
+
+        assertThat(valueOf.size(), is(0));
+    }
+
+    @Test
+    public void mapIsNull() {
+        final List<List<String>> valueOf = requestParameter.valueOf(null);
+
+        assertThat(valueOf.size(), is(0));
+    }
+
+    @Test
+    public void mapContainsCommaSeparatedList() {
+
+        repr.mapPut("x-ro-follow-links", "a,b.c");
+        final List<List<String>> valueOf = requestParameter.valueOf(repr);
+
+        assertThat(valueOf.size(), is(2));
+        assertThat(valueOf.get(0).size(), is(1));
+        assertThat(valueOf.get(0).get(0), is("a"));
+        assertThat(valueOf.get(1).size(), is(2));
+        assertThat(valueOf.get(1).get(0), is("b"));
+        assertThat(valueOf.get(1).get(1), is("c"));
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulResponse_HttpStatusCodeTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulResponse_HttpStatusCodeTest.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulResponse_HttpStatusCodeTest.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/RestfulResponse_HttpStatusCodeTest.java Sun Jan 22 08:05:17 2012
@@ -16,28 +16,28 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
-import org.junit.Test;
-
-public class RestfulResponse_HttpStatusCodeTest {
-
-    @Test
-    public void knownStatusCode() {
-        assertThat(HttpStatusCode.statusFor(200), is(HttpStatusCode.OK));
-    }
-
-    @Test
-    public void unknownStatusCode() {
-        HttpStatusCode statusFor = HttpStatusCode.statusFor(600);
-        assertThat(statusFor.getStatusCode(), is(600));
-        assertThat(statusFor.getFamily(), is(Family.OTHER));
-    }
-
-}
+package org.apache.isis.viewer.json.applib;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
+import org.junit.Test;
+
+public class RestfulResponse_HttpStatusCodeTest {
+
+    @Test
+    public void knownStatusCode() {
+        assertThat(HttpStatusCode.statusFor(200), is(HttpStatusCode.OK));
+    }
+
+    @Test
+    public void unknownStatusCode() {
+        final HttpStatusCode statusFor = HttpStatusCode.statusFor(600);
+        assertThat(statusFor.getStatusCode(), is(600));
+        assertThat(statusFor.getFamily(), is(Family.OTHER));
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/links/LinkRepresentationTest_equals.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/links/LinkRepresentationTest_equals.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/links/LinkRepresentationTest_equals.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/links/LinkRepresentationTest_equals.java Sun Jan 22 08:05:17 2012
@@ -16,39 +16,38 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.links;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-
-import java.io.UnsupportedEncodingException;
-
+package org.apache.isis.viewer.json.applib.links;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.io.UnsupportedEncodingException;
+
 import org.apache.isis.viewer.json.applib.HttpMethod;
-import org.apache.isis.viewer.json.applib.links.LinkRepresentation;
-import org.junit.Test;
-
-public class LinkRepresentationTest_equals {
-
-    @Test
-    public void equalDependsOnMethodAndHref() throws UnsupportedEncodingException {
-        LinkRepresentation link = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET);
-        LinkRepresentation link2 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET);
-        LinkRepresentation link3 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.PUT);
-        LinkRepresentation link4 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:456").withMethod(HttpMethod.GET);
-        
-        assertThat(link, is(equalTo(link2)));
-        assertThat(link, is(not(equalTo(link3))));
-        assertThat(link, is(not(equalTo(link4))));
-    }
-
-    @Test
-    public void equalDoesNotDependsOnMethodAndHref() throws UnsupportedEncodingException {
-        LinkRepresentation link = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET).withRel("something");
-        LinkRepresentation link2 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET).withRel("else");
-        
-        assertThat(link, is(equalTo(link2)));
-    }
-
-}
+import org.junit.Test;
+
+public class LinkRepresentationTest_equals {
+
+    @Test
+    public void equalDependsOnMethodAndHref() throws UnsupportedEncodingException {
+        final LinkRepresentation link = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET);
+        final LinkRepresentation link2 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET);
+        final LinkRepresentation link3 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.PUT);
+        final LinkRepresentation link4 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:456").withMethod(HttpMethod.GET);
+
+        assertThat(link, is(equalTo(link2)));
+        assertThat(link, is(not(equalTo(link3))));
+        assertThat(link, is(not(equalTo(link4))));
+    }
+
+    @Test
+    public void equalDoesNotDependsOnMethodAndHref() throws UnsupportedEncodingException {
+        final LinkRepresentation link = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET).withRel("something");
+        final LinkRepresentation link2 = new LinkRepresentation().withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET).withRel("else");
+
+        assertThat(link, is(equalTo(link2)));
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/EnumsTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/EnumsTest.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/EnumsTest.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/EnumsTest.java Sun Jan 22 08:05:17 2012
@@ -16,35 +16,30 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.apache.isis.viewer.json.applib.util.Enums;
-import org.junit.Test;
-
-public class EnumsTest {
-
-    private static enum MyEnum {
-        CONTENT_TYPE,
-        LAST_MODIFIED,
-        WARNING,
-        X_REPRESENTATION_TYPE,
-        OBJECT_ACTION
-    }
-    
-    @Test
-    public void converts() {
-        assertConverts(MyEnum.CONTENT_TYPE, "Content-Type", "contentType");
-        assertConverts(MyEnum.LAST_MODIFIED, "Last-Modified", "lastModified");
-        assertConverts(MyEnum.WARNING, "Warning", "warning");
-        assertConverts(MyEnum.X_REPRESENTATION_TYPE, "X-Representation-Type", "xRepresentationType");
-    }
-
-    protected void assertConverts(Enum<?> someEnum, String httpHeader, String camelCase) {
-        assertThat(Enums.enumToHttpHeader(someEnum), is(httpHeader));
-        assertThat(Enums.enumToCamelCase(someEnum), is(camelCase));
-    }
-
-}
+package org.apache.isis.viewer.json.applib.util;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class EnumsTest {
+
+    private static enum MyEnum {
+        CONTENT_TYPE, LAST_MODIFIED, WARNING, X_REPRESENTATION_TYPE, OBJECT_ACTION
+    }
+
+    @Test
+    public void converts() {
+        assertConverts(MyEnum.CONTENT_TYPE, "Content-Type", "contentType");
+        assertConverts(MyEnum.LAST_MODIFIED, "Last-Modified", "lastModified");
+        assertConverts(MyEnum.WARNING, "Warning", "warning");
+        assertConverts(MyEnum.X_REPRESENTATION_TYPE, "X-Representation-Type", "xRepresentationType");
+    }
+
+    protected void assertConverts(final Enum<?> someEnum, final String httpHeader, final String camelCase) {
+        assertThat(Enums.enumToHttpHeader(someEnum), is(httpHeader));
+        assertThat(Enums.enumToCamelCase(someEnum), is(camelCase));
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/ParserTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/ParserTest.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/ParserTest.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/ParserTest.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
+package org.apache.isis.viewer.json.applib.util;
+
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
@@ -34,167 +34,163 @@ import org.apache.isis.core.commons.matc
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulMediaType;
 import org.junit.Test;
-
-public class ParserTest {
-
-    @Test
-    public void forBoolean() {
-        Parser<Boolean> parser = Parser.forBoolean();
-        for (Boolean v : new Boolean[] {Boolean.TRUE, Boolean.FALSE}) {
-            final String asString = parser.asString(v);
-            final Boolean valueOf = parser.valueOf(asString);
-            assertThat(v, is(equalTo(valueOf)));
-        }
-        
-        final Boolean valueOf = parser.valueOf(Arrays.asList(parser.asString(Boolean.TRUE), parser.asString(Boolean.FALSE)));
-        assertThat(valueOf, is(Boolean.TRUE));
-    }
-
-    @Test
-    public void forString() {
-        Parser<String> parser = Parser.forString();
-        
-        for (String v : new String[] {"", "foo", "foz"}) {
-            final String asString = parser.asString(v);
-            final String valueOf = parser.valueOf(asString);
-            assertThat(v, is(equalTo(valueOf)));
-        }
-    }
-
-    @Test
-    public void forListOfStrings() {
-        Parser<List<String>> parser = Parser.forListOfStrings();
-        
-        List<String> v = Arrays.asList("", "foo", "foz" );
-        
-        final String asString = parser.asString(v);
-        final List<String> valueOf = parser.valueOf(asString);
-        
-        assertThat(v, IsisMatchers.sameContentsAs(valueOf));
-    }
-
-    @Test
-    public void forListOfListOfStringsDottedNotation() {
-        Parser<List<List<String>>> parser = Parser.forListOfListOfStrings();
-        
-        final List<List<String>> valueOf = parser.valueOf(Arrays.asList("a", "b.c", "d.e.f" ));
-        
-        assertThat(valueOf.size(), is(3));
-        assertThat(valueOf.get(0).size(), is(1));
-        assertThat(valueOf.get(0).get(0), is("a"));
-        assertThat(valueOf.get(1).size(), is(2));
-        assertThat(valueOf.get(1).get(0), is("b"));
-        assertThat(valueOf.get(1).get(1), is("c"));
-        assertThat(valueOf.get(2).size(), is(3));
-        assertThat(valueOf.get(2).get(0), is("d"));
-        assertThat(valueOf.get(2).get(1), is("e"));
-        assertThat(valueOf.get(2).get(2), is("f"));
-        
-        assertThat(parser.asString(valueOf), is("a,b.c,d.e.f"));
-    }
-
-    @Test
-    public void forListOfListOfStringsCommaSeparated() {
-        Parser<List<List<String>>> parser = Parser.forListOfListOfStrings();
-        
-        final List<List<String>> valueOf = parser.valueOf("a,b.c,d.e.f");
-        
-        assertThat(valueOf.size(), is(3));
-        assertThat(valueOf.get(0).size(), is(1));
-        assertThat(valueOf.get(0).get(0), is("a"));
-        assertThat(valueOf.get(1).size(), is(2));
-        assertThat(valueOf.get(1).get(0), is("b"));
-        assertThat(valueOf.get(1).get(1), is("c"));
-        assertThat(valueOf.get(2).size(), is(3));
-        assertThat(valueOf.get(2).get(0), is("d"));
-        assertThat(valueOf.get(2).get(1), is("e"));
-        assertThat(valueOf.get(2).get(2), is("f"));
-    }
-
-    @Test
-    public void forMediaTypes() {
-        Parser<MediaType> parser = Parser.forMediaType();
-        MediaType mediaType = RepresentationType.DOMAIN_OBJECT.getMediaType();
-        final String asString = parser.asString(mediaType);
-        final MediaType valueOf = parser.valueOf(asString);
-        
-        assertThat(valueOf, is(mediaType));
-    }
-
-
-    @Test
-    public void forListOfMediaTypes() {
-        Parser<List<MediaType>> parser = Parser.forListOfMediaTypes();
-        MediaType mediaType = RepresentationType.DOMAIN_OBJECT.getMediaType();
-        List<MediaType> v = Arrays.asList(mediaType, MediaType.APPLICATION_JSON_TYPE);
-        final String asString = parser.asString(v);
-        final List<MediaType> valueOf = parser.valueOf(asString);
-        
-        assertThat(v, IsisMatchers.sameContentsAs(valueOf));
-    }
-
-    @Test
-    public void forDate() {
-        Parser<Date> parser = Parser.forDate();
-        
-        final Calendar cal = Calendar.getInstance();
-        cal.setTime(new Date());
-        cal.set(Calendar.MILLISECOND, 0);
-        Date nowToNearestSecond = cal.getTime();
-        for (Date v : new Date[] {nowToNearestSecond}) {
-            final String asString = parser.asString(v);
-            final Date valueOf = parser.valueOf(asString);
-            assertThat(v, is(equalTo(valueOf)));
-        }
-    }
-
-    @Test
-    public void forInteger() {
-        Parser<Integer> parser = Parser.forInteger();
-        
-        for (Integer v : new Integer[] {1, 2, 3, -5, -100, 0, Integer.MAX_VALUE, Integer.MIN_VALUE}) {
-            final String asString = parser.asString(v);
-            final Integer valueOf = parser.valueOf(asString);
-            assertThat(v, is(equalTo(valueOf)));
-        }
-    }
-
-    @Test
-    public void forMediaType() {
-        Parser<MediaType> parser = Parser.forMediaType();
-        
-        for (MediaType v : new MediaType[] { 
-                MediaType.APPLICATION_ATOM_XML_TYPE, 
-                MediaType.APPLICATION_JSON_TYPE, 
-                MediaType.APPLICATION_XHTML_XML_TYPE, 
-                MediaType.valueOf(RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT) }) {
-            final String asString = parser.asString(v);
-            final MediaType valueOf = parser.valueOf(asString);
-            assertThat(v, is(equalTo(valueOf)));
-        }
-    }
-
-
-    @Test
-    public void forCacheControl() {
-        Parser<CacheControl> parser = Parser.forCacheControl();
-        
-        final CacheControl cc1 = createCacheControl();
-        cc1.setMaxAge(2000);
-        final CacheControl cc2 = createCacheControl();
-        cc2.setNoCache(true);
-        for (CacheControl v : new CacheControl[] { cc1, cc2 }) {
-            final String asString = parser.asString(v);
-            final CacheControl valueOf = parser.valueOf(asString);
-            assertThat(v, is(equalTo(valueOf)));
-        }
-    }
-
-    private static CacheControl createCacheControl() {
-        final CacheControl cacheControl = new CacheControl();
-        cacheControl.getCacheExtension(); // workaround for bug in CacheControl's equals() method
-        cacheControl.getNoCacheFields(); // workaround for bug in CacheControl's equals() method
-        return cacheControl;
-    }
-
-}
+
+public class ParserTest {
+
+    @Test
+    public void forBoolean() {
+        final Parser<Boolean> parser = Parser.forBoolean();
+        for (final Boolean v : new Boolean[] { Boolean.TRUE, Boolean.FALSE }) {
+            final String asString = parser.asString(v);
+            final Boolean valueOf = parser.valueOf(asString);
+            assertThat(v, is(equalTo(valueOf)));
+        }
+
+        final Boolean valueOf = parser.valueOf(Arrays.asList(parser.asString(Boolean.TRUE), parser.asString(Boolean.FALSE)));
+        assertThat(valueOf, is(Boolean.TRUE));
+    }
+
+    @Test
+    public void forString() {
+        final Parser<String> parser = Parser.forString();
+
+        for (final String v : new String[] { "", "foo", "foz" }) {
+            final String asString = parser.asString(v);
+            final String valueOf = parser.valueOf(asString);
+            assertThat(v, is(equalTo(valueOf)));
+        }
+    }
+
+    @Test
+    public void forListOfStrings() {
+        final Parser<List<String>> parser = Parser.forListOfStrings();
+
+        final List<String> v = Arrays.asList("", "foo", "foz");
+
+        final String asString = parser.asString(v);
+        final List<String> valueOf = parser.valueOf(asString);
+
+        assertThat(v, IsisMatchers.sameContentsAs(valueOf));
+    }
+
+    @Test
+    public void forListOfListOfStringsDottedNotation() {
+        final Parser<List<List<String>>> parser = Parser.forListOfListOfStrings();
+
+        final List<List<String>> valueOf = parser.valueOf(Arrays.asList("a", "b.c", "d.e.f"));
+
+        assertThat(valueOf.size(), is(3));
+        assertThat(valueOf.get(0).size(), is(1));
+        assertThat(valueOf.get(0).get(0), is("a"));
+        assertThat(valueOf.get(1).size(), is(2));
+        assertThat(valueOf.get(1).get(0), is("b"));
+        assertThat(valueOf.get(1).get(1), is("c"));
+        assertThat(valueOf.get(2).size(), is(3));
+        assertThat(valueOf.get(2).get(0), is("d"));
+        assertThat(valueOf.get(2).get(1), is("e"));
+        assertThat(valueOf.get(2).get(2), is("f"));
+
+        assertThat(parser.asString(valueOf), is("a,b.c,d.e.f"));
+    }
+
+    @Test
+    public void forListOfListOfStringsCommaSeparated() {
+        final Parser<List<List<String>>> parser = Parser.forListOfListOfStrings();
+
+        final List<List<String>> valueOf = parser.valueOf("a,b.c,d.e.f");
+
+        assertThat(valueOf.size(), is(3));
+        assertThat(valueOf.get(0).size(), is(1));
+        assertThat(valueOf.get(0).get(0), is("a"));
+        assertThat(valueOf.get(1).size(), is(2));
+        assertThat(valueOf.get(1).get(0), is("b"));
+        assertThat(valueOf.get(1).get(1), is("c"));
+        assertThat(valueOf.get(2).size(), is(3));
+        assertThat(valueOf.get(2).get(0), is("d"));
+        assertThat(valueOf.get(2).get(1), is("e"));
+        assertThat(valueOf.get(2).get(2), is("f"));
+    }
+
+    @Test
+    public void forMediaTypes() {
+        final Parser<MediaType> parser = Parser.forMediaType();
+        final MediaType mediaType = RepresentationType.DOMAIN_OBJECT.getMediaType();
+        final String asString = parser.asString(mediaType);
+        final MediaType valueOf = parser.valueOf(asString);
+
+        assertThat(valueOf, is(mediaType));
+    }
+
+    @Test
+    public void forListOfMediaTypes() {
+        final Parser<List<MediaType>> parser = Parser.forListOfMediaTypes();
+        final MediaType mediaType = RepresentationType.DOMAIN_OBJECT.getMediaType();
+        final List<MediaType> v = Arrays.asList(mediaType, MediaType.APPLICATION_JSON_TYPE);
+        final String asString = parser.asString(v);
+        final List<MediaType> valueOf = parser.valueOf(asString);
+
+        assertThat(v, IsisMatchers.sameContentsAs(valueOf));
+    }
+
+    @Test
+    public void forDate() {
+        final Parser<Date> parser = Parser.forDate();
+
+        final Calendar cal = Calendar.getInstance();
+        cal.setTime(new Date());
+        cal.set(Calendar.MILLISECOND, 0);
+        final Date nowToNearestSecond = cal.getTime();
+        for (final Date v : new Date[] { nowToNearestSecond }) {
+            final String asString = parser.asString(v);
+            final Date valueOf = parser.valueOf(asString);
+            assertThat(v, is(equalTo(valueOf)));
+        }
+    }
+
+    @Test
+    public void forInteger() {
+        final Parser<Integer> parser = Parser.forInteger();
+
+        for (final Integer v : new Integer[] { 1, 2, 3, -5, -100, 0, Integer.MAX_VALUE, Integer.MIN_VALUE }) {
+            final String asString = parser.asString(v);
+            final Integer valueOf = parser.valueOf(asString);
+            assertThat(v, is(equalTo(valueOf)));
+        }
+    }
+
+    @Test
+    public void forMediaType() {
+        final Parser<MediaType> parser = Parser.forMediaType();
+
+        for (final MediaType v : new MediaType[] { MediaType.APPLICATION_ATOM_XML_TYPE, MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XHTML_XML_TYPE, MediaType.valueOf(RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT) }) {
+            final String asString = parser.asString(v);
+            final MediaType valueOf = parser.valueOf(asString);
+            assertThat(v, is(equalTo(valueOf)));
+        }
+    }
+
+    @Test
+    public void forCacheControl() {
+        final Parser<CacheControl> parser = Parser.forCacheControl();
+
+        final CacheControl cc1 = createCacheControl();
+        cc1.setMaxAge(2000);
+        final CacheControl cc2 = createCacheControl();
+        cc2.setNoCache(true);
+        for (final CacheControl v : new CacheControl[] { cc1, cc2 }) {
+            final String asString = parser.asString(v);
+            final CacheControl valueOf = parser.valueOf(asString);
+            assertThat(v, is(equalTo(valueOf)));
+        }
+    }
+
+    private static CacheControl createCacheControl() {
+        final CacheControl cacheControl = new CacheControl();
+        cacheControl.getCacheExtension(); // workaround for bug in
+                                          // CacheControl's equals() method
+        cacheControl.getNoCacheFields(); // workaround for bug in CacheControl's
+                                         // equals() method
+        return cacheControl;
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_equalsHashcode.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_equalsHashcode.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_equalsHashcode.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_equalsHashcode.java Sun Jan 22 08:05:17 2012
@@ -16,43 +16,41 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import org.apache.isis.viewer.json.applib.util.PathNode;
-import org.junit.Test;
-
-public class PathNodeTest_equalsHashcode {
-
-
-    @Test
-    public void simple() throws Exception {
-        final PathNode node = PathNode.parse("foo");
-        final PathNode node2 = PathNode.parse("foo");
-        assertEquals(node, node2);
-    }
-
-    @Test
-    public void oneCriterium() throws Exception {
-        final PathNode node = PathNode.parse("a[b=c]");
-        final PathNode node2 = PathNode.parse("a");
-        assertEquals(node, node2);
-    }
-
-    @Test
-    public void moreThanOneCriterium() throws Exception {
-        final PathNode node = PathNode.parse("a[b=c d=e]");
-        final PathNode node2 = PathNode.parse("a");
-        assertEquals(node, node2);
-    }
-
-    @Test
-    public void notEqual() throws Exception {
-        final PathNode node = PathNode.parse("a[b=c d=e]");
-        final PathNode node2 = PathNode.parse("b");
-        assertFalse(node.equals(node2));
-    }
-
-}
+package org.apache.isis.viewer.json.applib.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+public class PathNodeTest_equalsHashcode {
+
+    @Test
+    public void simple() throws Exception {
+        final PathNode node = PathNode.parse("foo");
+        final PathNode node2 = PathNode.parse("foo");
+        assertEquals(node, node2);
+    }
+
+    @Test
+    public void oneCriterium() throws Exception {
+        final PathNode node = PathNode.parse("a[b=c]");
+        final PathNode node2 = PathNode.parse("a");
+        assertEquals(node, node2);
+    }
+
+    @Test
+    public void moreThanOneCriterium() throws Exception {
+        final PathNode node = PathNode.parse("a[b=c d=e]");
+        final PathNode node2 = PathNode.parse("a");
+        assertEquals(node, node2);
+    }
+
+    @Test
+    public void notEqual() throws Exception {
+        final PathNode node = PathNode.parse("a[b=c d=e]");
+        final PathNode node2 = PathNode.parse("b");
+        assertFalse(node.equals(node2));
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_parse.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_parse.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_parse.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/util/PathNodeTest_parse.java Sun Jan 22 08:05:17 2012
@@ -16,57 +16,54 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-
-import org.apache.isis.viewer.json.applib.util.PathNode;
-import org.junit.Test;
-
-public class PathNodeTest_parse {
-
-
-    @Test
-    public void simple() throws Exception {
-        final PathNode node = PathNode.parse("foo");
-        assertThat(node.getKey(), is("foo"));
-        assertThat(node.getCriteria().isEmpty(), is(true));
-    }
-
-    @Test
-    public void oneCriterium() throws Exception {
-        final PathNode node = PathNode.parse("foo[bar=coz]");
-        assertThat(node.getKey(), is("foo"));
-        final Map<String, String> criteria = node.getCriteria();
-        assertThat(criteria.isEmpty(), is(false));
-        assertThat(criteria.size(), is(1));
-        assertThat(criteria.get("bar"), is("coz"));
-    }
-
-    @Test
-    public void moreThanOneCriterium() throws Exception {
-        final PathNode node = PathNode.parse("foo[bar=coz dat=ein]");
-        assertThat(node.getKey(), is("foo"));
-        final Map<String, String> criteria = node.getCriteria();
-        assertThat(criteria.isEmpty(), is(false));
-        assertThat(criteria.size(), is(2));
-        assertThat(criteria.get("bar"), is("coz"));
-        assertThat(criteria.get("dat"), is("ein"));
-    }
-
-    @Test
-    public void whiteSpace() throws Exception {
-        final PathNode node = PathNode.parse("foo[bar=coz\tdat=ein]");
-        assertThat(node.getKey(), is("foo"));
-        final Map<String, String> criteria = node.getCriteria();
-        assertThat(criteria.isEmpty(), is(false));
-        assertThat(criteria.size(), is(2));
-        assertThat(criteria.get("bar"), is("coz"));
-        assertThat(criteria.get("dat"), is("ein"));
-    }
-
-
-}
+package org.apache.isis.viewer.json.applib.util;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+public class PathNodeTest_parse {
+
+    @Test
+    public void simple() throws Exception {
+        final PathNode node = PathNode.parse("foo");
+        assertThat(node.getKey(), is("foo"));
+        assertThat(node.getCriteria().isEmpty(), is(true));
+    }
+
+    @Test
+    public void oneCriterium() throws Exception {
+        final PathNode node = PathNode.parse("foo[bar=coz]");
+        assertThat(node.getKey(), is("foo"));
+        final Map<String, String> criteria = node.getCriteria();
+        assertThat(criteria.isEmpty(), is(false));
+        assertThat(criteria.size(), is(1));
+        assertThat(criteria.get("bar"), is("coz"));
+    }
+
+    @Test
+    public void moreThanOneCriterium() throws Exception {
+        final PathNode node = PathNode.parse("foo[bar=coz dat=ein]");
+        assertThat(node.getKey(), is("foo"));
+        final Map<String, String> criteria = node.getCriteria();
+        assertThat(criteria.isEmpty(), is(false));
+        assertThat(criteria.size(), is(2));
+        assertThat(criteria.get("bar"), is("coz"));
+        assertThat(criteria.get("dat"), is("ein"));
+    }
+
+    @Test
+    public void whiteSpace() throws Exception {
+        final PathNode node = PathNode.parse("foo[bar=coz\tdat=ein]");
+        assertThat(node.getKey(), is("foo"));
+        final Map<String, String> criteria = node.getCriteria();
+        assertThat(criteria.isEmpty(), is(false));
+        assertThat(criteria.size(), is(2));
+        assertThat(criteria.get("bar"), is("coz"));
+        assertThat(criteria.get("dat"), is("ein"));
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/IsisWebServerRule.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/IsisWebServerRule.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/IsisWebServerRule.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/IsisWebServerRule.java Sun Jan 22 08:05:17 2012
@@ -16,31 +16,32 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.tck;
-
+package org.apache.isis.viewer.json.tck;
+
 import org.apache.isis.runtimes.dflt.webserver.WebServer;
 import org.junit.rules.MethodRule;
 import org.junit.runners.model.FrameworkMethod;
 import org.junit.runners.model.Statement;
-
-public class IsisWebServerRule implements MethodRule {
-
-    private static ThreadLocal<WebServer> WEBSERVER = new ThreadLocal<WebServer>() {
-        protected WebServer initialValue() {
-            WebServer webServer = new WebServer();
-            webServer.run(39393);
-            return webServer;
-        };
-    }; 
-    
-    @Override
-    public Statement apply(Statement base, FrameworkMethod method, Object target) {
-        getWebServer(); // creates and starts running if required
-        return base;
-    }
-    
-    public WebServer getWebServer() {
-        return WEBSERVER.get();
-    }
-
-}
+
+public class IsisWebServerRule implements MethodRule {
+
+    private static ThreadLocal<WebServer> WEBSERVER = new ThreadLocal<WebServer>() {
+        @Override
+        protected WebServer initialValue() {
+            final WebServer webServer = new WebServer();
+            webServer.run(39393);
+            return webServer;
+        };
+    };
+
+    @Override
+    public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
+        getWebServer(); // creates and starts running if required
+        return base;
+    }
+
+    public WebServer getWebServer() {
+        return WEBSERVER.get();
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/RepresentationMatchers.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/RepresentationMatchers.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/RepresentationMatchers.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/RepresentationMatchers.java Sun Jan 22 08:05:17 2012
@@ -16,15 +16,14 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.tck;
-
+package org.apache.isis.viewer.json.tck;
+
 import javax.ws.rs.core.CacheControl;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
 
+import org.apache.isis.viewer.json.applib.HttpMethod;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.JsonRepresentation.LinksToSelf;
-import org.apache.isis.viewer.json.applib.HttpMethod;
 import org.apache.isis.viewer.json.applib.RestfulClient;
 import org.apache.isis.viewer.json.applib.RestfulResponse;
 import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
@@ -36,417 +35,416 @@ import org.hamcrest.TypeSafeMatcher;
 import org.junit.Assert;
 
 import com.google.common.base.Objects;
-
-
-public class RepresentationMatchers {
-
-    public static <T extends JsonRepresentation> Matcher<T> isMap() {
-        return new TypeSafeMatcher<T>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("map");
-            }
-
-            @Override
-            public boolean matchesSafely(T item) {
-                return item != null && item.isMap();
-            }
-        };
-    }
-
-    public static <T extends JsonRepresentation> Matcher<T> isArray() {
-        return new TypeSafeMatcher<T>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("array");
-            }
-
-            @Override
-            public boolean matchesSafely(T item) {
-                return item != null && item.isArray();
-            }
-        };
-    }
-
-    public static <T extends JsonRepresentation> Matcher<T> isString() {
-        return new TypeSafeMatcher<T>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("string");
-            }
-
-            @Override
-            public boolean matchesSafely(T item) {
-                return item != null && item.isValue() && item.asJsonNode().isTextual();
-            }
-        };
-    }
-
-    public static Matcher<LinkRepresentation> isLink(final HttpMethod httpMethod) {
-        return new TypeSafeMatcher<LinkRepresentation>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("link with method " + httpMethod.name());
-            }
-
-            @Override
-            public boolean matchesSafely(LinkRepresentation item) {
-                return item != null && item.getHttpMethod() == httpMethod;
-            }
-        };
-    }
-
-    public static <T extends JsonRepresentation> Matcher<T> isFollowableLinkToSelf(final RestfulClient client) {
-        return new TypeSafeMatcher<T>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("links to self");
-            }
-
-            @Override
-            public boolean matchesSafely(T item) {
-                LinksToSelf initialRepr = (LinksToSelf) item; // no easy way to do this with Hamcrest
-                // when
-                try {
-                    final RestfulResponse<T> followedResp = client.followT(initialRepr.getSelf());
-                    
-                    // then
-                    T repr2 = followedResp.getEntity();
-                    LinksToSelf repr2AsLinksToSelf = (LinksToSelf)repr2;
-                    return initialRepr.getSelf().equals(repr2AsLinksToSelf.getSelf());
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        };
-    }
-
-
-    public static <T extends JsonRepresentation> void assertThat(T actual, AbstractMatcherBuilder<T> matcherBuilder) {
-        Assert.assertThat(actual, matcherBuilder.build());
-    }
-
-    public static LinkMatcherBuilder isLink(RestfulClient client) {
-        return new LinkMatcherBuilder(client);
-    }
-
-    public static LinkMatcherBuilder isLink() {
-        return new LinkMatcherBuilder(null);
-    }
-
-
-    public static abstract class AbstractMatcherBuilder<T extends JsonRepresentation> {
-        protected RestfulClient client;
-
-        public AbstractMatcherBuilder() {
-            this(null);
-        }
-
-        public AbstractMatcherBuilder(RestfulClient client) {
-            this.client = client;
-        }
-        
-        public abstract Matcher<T> build();
-    }
-
-    public static class LinkMatcherBuilder extends AbstractMatcherBuilder<JsonRepresentation> {
-        private HttpStatusCode statusCode;
-        private HttpMethod httpMethod;
-        private String rel;
-        private String href;
-        private Matcher<String> hrefMatcher;
-        private Matcher<JsonRepresentation> valueMatcher;
+
+public class RepresentationMatchers {
+
+    public static <T extends JsonRepresentation> Matcher<T> isMap() {
+        return new TypeSafeMatcher<T>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("map");
+            }
+
+            @Override
+            public boolean matchesSafely(final T item) {
+                return item != null && item.isMap();
+            }
+        };
+    }
+
+    public static <T extends JsonRepresentation> Matcher<T> isArray() {
+        return new TypeSafeMatcher<T>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("array");
+            }
+
+            @Override
+            public boolean matchesSafely(final T item) {
+                return item != null && item.isArray();
+            }
+        };
+    }
+
+    public static <T extends JsonRepresentation> Matcher<T> isString() {
+        return new TypeSafeMatcher<T>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("string");
+            }
+
+            @Override
+            public boolean matchesSafely(final T item) {
+                return item != null && item.isValue() && item.asJsonNode().isTextual();
+            }
+        };
+    }
+
+    public static Matcher<LinkRepresentation> isLink(final HttpMethod httpMethod) {
+        return new TypeSafeMatcher<LinkRepresentation>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("link with method " + httpMethod.name());
+            }
+
+            @Override
+            public boolean matchesSafely(final LinkRepresentation item) {
+                return item != null && item.getHttpMethod() == httpMethod;
+            }
+        };
+    }
+
+    public static <T extends JsonRepresentation> Matcher<T> isFollowableLinkToSelf(final RestfulClient client) {
+        return new TypeSafeMatcher<T>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("links to self");
+            }
+
+            @Override
+            public boolean matchesSafely(final T item) {
+                final LinksToSelf initialRepr = (LinksToSelf) item; // no easy
+                                                                    // way to do
+                                                                    // this with
+                                                                    // Hamcrest
+                // when
+                try {
+                    final RestfulResponse<T> followedResp = client.followT(initialRepr.getSelf());
+
+                    // then
+                    final T repr2 = followedResp.getEntity();
+                    final LinksToSelf repr2AsLinksToSelf = (LinksToSelf) repr2;
+                    return initialRepr.getSelf().equals(repr2AsLinksToSelf.getSelf());
+                } catch (final Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        };
+    }
+
+    public static <T extends JsonRepresentation> void assertThat(final T actual, final AbstractMatcherBuilder<T> matcherBuilder) {
+        Assert.assertThat(actual, matcherBuilder.build());
+    }
+
+    public static LinkMatcherBuilder isLink(final RestfulClient client) {
+        return new LinkMatcherBuilder(client);
+    }
+
+    public static LinkMatcherBuilder isLink() {
+        return new LinkMatcherBuilder(null);
+    }
+
+    public static abstract class AbstractMatcherBuilder<T extends JsonRepresentation> {
+        protected RestfulClient client;
+
+        public AbstractMatcherBuilder() {
+            this(null);
+        }
+
+        public AbstractMatcherBuilder(final RestfulClient client) {
+            this.client = client;
+        }
+
+        public abstract Matcher<T> build();
+    }
+
+    public static class LinkMatcherBuilder extends AbstractMatcherBuilder<JsonRepresentation> {
+        private HttpStatusCode statusCode;
+        private HttpMethod httpMethod;
+        private String rel;
+        private String href;
+        private Matcher<String> hrefMatcher;
+        private Matcher<JsonRepresentation> valueMatcher;
         private Boolean novalue;
         private MediaType mediaType;
         private String typeParameterName;
-        private String typeParameterValue;
-
-        private LinkMatcherBuilder(RestfulClient client) {
-            super(client);
-        }
-
-        public LinkMatcherBuilder rel(String rel) {
-            this.rel = rel;
-            return this;
-        }
-
-        public LinkMatcherBuilder rel(Rel rel) {
+        private String typeParameterValue;
+
+        private LinkMatcherBuilder(final RestfulClient client) {
+            super(client);
+        }
+
+        public LinkMatcherBuilder rel(final String rel) {
+            this.rel = rel;
+            return this;
+        }
+
+        public LinkMatcherBuilder rel(final Rel rel) {
             this.rel = rel.getName();
             return this;
         }
 
-        public LinkMatcherBuilder href(String href) {
-            this.href = href;
-            return this;
-        }
-
-        public LinkMatcherBuilder href(Matcher<String> methodMatcher) {
-            this.hrefMatcher = methodMatcher;
-            return this;
-        }
-
-        public LinkMatcherBuilder httpMethod(HttpMethod httpMethod) {
-            this.httpMethod = httpMethod;
-            return this;
-        }
-
-        public LinkMatcherBuilder type(MediaType mediaType) {
+        public LinkMatcherBuilder href(final String href) {
+            this.href = href;
+            return this;
+        }
+
+        public LinkMatcherBuilder href(final Matcher<String> methodMatcher) {
+            this.hrefMatcher = methodMatcher;
+            return this;
+        }
+
+        public LinkMatcherBuilder httpMethod(final HttpMethod httpMethod) {
+            this.httpMethod = httpMethod;
+            return this;
+        }
+
+        public LinkMatcherBuilder type(final MediaType mediaType) {
             this.mediaType = mediaType;
             return this;
         }
 
-        public LinkMatcherBuilder typeParameter(String typeParameterName, String typeParameterValue) {
+        public LinkMatcherBuilder typeParameter(final String typeParameterName, final String typeParameterValue) {
             this.typeParameterName = typeParameterName;
             this.typeParameterValue = typeParameterValue;
             return this;
         }
 
-        public LinkMatcherBuilder novalue() {
-            if(valueMatcher != null) {
-                throw new IllegalStateException("cannot assert on both there being a value and there not being a value");
-            }
-            this.novalue = true;
-            return this;
-        }
-
-        public LinkMatcherBuilder value(Matcher<JsonRepresentation> valueMatcher) {
-            if(this.novalue != null) {
-                throw new IllegalStateException("cannot assert on both there being a value and there not being a value");
-            }
-            this.valueMatcher = valueMatcher;
-            return this;
-        }
-
-        public LinkMatcherBuilder returning(HttpStatusCode statusCode) {
-            this.statusCode = statusCode;
-            return this;
-        }
-
-        @Override
-        public Matcher<JsonRepresentation> build() {
-            return new TypeSafeMatcher<JsonRepresentation>() {
-
-                @Override
-                public void describeTo(Description description) {
-                    description.appendText("a link");
-                    if(rel != null) {
-                        description.appendText(" with rel '").appendText(rel).appendText("'");
-                    }
-                    if(href != null) {
-                        description.appendText(" with href '").appendText(href).appendText("'");
-                    }
-                    if(hrefMatcher != null) {
-                        description.appendText(" with href ");
-                        hrefMatcher.describeTo(description);
-                    }
-                    if(httpMethod != null) {
-                        description.appendText(" with method '").appendValue(httpMethod).appendText("'");
-                    }
-                    if(mediaType != null) {
+        public LinkMatcherBuilder novalue() {
+            if (valueMatcher != null) {
+                throw new IllegalStateException("cannot assert on both there being a value and there not being a value");
+            }
+            this.novalue = true;
+            return this;
+        }
+
+        public LinkMatcherBuilder value(final Matcher<JsonRepresentation> valueMatcher) {
+            if (this.novalue != null) {
+                throw new IllegalStateException("cannot assert on both there being a value and there not being a value");
+            }
+            this.valueMatcher = valueMatcher;
+            return this;
+        }
+
+        public LinkMatcherBuilder returning(final HttpStatusCode statusCode) {
+            this.statusCode = statusCode;
+            return this;
+        }
+
+        @Override
+        public Matcher<JsonRepresentation> build() {
+            return new TypeSafeMatcher<JsonRepresentation>() {
+
+                @Override
+                public void describeTo(final Description description) {
+                    description.appendText("a link");
+                    if (rel != null) {
+                        description.appendText(" with rel '").appendText(rel).appendText("'");
+                    }
+                    if (href != null) {
+                        description.appendText(" with href '").appendText(href).appendText("'");
+                    }
+                    if (hrefMatcher != null) {
+                        description.appendText(" with href ");
+                        hrefMatcher.describeTo(description);
+                    }
+                    if (httpMethod != null) {
+                        description.appendText(" with method '").appendValue(httpMethod).appendText("'");
+                    }
+                    if (mediaType != null) {
                         description.appendText(" with type '").appendValue(mediaType).appendText("'");
                     }
-                    if(typeParameterName != null) {
+                    if (typeParameterName != null) {
                         description.appendText(" with media type parameter '").appendText(typeParameterName).appendText("=").appendText(typeParameterValue).appendText("'");
                     }
-                    
-                    if(novalue != null && novalue) {
-                        description.appendText(" with no value");
-                    }
-                    if(valueMatcher != null) {
-                        description.appendText(" with value ");
-                        valueMatcher.describeTo(description);
-                    }
-                    
-                    // trigger link being followed
-                    if(statusCode != null) {
-                        if(client == null) {
-                            throw new IllegalStateException("require client in order to assert on statusCode");
-                        }
-                        description.appendText(" that when followed returns status " + statusCode);
-                    }
-                    
-                    // assertions on response
-                    if(statusCode != null) {
-                        description.appendText(" returns ").appendValue(statusCode);
-                    }
-                }
-
-                @Override
-                public boolean matchesSafely(JsonRepresentation linkRepr) {
-                    if(linkRepr == null) {
-                        return false;
-                    }
-                    LinkRepresentation link = linkRepr.asLink();
-                    if(rel != null && !rel.equals(link.getRel())) {
-                        return false;
-                    }
-                    if(href != null && !href.equals(link.getHref())) {
-                        return false;
-                    }
-                    if(hrefMatcher != null && !hrefMatcher.matches(link.getHref())) {
-                        return false;
-                    }
-                    if(httpMethod != null && !httpMethod.equals(link.getHttpMethod())) {
-                        return false;
+
+                    if (novalue != null && novalue) {
+                        description.appendText(" with no value");
+                    }
+                    if (valueMatcher != null) {
+                        description.appendText(" with value ");
+                        valueMatcher.describeTo(description);
+                    }
+
+                    // trigger link being followed
+                    if (statusCode != null) {
+                        if (client == null) {
+                            throw new IllegalStateException("require client in order to assert on statusCode");
+                        }
+                        description.appendText(" that when followed returns status " + statusCode);
                     }
-                    if(mediaType != null && !mediaType.isCompatible(mediaType)) {
+
+                    // assertions on response
+                    if (statusCode != null) {
+                        description.appendText(" returns ").appendValue(statusCode);
+                    }
+                }
+
+                @Override
+                public boolean matchesSafely(final JsonRepresentation linkRepr) {
+                    if (linkRepr == null) {
+                        return false;
+                    }
+                    final LinkRepresentation link = linkRepr.asLink();
+                    if (rel != null && !rel.equals(link.getRel())) {
+                        return false;
+                    }
+                    if (href != null && !href.equals(link.getHref())) {
+                        return false;
+                    }
+                    if (hrefMatcher != null && !hrefMatcher.matches(link.getHref())) {
+                        return false;
+                    }
+                    if (httpMethod != null && !httpMethod.equals(link.getHttpMethod())) {
+                        return false;
+                    }
+                    if (mediaType != null && !mediaType.isCompatible(mediaType)) {
                         return false;
-                    }
-                    if(typeParameterName != null) {
+                    }
+                    if (typeParameterName != null) {
                         final MediaType mediaType = link.getType();
-                        String parameterValue = mediaType.getParameters().get(typeParameterName);
-                        if(!typeParameterValue.equals(parameterValue)) {
+                        final String parameterValue = mediaType.getParameters().get(typeParameterName);
+                        if (!typeParameterValue.equals(parameterValue)) {
+                            return false;
+                        }
+                    }
+                    if (novalue != null && novalue && link.getValue() != null) {
+                        return false;
+                    }
+                    if (valueMatcher != null && !valueMatcher.matches(link)) {
+                        return false;
+                    }
+
+                    // follow link if criteria require it
+                    RestfulResponse<JsonRepresentation> jsonResp = null;
+                    if (statusCode != null) {
+                        if (client == null) {
+                            return false;
+                        }
+                        try {
+                            jsonResp = client.followT(link);
+                        } catch (final Exception e) {
+                            throw new RuntimeException(e);
+                        }
+                    }
+
+                    // assertions based on provided criteria
+                    if (statusCode != null) {
+                        if (jsonResp.getStatus() != statusCode) {
                             return false;
                         }
                     }
-                    if(novalue !=null && novalue && link.getValue() != null) {
-                        return false;
-                    }
-                    if(valueMatcher != null && !valueMatcher.matches(link)) {
-                        return false;
-                    }
-
-                    // follow link if criteria require it
-                    RestfulResponse<JsonRepresentation> jsonResp = null;
-                    if(statusCode != null) {
-                        if(client == null) {
-                            return false;
-                        }
-                        try {
-                            jsonResp = client.followT(link);
-                        } catch (Exception e) {
-                            throw new RuntimeException(e);
-                        }
-                    }
-
-                    // assertions based on provided criteria
-                    if(statusCode != null) {
-                        if(jsonResp.getStatus() != statusCode) {
-                            return false;
-                        }
-                    }
-                    
-                    return true;
-                }
-            };
-        }
-
-    }
-
-    public static EntryMatcherBuilder entry(String key) {
-        return new EntryMatcherBuilder(key); 
-    }
-
-    public static class EntryMatcherBuilder extends AbstractMatcherBuilder<JsonRepresentation>  {
-
-        private final String key;
-        private String value;
-        private EntryMatcherBuilder(String key) {
-            this.key = key;
-        }
-
-        public EntryMatcherBuilder value(String value) {
-            this.value = value;
-            return this;
-        }
-
-        @Override
-        public Matcher<JsonRepresentation> build() {
-            return new TypeSafeMatcher<JsonRepresentation>() {
-
-                @Override
-                public void describeTo(Description description) {
-                    description.appendText("map with entry with key: " + key);
-                    if(value != null) {
-                        description.appendText(", and value: " + value);
-                    }
-                }
-
-                @Override
-                public boolean matchesSafely(JsonRepresentation item) {
-                    if(!item.isMap()) {
-                        return false;
-                    }
-                    String val = item.getString(key);
-                    if(val == null) {
-                        return false;
-                    }
-                    if(value != null && !value.equals(val)) {
-                        return false;
-                    }
-                    return true;
-                }
-            };
-        }
-
-    }
-
-    public static Matcher<MediaType> hasType(final String type) {
-        return new TypeSafeMatcher<MediaType>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("has type " + type);
-            }
-
-            @Override
-            public boolean matchesSafely(MediaType item) {
-                return Objects.equal(type, item.getType());
-            }
-        };
-    }
-
-    public static Matcher<MediaType> hasSubType(final String subtype) {
-        return new TypeSafeMatcher<MediaType>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("has subtype " + subtype);
-            }
-
-            @Override
-            public boolean matchesSafely(MediaType item) {
-                return Objects.equal(subtype, item.getSubtype());
-            }
-        };
-    }
-
-    public static Matcher<MediaType> hasParameter(final String parameterName, final String parameterValue) {
-        return new TypeSafeMatcher<MediaType>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText(String.format("has parameter '%s' with value '%s'", parameterName, parameterValue));
-            }
-
-            @Override
-            public boolean matchesSafely(MediaType item) {
-                final String paramValue = item.getParameters().get(parameterName);
-                return Objects.equal(paramValue, parameterValue);
-            }
-        };
-    }
-
-    public static Matcher<CacheControl> hasMaxAge(final int maxAge) {
-        return new TypeSafeMatcher<CacheControl>() {
-
-            @Override
-            public void describeTo(Description description) {
-                description.appendText("has max age of " + maxAge + " secs");
-            }
-
-            @Override
-            public boolean matchesSafely(CacheControl item) {
-                return maxAge == item.getMaxAge();
-            }
-        };
-    }
-
-    
-}
-    
\ No newline at end of file
+
+                    return true;
+                }
+            };
+        }
+
+    }
+
+    public static EntryMatcherBuilder entry(final String key) {
+        return new EntryMatcherBuilder(key);
+    }
+
+    public static class EntryMatcherBuilder extends AbstractMatcherBuilder<JsonRepresentation> {
+
+        private final String key;
+        private String value;
+
+        private EntryMatcherBuilder(final String key) {
+            this.key = key;
+        }
+
+        public EntryMatcherBuilder value(final String value) {
+            this.value = value;
+            return this;
+        }
+
+        @Override
+        public Matcher<JsonRepresentation> build() {
+            return new TypeSafeMatcher<JsonRepresentation>() {
+
+                @Override
+                public void describeTo(final Description description) {
+                    description.appendText("map with entry with key: " + key);
+                    if (value != null) {
+                        description.appendText(", and value: " + value);
+                    }
+                }
+
+                @Override
+                public boolean matchesSafely(final JsonRepresentation item) {
+                    if (!item.isMap()) {
+                        return false;
+                    }
+                    final String val = item.getString(key);
+                    if (val == null) {
+                        return false;
+                    }
+                    if (value != null && !value.equals(val)) {
+                        return false;
+                    }
+                    return true;
+                }
+            };
+        }
+
+    }
+
+    public static Matcher<MediaType> hasType(final String type) {
+        return new TypeSafeMatcher<MediaType>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("has type " + type);
+            }
+
+            @Override
+            public boolean matchesSafely(final MediaType item) {
+                return Objects.equal(type, item.getType());
+            }
+        };
+    }
+
+    public static Matcher<MediaType> hasSubType(final String subtype) {
+        return new TypeSafeMatcher<MediaType>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("has subtype " + subtype);
+            }
+
+            @Override
+            public boolean matchesSafely(final MediaType item) {
+                return Objects.equal(subtype, item.getSubtype());
+            }
+        };
+    }
+
+    public static Matcher<MediaType> hasParameter(final String parameterName, final String parameterValue) {
+        return new TypeSafeMatcher<MediaType>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText(String.format("has parameter '%s' with value '%s'", parameterName, parameterValue));
+            }
+
+            @Override
+            public boolean matchesSafely(final MediaType item) {
+                final String paramValue = item.getParameters().get(parameterName);
+                return Objects.equal(paramValue, parameterValue);
+            }
+        };
+    }
+
+    public static Matcher<CacheControl> hasMaxAge(final int maxAge) {
+        return new TypeSafeMatcher<CacheControl>() {
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("has max age of " + maxAge + " secs");
+            }
+
+            @Override
+            public boolean matchesSafely(final CacheControl item) {
+                return maxAge == item.getMaxAge();
+            }
+        };
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.tck.resources;
-
+package org.apache.isis.viewer.json.tck.resources;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
@@ -37,85 +37,78 @@ import org.apache.isis.viewer.json.appli
 import org.apache.isis.viewer.json.tck.IsisWebServerRule;
 import org.jboss.resteasy.client.ClientRequest;
 import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.util.HttpHeaderNames;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-
-
-public class AnyResourceTest_exceptionHandling {
-
-    @Rule
-    public IsisWebServerRule webServerRule = new IsisWebServerRule();
-    
-    private RestfulClient client;
-
-    @Before
-    public void setUp() throws Exception {
-        WebServer webServer = webServerRule.getWebServer();
-        client = new RestfulClient(webServer.getBase());
-    }
-
-    @Test
-    public void noMediaType() throws Exception {
-        // given
-        RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
-        
-        // when
-        RestfulResponse<HomePageRepresentation> restfulResp = restfulReq.executeT();
-        
-        // then
-        assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
-        assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
-    }
-
-    @Test
-    public void correctMediaType() throws Exception {
-
-        // given
-        RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
-        restfulReq.withHeader(Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
-        
-        // when
-        RestfulResponse<HomePageRepresentation> restfulResp = restfulReq.executeT();
-        
-        // then
-        assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
-        assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
-    }
-
-    
-    @Test
-    public void incorrectMediaType_returnsNotAcceptable() throws Exception {
-
-        // given
-        ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("/");
-        clientRequest.accept(MediaType.APPLICATION_ATOM_XML_TYPE);
-        
-        // when
-        ClientResponse<?> resp = clientRequest.get();
-        RestfulResponse<JsonRepresentation> restfulResp = RestfulResponse.of(resp);
-        
-        // then
-        assertThat(restfulResp.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
-    }
-
-
-    @Test
-    public void runtimeException_isMapped() throws Exception {
-
-        // given
-        RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "version");
-        Header<Boolean> header = new Header<Boolean>("X-FAIL", Parser.forBoolean());
-        restfulReq.withHeader(header, true);
-        
-        // when
-        RestfulResponse<JsonRepresentation> jsonResp = restfulReq.execute();
-        
-        // then
-        assertThat(jsonResp.getStatus(), is(HttpStatusCode.METHOD_FAILURE));
-    }
-}
-
-
-    
\ No newline at end of file
+
+public class AnyResourceTest_exceptionHandling {
+
+    @Rule
+    public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+    private RestfulClient client;
+
+    @Before
+    public void setUp() throws Exception {
+        final WebServer webServer = webServerRule.getWebServer();
+        client = new RestfulClient(webServer.getBase());
+    }
+
+    @Test
+    public void noMediaType() throws Exception {
+        // given
+        final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
+
+        // when
+        final RestfulResponse<HomePageRepresentation> restfulResp = restfulReq.executeT();
+
+        // then
+        assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
+        assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
+    }
+
+    @Test
+    public void correctMediaType() throws Exception {
+
+        // given
+        final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
+        restfulReq.withHeader(Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+
+        // when
+        final RestfulResponse<HomePageRepresentation> restfulResp = restfulReq.executeT();
+
+        // then
+        assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
+        assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
+    }
+
+    @Test
+    public void incorrectMediaType_returnsNotAcceptable() throws Exception {
+
+        // given
+        final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("/");
+        clientRequest.accept(MediaType.APPLICATION_ATOM_XML_TYPE);
+
+        // when
+        final ClientResponse<?> resp = clientRequest.get();
+        final RestfulResponse<JsonRepresentation> restfulResp = RestfulResponse.of(resp);
+
+        // then
+        assertThat(restfulResp.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+    }
+
+    @Test
+    public void runtimeException_isMapped() throws Exception {
+
+        // given
+        final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "version");
+        final Header<Boolean> header = new Header<Boolean>("X-FAIL", Parser.forBoolean());
+        restfulReq.withHeader(header, true);
+
+        // when
+        final RestfulResponse<JsonRepresentation> jsonResp = restfulReq.execute();
+
+        // then
+        assertThat(jsonResp.getStatus(), is(HttpStatusCode.METHOD_FAILURE));
+    }
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_accept.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_accept.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_accept.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_accept.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.tck.resources.capabilities;
-
+package org.apache.isis.viewer.json.tck.resources.capabilities;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
@@ -35,47 +35,45 @@ import org.apache.isis.viewer.json.tck.I
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-
-public class VersionResourceTest_accept {
-
-    @Rule
-    public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
-    private RestfulClient client;
-
-    @Before
-    public void setUp() throws Exception {
-        WebServer webServer = webServerRule.getWebServer();
-        client = new RestfulClient(webServer.getBase());
-    }
-
-    @Test
-    public void applicationJson() throws Exception {
-
-        final RestfulRequest request = 
-                client.createRequest(HttpMethod.GET, "version").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
-        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
-
-        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
-    }
-
-    @Test
-    public void applicationJson_profileVersion() throws Exception {
-
-        final RestfulRequest request = 
-                client.createRequest(HttpMethod.GET, "version").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
-        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
-
-        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
-    }
-
-    @Test
-    public void applicationJson_invalid() throws Exception {
-
-        final RestfulRequest request = client.createRequest(HttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
-        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
-
-        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
-    }
-
-}
+
+public class VersionResourceTest_accept {
+
+    @Rule
+    public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+    private RestfulClient client;
+
+    @Before
+    public void setUp() throws Exception {
+        final WebServer webServer = webServerRule.getWebServer();
+        client = new RestfulClient(webServer.getBase());
+    }
+
+    @Test
+    public void applicationJson() throws Exception {
+
+        final RestfulRequest request = client.createRequest(HttpMethod.GET, "version").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
+
+        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+    }
+
+    @Test
+    public void applicationJson_profileVersion() throws Exception {
+
+        final RestfulRequest request = client.createRequest(HttpMethod.GET, "version").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
+        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
+
+        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+    }
+
+    @Test
+    public void applicationJson_invalid() throws Exception {
+
+        final RestfulRequest request = client.createRequest(HttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
+
+        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+    }
+
+}