Skip to content

ReferenceError: module is not defined

This is a line that I do not want to see anymore. It happened to me when I tried to set up testing an angular application with some directives, using karma. I thought that I had followed all the steps to set it all up correctly, but I kept on getting this line, indicating that something was indeed wrong. I finally got it all to work, and to prevent others (and myself) the hassle again of finding out what you have to do to get karma working correctly (especially when you already have some js files that you would like to test), I will outline here shortly what I did. Read more…

Spock, for tedious database conditions testing

As I mentioned earlier in my previous post, spock is a very nice groovy based testing framework, that helps us to write better readable test code. This is done through the use of groovy and by the use of behaviour driven development. In behaviour driven development you define what the system is supposed to do and express yourself in clear, hopefully, non programming terms. Groovy and spock helps you do just that. For instance, if I would like to test a valid login based on certain conditions, I could express that as follows:
Read more…

Advanced spock testing.

Spock is a nice groovy based testing framework and all though it can be very easy to get you started with spock, this blog will show some non-standard things that you can do as well with spock. For more information about the spock framework (and you should definitely check this out if you are not familiar yet with this great framework), see the Spock framework link
Read more…

Continuous integration with Git, Jenkins and Maven

Git is an excellent version control system, maven and jenkins are excellent ways for continuous integration and deployment, but how can you set them all up, so they will all work happily and content next to each other?

Requirements
To start it all of, you are going to need :

  • a maven project
  • a central git repository,
  • and jenkins.

Read more…

Test driven development, my way

We all do it, or at least some of us do it, trying to write test cases for a good code coverage of all the possible solutions for a complex problem. Some of us even try to drive the design for programs through a test driven approach. That is something that I am not a fan of because I think that once you start
programming for a while and start doing test driven development, you are capable enough of overseeing a problem and knowing the general direction for a solution, so the test driven design in my opinion can lead to waste. Waste as in test cases that are not needed anymore and if those test cases are not cleaned out might even lead to misunderstandings. Mind you, most of the time that won’t happen of course, because good test driven developers will clean away the waste. Read more…

Twitter 406 error code

Integrating with social sites, such as twitter, seems to be so easy, and it actually can be, once you get the configuration set up correctly. Last day however, I spend most of my time trying to hunt down a 406 error code when trying to login using a twitter account. According to the twitter site I have to :

  • Think of a name for my application that wants to use the twitter login, well that was not too hard
  • Enter a description
  • Tell on which domain your twitter application will be hosted, but you can enter a placeholder for this if you don’t know that yet, or want to test

And then you should be set and ready to go.

Twitter will then provide you with 2 keys that you need to use to communicate with twitter. Since there are already many libraries available that will take care of the communications for you with twitter, it looks like that was all that I needed to do. Started a webapp, using the playframework and the SecureSocial module and logged in using twitter. Or at least, I tried to login with twitter. Unfortunately, I was not allowed to login, since twitter returned me a 406 error:

WARNING: POST request for "https://api.twitter.com/oauth/request_token" resulted in 406 (Not Acceptable); invoking error handle

Checked it at the twitter error codes and it says :

406 Not Acceptable: Returned by the Search API when an invalid format is specified in the request.

Which is weird since I did not try to use the search api, I was trying to signin with the given keys. Googling around this error I ran into a number of solutions, none of them really worked for me, but after trying out a combination of solutions I finally got it working. This is what I had to do:

  • Allthough it is not required, you have to give a callback url. This url should be back to localhost but that is not a valid domain according to twitter. So I set the callback url to http://localhost.com
  • Changed my /etc/hosts file where localhost.com will now return the ip address of localhost

and now it was working. I could finally login. I think the 406 code explanation should be altered a bit to indicate that it might also be a configuration issue.

I found out later today that I could also have solved this by setting the callback url to http://127.0.0.1

Hope this helps someone sometime

Playframework artikel van java magazine

Het playframework is een action based web applicatie framework waarbij snelheid van ontwikkeling voorop staat. DIt wordt gerealiseerd door een eigen classloader systeem die elke aanpassing aan java sources en resources meteen oppikt en opnieuw inlaadt zonder enige tussenkomst van de ontwikkelaar. Dit betekent dat er bijna geen re-starts van de server meer nodig zijn. Het playframework zal zelf geen data op de server vasthouden zodat applicaties in principe onbeperkt schaalbaar zijn. Elke actie die op de applicatie uitgevoerd kan worden, kan aan dynamische urls verbonden worden, zodat er nette REST urls gevormd kunnen worden. Het playframework kan complexe data structuren opbouwen aan de hand van http parameters door middel van data binding zonder dat je daar zelf veel voor hoeft te doen. Kortom het playframework maakt het bouwen van webapplicaties weer een stuk leuker. Read more…

%d bloggers like this: