当前位置: 首页>>代码示例>>Scala>>正文


Scala WithApplication类代码示例

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


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


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