Getting in touch with Liquibase Migration Tool

Have you experienced a situation, when you had a database in your system, and you needed to migrate all it’s structure, to, say, another database ? Of course, you faced such situations and, of course, you manually copied all data from one server instance to another ? Something familiar ? Alternative approach How about idea of writing high-level instructions on how to deal with your database ? For example, you say “Create this table, and add this column , and insert this index, …” only once and all subsequent times you will just reuse this instructions ? Such idea is called “Database migration tool”, there is several migration frameworks for java, but I will show how to work with single tool - liquibase. The idea is that you store this instructions in xml files and when you run your liquibase migration script for the first time, liquibase will create two tables in your database databasechangelog and databasechangeloglock, where all information about running migrations kept. Say, you have only one migration changeset To run such script I use maven, here is pom.xml,as usual mvn liquibase:update If you wish, you can run liquibase from command line, the only thing you need is...

Spark - Micro Web Framework for creating web applications with minimal effort

Today I am going to write few words about Spark framework - micro framework for rapid web application development. Requirements Java 8 installed. We’re goind to use lambdas. Maven 3.+ Eclipse IDE Creating project Navigate to your project desired location and execute in terminal: mvn archetype:generate -DgroupId=org.ivanursul.spark -DartifactId=spark-example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false Then open your IDE and import maven project Adding dependency To include required libraries just add one dependency <dependency> <groupId>com.sparkjava</groupId> <artifactId>spark-core</artifactId> <version>2.1</version> </dependency> Don’t forget to add maven-compiler-plugin Now you are ready to write some code. Official site says, that it is enough to write something like import static spark.Spark.*; public class HelloWorld { public static void main(String[] args) { get("/hello", (req, res) -> "Hello World"); } } and after execution of program you car test this app by typing http://localhost:4567/hello Seems to be very easy, but let’s try something harder. Implementing CRUD operations To implement CRUD(create, remove, update, delete) for, say, person entity, we will gonna need: DTO(Person) Serializer/Deserializer(GSON? :) ) Note, that I will do it as simple, as I can, without any structures, just for testing this framework. Let’s start Add gson dependency <dependency> <groupId></groupId> <artifactId>gson</artifactId> <version>2.3.1</version> </dependency> Create person class Create main class That seems to...

How to integrate Jenkins with Bitbucket

Recently I had an issue with integrating Jenkins CI with Bitbucket CVS. My goal was to trigger jenkins to start running job, when commit to bitbucket will be pushed. Steps I made to made jenkins trigger job: Install Bitbucket plugin Set the Jekins job’s Build trigger to Poll SCM, but do not specify a schedule Create a github post-receive trigger to notify the URL http://yourserver/git/notifyCommit?url= example[email protected]:nick/project.git This will tell Jenkins to trigger whenever code in bitbucket will be changed. Note, that Jenkins will check whether changes were made and will start only in case of new changes in repository.

Gatling integration tool - making more flexibility

I recently had a chance to investigate how to increase flexibility of my integration test, written on gatling and scala. I have already written around 50 test cases, and I need couple of improvements: Be able to change url of my web service. By default, it should run on localhost, but as soon as I will configure continuous delivery, I will need to change web service url to some remote ip. For that needs I am planning to use maven preferences. More precise configuration of my setup function. By this time, I had no assertion strategies and I was confused that my tests go green even if some test case failed. Dynamic web service url I was hoping that gatling has something like Spring has - placeholders, but it occurs that the only way I can get property from maven is by system property val host = System.getProperty(“”) You also need to add additional configuration on your gatling plugin in maven <jvmArgs> <jvmArg>${integration.url}</jvmArg> </jvmArgs> Where ${integration.url} is taken from maven module properties Here is full pom.xml After this modification, You will be able to change your basicUrl mvn test -Dintegration.url=http:${REMOTE_IP}:8080/…. and my test scenarios will run on dedicated server. Such...

Java, Jenkins and UnsatisfiedLinkError

Today I experienced issue with Jenkins - After some system modifitcation I received failed build with message Caused by: java.lang.UnsatisfiedLinkError: > /home/${user}/tools/jdk1.7.0_71/jre/lib/i386/xawt/ cannot open shared object file: No such file or directory So I search in the internet and found the solution sudo apt-get install libxrender-dev sudo apt-get install libxtst-dev I’m really not sure what it was, I guess it could be because I accidentally installed openjdk instead of oracle jdk. In fact, It helped me.