← All tags

Tagged “android”

  • Using PBKDF2 on multiple platforms

    PBKDF2 is a popular choice when it comes to password hashing. I recently looked into PBKDF2 and wanted to use it across multiple platforms and spent some time trying to figure out how to implement it and how to make sure that hashes were the same no matter which platform they were generated on. The programming languages I used was Swift, Java and JavaScript (Node).

  • Secret menu for Huawei u8860

    I have an old Huawei 8860 Android phone which keeps running out of internal memory space. I constantly uninstall apps to make room not only for new apps but also just to be able to update my existing apps despite having more than 2GBs available according to the Storage settings. It turns out (I assume) that this behavior is caused by logs hiding in the /data/log folder. Too bad it is not possible to delete the files unless the device is rooted which I have not done (yet). I am still hoping to figure something out and recently found out that there is a secret system menu if you dial \*#\*#2846579#\*#\* in the stock phone app. It did not help me with my problem though.

  • Find Antenna welcomes UK

    From the Baltasound transmitter on the Shetland Islands in the North to the tiny St Brelades Bay transmitter on Jersey in the South, from the Lowestoft transmitter of Suffolk in the East to the Belcoo transmitter in Northern Ireland to the West. Find Antenna for Android now supports the entire United Kingdom.

  • Find Antenna officially released

    My very first mobile app was officially released yesterday. I have spent many evenings on ridiculous details and I am happy to say that the app is ready at last. The app can be used to determine the 5 closest DVB-T transmitters and in which direction they can be found. It is very useful if you want to figure out which way your TV antenna should point. It uses the location of the mobile phone to determine which transmitters are closest and the compass to determine the direction.

  • Concrete - My very own Android ORM

    I finally decided to write my own ORM for the Android platform simply because I thought this was really needed. The only option I found was the Active Android framework which is not open source in any way. So I figured it was time to code my own framework. So here is Concrete! The framework is still very rudimentary to say the least but if I find the time I think it will work out pretty nicely. I have been influenced by Hibernate, the Active Record pattern and of course Active Android. In the current state it does not support relations (yikes!) but I am working on this so stay tuned.

  • Android and XML parsers

    My first baby steps into the world of Android development has me started with writing a classic RSS feed application. I started out looking into basic UI and when that was done I focused on how to import a feed into Android. While searching for answers I came across this article on how to read a RSS feed with Android. It explains the different possibilities for parsing the returned XML in a very straight-forward manner and I highly recommend reading the piece. It is a really good read also if you just need to brush up your XML parsing skills on the Java platform.

← All tags

Tagged “database”

  • Setting character set to UTF-8 in MySQL

    The default installation of MySQL (5.5) does not use UTF-8 so every time I install an instance of MySQL I spend some time tinkering with the character setup so I decided to write a quick summary of the steps needed in order for MySQL to support UTF-8. When you have a vanilla installation of MySQL you can check your character settings by executing these commands.

  • Creating insert statements from table data

    Creating a SQL script which inserts data from an already existing table is not as straightforward as one would think. I found a pretty clean and easy solution which I will explain in detail here. I use MySQL but I believe the principles can be applied to most other databases if needed. Consider table A with the following content.

  • Accessing memory database in Play!

    The other day I was running some unit tests in an app using the Play! framework and I wanted to see how the data in the database looked like. Tests are run using a H2 memory database so accessing this was not as straightforward as I am used to since most configuration in Play! is done by convention (or magic, not sure which). So I did not know the connection string to the database nor the credentials used by the framework. After some googling I came across the information needed.

← All tags

Tagged “docpad”

  • Hello DocPad

    Today I relaunched my blog. I wanted to skip the Blogger platform for something more flexible for a long time and now I have finally made the switch. I examined a lot of Node blogging platforms and decided to go with DocPad. I looked at other alternatives such as Wheat and Blacksmith but the simplicity of DocPad really won me over. There is no database as everything is stored as files, documents can come in any format or shape and the community is very vibrant (as any Node community these days) just to name a few of the selling points. It is the perfect platform for blogs so the decision was not very hard.

← All tags

