You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/03/02 14:07:44 UTC
[isis] 01/02: ISIS-2296: remove experimental code
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
commit d419d21f4ce59f617157e24a685c526c99caddc7
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Mar 2 15:04:35 2020 +0100
ISIS-2296: remove experimental code
---
.../requestscope/IsisRequestCycleFilter.java | 65 -----------------
.../requestscope/WebModuleRequestCycleFilter.java | 84 ----------------------
.../transactions/TransactionRollbackTest.java | 44 ++++--------
3 files changed, 13 insertions(+), 180 deletions(-)
diff --git a/core/webapp/src/main/java/org/apache/isis/core/webapp/modules/requestscope/IsisRequestCycleFilter.java b/core/webapp/src/main/java/org/apache/isis/core/webapp/modules/requestscope/IsisRequestCycleFilter.java
deleted file mode 100644
index c9a2768..0000000
--- a/core/webapp/src/main/java/org/apache/isis/core/webapp/modules/requestscope/IsisRequestCycleFilter.java
+++ /dev/null
@@ -1,65 +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.core.webapp.modules.requestscope;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.springframework.beans.factory.annotation.Autowired;
-
-import org.apache.isis.core.security.authentication.AuthenticationSession;
-
-//import org.springframework.beans.factory.annotation.Autowired;
-//
-//import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
-//import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerService;
-//import org.apache.isis.core.commons.collections.Can;
-//
-//import lombok.val;
-import lombok.extern.log4j.Log4j2;
-
-/**
- * Simply logs the URL of any request that causes an exception to be thrown.
- */
-@Log4j2
-public class IsisRequestCycleFilter implements Filter {
-
- @Autowired private AuthenticationSession authenticationSession;
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- }
-
- @Override
- public void destroy() {
- }
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
- chain.doFilter(request, response);
- }
-
-
-}
diff --git a/core/webapp/src/main/java/org/apache/isis/core/webapp/modules/requestscope/WebModuleRequestCycleFilter.java b/core/webapp/src/main/java/org/apache/isis/core/webapp/modules/requestscope/WebModuleRequestCycleFilter.java
deleted file mode 100644
index 228267b..0000000
--- a/core/webapp/src/main/java/org/apache/isis/core/webapp/modules/requestscope/WebModuleRequestCycleFilter.java
+++ /dev/null
@@ -1,84 +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.core.webapp.modules.requestscope;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletException;
-
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Service;
-
-import org.apache.isis.applib.annotation.OrderPrecedence;
-import org.apache.isis.applib.services.inject.ServiceInjector;
-import org.apache.isis.core.commons.collections.Can;
-import org.apache.isis.core.webapp.modules.WebModuleAbstract;
-
-import lombok.Getter;
-
-/**
- * WebModule to hook into request-cycles of protected servlets.
- * Allows the framework to make a unique IsisSession instance available for each request-cycle.
- *
- * @implSpec filter must be configured with the servlet context filter chain after
- * an AuthenticationSession was made available
- *
- * @since 2.0
- */
-@Service
-@Named("isisWebapp.WebModuleLogOnExceptionLogger")
-@Order(OrderPrecedence.EARLY - 99)
-@Qualifier("WebModuleRequestCycleFilter")
-public final class WebModuleRequestCycleFilter
-extends WebModuleAbstract {
-
- private static final String FILTER_NAME = "IsisRequestCycleFilter";
-
-
- @Getter
- private final String name = "Request Cycle Filter";
-
- @Inject
- public WebModuleRequestCycleFilter(final ServiceInjector serviceInjector) {
- super(serviceInjector);
- }
-
-
- @Override
- public Can<ServletContextListener> init(ServletContext ctx) throws ServletException {
-
- registerFilter(ctx, FILTER_NAME, IsisRequestCycleFilter.class)
- .ifPresent(filterReg -> {
- filterReg.addMappingForUrlPatterns(
- null,
- true, // filterReg is forced last
- webModuleContext.getProtectedPaths().toArray(String.class));
- });
-
- return Can.empty(); // registers no listeners
- }
-
-
- // -- HELPER
-
-
-}
diff --git a/examples/smoketests/src/test/java/org/apache/isis/testdomain/transactions/TransactionRollbackTest.java b/examples/smoketests/src/test/java/org/apache/isis/testdomain/transactions/TransactionRollbackTest.java
index 7eebb9f..65a90cb 100644
--- a/examples/smoketests/src/test/java/org/apache/isis/testdomain/transactions/TransactionRollbackTest.java
+++ b/examples/smoketests/src/test/java/org/apache/isis/testdomain/transactions/TransactionRollbackTest.java
@@ -32,12 +32,12 @@ import org.apache.isis.applib.services.repository.RepositoryService;
import org.apache.isis.applib.services.xactn.TransactionService;
import org.apache.isis.core.commons.internal.exceptions._Exceptions;
import org.apache.isis.core.config.presets.IsisPresets;
-import org.apache.isis.core.runtime.session.IsisSessionFactory;
import org.apache.isis.testdomain.Smoketest;
import org.apache.isis.testdomain.conf.Configuration_usingJdo;
import org.apache.isis.testdomain.jdo.JdoTestDomainPersona;
import org.apache.isis.testdomain.jdo.entities.JdoBook;
import org.apache.isis.testing.fixtures.applib.fixturescripts.FixtureScripts;
+import org.apache.isis.testing.integtestsupport.applib.IsisIntegrationTestAbstract;
@Smoketest
@SpringBootTest(
@@ -45,29 +45,23 @@ import org.apache.isis.testing.fixtures.applib.fixturescripts.FixtureScripts;
Configuration_usingJdo.class,
})
@TestPropertySource(IsisPresets.UseLog4j2Test)
-class TransactionRollbackTest {
+class TransactionRollbackTest extends IsisIntegrationTestAbstract {
- @Inject FixtureScripts fixtureScripts;
- @Inject TransactionService transactionService;
- @Inject RepositoryService repository;
- @Inject IsisSessionFactory isisSessionFactory;
+ @Inject private FixtureScripts fixtureScripts;
+ @Inject private TransactionService transactionService;
+ @Inject private RepositoryService repository;
@BeforeEach
void setUp() {
// cleanup
fixtureScripts.runPersona(JdoTestDomainPersona.PurgeAll);
-
}
@Test
void happyCaseTx_shouldCommit() {
- isisSessionFactory.runAnonymous(()->{
-
- // expected pre condition
- assertEquals(0, repository.allInstances(JdoBook.class).size());
-
- });
+ // expected pre condition
+ assertEquals(0, repository.allInstances(JdoBook.class).size());
transactionService.executeWithinTransaction(()->{
@@ -76,25 +70,17 @@ class TransactionRollbackTest {
});
- isisSessionFactory.runAnonymous(()->{
-
- // expected post condition
- assertEquals(1, repository.allInstances(JdoBook.class).size());
-
- });
+ // expected post condition
+ assertEquals(1, repository.allInstances(JdoBook.class).size());
}
@Test
void whenExceptionWithinTx_shouldRollback() {
- isisSessionFactory.runAnonymous(()->{
-
- // expected pre condition
- assertEquals(0, repository.allInstances(JdoBook.class).size());
+ // expected pre condition
+ assertEquals(0, repository.allInstances(JdoBook.class).size());
- });
-
assertThrows(RuntimeException.class, ()->{
transactionService.executeWithinTransaction(()->{
@@ -107,12 +93,8 @@ class TransactionRollbackTest {
});
- isisSessionFactory.runAnonymous(()->{
-
- // expected post condition
- assertEquals(0, repository.allInstances(JdoBook.class).size());
-
- });
+ // expected post condition
+ assertEquals(0, repository.allInstances(JdoBook.class).size());
}