Oracle Developers
Published in

Oracle Developers

Build, deploy and test a Redis based Java application using Oracle Cloud

This blog will demonstrate how to get started with a Redis based Java application

  • Run it on Oracle Application Container cloud and CI/CD using Oracle Developer cloud
  • Execute Integration tests using NoSQLUnit
  • Our Redis instance will run in a Docker container on Oracle Container cloud

Application

Here is a summary of the what the application is about

  • Exposes REST endpoints using Jersey
  • Uses Redis as the data store
  • Jedis is used as the Java client for Redis
  • NoSQLUnit is the framework used for integration testing

Here is the application

NoSQLunit

NoSQLUnit is an open source testing framework for applications which use NoSQL databases. It works on the concept of (JUnit) Rules and a couple of annotations. These rules are meant for both database lifecycle (start/stop) as well as state (seeding/deleting test data) management. In the sample application, we use it for state management for Redis instance i.e.

  • with the help of a json file, we define test data which will be seeded to Redis before our tests start and then
  • use the annotation (@UsingDataSet) to specify the our modus operandi (in this case — its clean and insert)

Our test dataset in json format

NoSQLUnit in action

Setup

Redis on Oracle Container Cloud

  • Use the existing service or create your own (make sure you expose the default Redis port to the host IP) — documentation here
  • Start the deployment — documentation here
  • Note down the host IP of the worker node on which the Redis container is running

Configure Oracle Developer Cloud

We’ll start with bootstrapping the application in Oracle Developer Cloud. Check this section for reference Project & code repository creation. Once this is done, we can now start configuring our Build which is in the form of a pipeline consisting of the build, deployment, integration test and tear down phases

Build & deploy phase

The code is built and deployed on Oracle Application Container cloud. Please note that we are skipping the unit test part in order to keep things concise

Build step

Post-build (deploy)

Deployment

At the end of this phase, our application will be deployed to Application Container Cloud — its time to configure the integration tests

Integration test phase

Our integration tests will run directly against the deployed application using the Redis instance (on Oracle Container Cloud which we had setup earlier). For this

  • we define another build job and
  • make sure that it’s triggered after the build + deployment phase completes

Integration build job

Define the dependency

Tear Down phase

Thanks to Oracle Developer Cloud integration with Oracle PaaS Service Manager (PSM), it’s easy to add a PSMcli build step that invokes Oracle PaaS Service Manager command line interface (CLI) command to stop our ACCS application once the pipeline has been executed. More details in the documentation

We covered the following

  • Built a Java application on top of Redis
  • Orchestrated its build, deployment and integration test using Oracle Developer Cloud and Oracle Application Container Cloud
  • In the process, we also saw how its possible to treat our infrastructure as code and utilize our cloud services efficiently

Don’t forget to…

The views expressed in this post are my own and do not necessarily reflect the views of Oracle.

Aggregation of articles from Oracle engineers, Groundbreaker Ambassadors, Oracle ACEs, and Java Champions on all things Oracle technology. The views expressed are those of the authors and not necessarily of Oracle.

Recommended from Medium

How are 79.34% codes of double 11 modules generated intelligently

Love Yourself and Embrace Uncertainty

Relational NoSQL: Yes, that is an option

What is logical deletion and physical deletion?

Java extension mechanism — Self discovery & bean instantiation

5 Powerful Steps To Get Ahead at Work Without Playing Dirty

Tactics and manipulation, backstabbing, power plays, biased decisions, back channel communication

State Management in Flutter with BloC Pattern

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Gupta

Abhishek Gupta

Principal Developer Advocate at AWS | I ❤️ Databases, Go, Kubernetes

More from Medium

Deploying a Java application to Elastic Beanstalk by using GIT, CodeBuild, CodePipeline(CI/CD)

How to Configure CloudWatch to Monitor Spring Boot Application Log

OpenID Connect & OAUTH 2.0

Using Telepresence to intercept microservices on a Kubernetes cluster