Tagged “eclipse”

  • Mockito, static imports and Eclipse

    I recently started using Mockito as a mocking framework. Mockito makes heavy use of static imports which by default in Eclipse are not accessible through code completion. It is possible to use the Mockito methods by accessing them through their class by writing Mockito.when but this would quickly clutter your code with a lot of Mockito references. Code completion has been around for ages so not having it feels like coding in Notepad or vi. Fortunately I have found out that it is actually possible and quite easy to configure Eclipse to add the static imports which is a great relief.

  • Eclipse and JBoss AS 5.1 with minimal configuration

    As I explained yesterday I managed to improve startup times of my JBoss AS 5.1 server dramatically by fiddling a little with the web profile provided by Red Hat. It did however give me some problems when I wanted to start/stop/deploy my web project from Eclipse since this all of a sudden did not work anymore. I decided to fix this and this is what I did.

← All tags

Tagged “findantenna”

  • Find Antenna for iOS gets huge update

    Months of waiting is finally over. The iOS version of Find Antenna finally supports the same countries as the Android version which means iPhone users in the United Kingdom, Germany and Sweden can now enjoy the app just as users in Denmark have been able to for some months. The update was also used to adjust some of the Danish transmitters since Boxer has decided to upgrade the transmitters at Borups Alle and Lynetten.

  • Find Antenna welcomes UK

    From the Baltasound transmitter on the Shetland Islands in the North to the tiny St Brelades Bay transmitter on Jersey in the South, from the Lowestoft transmitter of Suffolk in the East to the Belcoo transmitter in Northern Ireland to the West. Find Antenna for Android now supports the entire United Kingdom.

  • Find Antenna now available on iPhone

    Finally my first iPhone app has hit the stores. The iPhone version of Find Antenna is available for download from the App Store. The functionality is the same as the Android version with some minor differences. I put a lot of work into the visual appearance of both app and icon to give a clearer visual identity. I also changed the layout of the app a little bit by using a scrollview instead of gesture recognizers to switch between transmitters. Representation of the signal strength was also changed to give a clearer indication on how to interpret the strength of the signal.

  • Find Antenna officially released

    My very first mobile app was officially released yesterday. I have spent many evenings on ridiculous details and I am happy to say that the app is ready at last. The app can be used to determine the 5 closest DVB-T transmitters and in which direction they can be found. It is very useful if you want to figure out which way your TV antenna should point. It uses the location of the mobile phone to determine which transmitters are closest and the compass to determine the direction.

← All tags

Tagged “food”

  • Muanlai - A true gem in Khao Lak

    Traveling to Khao Lak from the south you will pass a little restaurant called Muanlai about 1 km after the entrance to the Khao Lak-Lam Ru National Park. The restaurant sits on the hillside with unspoiled and spectacular views of the Khao Lak beach. It is the perfect spot for watching the sun set or just relax. It does not hurt either that the food is great and pretty cheap too. It is located a bit outside of Khao Lak so if you are staying in Khao Lak you either need to walk 2-3 kms or grab a tuk-tuk. It is within walking distance of most of the resorts in the southern part of Khao Lak but since it is situated in the opposite direction of Khao Lak it is easy to overlook this marvelous place.

← All tags

Tagged “h2”

  • Accessing memory database in Play!

    The other day I was running some unit tests in an app using the Play! framework and I wanted to see how the data in the database looked like. Tests are run using a H2 memory database so accessing this was not as straightforward as I am used to since most configuration in Play! is done by convention (or magic, not sure which). So I did not know the connection string to the database nor the credentials used by the framework. After some googling I came across the information needed.

← All tags

Tagged “hibernate”

  • Hibernate, Oracle, HSQLDB and sequences

    Recently I was writing some unit tests where I needed to access a database sequence for generation of unique numbers. The production environment uses Oracle while my unit tests use HQSLDB. The numbers from the sequence are extracted by ordinary SQL through Hibernate meaning that I could not rely on specifying the database dialect since the SQL is hardcoded. The code used for extracting the numbers (in Oracle) looked something like this

← All tags

