• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala WithApplication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中play.api.test.WithApplication的典型用法代码示例。如果您正苦于以下问题:Scala WithApplication类的具体用法?Scala WithApplication怎么用?Scala WithApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WithApplication类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: AwardsRepoSpec

//设置package包名称以及导入依赖的类
package repo

import models.AwardsRepo
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication

import scala.concurrent.Await
import scala.concurrent.duration.Duration


@RunWith(classOf[JUnitRunner])
class AwardsRepoSpec extends Specification {
  sequential

  def awardsRepo(implicit app: Application) = Application.instanceCache[AwardsRepo].apply(app)

  "Awards repository" should {

    "get a record" in new WithApplication {
      val result = awardsRepo.getAll
      val response = Await.result(result, Duration.Inf)
      response.head.name === "microsoft"
    }

    "delete a record" in new WithApplication {
      val result = awardsRepo.delete(2)
      val response = Await.result(result, Duration.Inf)
      response === 1
    }

    "add a record" in new WithApplication {
      val result = awardsRepo.add("scjp", "good", "2015", 1)
      val response = Await.result(result, Duration.Inf)
      response === 1
    }
    "UPDATE a record" in new WithApplication {
      val result = awardsRepo.update(2, "NCR Certificate", "worst", "2016", 3)
      val response = Await.result(result, Duration.Inf)
      response === 1
    }
    "get a record by id" in new WithApplication {
      val result = awardsRepo.getById(2)
      val response = Await.result(result, Duration.Inf)
      response.get.name === "sun certificate"
    }
    "get a record by User id" in new WithApplication {
      val result = awardsRepo.getByUserId(1)
      val response = Await.result(result, Duration.Inf)
      response.head.name === "microsoft"
    }
  }
} 
开发者ID:aarwee,项目名称:PLAY-SLICK-DEEPTI-KUNAL-RISHABH,代码行数:56,代码来源:AwardsRepoSpec.scala


示例2: AssignmentRepoSpec

//设置package包名称以及导入依赖的类
package repo

import models.AssignmentRepo
import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplication

import scala.concurrent.Await
import scala.concurrent.duration.Duration



class AssignmentRepoSpec extends Specification {

  sequential
  def assignmentRepo(implicit app: Application) = Application.instanceCache[AssignmentRepo].apply(app)

 "Awards repository" should {

   "get a record" in new WithApplication {
     val result = assignmentRepo.getAll
     val response = Await.result(result, Duration.Inf)
     response.head.name === "c++"
   }
   "delete a record" in new WithApplication {
     val result = assignmentRepo.delete(1)
     val response = Await.result(result, Duration.Inf)
     response === 1
   }
    "add a record" in new WithApplication {
         val result = assignmentRepo.add("scala", "2015-08-08", 22, "good",3)
         val response = Await.result(result, Duration.Inf)
         response === 1

 }
      "UPDATE a record" in new WithApplication {
       val result = assignmentRepo.update(1, "scala", "2015-08-08", 22, "good", 1)
       val response = Await.result(result, Duration.Inf)
     }
 "get record by id" in new WithApplication{
    val result = assignmentRepo.getById(1)
    val response = Await.result(result, Duration.Inf)
   response.get.name === "c++"
    }
    "get record by id" in new WithApplication{
    val result = assignmentRepo.getByUserId(1)
    val response = Await.result(result, Duration.Inf)

   response.head.name === "c++"
 }
  }
} 
开发者ID:aarwee,项目名称:PLAY-SLICK-DEEPTI-KUNAL-RISHABH,代码行数:53,代码来源:AssignmentRepoSpec.scala


示例3: AwardRepoTest

//设置package包名称以及导入依赖的类
package repository

import models.Award
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication

import scala.concurrent.Await
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class AwardRepoTest extends Specification{

  def awardRepo(implicit app:Application)=Application.instanceCache[AwardRepo].apply(app)

  "Award Repository" should {
    "get award records" in new WithApplication {
      val res = awardRepo.getAll()
      val response = Await.result(res, Duration.Inf)
      response.head.id ===1
    }

    "insert award records" in new WithApplication() {
      val res=awardRepo.insert(4,"best orator","school level")
      val response=Await.result(res,Duration.Inf)
      response===1
    }

    "update award records" in new WithApplication{
      val res=awardRepo.update(1,"best singer","school level")
      val response=Await.result(res,Duration.Inf)
      response===0
    }

    "delete award records" in new WithApplication() {
      val res=awardRepo.delete("best dancer")
      val response=Await.result(res,Duration.Inf)
      response===0
    }

    "get awards by id" in new WithApplication() {
      val res=awardRepo.getAward(1)
      val response=Await.result(res,Duration.Inf)
      response===Vector(Award(1,"best programmer","school level"))
    }
  }
} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:50,代码来源:AwardRepoTest.scala


