Jenkins and Maven SQL Plugin for cleaning Postgresql database

How many times did you experienced issue, when you need to clean your database from unused data ?For example, you have a qa server with thousands of rows, which you don’t need anymore, so it’s time to delete them. To clean up your database, someone call separate scripts for each table, someone create-drops database.I decided to delete all tables. To remove all rows, you can use maven sql plugin, which has powerful possibilities for doing work with sql. First of all, if you have your maven application, I would reccomend to create separate module for sql. If you don’t want to do this, just leave it as it is in your root pom.xml. You will need to add Maven Sql Plugin. Then, you need to map execution to install goal. You will need to create resource folder.This will be the place, where you will store your scripts. Before we start I don’t want anyone to think, that such module is the best place for storing your database schemas creation.For this purposes there is a good framework called liquibase - it saves migration history and can surely know, what should be updated, and what should not. Such module is always good...

Google Guice - Hello world example

It has been more than two years since I first acquainted with Spring Dependency Injection technology. At first, I didn’t understood what it was, but after few weeks I realized what powerful instrument do I have. From that time I started to love this type of object instantiation and I really don’t want to instantiate objects in some other way. But today I want to represent you a new framework for bean instantiation - Google Guice. So, how to try this Google Guice dependency injection framework ? First of all, open your Eclipse/InteliJIDEA IDE and create maven project: write groupId, artifactId and other things. After that, go to your pom.xml file and add additional dependency: Then, you should create interface NotificationService: We will have multiple implementations of above service to show posibillities of Google Guice Email service is one of the implementations of NotificationService One thing that I noticed is that Google Guice has it’s own @Singleton annotation - from JSR330. Google Guice 3.0 added the support for JSR-330 and we can use annotations from com.google.inject or javax.inject package. Next, we will create second implementation of NotificationService - FacebookService: Consumer class Since we are implementing dependency injection in our application,...

Spring XML Namespaces handling

You all know, that spring supports xml namespaces for defining custom bean definition. For example, if you want to set mvn annotation driven benavior, you can write such code in your xml As you noticed, there is no <bean … /> in this piece of code, but there is So, who is responsible for handling this namespaces? Answer is: NamespaceHandler For example, here is AnnotationDrivenBeanDefinitionParser implementation. Every Spring namespace has an associated NamespaceHandler implementation. The namespace schemas are mapped to schema files inside Spring JARs in various spring.schemas files. The XML schema namespaces are also mapped to handler classes in spring.handlers files (several as each Spring JAR might introduce different namespaces). For your convenience here is a list of most common namespaces: Spring core aop - AopNamespaceHandler c - SimpleConstructorNamespaceHandler cache - CacheNamespaceHandler context - ContextNamespaceHandler jdbc - JdbcNamespaceHandler jee - JeeNamespaceHandler jms - JmsNamespaceHandler lang - LangNamespaceHandler mvc - MvcNamespaceHandler oxm - OxmNamespaceHandler p - SimplePropertyNamespaceHandler task - TaskNamespaceHandler tx - TxNamespaceHandler util - UtilNamespaceHandler Spring Security security - SecurityNamespaceHandler oauth - OAuthSecurityNamespaceHandler Spring integration int - IntegrationNamespaceHandler amqp - AmqpNamespaceHandler event - EventNamespaceHandler feed - FeedNamespaceHandler file - FileNamespaceHandler ftp - FtpNamespaceHandler gemfire - GemfireIntegrationNamespaceHandler groovy - GroovyNamespaceHandler...

Develop your Angular.js application with Yeoman, Grunt and Bower

I position myself as backend developer, but I truly undestand, that I should know more about frontend world. So, by this post, I will start investigating frontend world. This time I will try angular.js - popular framework for building responsive web applications. Notice, that raw angular.js withour any thirdparty libraries is not so powerful, so I will be using Yeoman, Grunt and Bower in this article for convenient work. Expectation This tutorial will cover: Generating of bare angular.js project. Use Grunt to make testing Use Grunt to deploy application Use Bower to add thirdparty plugins Making some little changes to our application. I assume that you have already installed npm package manager. Prerequisites To be confident during this tutorial I recommend you to have the following skills and resources available: Basic knowledge of command line node.js and npm Knowledge of HTML, CSS, JS Ready, and tested Vanilla JS framework :D (Just joke) Resources You can find this project on his GitHub page Installation Before installation, I should say some words about setting up npm. When I first downloaded and installed npm on OS X and tried to configure project from various tutorials - I received plenty of permission exceptions in...

Testing RESTful CRUD Web Service with Gatling Tool

If you follow the right way of designing your web app, and choosed RESTful architecture, then it should be easy for you to test your appplication. By the REST style, you should implement CRUD operations for each entity in your application. What does it mean: You should be able to Create,Read, Update, Delete(CRUD) your entities. You should provide statuses for each operations. For example, for Create operation you should have 201 status in case of succesful operation. You application must have good exception handling. For example, if you will make GET request for retrieving some entity called person with id - 1, and there will be no such record in your storage with this id, then you need to tell your user, that there is no such person, and set status to 404(Not found) So, given that you will keep in mind all information above and will design your app with such instructions. Now it’s time to write some tests. Which framework you should choose? I choosed Gatling framework. Reasons: It runs on jvm It has maven module Configuration As I mentioned above, I will use maven for building my app. So, I will create a separate module for running...