Tagged “hsqldb”

  • Hibernate, Oracle, HSQLDB and sequences

    Recently I was writing some unit tests where I needed to access a database sequence for generation of unique numbers. The production environment uses Oracle while my unit tests use HQSLDB. The numbers from the sequence are extracted by ordinary SQL through Hibernate meaning that I could not rely on specifying the database dialect since the SQL is hardcoded. The code used for extracting the numbers (in Oracle) looked something like this

← All tags

Tagged “huawei”

  • Secret menu for Huawei u8860

    I have an old Huawei 8860 Android phone which keeps running out of internal memory space. I constantly uninstall apps to make room not only for new apps but also just to be able to update my existing apps despite having more than 2GBs available according to the Storage settings. It turns out (I assume) that this behavior is caused by logs hiding in the /data/log folder. Too bad it is not possible to delete the files unless the device is rooted which I have not done (yet). I am still hoping to figure something out and recently found out that there is a secret system menu if you dial \*#\*#2846579#\*#\* in the stock phone app. It did not help me with my problem though.

← All tags

Tagged “ios”

  • Using PBKDF2 on multiple platforms

    PBKDF2 is a popular choice when it comes to password hashing. I recently looked into PBKDF2 and wanted to use it across multiple platforms and spent some time trying to figure out how to implement it and how to make sure that hashes were the same no matter which platform they were generated on. The programming languages I used was Swift, Java and JavaScript (Node).

  • Find Antenna now available on iPhone

    Finally my first iPhone app has hit the stores. The iPhone version of Find Antenna is available for download from the App Store. The functionality is the same as the Android version with some minor differences. I put a lot of work into the visual appearance of both app and icon to give a clearer visual identity. I also changed the layout of the app a little bit by using a scrollview instead of gesture recognizers to switch between transmitters. Representation of the signal strength was also changed to give a clearer indication on how to interpret the strength of the signal.

← All tags

Tagged “iphone”

  • Find Antenna for iOS gets huge update

    Months of waiting is finally over. The iOS version of Find Antenna finally supports the same countries as the Android version which means iPhone users in the United Kingdom, Germany and Sweden can now enjoy the app just as users in Denmark have been able to for some months. The update was also used to adjust some of the Danish transmitters since Boxer has decided to upgrade the transmitters at Borups Alle and Lynetten.

  • Find Antenna now available on iPhone

    Finally my first iPhone app has hit the stores. The iPhone version of Find Antenna is available for download from the App Store. The functionality is the same as the Android version with some minor differences. I put a lot of work into the visual appearance of both app and icon to give a clearer visual identity. I also changed the layout of the app a little bit by using a scrollview instead of gesture recognizers to switch between transmitters. Representation of the signal strength was also changed to give a clearer indication on how to interpret the strength of the signal.

← All tags