示例4: LanguageRepoTest

//设置package包名称以及导入依赖的类
package repository

import models.Language
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication

import scala.concurrent.Await
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class LanguageRepoTest extends Specification{

  def langRepo(implicit app:Application)=Application.instanceCache[LanguageRepo].apply(app)

  "Language Repository" should {
    "get language records" in new WithApplication {
      val res = langRepo.getAll()
      val response = Await.result(res, Duration.Inf)
      response.head.id ===1
    }

    "insert language records" in new WithApplication() {
      val res=langRepo.insert(1,"french","basic")
      val response=Await.result(res,Duration.Inf)
      response===1
    }


    "update language records" in new WithApplication(){
      val res=langRepo.update(1,"spansih","basic")
      val response=Await.result(res,Duration.Inf)
      response === 1
    }

    "delete language record" in new WithApplication() {
      val res=langRepo.delete("hindi")
      val response=Await.result(res,Duration.Inf)
      response===1
    }

    "get records by id" in new WithApplication() {
      val res=langRepo.getLanguage(1)
      val response=Await.result(res,Duration.Inf)
      response===Vector(Language(1,"hindi","advanced"))
    }


  }

} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:54,代码来源:LanguageRepoTest.scala


示例5: UserRepoTest

//设置package包名称以及导入依赖的类
package repository

import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication

import scala.concurrent.Await
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class UserRepoTest extends Specification {

  def userRepo(implicit app:Application)=Application.instanceCache[UserRepo].apply(app)

  "User Repository" should {
    "get a student record" in new WithApplication {
      val res=userRepo.getUser("[email protected]")
      val response=Await.result(res,Duration.Inf)
      response.head.name === "himani"
    }

    "get all student records" in new WithApplication() {
      val res=userRepo.getAll()
      val response=Await.result(res,Duration.Inf)
      response.head.name==="himani"
    }

    "add student records" in new WithApplication{
      val res=userRepo.insert(3,"santosh","[email protected]","72745690","santosh")
      val response=Await.result(res,Duration.Inf)
      response ===1
    }

    "delete student record" in new WithApplication{
      val res=userRepo.delete(2)
      val response=Await.result(res,Duration.Inf)
      response ===1
    }

    "update student record" in new WithApplication() {
      val res=userRepo.update(1,"simar","[email protected]","22469870","simar")
      val response=Await.result(res,Duration.Inf)
      response===1
    }
  }
} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:49,代码来源:UserRepoTest.scala


示例6: AssignmentRepoTest

//设置package包名称以及导入依赖的类
package repository

import models.Assignment
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class AssignmentRepoTest extends Specification{

  def assigRepo(implicit app:Application)=Application.instanceCache[AssignmentRepo].apply(app)

  "Assignment Repository" should {

    "get assignment records" in new WithApplication {
      val res = assigRepo.getAll()
      val response = Await.result(res, Duration.Inf)
      response.head.id ===1
    }

    "insert assignment records" in new WithApplication() {
      val res=assigRepo.insert(1,"slick",5,"no remark")
      val response=Await.result(res,Duration.Inf)
      response===1
    }

    "delete assignment record" in new WithApplication() {
      val res=assigRepo.delete(1)
      val response=Await.result(res,Duration.Inf)
      response===1
    }


    "update assignment records" in new WithApplication(){
      val res=assigRepo.update(1,"c++",7,"can do better")
      val response=Await.result(res,Duration.Inf)
      response === 1

    }

    "get assignment by id" in new WithApplication() {
      val res=assigRepo.getAssignment(1)
      val response=Await.result(res,Duration.Inf)
      response===Vector(Assignment(1,"scala",7,"no remark"))
    }
  }

} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:53,代码来源:AssignmentRepoTest.scala


示例7: ProgLanguageRepoTest

//设置package包名称以及导入依赖的类
package repository

import models.ProgLanguage
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication

