7 | @title
8 |
9 |
10 |
11 |
12 |
13 | @content
14 |
15 |
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This software is licensed under the Apache 2 license, quoted below.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with
4 | the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
5 |
6 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
7 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
8 | language governing permissions and limitations under the License.
--------------------------------------------------------------------------------
/test/IntegrationSpec.scala:
--------------------------------------------------------------------------------
1 | import org.specs2.mutable._
2 | import org.specs2.runner._
3 | import org.junit.runner._
4 |
5 | import play.api.test._
6 | import play.api.test.Helpers._
7 |
8 | /**
9 | * add your integration spec here.
10 | * An integration test will fire up a whole play application in a real (or headless) browser
11 | */
12 | @RunWith(classOf[JUnitRunner])
13 | class IntegrationSpec extends Specification {
14 |
15 | "Application" should {
16 |
17 | "work from within a browser" in new WithBrowser {
18 |
19 | browser.goTo("http://localhost:" + port)
20 |
21 | browser.pageSource must contain("Your new application is ready.")
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %coloredLevel - %logger - %message%n%xException
8 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/conf/routes:
--------------------------------------------------------------------------------
1 | # Routes
2 | # This file defines all application routes (Higher priority routes first)
3 | # ~~~~
4 |
5 | # Home page
6 | GET / controllers.Application.index
7 | GET /categories controllers.Categories.index
8 | POST /categories controllers.Categories.store
9 | GET /categories/:id controllers.Categories.view(id: Long)
10 | PUT /categories/:id controllers.Categories.update(id: Long)
11 | DELETE /categories/:id controllers.Categories.destroy(id: Long)
12 |
13 | # Map static resources from the /public folder to the /assets URL path
14 | GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
15 |
--------------------------------------------------------------------------------
/test/ApplicationSpec.scala:
--------------------------------------------------------------------------------
1 | import org.specs2.mutable._
2 | import org.specs2.runner._
3 | import org.junit.runner._
4 |
5 | import play.api.test._
6 | import play.api.test.Helpers._
7 |
8 | /**
9 | * Add your spec here.
10 | * You can mock out a whole application including requests, plugins etc.
11 | * For more information, consult the wiki.
12 | */
13 | @RunWith(classOf[JUnitRunner])
14 | class ApplicationSpec extends Specification {
15 |
16 | "Application" should {
17 |
18 | "send 404 on a bad request" in new WithApplication{
19 | route(FakeRequest(GET, "/boum")) must beSome.which (status(_) == NOT_FOUND)
20 | }
21 |
22 | "render the index page" in new WithApplication{
23 | val home = route(FakeRequest(GET, "/")).get
24 |
25 | status(home) must equalTo(OK)
26 | contentType(home) must beSome.which(_ == "text/html")
27 | contentAsString(home) must contain ("Your new application is ready.")
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/RoutesSpec.scala:
--------------------------------------------------------------------------------
1 | import org.specs2.mutable._
2 | import org.specs2.runner._
3 | import org.junit.runner._
4 |
5 | import play.api.test._
6 | import play.api.test.Helpers._
7 |
8 | @RunWith(classOf[JUnitRunner])
9 | class RoutesSpec extends Specification {
10 |
11 | "Category Routes" should {
12 |
13 | "GET for /categories" in new WithApplication {
14 | val home = route(FakeRequest(GET, "/categories")).get
15 | status(home) must equalTo(OK)
16 | }
17 |
18 | "POST for /categories" in new WithApplication {
19 | val home = route(FakeRequest(POST, "/categories")).get
20 | status(home) must equalTo(OK)
21 | }
22 |
23 | "GET for /categories/1" in new WithApplication{
24 | val home = route(FakeRequest(GET, "/categories/1")).get
25 | status(home) must equalTo(OK)
26 | }
27 |
28 | "PUT for /categories/1" in new WithApplication{
29 | val home = route(FakeRequest(PUT, "/categories/1")).get
30 | status(home) must equalTo(OK)
31 | }
32 |
33 | "DELETE for /categories/1" in new WithApplication{
34 | val home = route(FakeRequest(DELETE, "/categories/1")).get
35 | status(home) must equalTo(OK)
36 | }
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/conf/application.conf:
--------------------------------------------------------------------------------
1 | # This is the main configuration file for the application.
2 | # ~~~~~
3 |
4 | # Secret key
5 | # ~~~~~
6 | # The secret key is used to secure cryptographics functions.
7 | #
8 | # This must be changed for production, but we recommend not changing it in this file.
9 | #
10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
11 | play.crypto.secret = "changeme"
12 |
13 | # The application languages
14 | # ~~~~~
15 | play.i18n.langs = [ "en" ]
16 |
17 | # Router
18 | # ~~~~~
19 | # Define the Router object to use for this application.
20 | # This router will be looked up first when the application is starting up,
21 | # so make sure this is the entry point.
22 | # Furthermore, it's assumed your route file is named properly.
23 | # So for an application router like `my.application.Router`,
24 | # you may need to define a router file `conf/my.application.routes`.
25 | # Default to Routes in the root package (and conf/routes)
26 | # play.http.router = my.application.Routes
27 |
28 | # Database configuration
29 | # ~~~~~
30 | # You can declare as many datasources as you want.
31 | # By convention, the default datasource is named `default`
32 | #
33 | # db.default.driver=org.h2.Driver
34 | # db.default.url="jdbc:h2:mem:play"
35 | # db.default.username=sa
36 | # db.default.password=""
37 |
38 | # Evolutions
39 | # ~~~~~
40 | # You can disable evolutions if needed
41 | # play.evolutions.enabled=false
42 |
43 | # You can disable evolutions for a specific datasource if necessary
44 | # play.evolutions.db.default.enabled=false
45 |
--------------------------------------------------------------------------------