Sunday, March 31, 2013

Integration testing of HTTP(S) communication with Java

Sometimes you want to be 100% sure your HTTP(s) client works exactly like it promises. That means you'll need tests. But what kind of? Just one real-life example: file downloading. How are you going to simulate connection lost, noisy network, broken data and all that weird network incidents? It could be done, partially, with the standalone HTTP servers. But they should be configured and have 100% uptime to use them in the continuous integration. Yes, we have mocks. They are unbeatable warriors of business logic testing. But, remember, we want to check everything, in fact, we just want to go through the real Client App <---> Network <---> Server App path.
That what I'm going to talk about in this article: we'll create a test which starts embedded HTTP(S) server (configured with our own HTTP handler) and runs the network-enabled code.

Wednesday, March 27, 2013

Load your Linux!

I just discovered brilliant tool to generate load (cpu, io, ram, disk) on a Linux machine - stress.

Thursday, February 14, 2013

Environment variables in log4j config

Today I discovered that log4j (at least, currently latest version in 1.2 family, 1.2.17) can use only java system properties (which are passed to java with -D).
Environment variables (those like PATH and GIT_SSH) can't be accessed in log4j config.

Saturday, February 9, 2013

Bug in JDK class com.sun.org.apache.xerces.internal.util.URI

Probably it a sign of my declining years, but yesterday I spotted a bug in Oracle's JDK. It's a first time of my life. And I want to say - there is nothing pleasant in this act.
So the bug is: you can't construct instance of com.sun.org.apache.xerces.internal.util.URI class with path containing non-ASCII characters - you'll get MalformedURLException.

Tuesday, November 27, 2012

Integration testing with Spring and DbUnit

The day has come and now you want to test your data access layer. Or, perhaps, you need to test a service layer but to be sure that your tests are really close to the System in Production you don't want to mock persistence layer and/or database. And you use the Spring framework in the project. If so, this article will guide you through the simplest solution I'd found so far to create integration tests.

Friday, October 26, 2012

Explore database while debugging Spring-based project

What if you are debugging your Spring-based project and database is not accessible for all that db viewers/managers/administrator tools. And rigt in your JDBC/ORM DAO method you see that things go wrong way and you want to check what's really in your db.

Monday, October 15, 2012

Tuesday, September 11, 2012

Convert properties file from ascii to native encoding

Everyone knows how to convert properties file with localization strings from native encoding to ASCII- simply use native2ascii which is part of JDK
native2ascii msg_native.properties msg_ascii.properties

But how to convert localized properties file back from ASCII to native encoding?
Easily!
native2ascii -reverse msg_ascii.properties msg_native.properties

Wednesday, August 15, 2012

Ubuntu 12.04 and Microsoft VPN

Hint for those who wants access their workplace (hosted in MS Windows Server LAN) via VPN from remote Ubuntu PC.
You need to add new VPN connection in Network Connections and:
  1. Set Gateway
  2. Set User name and Password
  3. Leave empty NT Domain
  4. In Advanced settings check Use Poit-toPoint encryption (MMPE)
That's all!

Wednesday, July 25, 2012

Installing Unity 3d on Ubuntu 12.04 with NVIDIA card

Two day's fight is over - with a (small) victory - I've got Unity 3d on my fresh Ubuntu 12.04 install.
Right after OS installation I had a working Unity 2d and my video drivers had not provided GLX support. Then I'd spent 2 days trying to install and make works NVIDIA proprietary drivers - no luck. Finally I'd decided to switch to the open-source NVIDIA drivers provided by Bumblebee Project and it worked out!