import scala.concurrent.Await
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class ProgLanguageRepoTest extends Specification{

  def plangRepo(implicit app:Application)=Application.instanceCache[ProgLanguageRepo].apply(app)

  "Programming language  Repository" should {
    "get programming language records" in new WithApplication {
      val res = plangRepo.getAll()
      val response = Await.result(res, Duration.Inf)
      response.head.id ===1
    }

    "insert programming language records" in new WithApplication() {
      val res=plangRepo.insert(4,"c#")
      val response=Await.result(res,Duration.Inf)
      response===1
    }


    "update programming language records" in new WithApplication(){
      val res=plangRepo.update(1,"java")
      val response=Await.result(res,Duration.Inf)
      response === 1

    }

    "delete programming language record" in new WithApplication() {
      val res=plangRepo.delete("c++")
      val response=Await.result(res,Duration.Inf)
      response===1
    }

    "get a particular record" in new WithApplication{
      val res=plangRepo.getProgLanguage(1)
      val response=Await.result(res,Duration.Inf)
     response===Vector(ProgLanguage(1,"c++"))

    }

  }

} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:55,代码来源:ProgLanguageRepoTest.scala


示例8: UserTest

//设置package包名称以及导入依赖的类
package database

import dal.repositories.authentication.{Authentication, AuthenticationRepository}
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.test.WithApplication


@RunWith(classOf[JUnitRunner])
class UserTest extends Specification {

  "User must return id in string type" in new WithApplication {
    val userAuth : AuthenticationRepository = new Authentication()
    val id : String = userAuth getUserID("mubeen","abc") getOrElse("404")
    assert(id == "58fa4ce3d1ba90513ed53651")
  }

  "User login is updated successfully" in new WithApplication {
    val userAuth : AuthenticationRepository = new Authentication()
    val affects = userAuth updateLogin("58fa4ce3d1ba90513ed53651")
    assert(affects == 1)
  }
} 
开发者ID:mubeenahmed,项目名称:MeGuideApi,代码行数:25,代码来源:UserTest.scala


示例9: LoginAPITestextends

//设置package包名称以及导入依赖的类
package integration.api

import com.github.simplyscala.MongodProps
import org.specs2.mutable.Before

import scala.language.existentials
import play.api.libs.json.Json
import play.api.test.{FakeRequest, PlaySpecification, WithApplication}


class LoginAPITestextends extends PlaySpecification {

  "respond to the no login data Action" in new WithApplication {
    val Some(result) = route(app, FakeRequest(POST, "/login"))
    status(result) must equalTo(400)
  }
  "response to the with loign data but no authentication" in new WithApplication {
    val Some(result) = route(app, FakeRequest(POST, "/login").withJsonBody(Json.parse("""{"username":"no_data", "password":"abc"}""") ))
    status(result) must equalTo(401)
    contentType(result) must beSome("application/json")
  }
  "response to the with login data and authentication" in new WithApplication {
    val Some(result) = route(app, FakeRequest(POST, "/login").withJsonBody(Json.parse("""{"username":"mubeen", "password":"mubeen"}""")))
    status(result) must equalTo(200)
    contentType(result) must beSome("application/json")
  }
} 
开发者ID:mubeenahmed,项目名称:MeGuideApi,代码行数:28,代码来源:LoginAPITest.scala


示例10: ProgrammingLanguageRepoSpec

//设置package包名称以及导入依赖的类
package repository

import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.duration._
import scala.concurrent.Await


class ProgrammingLanguageRepoSpec  extends Specification{

  "Programming Language repository" should {
    def progLanguageRepo(implicit app: Application) = Application.instanceCache[ProgrammingLanguageRepo].apply(app)

    "Get all programming language records Test" in new WithApplication {
      val result = Await.result(progLanguageRepo.getAllProgLanguage, 5 seconds)
      assert(result.length === 2)
      assert(result === List(ProgrammingLanguage(1,"akshay","scala","read/write"),ProgrammingLanguage(2,"deepak","scala","read/write")))

    }

    "Get user programming language Test" in new WithApplication {
      val result = Await.result(progLanguageRepo.getUserProgLanguage("deepak"), 5 seconds)
      assert(result.length === 1)
      assert(result === List(ProgrammingLanguage(2,"deepak","scala","read/write")))

    }


    "Add programming language Test" in new WithApplication {
      val result = Await.result(progLanguageRepo.addProgLanguage(ProgrammingLanguage(3,"Sangeeta","Scala","r/w")), 5 seconds)
      assert(result === 1)
    }
  }
} 
开发者ID:SangeetaGulia,项目名称:FirstHeroku,代码行数:36,代码来源:ProgrammingLanguageRepoSpec.scala


示例11: LanguageRepoSpec

