Cucumber tests with annotated configuration in Spring

Cucumber tests with annotated configuration in Spring

Fresh out of the workshop Acceptance Test Driven Design (Development) also known as Behavior Driven Design. Time to put this to the ‘test’ using Specification by Example. Since I am a hardcore (Java) developer I will use Cucumber for my implementation within a Spring 4 project.

Continue reading »

Posted in Cucumber, Java, Spring, Testing | Tagged , , , | Leave a comment

Coffee Addiction

As a true Java developer, I have a coffee addiction. Yet another scientific research has confirmed that drinking coffee has yet one more benefit. a quote from reads:

Volgens hoofdonderzoek Chang Y. Lee geeft het onderzoek ons meer inzicht in de gezondheidsvoordelen van natuurlijke voeding. “Koffie is de meest populaire drank in de wereld en we begrijpen steeds beter welke voordelen het heeft. Eerder onderzoek liet al zien dat koffie de kans verkleint op chronische aandoeningen als de ziekte van Parkinson, diabetes, prostaatkanker, de ziekte van Alzheimer en andere cognitieve achteruitgang.”
Vervolgonderzoek moet uitwijzen of we door het drinken van koffie het zelfde effect krijgen als bij de behandeling met chlorogeenzuur. Onderzoekers weten dat chlorogeenzuur wordt opgenomen via de spijsvertering, maar het is nog onduidelijk of het ook daadwerkelijk het netvlies bereikt. Als dit zo is dan kan koffie de ogen ‘beschermen’. Ook oogdruppels met chlorogeenzur vormen een mogelijkheid.


Posted in Off topic | Tagged , , | Leave a comment

Testing a Camel Route with Testng


One of the most frustrating things as a developer is; A problem and hardly any online resources and/or examples online that give you any hints towards a solution.

I found out that Testing a Camel Route with Testng is not the most common method of testing it. You can find some examples, but most of them are just not complete. That is the other frustrating thing. You see an example, but you have to guess what to use, where to get the stuff from etc. I will try to show you a full example how to test a basic route (defined in a spring XML file) in TestNG.
Continue reading »

Posted in Camel, Java, Maven, Spring | Tagged , , , , | Leave a comment

Android read file from URL

How to read a file from the internet

While coding y next app for Android, I found out that I needed to read files from URL locations and saven them on my Android device.
I searched for the first sample and put that code to work in my app. That was a quick disappointment. It dit not work and it gave me the message: Server returned HTTP response code: 401 for URL
  DefaultRequestDirector(5824): Authentication error: Unable to respond to any of these challenges: {}

I did not know what to make of this, since my file on the net is not protected by authentication. A lot of searching on the web did not reveal any solution to my problem (only solutions where you had to authenticate).

After long hours of searching I found a workaround for my problem. Just send in some dummy authentication and it will work.

HTTPClient / UrlConnection example

Here is my sample of my workaround

      URI _url = new URI(location);
      HttpGet httpget = new HttpGet(_url);
      DefaultHttpClient httpclient = new DefaultHttpClient();
      httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin","admin"));
      String _generatedFilename = generateFilename(_filename, savedconfiglist);
      HttpResponse response = httpclient.execute(httpget);
      HttpEntity entity = response.getEntity();
      if (response.getStatusLine().getStatusCode()==200) {
          saveArmyConfig(_generatedFilename, entity.getContent());
      } else {
        Log.d("TESTING", "error receiving content");
    } catch (IOException e) {
    } catch (URISyntaxException e) {

Kind regards,

Posted in Android, Java | Tagged , , , , , | Leave a comment

Android XML parsing workaround

The problem

I came across a problem while using XML in my android application. When trying to parse XML in android 2.2 and above, I read the qName variable and use that to do my magic. But in sdk version 7 (2.1) this poses a serious problem. A bug in the Android code, causes the qName to be empty and the localname to be filled with your XML element value.
Continue reading »

Posted in Android, Java | Tagged , , , | Leave a comment

Android Form Field Validation

Validation ??

After coding a while for the Android platform, I was getting annoyed that there was no default validation support (i.e that I could find) for the validation of EditText, CheckBox etc fields.
Therefore I have written a small set of interfaces/Classes that gives you and me the possibility to do the validation you need.
Continue reading »

Posted in Android, Interaction, Java, Validation | Tagged , , | 2 Comments

JEE Webservice basic auth security check with Glassfish

No @RolesAllowed available for Webservices

The JEE specification is growing into a nice and easy to use specification. But some features, like Webservices and RolesAllowed, are not good enough yet. To be more precise. @RolesAllowed is not supported for plain Webservices (not doubling as EJB’s) until version 3.0 in the Servlet Specification.

After much reading on this subject, I have come to the conclusion that a pragmatic solution is required. My solution is just to inspect the principals based upon the logged in user and check myself if the user is allowed to continue. But you can also define the webservice as EJB.
Continue reading »

Posted in Java, JEE, Webservices | Tagged , , , , | Leave a comment

Flex: Dynamic binding using a mapping file


Binding can be an time consuming task in Flex. If you have a domain model and the DTO’s for your components, you need an easy way to bind the two together. Here you have two options. The first is to write alot of BindingUtils statements in either models. And finally you can write a mapping file in xml, create a custom binder class which uses the mapping file and bind the two models together.

I have chosen the last option, because this gives me some more flexibility handling the bindings.
Continue reading »

Posted in Actionscript, Adobe, Flex 3.0 | Tagged , , , , , , | Leave a comment

Flex 3 Custom validation of grouped input fields


Flex 3 has nicely build-in validation mechanism, but sometimes you wish they had not embedded this so deep into the components, that customization becomes a laborish task. I have also read many articles on customizations of this mechanism, but I have not found a working solution to my specific wish. What I want is validation of single input fields, multiple input and arbitrary placement of errors
besides the tooltip method.

Continue reading »

Posted in Actionscript, Adobe, Flex 3.0, Interaction | Tagged , , , , , | 3 Comments

How To: Load a spring application from a jar file

Consider the following situation:

Loading 3 application context files in a Swing application. 2 of the context files are in jar-files.
All context files depend on the component-scan option. The Application context gets loaded from my Swing app.
The method I use, is the import resource option in the context file. Read on how to configure this in your application context.
Continue reading »

Posted in Java, Spring | Tagged , , , , | Leave a comment