Creating A Walking Skeleton



Similar documents
Arjun V. Bala Page 20

Chapter 1. JOnAS and JMX, registering and manipulating MBeans

Implementing a Web Service Client using Java

Managing Data on the World Wide-Web

Volta Log Library user manual

SSO Plugin. HP Service Request Catalog. J System Solutions. Version 3.6

Web Application Architecture (based J2EE 1.4 Tutorial)

Creating Java EE Applications and Servlets with IntelliJ IDEA

ANTAL Margit. Sapientia - EMTE, Pannon Forrás,,Egységes erdélyi felnőttképzés a

SpiraTest / SpiraTeam Automated Unit Testing Integration & User Guide Inflectra Corporation

Unit Testing & JUnit

JSP. Common patterns

Tutorial for Spring DAO with JDBC

JUnit Automated Software Testing Framework. Jeff Offutt. SWE 437 George Mason University Thanks in part to Aynur Abdurazik. What is JUnit?

Mastering Tomcat Development

SSO Plugin. Authentication service for HP, Kinetic, Jasper, SAP and CA products. J System Solutions. JSS SSO Plugin Authentication service

Servlet and JSP Filters

PA165 - Lab session - Web Presentation Layer

Appium mobile test automation

Active Directory Authentication Integration

FaxCore 2007 Getting Started Guide (v1.0)

Intellicus Single Sign-on

Advanced OpenEdge REST/Mobile Security

Integration of Shibboleth and (Web) Applications

SSO Plugin. Authentication service for HP, Kinetic, Jasper, SAP and CA products. J System Solutions. Page 1 of 23.

Oracle WebLogic Server

White Paper March 1, Integrating AR System with Single Sign-On (SSO) authentication systems

OPENRULES. Release TUTORIAL Cloud Application Development

Web Container Components Servlet JSP Tag Libraries

RUP. Development Process. Iterative Process (spiral) Waterfall Development Process. Agile Development Process. Well-known development processes

How To Write A File Station In Android.Com (For Free) On A Microsoft Macbook Or Ipad (For A Limited Time) On An Ubuntu 8.1 (For Ubuntu) On Your Computer Or Ipa (For

Web Applications. Originals of Slides and Source Code for Examples:

Web Applications. For live Java training, please see training courses at

Social Enterprise Java Apps

Multiple vulnerabilities in Apache Foundation Struts 2 framework. Csaba Barta and László Tóth

+ Introduction to JUnit. IT323 Software Engineering II By: Mashael Al-Duwais

Configure a SOAScheduler for a composite in SOA Suite 11g. By Robert Baumgartner, Senior Solution Architect ORACLE

Using Blackboard Learn 9 Web Services - Part 2 Learning About The Web Service Classes And Methods

Virtual Code Authentication User Guide for Administrators

Author: Sascha Wolski Sebastian Hennebrueder Tutorials for Struts, EJB, xdoclet and eclipse.

Install guide for Websphere 7.0

CIMHT_006 How to Configure the Database Logger Proficy HMI/SCADA CIMPLICITY

JusticeConnect AVL for Windows SETUP GUIDE

How To - Implement Single Sign On Authentication with Active Directory

Active Directory Requirements and Setup

Overview of Web Services API

PC Monitor Enterprise Server. Setup Guide

Apache Shiro - Executive Summary

HttpUnit Laboratorio di Sistemi Software - A.A. 2003/2004

LAB 6: Code Generation with Visual Paradigm for UML and JDBC Integration

Hello World RESTful web service tutorial

Ad Hoc (Temporary) Accounts Instructions

IIS, FTP Server and Windows

Oracle Hyperion Financial Management Custom Pages Development Guide

HowTo. Planning table online

Summer Internship 2013

UPGRADING TO XI 3.1 SP6 AND SINGLE SIGN ON. Chad Watson Sr. Business Intelligence Developer

Test Automation Integration with Test Management QAComplete

Upgrading Your Web Server from ClientBase Browser Version 2.0 or Above to Version 2.1.1

BIRT Application and BIRT Report Deployment Functional Specification

Word count example Abdalrahman Alsaedi

Ch-03 Web Applications

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

Pierce County IT Department GIS Division Xuejin Ruan Dan King

Virtual Code Authentication User s Guide. June 25, 2015

Download/Install IDENTD

Java Unit testing with JUnit 4.x in Eclipse

VoIPon Tel: +44 (0) Fax: +44 (0)

A detailed walk through a CAS authentication

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

Jiří Tomeš. Nástroje pro vývoj a monitorování SW (NSWI026)

Creating Custom Web Pages for cagrid Services

Oracle Hyperion Financial Management Developer and Customization Guide

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

How to Write AllSeen Alliance Self- Certification Test Cases September 25, 2014

WHMCS LUXCLOUD MODULE

Mobile Solutions for Data Collection. Sarah Croft and Laura Pierik

Onset Computer Corporation

How do I use Citrix Staff Remote Desktop

Hadoop Setup. 1 Cluster

MIGRATING TO AVALANCHE 5.0 WITH MS SQL SERVER

Knoa MicroStrategy Web Configuration Table of contents

Part I. OpenCIT Server

Start Here. Installation Guide. Rosetta Stone Standalone License. This Guide Will Show You How To: Install the Student Management System...

Ehcache Web Cache User Guide. Version 2.9

Database Applications Recitation 10. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Please send your comments to:

Zebra and MapReduce. Table of contents. 1 Overview Hadoop MapReduce APIs Zebra MapReduce APIs Zebra MapReduce Examples...

Lucid Key Server v2 Installation Documentation.

Continuous Integration

MSI Admin Tool User Guide

JWIG Yet Another Framework for Maintainable and Secure Web Applications

Developer's Guide: Driving Tivoli Workload Automation

Step 4: Configure a new Hadoop server This perspective will add a new snap-in to your bottom pane (along with Problems and Tasks), like so:

Java Web Programming. Student Workbook

Web Applications Testing

Setting Up Scan to SMB on TaskALFA series MFP s.

Active Directory Integration

Content Management System

Hadoop Basics with InfoSphere BigInsights

Transcription:

Creating A Walking Skeleton Write and Automate First Acceptance Test Automate Build and Package Automate Deploy Implement Feature Automate Static Analysis Automate Code Coverage & Integration Test 1. Add an abstract JUnit test class called AbstractLogin to the common package: import static org.junit.assert.assertequals; import java.io.ioexception; import java.net.malformedurlexception; import org.junit.after; import org.junit.before; import org.junit.test; import com.gargoylesoftware.htmlunit.failinghttpstatuscodeexception; import com.gargoylesoftware.htmlunit.webclient; import com.gargoylesoftware.htmlunit.html.htmlpage; public abstract class AbstractLogin private WebClient webclient; // HTML Unit @Before public void setup() throws Exception webclient = new WebClient(); @After public void teardown() throws Exception webclient.closeallwindows(); @Test public void LoginPageIsDisplayedWhenAccessingTheApplicationForTheFirstTime() throws FailingHttpStatusCodeException, MalformedURLException, IOException final HtmlPage page = webclient.getpage(getappurl()); assertequals("login Page", page.gettitletext()); protected abstract String getappurl();

2. Add a new class call LoginTest to the integration package: import walkingskeleton.common.abstractlogin; public class LoginTest extends AbstractLogin private final static String APP_URL = "http://localhost:8080/walkingskeleton"; protected String getappurl() return APP_URL; 3. Add compile test target to build.xml: <import file="$buildfiles.dir/compile.xml"/> <target name = "compile-test" depends = "init"> <antcall target="compile.compile-test"/> <target name = "ci-build" depends = "clean, compile-test"/> 4. Add acceptance test target to build.xml: <!-- Acceptance Test --> <import file="$buildfiles.dir/test.xml"/> <target name = "acceptance-test" depends = "compile-test"> <antcall target="test.run-acceptance-test"/> <target name = "ci-build" depends = "clean, acceptance-test"/> 5. Add a package called walkingskeleton.sl.logging to the src folder.

6. Add a class called Log4jInitListener to the logging package: import javax.servlet.servletcontextevent; import javax.servlet.servletcontextlistener; import org.apache.log4j.logger; import org.apache.log4j.propertyconfigurator; public class Log4jInitListener implements ServletContextListener private static final Logger log = Logger.getLogger(Log4jInitListener.class); public void contextinitialized(servletcontextevent ce) final String prefix = ce.getservletcontext().getrealpath("/"); final String file = ce.getservletcontext().getinitparameter("log4j-initfile"); if ( file!= null ) final String path = prefix + "/" + file; PropertyConfigurator.configure(path); log.info("log4j configured by file " + path); public void contextdestroyed(servletcontextevent arg0) /* No op. */ 7. Add compile & compress targets: <import file="$buildfiles.dir/compile.xml"/> <target name = "compile" depends = "init"> <antcall target="compile.compile"/> <import file="$buildfiles.dir/compress.xml"/> <property name = "jar.file" value="$build.lib.dir/walkingskeleton.jar" /> <target name = "compress" depends="compile"> <antcall target="compress.compress"/> <target name = "ci-build" depends = "clean, compress, run-acceptancetest"/> 8. Add package target: <import file="$buildfiles.dir/package.xml"/> <property name = "war.file" value="$build.dir/$webapp.name.war"/> <target name = "package" depends="compress"> <antcall target="package.package"/>

9. Add deploy target: <import file="$buildfiles.dir/deploy.xml"/> <target name = "deploy" depends="package"> <antcall target="deploy.deploy-webapp"/> 10. Update run acceptance test target: <target name = "run-acceptance-test" depends = "deploy,compile-test"> And ci-built task: <target name = "ci-build" depends = "undeploy-webapp, clean, runacceptance-test"/> 11. Add spring web.xml configuration: <listener> <listener-class> org.springframework.web.context.contextloaderlistener </listener-class> </listener> <context-param> <param-name>contextconfiglocation</param-name> <param-value> /WEB-INF/security-app-context.xml </param-value> </context-param> <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class> org.springframework.web.filter.delegatingfilterproxy </filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 12. Copy security-app-context.xml to WEB-INF direcotry. Run test and see it pass.

13. Add remaining tests to AbstractLogin: import static org.junit.assert.fail;... @Test public void BadUsernameResultsInErrorMessage() fail("not Implemented"); @Test public void BadPasswordResultsInErrorMessage() fail("not Implemented"); @Test public void CorrectCredentialsDisplayHomePage() fail("not Implemented"); 14. Add test constants to AbstractLogin: private static final String USERNAME private static final String PASSWORD private static final String BAD_USERNAME private static final String BAD_PASSWORD private static final String ERROR_MSG = "admin"; = "admin"; = "bad username"; = "bad password"; = "Reason: Bad credentials";

15. Add login helper method to AbstractLogin: private HtmlPage login(string username, String password) try final HtmlPage page = webclient.getpage(getappurl()); final HtmlForm form = page.getformbyname("f"); if (username!= null) final HtmlTextInput usernamefield = form.getinputbyname("j_username"); usernamefield.setvalueattribute(username); if (password!= null) final HtmlPasswordInput passwordfield = form.getinputbyname("j_password"); passwordfield.setvalueattribute(password); final HtmlSubmitInput submitbtn = form.getinputbyname("submit"); return submitbtn.click(); catch(exception e) throw new RuntimeException(e); 16. Add implementation for next test: import static org.junit.assert.assertthat; import static org.junit.matchers.junitmatchers.containsstring;... inal HtmlPage page = login(bad_username, PASSWORD); assertthat(page.asxml(), containsstring(error_msg)); 17. Add final test: final HtmlPage page = login(username, PASSWORD); assertequals("walking Skeleton", page.gettitletext()); assertthat(page.asxml(), containsstring("welcome!")); 18. Add static code analysis to build.xml: <!-- Statis Analysis --> <import file="$buildfiles.dir/check.xml"/> <target name = "ci-build" depends = "undeploy-webapp, clean, acceptancetest, check"/> 19. Add: @SuppressWarnings("PMD.VariableNamingConventions") to Login4JInitListener.java. Add: @SuppressWarnings("PMD.TestClassWithoutTestCases")

to LoginTest.java. 20. Fix Eclipse warnings: Java Compiler->Errors / Warnings -> Enable Project Specific Settings->Unhandled token in @SuppressWarnings->Ignore. 21. Add integration LoginTest.java: import net.purpletube.embeddedtomcat.embeddedtomcat; import net.purpletube.embeddedtomcat.servletcontainer; import net.purpletube.embeddedtomcat.startstoptimer; import walkingskeleton.common.abstractlogin; @SuppressWarnings("PMD.TestClassWithoutTestCases") public class LoginTest extends AbstractLogin private final static int PORT = 8890; private final static String CONTEXT = "/WalkingSkeleton"; private final static String WAR_PATH = "./war"; private final ServletContainer server = new StartStopTimer( new EmbeddedTomcat(CONTEXT, WAR_PATH, PORT)); public void setup() throws Exception server.start(); super.setup(); public void teardown() throws Exception super.teardown(); server.stop(); protected String getappurl() return server.geturl(); 22. Add code coverage task: <!-- Coverage --> <import file="$buildfiles.dir/coverage.xml"/> <target name = "coverage" depends = "compile-test"> <antcall target="coverage.coverage"/> <target name = "ci-build" depends = "undeploy-webapp, clean, acceptancetest, check, coverage"/>

23. Add context parameter for log4j properties file and listener: <context-param> <param-name>log4j-init-file</param-name> <param-value> WEB-INF/log4j.properties </param-value> </context-param> <listener> <listener-class> walkingskeleton.sl.logging.log4jinitlistener </listener-class> </listener>