BAEL-226 - Source code for wicket

This commit is contained in:
slavisa-baeldung 2016-09-17 13:07:39 +02:00
parent b8eb2a799a
commit cf53bc6585
14 changed files with 73 additions and 74 deletions

View File

@ -101,7 +101,7 @@
<module>lombok</module>
<module>redis</module>
<module>webjars</module>
<module>wicket-intro</module>
<module>wicket</module>
<module>mutation-testing</module>
<module>spring-mvc-velocity</module>

View File

@ -1,10 +0,0 @@
package com.baeldung.wicket.examples;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
public class ApplicationConfiguration {
}

View File

@ -1,26 +0,0 @@
package com.baeldung.wicket.examples;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.wicket.protocol.http.WicketFilter;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) throws ServletException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
container.addListener(new ContextLoaderListener(context));
context.register(ApplicationConfiguration.class);
FilterRegistration filter = container.addFilter("ExamplesApplication", WicketFilter.class);
filter.setInitParameter("applicationClassName", ExamplesApplication.class.getName());
filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
filter.addMappingForUrlPatterns(null, false, "/*");
}
}

View File

@ -13,13 +13,9 @@
<jetty9.version>9.2.13.v20150730</jetty9.version>
<log4j.version>2.5</log4j.version>
<junit.version>4.12</junit.version>
<spring-web.version>4.1.1.RELEASE</spring-web.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<wicket-spring.version>8.0.0-M1</wicket-spring.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<wtp.version>none</wtp.version>
</properties>
<dependencies>
<!-- WICKET DEPENDENCIES -->
@ -29,24 +25,6 @@
<version>${wicket.version}</version>
</dependency>
<!-- SPRING DEPENDENCIES -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-web.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-spring</artifactId>
<version>${wicket-spring.version}</version>
</dependency>
<!-- JUNIT DEPENDENCY FOR TESTING -->
<dependency>
<groupId>junit</groupId>
@ -64,7 +42,6 @@
</dependency>
</dependencies>
<build>
<finalName>WicketIntro</finalName>
<resources>
<resource>
<filtering>false</filtering>
@ -81,6 +58,22 @@
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<filtering>false</filtering>
<directory>src/test/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<inherited>true</inherited>
@ -110,17 +103,4 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>Apache Nexus</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,23 @@
package com.baeldung.wicket.examples;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.Before;
import org.junit.Test;
public class TestHomePage {
private WicketTester tester;
@Before
public void setUp() {
tester = new WicketTester(new ExamplesApplication());
}
@Test
public void whenPageInvoked_thanRenderedOK() {
//start and render the test page
tester.startPage(Examples.class);
//assert rendered page class
tester.assertRenderedPage(Examples.class);
}
}

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>CafeAddress</display-name>
<!--
There are three means to configure Wickets configuration mode and they
are tested in the order given.
1) A system property: -Dwicket.configuration
2) servlet specific <init-param>
3) context specific <context-param>
The value might be either "development" (reloading when templates change) or
"deployment". If no configuration is found, "development" is the default. -->
<filter>
<filter-name>wicket.examples</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.baeldung.wicket.examples.ExamplesApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wicket.examples</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>