In this article, I will explain how to keep data persistent over multiple runs of a Java Application (not Web Application) using Google Datastore.
I run this program in a linux machine ( Ubuntu 10.10 ) using appengine-1.7.0. Most of the work is based on the tutorial on Local Unit Testing for Java by Google Developers.
The unit testing process explained in the tutorial stores all the data in memory. That you can not use the data stored in a particular run in later runs. But data can be made persistent using a file which is actually done by appengine in an web application project. You will find the following file
….. /<project_name>/war/WEB-INF/appengine-generated/local_db.bin
in a Web Application project powered by google appengine ( I am using Eclipse IDE ). It is the file used for keeping the data persistent over multiple runs of the application.
I will explain the process through a code. The comments provided in the code will give the guideline. The requirement in the referred article must be fulfilled (i.e. placing jars in classpath) to run the code. Also place the library for App engine SDK in classpath.
Related code for the process can be found here. The init() and finish() is used to controlling the environment.
I run this program in a linux machine ( Ubuntu 10.10 ) using appengine-1.7.0. Most of the work is based on the tutorial on Local Unit Testing for Java by Google Developers.
The unit testing process explained in the tutorial stores all the data in memory. That you can not use the data stored in a particular run in later runs. But data can be made persistent using a file which is actually done by appengine in an web application project. You will find the following file
….. /<project_name>
in a Web Application project powered by google appengine ( I am using Eclipse IDE ). It is the file used for keeping the data persistent over multiple runs of the application.
I will explain the process through a code. The comments provided in the code will give the guideline. The requirement in the referred article must be fulfilled (i.e. placing jars in classpath) to run the code. Also place the library for App engine SDK in classpath.
Related code for the process can be found here. The init() and finish() is used to controlling the environment.