Spring Boot starter cache is able to cache REST API response but expiring the cache will be troublesome to implement. Guava cache will solve this problem. Example below is a prototype from scratch on how to implement Guava cache.

Spring initializer



There are several ways that you could create a common reusable shared function in Karate Test Automation but I method I prefer is to write it in Java and then call it from the feature file.

By writing it in Java, it is easier to step through to debug if the function you are building has bugs in it. I’ve created a Java file named MyRandom.java and placed it at the location shown in the screenshot below.

The content of the MyRandom.java

Define the function in feature file background section and you will be able to call it like a normal function. See screenshot below.



I’m assuming JDK or JRE is installed and configured but currently missing Maven. To setup first download the binary tar.gz archive from https://maven.apache.org/download.cgi

Next deflate it to your preferred location. I like to put mine at ~/Documents/

mv apache-maven-3.8.7-bin.tar.gz ~/Documents 
cd ~/Documents
tar -xzvf apache-maven-3.8.7-bin.tar.gz

Now setup your PATH by editing .zprofile at home folder

vim .zprofile

Copy the below into your .zprofile and amend your path accordingly.

export M2_HOME='/Users/kevin/Documents/apache-maven-3.8.7'
export PATH

Close your terminal and reopen a new one. The changes should take effect already. Test your Maven by checking for its version.



Normally Apache Tomcat comes with the default index.html file. So if you go to http://localhost:8080/index.html with your web browser it will serve you the index.html file with HTTP status 200.

At the terminal, the HTTP status can be obtained with the following command.

curl -sI http://localhost:8080/index.html|head -1|awk '{print $2}'

This works if the Apache Tomcat is serving a file. What if it is a load balancer that listens to port 8080 but does not serve any files. To test if it is working and listening to port 8080. Use the following command.

nc -z localhost 8080 2>&1|grep succeeded|wc -l



My cheat sheet of array related functions. I’ll add more along the way when I use more of it.

Declaring Array

int[] ia = new int[3];
ia[0] = 9;
ia[1] = 8;
ia[2] = 7;

Char Array To String

char[] ca = {'a', 'p', 'p', 'l', 'e'};
String s = String.valueOf(ca);

Array Sort

String[] fruits = {"pear", "apple", "banana", "orange"};
for(String fruit:fruits){

Array List Sort

ArrayList<String> fruits = new ArrayList<String>();
# size
System.out.println(fruits.size()); # 4
# get item 0
System.out.println(fruits.get(0)); # apple

< Back to all the stories I had written



Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.