Webapp-Rule

Junit Rules for web app integration testing

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.unseenspace.junit
ArtifactId

ArtifactId

webapp-rule
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Webapp-Rule
Junit Rules for web app integration testing
Source Code Management

Source Code Management

http://github.com/bornskilled200/webapp-rule/tree/master

Download webapp-rule

How to add to project

<!-- https://jarcasting.com/artifacts/com.unseenspace.junit/webapp-rule/ -->
<dependency>
    <groupId>com.unseenspace.junit</groupId>
    <artifactId>webapp-rule</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.unseenspace.junit/webapp-rule/
implementation 'com.unseenspace.junit:webapp-rule:0.1.1'
// https://jarcasting.com/artifacts/com.unseenspace.junit/webapp-rule/
implementation ("com.unseenspace.junit:webapp-rule:0.1.1")
'com.unseenspace.junit:webapp-rule:jar:0.1.1'
<dependency org="com.unseenspace.junit" name="webapp-rule" rev="0.1.1">
  <artifact name="webapp-rule" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.unseenspace.junit', module='webapp-rule', version='0.1.1')
)
libraryDependencies += "com.unseenspace.junit" % "webapp-rule" % "0.1.1"
[com.unseenspace.junit/webapp-rule "0.1.1"]

Dependencies

compile (11)

Group / Artifact Type Version
org.eclipse.jetty : jetty-server jar 9.3.7.v20160115
org.eclipse.jetty : jetty-annotations jar 9.3.7.v20160115
org.eclipse.jetty : jetty-webapp jar 9.3.7.v20160115
org.eclipse.jetty : jetty-jndi jar 9.3.7.v20160115
org.eclipse.jetty : jetty-plus jar 9.3.7.v20160115
org.eclipse.jetty : apache-jsp jar 9.3.7.v20160115
org.eclipse.jetty : apache-jstl jar 9.3.7.v20160115
com.h2database : h2 jar 1.4.186
net.sourceforge.htmlunit : htmlunit jar 2.19
commons-io : commons-io jar 2.4
junit : junit jar 4.12

test (2)

Group / Artifact Type Version
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-core jar 2.0.5-beta

Project Modules

There are no modules declared in this project.

webapp-rule

Simple rules to reduce boilerplate when integration testing for web apps.

public class IntegrationTest {
  public static H2DataSourceRule dataSourceRule = new H2DataSourceRule("test");

  public static JettyRule jettyRule = JettyRule.builder()
          .webapp()
          .jars("shiro-web", "struts")
          .jsp()
          .jndi()
          .jndi("hospital", dataSourceRule.getDataSource())
          .jndi("hibernate.dialect", "org.hibernate.dialect.H2Dialect")
          .jndi("hibernate.hbm2ddl.auto", "update")
          .build();

  @ClassRule
  public static TestRule testRule = RuleChain.outerRule(dataSourceRule).around(jettyRule);
  
  @Rule
  public HtmlUnitRule htmlUnitRule = new HtmlUnitRule();
  
  @Test
  public void testConnection() {
    assertThat(htmlUnitRule.getWebClient().getPage(jettyRule.getUrl()).getWebResponse().getStatusCode(), is(200)));
  }
}

Versions

Version
0.1.1
0.1