Git Product home page Git Product logo

spring-functionaltest's Introduction

Spring Functional Test

This project provides functional tests of Macchinetta Server Framework (1.x) Development Guideline.

How to perform functional test

Preconditions are as follow:

  • JDK 8 or JDK 7 installed (JAVA_HOME defined as environment variable)
  • "JCE Unlimited Strength Jurisdiction Policy Files" (for JDK 8 or JDK 7) installed
  • Maven installed (Can run mvn command)
  • Firefox(for personal or ESR) installed (ESR is used on our CI environment)

[Step 1] Create database of PostgreSQL (Optional)

If PostgreSQL use as database , you need to create database of PostgreSQL into local machine. (PostgreSQL can download via here site).

Note:

If H2 use as database, you can skip this step.

Download & install

By default, database owner is postgres user, and password of postgres user is 'P0stgres'.

Create database

$ createdb -U postgres spring-functionaltest --locale=C --encoding=UTF8 --template=template0
$ createdb -U postgres spring-functionaltest-open --locale=C --encoding=UTF8 --template=template0
$ createdb -U postgres spring-functionaltest-close --locale=C --encoding=UTF8 --template=template0

[Step 2] Clone a repository

Clone the Macchinetta/spring-functionaltest repository into local machine.

$ git clone https://github.com/Macchinetta/spring-functionaltest.git

[Step 3] Place dependent libraries

Place iTextAsian-1.0.jar and ojdbc7-12.1.0.2.0.jar on spring-functionaltest-env/3rdparty. You have to get these jar files in some way.

$ mv iTextAsian-1.0.jar spring-functionaltest-env/3rdparty/com/lowagie/iTextAsian/1.0
$ mv ojdbc7-12.1.0.2.0.jar spring-functionaltest-env/3rdparty/com/oracle/ojdbc7/12.1.0.2.0/

If you'd like to use another version, it's necessary to change some configurations.

[Step 4] Build artifacts

Build artifacts using maven commands as follows.

Case that use embedded H2 as database

$ cd {your repository directory}
$ git checkout {target branch}
$ mvn -U install -am -pl spring-functionaltest-web

Note:

When using JDK 7, build as follows.
you must compile with the target version 1.7 in accordance with the runtime environment JVM and exclude the source code that depends on JDK 1.8 .
You can set the target version using java-version property, and you can exclude using build-for-jdk7 Maven Profile in addition to the default profile.

$ mvn -U install -am -pl spring-functionaltest-web -Djava-version=1.7 -P local,build-for-jdk7

Case that use PostgreSQL as database

$ cd {your repository directory}
$ git checkout {target branch}
$ mvn -U install -am -pl spring-functionaltest-web -P tomcat8-postgresql,warpack-env,warpack-jstl,warpack-cxf,warpack-transaction,travis

Note:

If you not use default user(postgres) or password(P0stgres), you should modify settings in terasoluna-gfw-functionaltest-env/configs/travis/ContainerConfigXML/context.xml.

[Step 5] Initialize database (Optional)

If PostgreSQL use as database, initialize database before run functional test.

$ mvn -U sql:execute -pl spring-functionaltest-initdb -P local-postgres
$ mvn -U sql:execute -pl spring-functionaltest-initdb -P local-postgres-open
$ mvn -U sql:execute -pl spring-functionaltest-initdb -P local-postgres-close

Note:

If you not use default user(postgres) or password(P0stgres), you should specify -Ddb.username={your user} or -Ddb.password={your password} or both.

[Step 6] Startup Tomcat8 and deploy war file

Startup Tomcat8 and deploy war file using CARGO maven plugin.

Case that use embedded H2 as database

$ cd {your repository directory}
$ mvn -U cargo:run -pl spring-functionaltest-web

Case that use PostgreSQL as database (use Tomcat JNDI Resource)

$ cd {your repository directory}
$ mvn -U cargo:run -pl spring-functionaltest-web -P travis

Note:

