Sample Java Spring app for your abuse and amusement
This page describes the various ways to install and use a simple Java application for learning Java Spring and exploring JVM tools.
The app provides a shopping cart because it’s a common use case on the internet. Different items within several categories (of pets).
Landing page (Main Menu)
The page has 3 columns under a header. The image above was adjusted to the smallest width without wrapping. The page design is HTML4 transitional, not HTML5 “responsive” for mobile, which is an SEO issue.
Thankfully, one company has it running all the time at http://demo.kieker-monitoring.net/jpetstore/actions/Catalog.action It rated 90/100 for Desktop on Google Page Speed and 83/100 for Mobile. Google recommends:
Leverage browser caching. Setting an expiry date or a maximum age in the HTTP headers for static resources (.gif media files) instructs the browser to load previously downloaded resources from local disk rather than over the network.
The css file is not mimified.
Use case loops
An explanation of the UI actions is available by clicking the (?) on the heading, at
This site map is from the comparison by Clinton Begin (of Alberta):
Performance testing needs a set of loops to impose artificial load.
Landing page and Info (?) page for network variability measurement.
Browsing through items (without login or buying) to specifically stress the web server.
Rather than coding to click specific items, this activity is often specified by a file with the test program iterates through.
Register to see how many the system can accommodate when the system is widely announced to the public.
QUESTION: j2ee is the default user? What’s the password?
The user registration link is not on the landing page (Main Menu), reached after a click of Sign In.
TODO: Variations in registration data from a file to load various users.
Login to see what happens when everyone arrives at the same time (such as at a call center during start of shift).
Search form usage, especially for form fields that return an autocomplete list for user ease-of-use.
Add to cart from an item listing, which adds to the database for each unique user, specifically to stress the database.
Purchase to ensure that payment gateways can keep up with a lot of people buying at once.
Except the JPetStore app does not connect with a payment gateway.
End-to-end with all the above to ensure that the system can handle a pattern of work during scalability testing (to emulate a mention on Reddit or Hacker News that causes a buying frenzy).
My Orders lists order history for a user, by reading from the database. A link to it is at the bottom of the User Information page after a user is logged in and has completed an order.
Additionally, there are error responses to each of the above, created by “negative” tests:
Server unavailable (NGINX).
Item not available during browsing.
Registration error (such as bad email, user already defined, etc.).
Login error, such as forgotten password change.
Search not found.
Options for performance testing apps
Since JPeterStore was built for developers, missing are some features in the WebTours app Mercury/HP built to use as a sample app during demos and training for LoadRunner.
Pattern of iteration
To mimic real-life load across the various pages, not every iteration would invoke “My Orders”. So the automation scripts would need to use a percentage chance when the action is performed.
Ideally, we would have a data-driven approach where a file external to the code specifies the pattern of invocation. This approach would not require a re-compile after changes.
QUESTION: How to reset the Orders data for a user?
On the Main Menu, there are links to category lists from the text at the left, the headings at the top, and icons at the center.
On the heading, when a user is signed in, “Sign In” changes to “My Account”.
User Profile Options
These change behavior, which automation scripts need to respond to:
WARNING: There are several obsolete versions on the internet, such as v4 on Sourceforge.
There are several variations
TODO: Create a bootstrap script that does the following:
Create a folder to hold. I prefer to have a container folder (jpetstore) because there are multiple repositories:
is an alternative from Kazuki Shimizu of Japan. It is implemented using Thymeleaf 3.0 templating.
In a Terminal, obtain the whole repository with its history:
git clone https://github.com/mybatis/jpetstore-6.git cd jpetstore-6
Have Maven download and install dependencies defined in pom.xml:
mvn clean package
JPetStore 6 should run in any Servlet 2.5 y JSP 2.1 compliant Java server.
Eclipse is not needed. You can run the sample from your favorite IDE or the command line.
Startup the Tomcat server and deploy web application using the Cargo Maven plug-in
The pom.xml file has several versions of Tomcat loaded.
In a browser, use the app as a user:
You should now see the entry screen:
Click “Enter the store” for the main menu.
To change the port from the default 8080 to something else, edit file:
Scroll down to the line:
<Connector SSLEnabled=”false” URIEncoding=”ISO-8859-1” connectionTimeout=”20000” port=”8080” protocol=”HTTP/1.1” redirectPort=”8443” scheme=”http” secure=”false”/>
Change the number.
Save the file and restart the server.
Java 1.6 and above (1.8.11 at January 2017)
Stripes - https://github.com/StripesFramework
MyBatis 3 SQL mapping framework for Java
MyBatis mappers and dependency injection lets you build applications without dependencies. Thus, the source has no code to deal with JDBC, to create objects or bind them or to handle transactions.
(There is a port to .NET)
The iBATIS Database Layer uses simple XML descriptor filesto describe the inputs and outputs of each SQL statement. It allows the programmer to simply pass a JavaBean into a MappedStatement as a parameter (input) and receive a JavaBean as a result (output).
Formatter Tag Library by Tak Yoshida of ibatis.
Tomcat web server from the Apache Foundation.
JUnit for Mokito
Used by tests
Online Solution http://demo.kieker-monitoring.net/
JPetStore v6 is vendor-independent open source freeware first released in 2002 in 3,154 lines of code. It uses the Jakarta Struts Model-View-Controller based presentation layer. It has NO SQL in code nor stored procedures running in a database, so is independent of database vendors (Oracle SQL in particular). PostgreSQL is free.
It has no generated code, nor HTML in the database.
Eclipse is not required, but there is a MyBatis plug-in
Docs at http://www.mybatis.org/jpetstore-6/ says:
The purpose of JPetStore 6 is to demonstrate how to build a web application with very few classes and no advanced coding skills. You just need to know plain Java and SQL.
Java source code is in the src/mainjava/org/mybatis/jpetstore folder.
Sun created a J2EE Pet Store, in a massive 15,000 lines, as a demonstration of various coding features (not for benchmarking).
Microsoft contracted with Vertigo Software to create a sample .Net Pet Shop when it orginally debuted its .NET framework. The repo had 3,484 lines of code and was tuned for benchmarking speed rather than coding best practices.
More on IoT
This is one of a series on IoT:
- IoT Apprentice school curriculum
- IoT use cases
- IoT reminders prevent dead mobile battery
- IoT text to speech synthesis
- IoT AWS button
- Intel IoT
- IoT Raspberry hardware
- IoT Clouds
- Predix basics
- Predix installation
- Predix services
- Predix programming