//设置package包名称以及导入依赖的类
package repository


import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.duration._
import scala.concurrent.Await


class LanguageRepoSpec extends Specification{

  "Language repository" should {
    def languageRepo(implicit app: Application) = Application.instanceCache[LanguageRepo].apply(app)

    "Get all language records Test" in new WithApplication {
      val result = Await.result(languageRepo.getAllLanguage, 5 seconds)
      assert(result.length === 2)
      assert(result === List(Language(1,"akshay","hindi","read/write"),Language(2,"deepak","english","read/write")))
    }

    "Get user language Test" in new WithApplication {
      val result = Await.result(languageRepo.getUserLanguage("deepak"), 5 seconds)
      assert(result.length === 1)
      assert(result === List(Language(2,"deepak","english","read/write")))
    }


    "Add language Test" in new WithApplication {
      val result = Await.result(languageRepo.addLanguage(Language(3,"Sangeeta","English","r/w")), 5 seconds)
      assert(result === 1)
    }
  }
} 
开发者ID:SangeetaGulia,项目名称:FirstHeroku,代码行数:35,代码来源:LanguageRepoSpec.scala


示例12: AssignmentRepoSpec

//设置package包名称以及导入依赖的类
package repository

import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.duration._
import scala.concurrent.Await


class AssignmentRepoSpec extends Specification{

  "Assignment repository" should {
    def assignmentRepo(implicit app: Application) = Application.instanceCache[AssignmentRepo].apply(app)

    "Get all assignment records test" in new WithApplication {
      val result = Await.result(assignmentRepo.getAllAssignment, 5 seconds)
      assert(result.length === 2)
      assert(result === List(Assignment("akshay","scala","1st jan",6,"average",1),Assignment("deepak","scala","3rd jan",6,"average",2)))
    }

    "Add assignment test" in new WithApplication {
      val result = Await.result(assignmentRepo.addAssignment(Assignment("Sangeeta","Scala","1st jan",6,"average",3)), 5 seconds)
      assert(result === 1)
    }

    "Get assignment record test" in new WithApplication {
      val result = Await.result(assignmentRepo.getUserAssignment("akshay"), 5 seconds)
      assert(result.length === 1)
      assert(result === List(Assignment("akshay","scala","1st jan",6,"average",1)))
    }
  }
} 
开发者ID:SangeetaGulia,项目名称:FirstHeroku,代码行数:33,代码来源:AssignmentRepoSpec.scala


示例13: InternRepoSpec

//设置package包名称以及导入依赖的类
package repository

import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.duration._
import scala.concurrent.Await



class InternRepoSpec extends Specification{


  "Intern repository" should {
    def internRepo(implicit app: Application) = Application.instanceCache[InternRepo].apply(app)

    "Get all interns records test" in new WithApplication {
      val result = Await.result(internRepo.getAllInterns(), 5 seconds)
      assert(result.length === 2)
      assert(result === List(Interns("sangeeta", "[email protected]", 4342534, "Java Certified"), Interns("admin","[email protected]",2432466,"C# Certified")))
    }

    "Add intern test" in new WithApplication {
      val result = Await.result(internRepo.addInterns(Interns("akshay", "[email protected]", 434234, "C Certified")), 5 seconds)
      assert(result === 1)
    }
  }
} 
开发者ID:SangeetaGulia,项目名称:FirstHeroku,代码行数:29,代码来源:InternRepoSpec.scala


示例14: AwardRepoSpec

//设置package包名称以及导入依赖的类
package repository

import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.duration._
import scala.concurrent.Await


class AwardRepoSpec extends Specification{


  "Award repository" should {
    def awardRepo(implicit app: Application) = Application.instanceCache[AwardRepo].apply(app)

    "Get all awards records test" in new WithApplication {
      val result = Await.result(awardRepo.getAllAwards(), 5 seconds)
      assert(result.length === 2)
      assert(result === List(Awards("akshay","Lan game First Prize",2016,1),Awards("deepak","Coding First Prize",2016,2)))
    }

    "Add award test" in new WithApplication {
      val result = Await.result(awardRepo.addAwards(Awards("sangeeta","first division",2016,3)), 5 seconds)
      assert(result === 1)
    }

    "Get award record test" in new WithApplication {
      val result = Await.result(awardRepo.getUserAwards("akshay"), 5 seconds)
      assert(result.length === 1)
      assert(result === List(Awards("akshay","Lan game First Prize",2016,1)))
    }
  }
} 
开发者ID:SangeetaGulia,项目名称:FirstHeroku,代码行数:34,代码来源:AwardRepoSpec.scala


