A simple spec/test project to demonstrate how to use Typesafe's Configuration in a Java module.
Install these following softwares in your machine:
- JDK 7 with latest updates version.
- Git client
- Intellij IDEA 12
- Open the git bash console.
- Change directory to a folder where you are going to put the source code in.
- Type & run this command: git clone [email protected]:Xtremecode-asia/Demo.Typesafe.Config.Spec.git
- Run your intellij IDEA.
- Open the project.
- Click "Run" -> "Edit Configuration" menu.
- On the "Run/Debug Configurations", click greenish '+' small icon and click "Junit".
- On the Junit section panel, enter the Name field with any string (e.g. Demo.Typesafe.Config.Spec ), Package: demo.typesafe.config.spec, Search for tests: Across module dependencies, Working directory: the path of Demo.Typesafe.Config.Spec project, Use classpath of module: Demo.Typesafe.Config.Spec.
- Click [Apply] and then [Ok].
- Run the unit test through pressing [CTL]+[F5] or click "Run"->"Run ''".
- Run your intellij IDEA.
- Open the project.
- Click "Run" -> "Edit Configuration" menu.
- On the "Run/Debug Configurations", click greenish '+' small icon and click "Application".
- On the Application section panel, enter the Name field with any string (e.g. Console ), Main class: demo.typesafe.config.client.Console, Working directory: the path of Demo.Typesafe.Config.Client.Console project, Use classpath of module: Demo.Typesafe.Config.Client.Console.
- Click [Apply] and then [Ok].
- Run the unit test through pressing [CTL]+[F5] or click "Run"->"Run ''".
- Demo.Typesafe.Config.Spec - the JBehave-based unit testing project for this demo.
- Demo.Typesafe.Config.Params - Library which contains a class exposing its own configuration value.
- Demo.Typesafe.Config.Messages - Serves same purpose as Demo.Typesafe.Config.Params but exposing configuration value which is belong to this project.
- Demo.Typesafe.Config.Base - Hold a base class which is subclassed by classes in Demo.Typesafe.Config.Params & Demo.Typesafe.Config.Messages projects.
- Demo.Typesafe.Config.Client.Console - simple console app which reads the config values from Demo.Typesafe.Config.Messages & Demo.Typesafe.Config.Params.
- Run the JBehave test in Intellij IDEA 12, confirm that all scenario tests are PASSED.
- Run the console app, confirm that the console screen displays the following output: demo-typesafe-config.parameters.timeOut = 10000 Timeout Error Mesasge= 'Your request is timed out. Our server might be busy or under heavy load. Please re-send your request at next few moments. Thank you.'
- Typesafe Configuration's Git Wiki: https://github.com/typesafehub/config
- Typesafe Configuration's API doc ref: http://typesafehub.github.com/config/latest/api/