Shutdown trigger is "Ctrl + C" on console.

[Step 7] Run functional tests

Run tests using Selenium(WebDriver) on JUnit.

$ cd {your repository directory}
$ mvn -U test -pl spring-functionaltest-selenium

Note:

If functional test is failed, try again using latest Selenium(specify with -Dselenium.version={latest version}).

Note:

When using JDK 7, please build as follows.

$ mvn -U test -pl spring-functionaltest-selenium -Djava-version=1.7 -P build-for-jdk7

Appendix

How to use latest or any branch snapshot of Common Library

If latest or any branch snapshot of Common Library want to use, install latest or any branch snapshot before build and test.

Clone terasoluna-gfw repository into local machine

$ git clone https://github.com/terasolunaorg/terasoluna-gfw.git

Install latest or any branch snapshot of Common Library into local machine

$ cd {your repository directory of terasoluna-gfw}
$ git checkout {target branch}
$ mvn -U clean install

How to build war for various environments

Using the maven profile , build the war in accordance with the environment that you want to deploy.

$ cd {your repository directory}
$ git checkout {target branch}
$ mvn -U package -am -pl spring-functionaltest-web -P weblogic-oracle,warpack-env

Profiles that are available are as follows.

The Combination of application server and a database

environments specify maven profiles
Tomcat8.5 + Postgresql tomcat85-postgresql,warpack-env,warpack-jstl,warpack-cxf,warpack-transaction,travis
Tomcat8.5 + Postgresql 1 tomcat85-postgresql,warpack-jstl,warpack-cxf,warpack-transaction
Tomcat8.5 + Oracle 1 tomcat85-oracle,warpack-jstl,warpack-cxf,warpack-transaction
Tomcat8 + H2 (not specify)
Tomcat8 + Postgresql tomcat8-postgresql,warpack-env,warpack-jstl,warpack-cxf,warpack-transaction,travis
Tomcat8 + Postgresql 1 tomcat8-postgresql,warpack-jstl,warpack-cxf,warpack-transaction
Tomcat8 + Oracle 1 tomcat8-oracle,warpack-jstl,warpack-cxf,warpack-transaction
Tomcat7 + Postgresql tomcat-postgresql,warpack-env,warpack-jstl,warpack-cxf,warpack-transaction,travis
Tomcat7 + Postgresql 1 tomcat-postgresql,warpack-jstl,warpack-cxf,warpack-transaction
Tomcat7 + Oracle 1 tomcat-oracle,warpack-jstl,warpack-cxf,warpack-transaction
Weblogic + Oracle weblogic-oracle,warpack-env
JBoss7 + Postgresql jboss7-postgresql,warpack-env
JBoss + Postgresql jboss-postgresql,warpack-env,warpack-transaction
Interstage + Postgresql interstage11-postgresql,warpack-env
WebOTX + Oracle webotx-oracle,warpack-env
WebSphere(LP) + DB2 webpshere-db2,warpack-env,change-wsdl-location

The JVM version of build and runtime environment

environments specify maven profile
Java8 (not specify)
Java7 build-for-jdk7

How to switch bean definition for various environments

Using the spring profile , enable to switch the bean definition in accordance with the environment that you want to run.

<context-param>
    <param-name>spring.profiles.active</param-name>
    <param-value>nonMailServer,nonMqServer</param-value>
</context-param>

Profiles that are available are as follows.

Connecting mail server

environments specify spring profiles
using embedded GreenMail nonMailServer (default)
using actual Mail Server mailServer 1

Connecting message queue

environments specify spring profiles
using embedded ActiveMQ nonMqServer (default)
using actual Message Queue mqServer 1

Footnotes

  1. Please deploy spring-functionaltest-web.war, spring-functionaltest-env.jar, and context.xml. 2 3 4 5 6 7 8

spring-functionaltest's People

Contributors

tiwatsuka avatar

Watchers

James Cloos avatar Kazuki Shimizu avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.