示例15: ApplicationSpec

//设置package包名称以及导入依赖的类
package controllers

import com.knoldus.search.AutoCompleteProcessor
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
import play.api.mvc.Results
import play.api.test.{FakeRequest, PlaySpecification, WithApplication}
import org.specs2.mock.Mockito


@RunWith(classOf[JUnitRunner])
class ApplicationSpec extends PlaySpecification with Results with Mockito {

  val mockedProcessor = mock[AutoCompleteProcessor]
  val mockedJars = mock[WebJarAssets]

  val testController = new Application(mockedJars, mockedProcessor)

  "Application" should {

    "search suggestion" in new WithApplication {
      mockedProcessor.getMatches("java") returns List("java", "javascript", "jQuery")
      val result = testController.searchText("java").apply(FakeRequest("GET", "/search_text"))
      val resultAsString = contentAsString(result)
      resultAsString === """["java","javascript","jQuery"]"""
      status(result) must be equalTo 200
    }

    "search movies" in new WithApplication {
      mockedProcessor.getMovies("Batman v Superman: Dawn of Justice") returns List("""{"Title":"Batman v Superman: Dawn of Justice","Year":"2016","Released":"25 Mar 2016","Genre":"Action, Adventure, Sci-Fi","Director":"Zack Snyder","Plot":"steel.","Poster":"http://ia.media-imdb.com/images/M/[email protected]_V1_SX300.jpg","imdbRating":"7.0"}""")
      val result = testController.searchMovie("Batman v Superman: Dawn of Justice").apply(FakeRequest("GET", "/search_content"))
      status(result) must be equalTo 200
    }

  }

} 
开发者ID:knoldus,项目名称:activator-play-elasticsearch-autocomplete.g8,代码行数:38,代码来源:ApplicationSpec.scala


示例16: AutoCompleteProcessorTest

//设置package包名称以及导入依赖的类
package com.knoldus.search

import java.io.File

import com.knoldus.util.ESManager
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest
import org.elasticsearch.client.Client
import org.specs2.specification.BeforeAfterAll
import play.api.test.{PlaySpecification, WithApplication}
import util.TestHelper

import scala.io.Source

class AutoCompleteProcessorTest extends PlaySpecification with TestHelper with BeforeAfterAll {

  val autoCompleteProcessor = new AutoCompleteProcessor(new ESManager {
    override lazy val client: Client = localClient.client
  })

  val client: Client = localClient.client
  val index = "movie"

  override def afterAll = {
    client.close()
    client.admin().indices().prepareDelete(index).get
  }

  override def beforeAll = {
    val settings = Source.fromFile(new File("extra/es-mapping.json")).mkString
    client.admin().indices().prepareCreate(index).setSource(settings).get
    val bulkRequest = client.prepareBulk()
    Source.fromFile(new File("extra/movies.json")).getLines().foreach {
      movie => bulkRequest.add(client.prepareIndex(index, "movies").setSource(movie))
    }
    bulkRequest.get()
    client.admin().indices().refresh(new RefreshRequest(index)).get
  }

  "Play Specification" should {

    "autocomplete" in new WithApplication {
      val result = autoCompleteProcessor.getMatches("go")
      assert(result === List("Gone Girl"))
    }

    "get movies" in new WithApplication {
      val result = autoCompleteProcessor.getMovies("Gone Girl")
      assert(result.head.contains("Gone Girl"))
    }

  }

} 
开发者ID:knoldus,项目名称:activator-play-elasticsearch-autocomplete.g8,代码行数:54,代码来源:AutoCompleteProcessorTest.scala


示例17: SignupSpec

//设置package包名称以及导入依赖的类
import play.api.test.Helpers._
import play.api.test.{FakeRequest, WithApplication}
import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._

import play.api.test._
import play.api.test.Helpers._
import controllers.Signup


class SignupSpec extends Specification{

  "Signup" should {
    "send 404 on a bad request" in new WithApplication{
      route(FakeRequest(GET, "/boum")) must beSome.which (status(_) == NOT_FOUND)
    }

    "render the signup page" in new WithApplication{
      val home = route(FakeRequest(GET, "/signup")).get
      status(home) must equalTo(OK)
    }

    "invalid form submission" in new WithApplication() {
      val input = route(FakeRequest(GET, "/show")).get
      status(input) must equalTo(200)
    }

    "valid" in new WithApplication(){
      val input = route(FakeRequest(GET, "/changepassword")).get
      status(input) must equalTo(200)
    }
  }
} 
开发者ID:aarwee,项目名称:Kunal_RIshabh,代码行数:35,代码来源:SignupSpec.scala


