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 2013/04/27 20:31:22 UTC
[03/50] [abbrv] ISIS-233: more on user, version, services list
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java
new file mode 100644
index 0000000..b8221b1
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.home;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class HomePageResourceTest_representation {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private HomePageResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getHomePageResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // given
+ final Response resp = resource.homePage();
+
+ // when
+ final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+ assertThat(restfulResponse.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+
+ final HomePageRepresentation repr = restfulResponse.getEntity();
+ assertThat(repr, is(not(nullValue())));
+ assertThat(repr, isMap());
+
+ assertThat(repr.getSelf(), isLink(client)
+ .rel(Rel.SELF)
+ .href(endsWith(":39393/"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.HOME_PAGE.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getUser(), isLink(client)
+ .rel(Rel.USER)
+ .href(endsWith(":39393/user"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.USER.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getServices(), isLink(client)
+ .rel(Rel.SERVICES)
+ .href(endsWith(":39393/services"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.LIST.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getVersion(), isLink(client)
+ .rel(Rel.VERSION)
+ .href(endsWith(":39393/version"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.VERSION.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java
new file mode 100644
index 0000000..f4d8231
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.home;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class HomePageResourceTest_responseHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private HomePageResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getHomePageResource();
+ }
+
+
+ @Test
+ public void contentType_and_cacheControl() throws Exception {
+ // given
+ final Response resp = resource.homePage();
+
+ // when
+ final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+
+ // then
+ final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
+ assertThat(contentType, hasType("application"));
+ assertThat(contentType, hasSubType("json"));
+ assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/homepage"));
+ assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));
+
+ // then
+ final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
+ assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
+ assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java
deleted file mode 100644
index acb0c6d..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.home;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class HomePageResourceTest_templated_representation {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private HomePageResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getHomePageResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- final Response resp = resource.homePage();
-
- // when
- final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
- assertThat(restfulResponse.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
-
- final HomePageRepresentation repr = restfulResponse.getEntity();
- assertThat(repr, is(not(nullValue())));
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink(client)
- .rel(Rel.SELF)
- .href(endsWith(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.HOME_PAGE.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getUser(), isLink(client)
- .rel(Rel.USER)
- .href(endsWith(":39393/user"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.USER.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getServices(), isLink(client)
- .rel(Rel.SERVICES)
- .href(endsWith(":39393/services"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.LIST.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getVersion(), isLink(client)
- .rel(Rel.VERSION)
- .href(endsWith(":39393/version"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.VERSION.getMediaType())
- .returning(HttpStatusCode.OK)
- );
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java
deleted file mode 100644
index 201683e..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.home;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class HomePageResourceTest_templated_responseHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private HomePageResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getHomePageResource();
- }
-
-
- @Test
- public void headers() throws Exception {
- // given
- final Response resp = resource.homePage();
-
- // when
- final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/homepage"));
- assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
- assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
index f86249e..4af1ad0 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
@@ -57,18 +57,30 @@ public class HomePageResourceTest_xrofollowlinks {
public void setUp() throws Exception {
client = webServerRule.getClient();
+ }
+
+ @Test
+ public void noFollow() throws Exception {
request = client.createRequest(RestfulHttpMethod.GET, "");
restfulResponse = request.executeT();
repr = restfulResponse.getEntity();
-
- // given
+
+ assertThat(repr.getSelf().getValue(), is(nullValue()));
assertThat(repr.getUser().getValue(), is(nullValue()));
assertThat(repr.getVersion().getValue(), is(nullValue()));
assertThat(repr.getServices().getValue(), is(nullValue()));
}
+
+ @Test
+ public void self() throws Exception {
+
+ repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SELF.getName() + "]");
+
+ assertThat(repr.getSelf().getValue(), is(not(nullValue())));
+ }
@Test
- public void canFollowUser() throws Exception {
+ public void user() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.USER.getName() + "]");
@@ -76,7 +88,7 @@ public class HomePageResourceTest_xrofollowlinks {
}
@Test
- public void canFollowServices() throws Exception {
+ public void services() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "]");
@@ -84,7 +96,7 @@ public class HomePageResourceTest_xrofollowlinks {
}
@Test
- public void canFollowVersion() throws Exception {
+ public void version() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.VERSION.getName() + "]");
@@ -92,7 +104,7 @@ public class HomePageResourceTest_xrofollowlinks {
}
@Test
- public void canFollowAll() throws Exception {
+ public void multiple() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/",
"links[rel=" + Rel.USER.getName() + "]," +
@@ -105,7 +117,7 @@ public class HomePageResourceTest_xrofollowlinks {
}
@Test
- public void servicesValues() throws Exception {
+ public void allServices_Value() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value");
@@ -127,7 +139,7 @@ public class HomePageResourceTest_xrofollowlinks {
}
@Test
- public void servicesValuesWithCriteria() throws Exception {
+ public void selectedService_Value() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value[rel=" + Rel.SERVICE.andParam("serviceId", "WrapperValuedEntities")+"]");
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
index 73b6edf..913867e 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
@@ -84,7 +84,7 @@ public class DomainServiceResourceTest_invokeAction {
final RestfulResponse<ListRepresentation> restfulResponse = client.followT(invokeLink);
final ListRepresentation listRepr = restfulResponse.getEntity();
- assertThat(listRepr.getValues().size(), is(5));
+ assertThat(listRepr.getValue().size(), is(5));
}
@Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
@@ -259,7 +259,7 @@ public class DomainServiceResourceTest_invokeAction {
final RestfulResponse<ListRepresentation> restfulResponse = client.followT(invokeLink);
final ListRepresentation listRepr = restfulResponse.getEntity();
- return listRepr.getValues().arrayGet(num).asLink();
+ return listRepr.getValue().arrayGet(num).asLink();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_accept.java
deleted file mode 100644
index 9362707..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_accept.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.service.services;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.MediaType;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceResourceTest_services_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(RestfulHttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileList() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.LIST.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_invalid() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java
deleted file mode 100644
index 1d80286..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.service.services;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceResourceTest_services_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // when
- final Response response = resource.services();
- final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(response);
-
- // then
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.LIST.getMediaType()));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CACHE_CONTROL).getMaxAge(), is(24 * 60 * 60));
-
- final ListRepresentation repr = restfulResponse.getEntity();
-
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink().httpMethod(RestfulHttpMethod.GET));
-
- assertThat(repr.getValues(), isArray());
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- final ListRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
- @Test
- public void linksToDomainServiceResources() throws Exception {
-
- // given
- final ListRepresentation repr = givenRepresentation();
-
- // when
- final JsonRepresentation values = repr.getValues();
-
- // then
- for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
- assertThat("HiddenRepository should not show up in services list", false, is(link.getHref().endsWith("HiddenRepository")));
-
- final RestfulResponse<JsonRepresentation> followJsonResp = client.follow(link);
- assertThat(followJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- final JsonRepresentation followRepr = followJsonResp.getEntity();
- final LinkRepresentation self = followRepr.getLink("links[rel=self]");
-
- assertThat(self.getHref(), is(link.getHref()));
- }
- }
-
- private ListRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
- final RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
- return jsonResp.getEntity();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java
deleted file mode 100644
index d52903b..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.service.services;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
-
-import org.hamcrest.Matchers;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest.RequestParameter;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class DomainServiceResourceTest_services_xrofollowlinks {
-
- @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 xrofollowLinks() throws Exception {
-
- RestfulRequest request;
- RestfulResponse<ListRepresentation> restfulResponse;
- ListRepresentation repr;
-
- request = client.createRequest(RestfulHttpMethod.GET, "services");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getValues(), isArray());
- assertThat(repr.getValues().size(), is(greaterThan(0)));
- assertThat(repr.getValues().arrayGet(0), isLink().novalue());
-
- request = client.createRequest(RestfulHttpMethod.GET, "services").withArg(RequestParameter.FOLLOW_LINKS, "values");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getValues().arrayGet(0), isLink().value(is(not(Matchers.nullValue(JsonRepresentation.class)))));
- assertThat(repr.getValues().arrayGet(0).getRepresentation("value"), isMap());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_acceptHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_acceptHeader.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_acceptHeader.java
new file mode 100644
index 0000000..af9adf7
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_acceptHeader.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_acceptHeader {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private RestfulRequest request;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ request = client.createRequest(RestfulHttpMethod.GET, "user");
+ }
+
+ @Test
+ public void applicationJson_noProfile_returns200() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.USER.getMediaType()));
+ }
+
+ @Test
+ public void applicationJson_profileUser_returns200() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void missingHeader_returns200() throws Exception {
+
+ final RestfulResponse<UserRepresentation> restfulResp = request.executeT();
+
+ assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_profileIncorrect_returns406() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+ @Test
+ public void incorrectMediaType_returnsNotAcceptable() throws Exception {
+
+ // given
+ final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("user");
+ 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));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java
deleted file mode 100644
index 4246313..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.user;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.MediaType;
-
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class UserResourceTest_get_accept {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- }
-
- @Test
- public void applicationJson_noProfile_returns200() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.USER.getMediaType()));
- }
-
- @Test
- public void applicationJson_profileUser_returns200() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void missingHeader_returns200() throws Exception {
- // given
- final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.GET, "user");
-
- // when
- final RestfulResponse<UserRepresentation> restfulResp = restfulReq.executeT();
-
- // then
- assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileIncorrect_returns406() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
- final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
- @Test
- public void incorrectMediaType_returnsNotAcceptable() throws Exception {
-
- // given
- final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("user");
- 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));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representation.java
new file mode 100644
index 0000000..1dec9b5
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representation.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_representation {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private UserResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getUserResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // given
+ final Response resp = resource.user();
+
+ // when
+ final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resp);
+ assertThat(jsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
+
+ final UserRepresentation repr = jsonResp.getEntity();
+ assertThat(repr, is(not(nullValue())));
+ assertThat(repr.isMap(), is(true));
+
+ assertThat(repr.getSelf(), isLink(client)
+ .rel(Rel.SELF)
+ .href(endsWith(":39393/user"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.USER.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getUp(), isLink(client)
+ .rel(Rel.UP)
+ .href(endsWith(":39393/"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.HOME_PAGE.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getUserName(), is(not(nullValue())));
+
+ // TODO: change fixture so populated
+ assertThat(repr.getFriendlyName(), is(nullValue()));
+ assertThat(repr.getEmail(), is(nullValue()));
+ assertThat(repr.getRoles(), is(not(nullValue())));
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_responseHeaders.java
new file mode 100644
index 0000000..f15a265
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_responseHeaders.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_responseHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private UserResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getUserResource();
+ }
+
+
+ @Test
+ public void contentType_and_cacheControl() throws Exception {
+
+ // given
+ final Response resp = resource.user();
+
+ // when
+ final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+
+ // then
+ final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
+ assertThat(contentType, hasType("application"));
+ assertThat(contentType, hasSubType("json"));
+ assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/user"));
+ assertThat(contentType, is(RepresentationType.USER.getMediaType()));
+
+ // then
+ final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
+ assertThat(cacheControl, hasMaxAge(60 * 60));
+ assertThat(cacheControl.getMaxAge(), is(60 * 60));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java
deleted file mode 100644
index da95307..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.user;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class UserResourceTest_templated_representation {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private UserResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getUserResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- final Response resp = resource.user();
-
- // when
- final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resp);
- assertThat(jsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
-
- final UserRepresentation repr = jsonResp.getEntity();
- assertThat(repr, is(not(nullValue())));
- assertThat(repr.isMap(), is(true));
-
- assertThat(repr.getSelf(), isLink(client)
- .rel(Rel.SELF)
- .href(endsWith(":39393/user"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.USER.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getUp(), isLink(client)
- .rel(Rel.UP)
- .href(endsWith(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.HOME_PAGE.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getUserName(), is(not(nullValue())));
-
- // TODO: change fixture so populated
- assertThat(repr.getFriendlyName(), is(nullValue()));
- assertThat(repr.getEmail(), is(nullValue()));
- assertThat(repr.getRoles(), is(not(nullValue())));
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java
deleted file mode 100644
index ea6e6ec..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.user;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class UserResourceTest_templated_responseHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private UserResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getUserResource();
- }
-
-
- @Test
- public void headers() throws Exception {
-
- // given
- final Response resp = resource.user();
-
- // when
- final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/user"));
- assertThat(contentType, is(RepresentationType.USER.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(60 * 60));
- assertThat(cacheControl.getMaxAge(), is(60 * 60));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_xrofollowlinks.java
new file mode 100644
index 0000000..7d683ca
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_xrofollowlinks.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest.RequestParameter;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_xrofollowlinks {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private RestfulRequest request;
+ private RestfulResponse<UserRepresentation> restfulResponse;
+ private UserRepresentation repr;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ }
+
+ @Test
+ public void noFollow() throws Exception {
+
+ request = client.createRequest(RestfulHttpMethod.GET, "user");
+ restfulResponse = request.executeT();
+ repr = restfulResponse.getEntity();
+
+ assertThat(repr.getSelf().getValue(), is(nullValue()));
+ assertThat(repr.getUp().getValue(), is(nullValue()));
+ }
+
+ @Test
+ public void self() throws Exception {
+
+ request = client.createRequest(RestfulHttpMethod.GET, "user")
+ .withArg(RequestParameter.FOLLOW_LINKS, "links[rel=" + Rel.SELF.getName() + "]");
+ restfulResponse = request.executeT();
+ repr = restfulResponse.getEntity();
+
+ assertThat(repr.getSelf().getValue(), is(not(nullValue())));
+ }
+
+ @Test
+ public void up() throws Exception {
+
+ request = client.createRequest(RestfulHttpMethod.GET, "user")
+ .withArg(RequestParameter.FOLLOW_LINKS, "links[rel=" + Rel.UP.getName() + "]");
+ restfulResponse = request.executeT();
+ repr = restfulResponse.getEntity();
+
+ assertThat(repr.getUp().getValue(), is(not(nullValue())));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/5491a130/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/version/VersionResourceTest_acceptHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/version/VersionResourceTest_acceptHeader.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/version/VersionResourceTest_acceptHeader.java
new file mode 100644
index 0000000..2efa8e6
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/version/VersionResourceTest_acceptHeader.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.version;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.version.VersionRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class VersionResourceTest_acceptHeader {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private RestfulRequest request;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ request = client.createRequest(RestfulHttpMethod.GET, "version");
+ }
+
+ @Test
+ public void applicationJson_noProfile_returns200() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.VERSION.getMediaType()));
+ }
+
+
+ @Test
+ public void applicationJson_profileVersion_returns200() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
+ final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void missingHeader_returns200() throws Exception {
+
+ final RestfulResponse<VersionRepresentation> restfulResp = request.executeT();
+
+ assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_profileIncorrect_returns406() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+ @Test
+ public void incorrectMediaType_returnsNotAcceptable() throws Exception {
+
+ // given
+ final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("version");
+ 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));
+ }
+}