incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1352724 - in /incubator/isis/trunk/framework: tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/ viewer/json/json-tck/ viewer/json/json-tck/src/main/webapp/WEB-INF/ viewer/json/json-tck/src/test/java/org/apache/isis/viewer/jso...
Date Thu, 21 Jun 2012 23:08:02 GMT
Author: danhaywood
Date: Thu Jun 21 23:08:00 2012
New Revision: 1352724

URL: http://svn.apache.org/viewvc?rev=1352724&view=rev
Log:
ISIS-233: resurrecting some of the json viewer tests

Added:
    incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/AssociatedEntitiesFixture.java
      - copied, changed from r1344518, incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/ParentAndChildEntityFixture.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_clientAcceptHeader_exceptionHandling.java
      - copied, changed from r1344518, incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
  (with props)
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_accept.java
      - copied, changed from r1344518, incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_accept.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_representationAndHeaders.java
      - copied, changed from r1344518, incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_representationAndHeaders.java
Removed:
    incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/ParentAndChildEntityFixture.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/test/java/org/apache/isis/viewer/restful/
Modified:
    incubator/isis/trunk/framework/viewer/json/json-tck/pom.xml
    incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/web.xml
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java

Copied: incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/AssociatedEntitiesFixture.java
(from r1344518, incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/ParentAndChildEntityFixture.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/AssociatedEntitiesFixture.java?p2=incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/AssociatedEntitiesFixture.java&p1=incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/ParentAndChildEntityFixture.java&r1=1344518&r2=1352724&rev=1352724&view=diff
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/ParentAndChildEntityFixture.java
(original)
+++ incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/refs/AssociatedEntitiesFixture.java
Thu Jun 21 23:08:00 2012
@@ -23,7 +23,7 @@ import org.apache.isis.applib.fixtures.A
 import org.apache.isis.tck.dom.refs.AssociatedEntitiesRepository;
 import org.apache.isis.tck.dom.refs.ParentEntity;
 
-public class ParentAndChildEntityFixture extends AbstractFixture {
+public class AssociatedEntitiesFixture extends AbstractFixture {
 
     @Override
     public void install() {

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/pom.xml?rev=1352724&r1=1352723&r2=1352724&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/pom.xml (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/pom.xml Thu Jun 21 23:08:00 2012
@@ -37,7 +37,7 @@
 		<siteBaseDir>../../..</siteBaseDir>
 		<relativeUrl>viewer/json/json-tck/</relativeUrl>
 		<!-- until someone comes up with a better solution -->
-                <distMgmtSiteUrl>file:///tmp/m2-sites/isis/viewer/json</distMgmtSiteUrl>
+        <distMgmtSiteUrl>file:///tmp/m2-sites/isis/viewer/json</distMgmtSiteUrl>
     </properties>
 	
 

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties?rev=1352724&r1=1352723&r2=1352724&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties
Thu Jun 21 23:08:00 2012
@@ -14,15 +14,15 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
-isis.services.prefix = org.apache.isis.tck.objstore.dflt
+isis.services.prefix = org.apache.isis.tck.dom
 isis.services =\
-    scalars.ApplibValuedEntityRepositoryDefault,\
-    scalars.JdkValuedEntityRepositoryDefault,\
-    scalars.PrimitiveValuedEntityRepositoryDefault,\
-    scalars.WrapperValuedEntityRepositoryDefault, \
-    simples.SimpleEntityRepositoryDefault,\
-    assocs.ParentEntityRepositoryDefault,\
-    defaults.WithDefaultsEntityRepositoryDefault
+    scalars.ApplibValuedEntityRepository,\
+    scalars.JdkValuedEntityRepository,\
+    scalars.PrimitiveValuedEntityRepository,\
+    scalars.WrapperValuedEntityRepository, \
+    refs.AssociatedEntitiesRepository,\
+    defaults.WithDefaultsEntityRepository
+
 
 isis.fixtures.prefix= org.apache.isis.tck.fixture
 isis.fixtures=\
@@ -31,11 +31,11 @@ isis.fixtures=\
     scalars.JdkValuedEntityFixture,\
     scalars.PrimitiveValuedEntityFixture,\
     scalars.WrapperValuedEntityFixture,\
-    simples.SimpleEntityFixture,\
-    assocs.ParentAndChildEntityFixture,\
+    refs.AssociatedEntitiesFixture,\
     defaults.WithDefaultsEntityFixture
 
 
+
 isis.reflector.class-substitutor=org.apache.isis.runtimes.dflt.bytecode.dflt.classsubstitutor.CglibClassSubstitutor
 #isis.reflector.class-substitutor=org.apache.isis.runtimes.dflt.bytecode.javassist.classsubstitutor.JavassistClassSubstitutor
 #isis.reflector.class-substitutor=org.apache.isis.runtimes.dflt.bytecode.identity.classsubstitutor.ClassSubstitutorIdentity
@@ -52,8 +52,8 @@ isis.persistor.domain-object-container=o
 #isis.reflector.facets.include=org.apache.isis.runtimes.dflt.runtime.authorization.standard.AuthorizationFacetFactoryImpl
 #isis.authorization.learn=true
 
-isis.authentication=noop
-isis.authorization=noop
+isis.authentication=dflt
+isis.authorization=dflt
 
 isis.user-profile-store=in-memory
 isis.persistor=in-memory

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/web.xml?rev=1352724&r1=1352723&r2=1352724&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/web.xml Thu
Jun 21 23:08:00 2012
@@ -42,8 +42,8 @@
 		<filter-class>org.apache.isis.runtimes.dflt.webapp.IsisSessionFilter</filter-class>
 		<init-param>
 			<!-- trusted client, so no authentication required -->
-			<param-name>authenticationSessionLookupStrategy</param-name>
-			<param-value>org.apache.isis.viewer.json.viewer.authentication.AuthenticationSessionLookupStrategyTrusted</param-value>
+			<param-name>authenticationSessionStrategy</param-name>
+			<param-value>org.apache.isis.viewer.json.viewer.authentication.AuthenticationSessionStrategyTrusted</param-value>
 		</init-param>
 		<init-param>
             <!-- what to do if no session was found; we indicate to issue a 401 basic
authentication challenge -->

Copied: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_clientAcceptHeader_exceptionHandling.java
(from r1344518, 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_clientAcceptHeader_exceptionHandling.java?p2=incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_clientAcceptHeader_exceptionHandling.java&p1=incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_exceptionHandling.java&r1=1344518&r2=1352724&rev=1352724&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_clientAcceptHeader_exceptionHandling.java
Thu Jun 21 23:08:00 2012
@@ -26,6 +26,7 @@ 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.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -42,7 +43,7 @@ import org.apache.isis.viewer.json.appli
 import org.apache.isis.viewer.json.applib.util.Parser;
 import org.apache.isis.viewer.json.tck.IsisWebServerRule;
 
-public class AnyResourceTest_exceptionHandling {
+public class AnyResourceTest_clientAcceptHeader_exceptionHandling {
 
     @Rule
     public IsisWebServerRule webServerRule = new IsisWebServerRule();
@@ -56,7 +57,7 @@ public class AnyResourceTest_exceptionHa
     }
 
     @Test
-    public void noMediaType() throws Exception {
+    public void whenSetsNoAcceptHeader_isOk() throws Exception {
         // given
         final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
 
@@ -69,7 +70,7 @@ public class AnyResourceTest_exceptionHa
     }
 
     @Test
-    public void correctMediaType() throws Exception {
+    public void whenSetsAcceptHeaderOfApplicationJson_isOk() throws Exception {
 
         // given
         final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
@@ -83,8 +84,9 @@ public class AnyResourceTest_exceptionHa
         assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
     }
 
+    @Ignore("RestEasy seems to reject with a 500, 'No match for accept header', rather than
a 405.")
     @Test
-    public void incorrectMediaType_returnsNotAcceptable() throws Exception {
+    public void whenSetsIncorrectMediaType_returnsNotAcceptable() throws Exception {
 
         // given
         final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("/");
@@ -93,23 +95,11 @@ public class AnyResourceTest_exceptionHa
         // when
         final ClientResponse<?> resp = clientRequest.get();
         final RestfulResponse<JsonRepresentation> restfulResp = RestfulResponse.of(resp);
+        
+        final String entity = restfulResp.getEntity().toString();
 
         // 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));
-    }
 }

Added: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_serverSideException_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_serverSideException_exceptionHandling.java?rev=1352724&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
(added)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
Thu Jun 21 23:08:00 2012
@@ -0,0 +1,72 @@
+/*
+ *  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.json.tck.resources;
+
+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.runtimes.dflt.webserver.WebServer;
+import org.apache.isis.viewer.json.applib.HttpMethod;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.RestfulClient;
+import org.apache.isis.viewer.json.applib.RestfulRequest;
+import org.apache.isis.viewer.json.applib.RestfulRequest.Header;
+import org.apache.isis.viewer.json.applib.RestfulResponse;
+import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.json.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.json.applib.util.Parser;
+import org.apache.isis.viewer.json.tck.IsisWebServerRule;
+
+public class AnyResourceTest_serverSideException_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 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));
+    }
+}

Propchange: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_accept.java
(from r1344518, 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/version/VersionResourceTest_accept.java?p2=incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_accept.java&p1=incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_accept.java&r1=1344518&r2=1352724&rev=1352724&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/version/VersionResourceTest_accept.java
Thu Jun 21 23:08:00 2012
@@ -16,7 +16,7 @@
  *  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.version;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;

Copied: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_representationAndHeaders.java
(from r1344518, incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_representationAndHeaders.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/version/VersionResourceTest_representationAndHeaders.java?p2=incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_representationAndHeaders.java&p1=incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_representationAndHeaders.java&r1=1344518&r2=1352724&rev=1352724&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/capabilities/VersionResourceTest_representationAndHeaders.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/version/VersionResourceTest_representationAndHeaders.java
Thu Jun 21 23:08:00 2012
@@ -16,7 +16,7 @@
  *  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.version;
 
 import static org.apache.isis.viewer.json.tck.RepresentationMatchers.assertThat;
 import static org.apache.isis.viewer.json.tck.RepresentationMatchers.hasMaxAge;

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java?rev=1352724&r1=1352723&r2=1352724&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
Thu Jun 21 23:08:00 2012
@@ -115,7 +115,10 @@ public abstract class ResourceAbstract {
     }
 
     protected void init(final RepresentationType representationType) {
-        if (!IsisContext.inSession() || getAuthenticationSession() == null) {
+        if (!IsisContext.inSession()) {
+            throw JsonApplicationException.create(HttpStatusCode.UNAUTHORIZED);
+        } 
+        if (getAuthenticationSession() == null) {
             throw JsonApplicationException.create(HttpStatusCode.UNAUTHORIZED);
         }
 



Mime
View raw message