[ https://issues.apache.org/jira/browse/WICKET-5926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14598286#comment-14598286 ]
ASF GitHub Bot commented on WICKET-5926: ---------------------------------------- Github user martin-g commented on a diff in the pull request: https://github.com/apache/wicket/pull/129#discussion_r33086279 --- Diff: testing/wicket-arquillian/pom.xml --- @@ -0,0 +1,316 @@ +<?xml version="1.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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.wicket</groupId> + <artifactId>wicket-parent</artifactId> + <version>7.0.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <artifactId>wicket-arquillian-testing</artifactId> + <packaging>war</packaging> + + <name>Wicket Arquillian Testing with Wildfly Java EE 6 Managed and Unpacked :: WAR</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <distribution>repo</distribution> + <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> + </license> + </licenses> + + <description> + A sample JAVA EE 6 project demonstrating how to use Arquillian with Wicket Framework deployed on JBoss WildFly managed downloaded from maven repository (NEXUS for example) and unpacked with dependency plugin. + WAR version (everything in a single .war file). + </description> + + + <properties> + <!-- Wildfly dependency versions --> + <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin> + <version.wildfly_8>8.1.0.Final</version.wildfly_8> --- End diff -- Does it also work with 8.2.0? I think this is the latest stable. It is OK to use 8.1.0 too. > Arquillian Support with Container ServletContext in > BaseWicketTester/WicketTester. > ---------------------------------------------------------------------------------- > > Key: WICKET-5926 > URL: https://issues.apache.org/jira/browse/WICKET-5926 > Project: Wicket > Issue Type: Improvement > Components: wicket > Affects Versions: 6.10.0, 6.11.0, 6.12.0, 6.13.0, 6.14.0, 6.15.0, 6.16.0, > 7.0.0-M2, 7.0.0-M3, 6.17.0, 6.18.0, 1.5.13, 7.0.0-M4, 7.0.0-M5, 6.19.0, 6.20.0 > Environment: Ubuntu 14.04, JDK 8/7/6 > Reporter: Felipe Campos de Almeida > Labels: automation, features, patch, test > > Hello all, > I'm wondering if BaseWicketTester could support an ServletContext and > WicketFilter provided by an web.xml configured and the container reading and > installing my XTestWebApplication.java instead of using Mock everytime. > I'm using Arquillian from http://arquillian.org. > And this improvement is going to help to run my tests with success using > webapp/WEB-INF/ configuration (like web.xml and so on). > I've already done the code and I'll commit (after some tests to maintain the > legacy) to my github: https://github.com/felipecalmeida/wicket > In my initial tests, the wicket-core tests are passing. > For this first commit, I kept the mock on Session, request and respond, > because it's not a problem yet. > I don't have yet a sample test to help to understand better this > modification, because I've to create a sample project using Arquillian in my > github. But I can take some screenshots later and upload here or in my > github, if it helps. > I'll post here the full code before commit: > {code:title=BaseWicketTester.java|borderStyle=solid} > /** > * Creates a <code>WicketTester</code>. Constructor to keep the legacy > code. > * > * @param application > * a <code>WicketTester</code> <code>WebApplication</code> > object > * @param servletCtx > * the servlet context used as backend > */ > public BaseWicketTester(final WebApplication application, final > ServletContext servletCtx) > { > // Keeping legacy code. > this(application, servletCtx, true); > } > > /** > * Creates a <code>WicketTester</code>. > * > * @param application > * a <code>WicketTester</code> <code>WebApplication</code> > object > * @param servletCtx > * the servlet context used as backend > * @param initializeApplication > * if don't have an application, initialize it > */ > public BaseWicketTester(final WebApplication application, final > ServletContext servletCtx, boolean initializeApplication) > { > // Default is to initialize the application. > if(initializeApplication) > { > > if(servletCtx == null) > { > servletContext = new > MockServletContext(application, null); > } > else > { > servletContext = servletCtx; > } > } > else > { > // Uses the servletContext provided by the container. > servletContext = application.getServletContext(); > } > > // Container that don't provide a WicketFilter. > if(application.getWicketFilter() == null) > { > final FilterConfig filterConfig = new > TestFilterConfig(); > WicketFilter filter = new WicketFilter() > { > @Override > public FilterConfig getFilterConfig() > { > return filterConfig; > } > }; > > application.setWicketFilter(filter); > } > > httpSession = new MockHttpSession(servletContext); > ThreadContext.detach(); > this.application = application; > if(initializeApplication) > { > // FIXME some tests are leaking applications by not > calling destroy on them or overriding > // teardown() without calling super, for now we work > around by making each name unique > application.setName("WicketTesterApplication-" + > UUID.randomUUID()); > } > > ThreadContext.setApplication(application); > if(initializeApplication) > { > application.setServletContext(servletContext); > // initialize the application > application.initApplication(); > } > // We don't expect any changes during testing. In addition we > avoid creating > // ModificationWatcher threads tests. > > application.getResourceSettings().setResourcePollFrequency(getResourcePollFrequency()); > // reconfigure application for the test environment > application.setPageRendererProvider(new > LastPageRecordingPageRendererProvider( > application.getPageRendererProvider())); > application.setRequestCycleProvider(new > TestRequestCycleProvider( > application.getRequestCycleProvider())); > // set a feedback message filter that will not remove any > messages > originalFeedbackMessageCleanupFilter = > application.getApplicationSettings() > .getFeedbackMessageCleanupFilter(); > > application.getApplicationSettings().setFeedbackMessageCleanupFilter( > IFeedbackMessageFilter.NONE); > IPageManagerProvider pageManagerProvider = > newTestPageManagerProvider(); > if (pageManagerProvider != null) > { > application.setPageManagerProvider(pageManagerProvider); > } > // create a new session when the old one is invalidated > application.getSessionStore().registerUnboundListener(new > UnboundListener() > { > @Override > public void sessionUnbound(String sessionId) > { > newSession(); > } > }); > // prepare session > setupNextRequestCycle(); > } > {code} > {code:title=WicketTester.java|borderStyle=solid} > /** > * Creates a <code>WicketTester</code> to help unit testing. > Constructor to keep the legacy code. > * > * @param application > * a <code>WicketTester</code> <code>WebApplication</code> > object > * @param servletCtx > * the servlet context used as backend > */ > public WicketTester(WebApplication application, ServletContext > servletCtx) > { > super(application, servletCtx); > } > > /** > * Creates a <code>WicketTester</code> to help unit testing. > * > * @param application > * a <code>WicketTester</code> <code>WebApplication</code> > object > * @param servletCtx > * the servlet context used as backend > * @param initializeApplication > * if don't have an application, initialize it > */ > public WicketTester(WebApplication application, ServletContext > servletCtx, boolean initializeApplication) > { > super(application, servletCtx, initializeApplication); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)