Tagged “java”

  • Accessing memory database in Play!

    The other day I was running some unit tests in an app using the Play! framework and I wanted to see how the data in the database looked like. Tests are run using a H2 memory database so accessing this was not as straightforward as I am used to since most configuration in Play! is done by convention (or magic, not sure which). So I did not know the connection string to the database nor the credentials used by the framework. After some googling I came across the information needed.

  • Changing unnamed constraints in Play!

    I have been working on a project based on the Play! framework lately (the old version, 1.2.4) and I came across a real headscratcher. My problem was I needed to delete a foreign constraint in a table but this constraint had no name (it was not given a name when it was created). Deleting a constraint with standard SQL requires a name so I had to do come up with something else for my evolution script. I was using MySQL in production and H2 in test so it was not an option to use some MySQL specific code unless it was compatible with H2.

  • Hibernate, Oracle, HSQLDB and sequences

    Recently I was writing some unit tests where I needed to access a database sequence for generation of unique numbers. The production environment uses Oracle while my unit tests use HQSLDB. The numbers from the sequence are extracted by ordinary SQL through Hibernate meaning that I could not rely on specifying the database dialect since the SQL is hardcoded. The code used for extracting the numbers (in Oracle) looked something like this

  • Mockito, static imports and Eclipse

    I recently started using Mockito as a mocking framework. Mockito makes heavy use of static imports which by default in Eclipse are not accessible through code completion. It is possible to use the Mockito methods by accessing them through their class by writing Mockito.when but this would quickly clutter your code with a lot of Mockito references. Code completion has been around for ages so not having it feels like coding in Notepad or vi. Fortunately I have found out that it is actually possible and quite easy to configure Eclipse to add the static imports which is a great relief.

  • Concrete - My very own Android ORM

    I finally decided to write my own ORM for the Android platform simply because I thought this was really needed. The only option I found was the Active Android framework which is not open source in any way. So I figured it was time to code my own framework. So here is Concrete! The framework is still very rudimentary to say the least but if I find the time I think it will work out pretty nicely. I have been influenced by Hibernate, the Active Record pattern and of course Active Android. In the current state it does not support relations (yikes!) but I am working on this so stay tuned.

  • Speeding up unit tests using in-memory database

    I am a big fan of test-driven principles but have been on projects where running the full unit test suite would last 2-3 hours simply because writing to and reading from the database would slow everything down. This normally lead to optimizations such as only creating test data once having the unfortunate side effect of making unit tests dependent on each other (one unit test may change some data used in another unit test). It can also lead to random behavior making the test pass one time and then not the other simply because unit tests are not necessarily run in the same sequence every time.

  • Test dependencies in Maven

    For some time I have struggled with test dependencies between modules in Maven. Imagine this situation:

  • Setting up a datasource in JNDI

    Writing code quite often involves writing a lot of unit tests. If your tests cover isolated business logic (standard unit tests) writing tests is usually pretty easy. No big dependencies and very isolated testing. If you are writing tests involving database connections things can get a little more complex. The datasource in an application context is usually stored in JNDI so you need to initialize this yourself when writing tests. I use simple-jndi for this and this is how I do it.

  • Android and XML parsers

    My first baby steps into the world of Android development has me started with writing a classic RSS feed application. I started out looking into basic UI and when that was done I focused on how to import a feed into Android. While searching for answers I came across this article on how to read a RSS feed with Android. It explains the different possibilities for parsing the returned XML in a very straight-forward manner and I highly recommend reading the piece. It is a really good read also if you just need to brush up your XML parsing skills on the Java platform.

  • CPU spikes on JBoss AS 5.1

    While deploying a pretty simple web application on JBoss AS 5.1 (using the default profile) I noticed some weird cyclic CPU spikes even without ANY load on the server. It would start right after the server was started and the spikes would use ~40% of the CPU. Not exactly satisfying. I did the usual trip around the good, old web and quickly found out that the administration console in JBoss AS 5.x would create these hiccups. I deleted the administration console and saw CPU utilization drop to ~10%. That is what I call improvement.

  • Using Java VisualVM with JBoss AS 5.1

    Java VisualVM is a nice little tool for monitoring any Java application. I used it for monitoring a JBoss AS 5.1 server and had to add some system properties to the run.sh/run.bat file before it would let me connect. The system properties are

  • Eclipse and JBoss AS 5.1 with minimal configuration

    As I explained yesterday I managed to improve startup times of my JBoss AS 5.1 server dramatically by fiddling a little with the web profile provided by Red Hat. It did however give me some problems when I wanted to start/stop/deploy my web project from Eclipse since this all of a sudden did not work anymore. I decided to fix this and this is what I did.

  • Minimal JBoss AS 5.1 configuration

    When I deploy applications on the JBoss AS platform I normally just use the default profile provided by Red Hat. JBoss AS 5.1 is however horrendously slow when starting up so I decided to look into the other (lesser) profiles to see if this would speed things up a bit. I am running a standard web application (packaged as a .war file) based on JSF 1.2 (Sun RI) and Hibernate which accesses an Oracle database.

  • JSF and OnLoad for JDK 1.4

    Calling a method in a bean when a JSF page is hit is often a needed requirement when doing JSF. This is however not something you get out of the box unfortunately and you need to look at solutions outside of the scope of the JSF specification. Frameworks like Seam and Shale does address this but if you only need this functionality in one or two places it might seem a little overkill to include frameworks like these. Instead I discovered the JSF On-Load Action Listener from jsf-comp which does excactly what I want.

← All tags