示例18: DashboardSpec

//设置package包名称以及导入依赖的类
import org.specs2.mutable._
import play.api.test.Helpers._
import play.api.test.{FakeRequest, WithApplication}



class DashboardSpec extends Specification{
  "Dashboard" should {
    "send 404 on a bad request" in new WithApplication{
      route(FakeRequest(GET, "/boum")) must beSome.which (status(_) == NOT_FOUND)
    }

    "url hit without session" in new WithApplication{
      val home = route(FakeRequest(GET, "/show")).get

      status(home) must equalTo(303)
    }

    "Log out button" in new WithApplication() {
      val input = route(FakeRequest(GET, "/logout")).get
      status(input) must equalTo(303)
    }

    "change password button" in new WithApplication(){
      val input = route(FakeRequest(GET, "/changepassword")).get
      status(input) must equalTo(200)
    }
  }
} 
开发者ID:aarwee,项目名称:Kunal_RIshabh,代码行数:30,代码来源:DashboardSpec.scala


示例19: ForgotPasswordSpec

//设置package包名称以及导入依赖的类
import org.specs2.mutable._
import play.api.test.Helpers._
import play.api.test.{FakeRequest, WithApplication}

class ForgotPasswordSpec extends Specification{
  "ForgotPassword" should {
    "send 404 on a bad request" in new WithApplication{
      route(FakeRequest(GET, "/boum")) must beSome.which (status(_) == NOT_FOUND)
    }

    "render the forgot password page" in new WithApplication{
      val home = route(FakeRequest(GET, "/forgotpassword")).get

      status(home) must equalTo(OK)
      contentType(home) must beSome.which(_ == "text/html")
      contentAsString(home) must contain ("email")
    }

    "invalid email" in new WithApplication() {
      val input = route(FakeRequest(POST, "/checkpass").withFormUrlEncodedBody("email"->"abcd")).get
      status(input) must equalTo(400)
    }

    "valid email" in new WithApplication(){
      val input = route(FakeRequest(POST, "/checkpass").withFormUrlEncodedBody("email"->"[email protected]")).get
      status(input) must equalTo(303)
    }
  }
} 
开发者ID:aarwee,项目名称:Kunal_RIshabh,代码行数:30,代码来源:ForgotPasswordSpec.scala


示例20: PostgresSurveyRespondentRepositorySpec

//设置package包名称以及导入依赖的类
package models

import anorm._
import org.specs2.mutable.Specification
import play.api.Play.current
import play.api.db._
import play.api.test.WithApplication

class PostgresSurveyRespondentRepositorySpec extends Specification {
  val repo = PostgresSurveyRespondentRepository()
  val surveyRespondent = SurveyRespondent(username = "malina")

  def deleteAll(): Boolean = {
    DB.withConnection { implicit c =>
      SQL("TRUNCATE table survey_respondents").execute();
    }
  }

  "PostgresSurveyRespondentRepository" should {
    "#create returns Some[Long] and surveyRespondent exists in database when given valid surveyRespondent" in new WithApplication {
      deleteAll()
      val result: Option[Long] = repo.create(surveyRespondent)

      result.isDefined must equalTo(true)
    }

    "#getAll returns one SurveyRespondent when there is only one SurveyRespondent in the db" in new WithApplication {
      deleteAll()
      repo.create(surveyRespondent)

      val results = repo.getAll()

      results.length must equalTo(1)
    }

    "#findById returns one SurveyRespondent given a SurveyRespondent's ID" in new WithApplication {
      val id = repo.create(surveyRespondent).get

      val result = repo.findById(id)

      result.username must equalTo("malina")
      result.id must equalTo(Option(id))
    }

    "#deleteById removes a single record in the db given a SurveyRespondent's ID" in new WithApplication {
      deleteAll()
      val id = repo.create(surveyRespondent).get

      repo.deleteById(id)

      val results = repo.getAll()
      results.length must equalTo(0)
    }
  }
} 
开发者ID:mh120888,项目名称:surveybot,代码行数:56,代码来源:PostgresSurveyRespondentRepositorySpec.scala



注:本文中的play.api.test.WithApplication类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala HiveConf类代码示例发布时间:2022-05-23
下一篇:
Scala ReactiveMongoApi类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap