From 4676023f1c6c729eabd51dd1fe45db277b9d88fa Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 16 Nov 2011 21:11:06 -0500 Subject: [PATCH] add the Play 1.2 "yabe" example application.conf as test05.conf --- src/test/resources/test05.conf | 154 ++++++++++++++++++ .../com/typesafe/config/impl/ConfigTest.scala | 10 ++ 2 files changed, 164 insertions(+) create mode 100644 src/test/resources/test05.conf diff --git a/src/test/resources/test05.conf b/src/test/resources/test05.conf new file mode 100644 index 00000000..3d86ac50 --- /dev/null +++ b/src/test/resources/test05.conf @@ -0,0 +1,154 @@ +# This is the main configuration file for the application. +# ~~~~~ +application.name=Yet Another Blog Engine + +# Configuration of the blog engine +# ~~~~~ +blog.title=Yet another blog +blog.baseline=We will write about nothing + +# Application mode +# ~~~~~ +# Set to dev to enable instant reloading and other development help. +# Otherwise set to prod. +application.mode=dev +%prod.application.mode=prod + +# Secret key +# ~~~~~ +# The secret key is used to secure cryptographics functions +# If you deploy your application to several instances be sure to use the same key ! +application.secret=s1kwayg211q9v4387pvarbmyqnht7hrl54d34lsz0yh9btb117br293a25trz31o + +# Additional modules +# ~~~~~ +# A module is another play! application. Add a line for each module you want +# to add to your application. Modules path are either absolutes or relative to +# the application root. + +# Import the crud module +module.crud=${play.path}/modules/crud + +# Import the secure module +module.secure=${play.path}/modules/secure + +# Import the cobertura module in test mode +#%test.module.cobertura=${play.path}/modules/cobertura + +# i18n +# ~~~~~ +# Define locales used by your application. +# You can then place localized messages in conf/messages.{locale} files +# application.langs=fr,en,ja + +# Server configuration +# ~~~~~ +# If you need to change the HTTP port, uncomment this (default is set to 9000) +# http.port=9000 +# +# By default the server listen for HTTP on the wilcard address. +# You can restrict this. +# http.address=127.0.0.1 + +# Session configuration +# ~~~~~~~~~~~~~~~~~~~~~~ +# By default, session will be written to the transient PLAY_SESSION cookie. +# application.session.cookie=PLAY +# application.session.maxAge=1h + +# JPDA configuration +# ~~~~~ +# Define which port is used by JPDA when application is in debug mode (default is set to 8000) +# jpda.port=8000 + +# Log level +# ~~~~~ +# Specify log level for your application. +# If you want a very customized log, create a log4j.properties file in the conf directory +application.log=INFO + +# Database configuration +# ~~~~~ +# Enable a database engine if needed. +# +# To quickly set up a development database, use either: +# - mem : for a transient in memory database (H2 in memory) +# - fs : for a simple file written database (H2 file stored) +db=mem +# +# To connect to a local MySQL5 database, use: +# db=mysql:user:pwd@database_name +# +# If you need a full JDBC configuration use the following : +# db.url=jdbc:postgresql:database_name +# db.driver=org.postgresql.Driver +# db.user=root +# db.pass=secret +# +# Connections pool configuration : +# db.pool.timeout=1000 +# db.pool.maxSize=30 +# db.pool.minSize=10 +# +# If you want to reuse an existing Datasource from your application server, use: +# db=java:/comp/env/jdbc/myDatasource + +# JPA Configuration (Hibernate) +# ~~~~~ +# +# Specify the custom JPA dialect to use here (default to guess): +# jpa.dialect=org.hibernate.dialect.PostgreSQLDialect +# +# Specify the ddl generation pattern to use (default to update, set to none to disable it): +jpa.ddl=update +# +# Debug SQL statements (logged using DEBUG level): +# jpa.debugSQL=true +# +# You can even specify additional hibernate properties here: +# hibernate.use_sql_comments=true +# ... + +# Memcached configuration +# ~~~~~ +# Enable memcached if needed. Otherwise a local cache is used. +# memcached=enabled +# +# Specify memcached host (default to 127.0.0.1:11211) +# memcached.host=127.0.0.1:11211 +# +# Or you can specify multiple host to build a distributed cache +# memcached.1.host=127.0.0.1:11211 +# memcached.2.host=127.0.0.1:11212 + +# Mail configuration +# ~~~~~ +# Default is to use a mock Mailer +mail.smtp=mock + +# Or, specify mail host configuration +# mail.smtp.host=127.0.0.1 +# mail.smtp.user=admin +# mail.smtp.pass= +# mail.smtp.channel=ssl + +# Execution pool +# ~~~~~ +# Default to 1 thread in DEV mode or nb processors + 1 threads in PROD mode. +# Try to keep a low as possible. 1 thread will serialize all requests (very usefull for debugging purpose) +# play.pool=3 + +# Open file from errors pages +# ~~~~~ +# If your text editor supports to open files using URL, Play! will link +# error pages to files dynamically +# +# Example, for textmate: +# play.editor=txmt://open?url=file://%s&line=%s + +# Testing. Set up a custom configuration for test mode +# ~~~~~ +%test.application.mode=dev +%test.db=mem +%test.jpa.ddl=create-drop +%test.mail.smtp=mock diff --git a/src/test/scala/com/typesafe/config/impl/ConfigTest.scala b/src/test/scala/com/typesafe/config/impl/ConfigTest.scala index d53181b6..d347d2be 100644 --- a/src/test/scala/com/typesafe/config/impl/ConfigTest.scala +++ b/src/test/scala/com/typesafe/config/impl/ConfigTest.scala @@ -9,6 +9,8 @@ import com.typesafe.config.ConfigException import java.util.concurrent.TimeUnit import scala.collection.JavaConverters._ import com.typesafe.config.ConfigResolveOptions +import java.io.File +import com.typesafe.config.ConfigParseOptions class ConfigTest extends TestUtils { @@ -700,4 +702,12 @@ class ConfigTest extends TestUtils { assertEquals("round-robin", conf.getString("akka.actor.deployment.\"/app/service-ping\".router")) assertEquals(true, conf.getBoolean("akka.stm.quick-release")) } + + @Test + def test05LoadPlayApplicationConf() { + val conf = Config.load("test05") + + assertEquals("prod", conf.getString("%prod.application.mode")) + assertEquals("Yet another blog", conf.getString("blog.title")) + } }