Tagged “jboss”

  • CPU spikes on JBoss AS 5.1

    While deploying a pretty simple web application on JBoss AS 5.1 (using the default profile) I noticed some weird cyclic CPU spikes even without ANY load on the server. It would start right after the server was started and the spikes would use ~40% of the CPU. Not exactly satisfying. I did the usual trip around the good, old web and quickly found out that the administration console in JBoss AS 5.x would create these hiccups. I deleted the administration console and saw CPU utilization drop to ~10%. That is what I call improvement.

  • Using Java VisualVM with JBoss AS 5.1

    Java VisualVM is a nice little tool for monitoring any Java application. I used it for monitoring a JBoss AS 5.1 server and had to add some system properties to the run.sh/run.bat file before it would let me connect. The system properties are

  • Eclipse and JBoss AS 5.1 with minimal configuration

    As I explained yesterday I managed to improve startup times of my JBoss AS 5.1 server dramatically by fiddling a little with the web profile provided by Red Hat. It did however give me some problems when I wanted to start/stop/deploy my web project from Eclipse since this all of a sudden did not work anymore. I decided to fix this and this is what I did.

  • Minimal JBoss AS 5.1 configuration

    When I deploy applications on the JBoss AS platform I normally just use the default profile provided by Red Hat. JBoss AS 5.1 is however horrendously slow when starting up so I decided to look into the other (lesser) profiles to see if this would speed things up a bit. I am running a standard web application (packaged as a .war file) based on JSF 1.2 (Sun RI) and Hibernate which accesses an Oracle database.

← All tags

Tagged “jndi”

  • Setting up a datasource in JNDI

    Writing code quite often involves writing a lot of unit tests. If your tests cover isolated business logic (standard unit tests) writing tests is usually pretty easy. No big dependencies and very isolated testing. If you are writing tests involving database connections things can get a little more complex. The datasource in an application context is usually stored in JNDI so you need to initialize this yourself when writing tests. I use simple-jndi for this and this is how I do it.

← All tags

Tagged “khao lak”

  • Muanlai - A true gem in Khao Lak

    Traveling to Khao Lak from the south you will pass a little restaurant called Muanlai about 1 km after the entrance to the Khao Lak-Lam Ru National Park. The restaurant sits on the hillside with unspoiled and spectacular views of the Khao Lak beach. It is the perfect spot for watching the sun set or just relax. It does not hurt either that the food is great and pretty cheap too. It is located a bit outside of Khao Lak so if you are staying in Khao Lak you either need to walk 2-3 kms or grab a tuk-tuk. It is within walking distance of most of the resorts in the southern part of Khao Lak but since it is situated in the opposite direction of Khao Lak it is easy to overlook this marvelous place.

← All tags

Tagged “linux”

  • Removing all .svn folders

    Every now and then I need to copy a folder which is under source control. By copying the folder all source control information is copied along which needs to be removed afterwards. If the amount of folders is small this is done pretty easy manually but when we are talking larger amounts of folders doing it manually easily ends up pretty time consuming.

← All tags

Tagged “maven”

  • Test dependencies in Maven

    For some time I have struggled with test dependencies between modules in Maven. Imagine this situation:

← All tags

Tagged “mockito”

  • Mockito, static imports and Eclipse

    I recently started using Mockito as a mocking framework. Mockito makes heavy use of static imports which by default in Eclipse are not accessible through code completion. It is possible to use the Mockito methods by accessing them through their class by writing Mockito.when but this would quickly clutter your code with a lot of Mockito references. Code completion has been around for ages so not having it feels like coding in Notepad or vi. Fortunately I have found out that it is actually possible and quite easy to configure Eclipse to add the static imports which is a great relief.

← All tags

