Lightning Talk by Ted Young. What is Integration Testing?

Slides:



Advertisements
Similar presentations
Java OSS Web Technologies By Dave Ford Introduction Purpose Describe Javas relationship to the OSS community Describe OSS tools used on recent project.
Advertisements

CTS2 DEVELOPMENT FRAMEWORK CTS2 Overview. Schedule What is it? Why a framework? What does this do for me? Plugins Implementations available now CTS2 Compliance.
Mock junit framework uses pre- populated mock java objects instead of live database connection for executing the unit test cases.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Tool Naming Tips Aaron Zeckoski
Dependency injection when you only have one dependency JavaZone Johannes Brodwall, Recovering Spring User Steria Norway.
Developing in CAS. Why? As distributed you edit CAS 3 with Eclipse and build with Maven 2 – Best Practice for Release Engineering – Difficult edit-debug.
@mnriem#DV14 #MVC MVC 1.0 in JavaEE 8 A long time coming, or like some would say “finally!” Why are we doing it now? Survey input Customer input JavaEE.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Unit and Functional Testing with JUnit and Related Tools Greg Barnes University of Washington
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Lecture 10: Web Services. Outline Overview of Web Services Create a Web Service with Sun J2EE (JAX-RPC)
Pragmatic Application Building: Step by Step Jay Sissom Principal Systems Analyst Indiana University
An Introduction To the Spring M.V.C. Framework Reference From Website By Tom Kochanowicz.
Structure of a web application1 Dr Jim Briggs. MVC Structure of a web application2.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Stateful Web Application Development with Spring Web Flow John Case Senior Consultant Centare Group, Ltd.
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Thomas Ferris Nicolaisen - Objectware. Sprint TestContext Framework Thomas Ferris Nicolaisen Objectware JavAcademy desember 2007.
UNIT-V The MVC architecture and Struts Framework.
Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Maven & Bamboo CONTINUOUS INTEGRATION. QA in a large organization In a large organization that manages over 100 applications and over 20 developers, implementing.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
CDM Developer Workshop. TDWG Andreas Kohlbecker Taxonomic Workflow in the EDIT Platform for Cybertaxonomy Purpose What do you want from this workshop?
OpusCollege and the use of Spring and iBatis
Introduction to Java Server Pages (JSPs) Robert Thornton.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Understanding the Bean Lifecycle An.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
JBoss Seam Presented by Andy Nguyen Truc Pham. What is JBoss Seam? Created by Gavin King Created by Gavin King A lightweight framework for Java EE 5.0.
Anti Orgla, Nortal AS Spring Framework
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
1 Apache TomEE // JavaEE Web Profile on Tomcat Jonathan #TomEE.
The perfSONAR Test Harness Brian Tierney, LBNL/ESnet.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Views Rendering custom views.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Testing Spring Applications Unit Testing.
Test it! Unit, mocking and in-container Meet Arquillian! Ivan St. Ivanov.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
Unit, Regression, and Behavioral Testing Based On: Unit Testing with JUnit and CUnit by Beth Kirby Dec 13, 2002 Jules.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
CAS 3 Introduction and Overview. CAS2 is simple to understand 6 servlets and fewer than 10 JSPs 6 servlets and fewer than 10 JSPs auth package – where.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Developing Rich Web Applications with.
Multi-purpose tests (Cool tricks with JUnit) JavaZone 2012 Johannes Brodwall, Principal Architect Steria
Chapter 2 Java Struct 2. Content Basic MVC Architecture Struts 2 Overview Struts 2 - Architecture.
Test Java EE applications with Arquillian Ivan St. Ivanov.
Testing PA165 Dec 9, 2014 Petr Adámek, Tomáš Pitner.
1 EJB 3.0: There’s Something Different About You Martin Jäkle, TSBU Middleware.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
J2EE Lecture 6: Spring – IoC and Dependency Injection
Structure of a web application
Understanding SOAP and REST calls The types of web service requests
Testing with Spring Boot
Spring Boot Introduction
CS520 Web Programming Spring – Inversion of Control
An Introduction To the Spring M.V.C. Framework
מבוא ל Groovy אליהו חלסצ'י תכנות מתקדם תרגול מספר 12
Intro to Spring CJUG - January 2013.
CS5220 Advanced Topics in Web Programming Spring – Web MVC
CS5220 Advanced Topics in Web Programming Spring – Web MVC
CS4961 Software Design Laboratory Understand Aquila Backend
Presentation transcript:

Lightning Talk by Ted Young

What is Integration Testing?

Unit TestIntegration Test IsolationEntire Stack Unit Versus Integration Tests

Unit TestIntegration Test IsolationEntire Stack Inject MocksInject Implementations Unit Versus Integration Tests

Unit TestIntegration Test IsolationEntire Stack Inject MocksInject Implementations Verifies CodeVerifies Application Unit Versus Integration Tests

public void persist(Foo foo) { entityManager.persist(foo); } public List find() { return entityManager.createQuery("from Foo").getResultList(); } public List findByName(String name) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery query = cb.createQuery(Foo.class); Root root = query.from(Foo.class); query.where(cb.equal(root.get(Foo_.name), name)); return entityManager.createQuery(query).getResultList(); } Unit Tests Arent Always Best

External Tool (e.g. JMeter)Test Harness (e.g. JUnit) External ToolIDE, Maven, CI, etc. Integration Testing Controllers

External Tool (e.g. JMeter)Test Harness (e.g. JUnit) External ToolIDE, Maven, CI, etc. Script ActionsBuild Requests in Java Integration Testing Controllers

External Tool (e.g. JMeter)Test Harness (e.g. JUnit) External ToolIDE, Maven, CI, etc. Script ActionsBuild Requests in Java No Knowledge of ApplicationIntimate Knowledge of Application: Security System Data Model Make Use of Spring Integration Testing Controllers

External Tool (e.g. JMeter)Test Harness (e.g. JUnit) External ToolIDE, Maven, CI, etc. Script ActionsBuild Requests in Java No Knowledge of ApplicationIntimate Knowledge of Application: Security System Data Model Make Use of Spring Refactor = RewriteMake Use of IDE Tools Integration Testing Controllers

External Tool (e.g. JMeter)Test Harness (e.g. JUnit) External ToolIDE, Maven, CI, etc. Script ActionsBuild Requests in Java No Knowledge of ApplicationIntimate Knowledge of Application: Security System Data Model Make Use of Spring Refactor = RewriteMake Use of IDE Tools Errors at RuntimeErrors at Compiletime Integration Testing Controllers

Testing a Controller Servlet Container Controller

Testing a Spring MVC Controller Servlet Container Controller Spring MVC

Testing a Spring MVC Controller Servlet Container Controller Spring MVC View Resolution Transactions Request Mapping

Testing a Spring MVC Controller Servlet Container Controller Spring MVC View Resolution Transactions Request Mapping DispatcherServlet

Mocking DispatcherServlet DispatcherServlet

Mocking DispatcherServlet DispatcherServlet WebApplicationContext

Mocking DispatcherServlet DispatcherServlet WebApplicationContext ServletConfigServletContext

public class SomeControllerTests {... } Spring and JUnit

locations="classpath:spring.xml", loader=MockWebApplicationContextLoader.class) public class SomeControllerTests {... } Spring and JUnit

locations="classpath:spring.xml", name="some-controller", webapp="/src/main/webapp") public class SomeControllerTests {... } Spring and JUnit

How Many Use: JSPs Velocity Freemarker Facelets View Technologies

@Autowired private DispatcherServlet private SomeRepository public void viewTest() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/view"); request.addParameter("id", "0"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); String results = response.getContentAsString().trim(); Assert.assertEquals( " Hello World! ", results); } An Example Test

@Test public void saveTest() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); request.addParameter("name", "Ted"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); Assert.assertEquals("Ted", repository.find(1).getName()); } Prepare and Review Model

@Test(expected=NestedServletException.class) public void saveFailedTest() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); request.addParameter("name", ""); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); } Test Validation

@Test(expected=NestedServletException.class) public void secureFailedTest() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/secure/view"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); } Test Security

@Test public void secureTest() throws Exception { SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken( "Ted", "password")); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/secure/view"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); String results = response.getContentAsString().trim(); Assert.assertEquals( " Hello Ted! ", results); } Test Security