Tagged “mysql”

  • Setting character set to UTF-8 in MySQL

    The default installation of MySQL (5.5) does not use UTF-8 so every time I install an instance of MySQL I spend some time tinkering with the character setup so I decided to write a quick summary of the steps needed in order for MySQL to support UTF-8. When you have a vanilla installation of MySQL you can check your character settings by executing these commands.

  • Creating insert statements from table data

    Creating a SQL script which inserts data from an already existing table is not as straightforward as one would think. I found a pretty clean and easy solution which I will explain in detail here. I use MySQL but I believe the principles can be applied to most other databases if needed. Consider table A with the following content.

  • Changing unnamed constraints in Play!

    I have been working on a project based on the Play! framework lately (the old version, 1.2.4) and I came across a real headscratcher. My problem was I needed to delete a foreign constraint in a table but this constraint had no name (it was not given a name when it was created). Deleting a constraint with standard SQL requires a name so I had to do come up with something else for my evolution script. I was using MySQL in production and H2 in test so it was not an option to use some MySQL specific code unless it was compatible with H2.

← All tags

Tagged “node”

  • Using PBKDF2 on multiple platforms

    PBKDF2 is a popular choice when it comes to password hashing. I recently looked into PBKDF2 and wanted to use it across multiple platforms and spent some time trying to figure out how to implement it and how to make sure that hashes were the same no matter which platform they were generated on. The programming languages I used was Swift, Java and JavaScript (Node).

  • Hello DocPad

    Today I relaunched my blog. I wanted to skip the Blogger platform for something more flexible for a long time and now I have finally made the switch. I examined a lot of Node blogging platforms and decided to go with DocPad. I looked at other alternatives such as Wheat and Blacksmith but the simplicity of DocPad really won me over. There is no database as everything is stored as files, documents can come in any format or shape and the community is very vibrant (as any Node community these days) just to name a few of the selling points. It is the perfect platform for blogs so the decision was not very hard.

← All tags

Tagged “oracle”

  • Hibernate, Oracle, HSQLDB and sequences

    Recently I was writing some unit tests where I needed to access a database sequence for generation of unique numbers. The production environment uses Oracle while my unit tests use HQSLDB. The numbers from the sequence are extracted by ordinary SQL through Hibernate meaning that I could not rely on specifying the database dialect since the SQL is hardcoded. The code used for extracting the numbers (in Oracle) looked something like this

← All tags

Tagged “play”

  • Accessing memory database in Play!

    The other day I was running some unit tests in an app using the Play! framework and I wanted to see how the data in the database looked like. Tests are run using a H2 memory database so accessing this was not as straightforward as I am used to since most configuration in Play! is done by convention (or magic, not sure which). So I did not know the connection string to the database nor the credentials used by the framework. After some googling I came across the information needed.

  • Changing unnamed constraints in Play!

    I have been working on a project based on the Play! framework lately (the old version, 1.2.4) and I came across a real headscratcher. My problem was I needed to delete a foreign constraint in a table but this constraint had no name (it was not given a name when it was created). Deleting a constraint with standard SQL requires a name so I had to do come up with something else for my evolution script. I was using MySQL in production and H2 in test so it was not an option to use some MySQL specific code unless it was compatible with H2.

← All tags

Tagged “restaurant”

  • Muanlai - A true gem in Khao Lak

    Traveling to Khao Lak from the south you will pass a little restaurant called Muanlai about 1 km after the entrance to the Khao Lak-Lam Ru National Park. The restaurant sits on the hillside with unspoiled and spectacular views of the Khao Lak beach. It is the perfect spot for watching the sun set or just relax. It does not hurt either that the food is great and pretty cheap too. It is located a bit outside of Khao Lak so if you are staying in Khao Lak you either need to walk 2-3 kms or grab a tuk-tuk. It is within walking distance of most of the resorts in the southern part of Khao Lak but since it is situated in the opposite direction of Khao Lak it is easy to overlook this marvelous place.

← All tags

Tagged “security”

  • Using PBKDF2 on multiple platforms

    PBKDF2 is a popular choice when it comes to password hashing. I recently looked into PBKDF2 and wanted to use it across multiple platforms and spent some time trying to figure out how to implement it and how to make sure that hashes were the same no matter which platform they were generated on. The programming languages I used was Swift, Java and JavaScript (Node).

← All tags

Tagged “sql”

  • Creating insert statements from table data

    Creating a SQL script which inserts data from an already existing table is not as straightforward as one would think. I found a pretty clean and easy solution which I will explain in detail here. I use MySQL but I believe the principles can be applied to most other databases if needed. Consider table A with the following content.

  • Changing unnamed constraints in Play!

    I have been working on a project based on the Play! framework lately (the old version, 1.2.4) and I came across a real headscratcher. My problem was I needed to delete a foreign constraint in a table but this constraint had no name (it was not given a name when it was created). Deleting a constraint with standard SQL requires a name so I had to do come up with something else for my evolution script. I was using MySQL in production and H2 in test so it was not an option to use some MySQL specific code unless it was compatible with H2.

← All tags

Tagged “subversion”

  • Removing all .svn folders

    Every now and then I need to copy a folder which is under source control. By copying the folder all source control information is copied along which needs to be removed afterwards. If the amount of folders is small this is done pretty easy manually but when we are talking larger amounts of folders doing it manually easily ends up pretty time consuming.

← All tags

Tagged “test”

  • Hibernate, Oracle, HSQLDB and sequences

    Recently I was writing some unit tests where I needed to access a database sequence for generation of unique numbers. The production environment uses Oracle while my unit tests use HQSLDB. The numbers from the sequence are extracted by ordinary SQL through Hibernate meaning that I could not rely on specifying the database dialect since the SQL is hardcoded. The code used for extracting the numbers (in Oracle) looked something like this

  • Mockito, static imports and Eclipse

    I recently started using Mockito as a mocking framework. Mockito makes heavy use of static imports which by default in Eclipse are not accessible through code completion. It is possible to use the Mockito methods by accessing them through their class by writing Mockito.when but this would quickly clutter your code with a lot of Mockito references. Code completion has been around for ages so not having it feels like coding in Notepad or vi. Fortunately I have found out that it is actually possible and quite easy to configure Eclipse to add the static imports which is a great relief.

  • Speeding up unit tests using in-memory database

    I am a big fan of test-driven principles but have been on projects where running the full unit test suite would last 2-3 hours simply because writing to and reading from the database would slow everything down. This normally lead to optimizations such as only creating test data once having the unfortunate side effect of making unit tests dependent on each other (one unit test may change some data used in another unit test). It can also lead to random behavior making the test pass one time and then not the other simply because unit tests are not necessarily run in the same sequence every time.

  • Test dependencies in Maven

    For some time I have struggled with test dependencies between modules in Maven. Imagine this situation:

  • Setting up a datasource in JNDI

    Writing code quite often involves writing a lot of unit tests. If your tests cover isolated business logic (standard unit tests) writing tests is usually pretty easy. No big dependencies and very isolated testing. If you are writing tests involving database connections things can get a little more complex. The datasource in an application context is usually stored in JNDI so you need to initialize this yourself when writing tests. I use simple-jndi for this and this is how I do it.

← All tags

Tagged “thailand”

  • Muanlai - A true gem in Khao Lak

    Traveling to Khao Lak from the south you will pass a little restaurant called Muanlai about 1 km after the entrance to the Khao Lak-Lam Ru National Park. The restaurant sits on the hillside with unspoiled and spectacular views of the Khao Lak beach. It is the perfect spot for watching the sun set or just relax. It does not hurt either that the food is great and pretty cheap too. It is located a bit outside of Khao Lak so if you are staying in Khao Lak you either need to walk 2-3 kms or grab a tuk-tuk. It is within walking distance of most of the resorts in the southern part of Khao Lak but since it is situated in the opposite direction of Khao Lak it is easy to overlook this marvelous place.

← All tags

Tagged “travel”

  • Muanlai - A true gem in Khao Lak

    Traveling to Khao Lak from the south you will pass a little restaurant called Muanlai about 1 km after the entrance to the Khao Lak-Lam Ru National Park. The restaurant sits on the hillside with unspoiled and spectacular views of the Khao Lak beach. It is the perfect spot for watching the sun set or just relax. It does not hurt either that the food is great and pretty cheap too. It is located a bit outside of Khao Lak so if you are staying in Khao Lak you either need to walk 2-3 kms or grab a tuk-tuk. It is within walking distance of most of the resorts in the southern part of Khao Lak but since it is situated in the opposite direction of Khao Lak it is easy to overlook this marvelous place.