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

Scala OneAppPerTest类代码示例

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

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



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

示例1: UsersSpec

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

import _root_.test._
import org.scalatest.Matchers._
import org.scalatest.{ TestData, WordSpec }
import org.scalatestplus.play.OneAppPerTest
import play.api._

class UsersSpec extends WordSpec with OneAppPerTest {

  override def newAppForTest(testData: TestData): Application = fakeApp

  "Users" should {
    "create and find" in {
      val users = app.injector.instanceOf(classOf[Users])
      val user = users.create(User(0L, "test1", true))
      user.id !== 0L
      val userFound = users.find(user.id)
      userFound shouldBe defined
      userFound.foreach(_.name shouldBe "test1")
    }


  }
} 
开发者ID:getquill,项目名称:play-quill-jdbc,代码行数:26,代码来源:UsersSpec.scala


示例2: writes

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

import models.Person
import org.joda.time.DateTime
import org.scalatestplus.play.{ OneAppPerTest, PlaySpec }
import play.api.libs.functional.syntax._
import play.api.libs.json.{ JsPath, Json, Reads, Writes }
import play.api.mvc.Result
import play.api.test.Helpers._
import play.api.test.{ FakeHeaders, FakeRequest }

import scala.concurrent.Future

trait PersonTestHelper extends PlaySpec with OneAppPerTest {

  private val PostHeaders = FakeHeaders(Seq("Content-type" -> "application/json"))

  private implicit val PersonWrites = new Writes[Person] {
    def writes(person: Person) = Json.obj(
      "id" -> person.id,
      "name" -> person.name,
      "age" -> person.age,
      "lastUpdate" -> person.lastUpdate
    )
  }

  private implicit val PersonReads: Reads[Person] = (
    (JsPath \ "id").read[Long] and
    (JsPath \ "name").read[String] and
    (JsPath \ "age").read[Int] and
    (JsPath \ "lastUpdate").read[DateTime]
  )(Person.apply _)

  def getPeople: Future[Result] = {
    val postRequest = FakeRequest(GET, controllers.routes.PersonController.returnPeople().url)
    route(app, postRequest).get
  }

  def postPerson(person: Person): Future[Result] = {
    val json = Json.toJson(person)
    val request = FakeRequest(POST, controllers.routes.PersonController.createPerson().url, PostHeaders, json)
    route(app, request).get
  }

  def persons(response: Future[Result]): Seq[Person] = {
    Json.fromJson[Seq[Person]](Json.parse(contentAsString(response))).get
  }
} 
开发者ID:marciogualtieri,项目名称:PersonService,代码行数:49,代码来源:PersonTestHelper.scala


示例3: SchemaSpec

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

import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import slick.driver.SQLiteDriver.api._

class SchemaSpec  extends PlaySpec with OneAppPerTest {
  "Accounts" should {
    "print the table schema" in {
      Accounts.schema.createStatements.foreach(println)
    }
  }

  "Users" should {
    "print the table schema" in {
      Users.schema.createStatements.foreach(println)
    }
  }

  "Posts" should {
    "print the table schema" in {
      Posts.schema.createStatements.foreach(println)
    }
  }
} 
开发者ID:umbc-cmcs447-grp,项目名称:rest-api,代码行数:25,代码来源:SchemaSpec.scala


示例4: RootControllerSuite

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

import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.test.FakeRequest
import play.api.test.Helpers._
import utils.TimeTestSpec

class RootControllerSuite extends PlaySpec with OneAppPerTest with TimeTestSpec {

  "index action" should {
    "render index page" in withFixture {
      finishMaintenance()

      val index = route(app, FakeRequest(GET, "/")).get

      status(index) mustBe OK
      contentType(index) mustBe Some("text/html")
      contentAsString(index) must include ("Your new application is ready.")
    }

    "render maintenance page when maintenance" in withFixture {
      startMaintenance()

      val index = route(app, FakeRequest(GET, "/")).get

      status(index) mustBe OK
      contentType(index) mustBe Some("text/html")
      contentAsString(index) must include ("Under maintenance.")
    }
  }

  "api action" should {
    "return OK" in withFixture {
      finishMaintenance()

      route(app, FakeRequest(GET, "/api")).map(status) mustBe Some(OK)
    }

    "return ServiceUnavailable when maintenance" in withFixture {
      startMaintenance()

      route(app, FakeRequest(GET, "/api")).map(status) mustBe Some(SERVICE_UNAVAILABLE)
    }
  }

} 
开发者ID:harry0000,项目名称:PlayTime-basedTestingSample,代码行数:47,代码来源:RootControllerSuite.scala


示例5: StorageUrlControllerTest

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

import com.google.gson.Gson
import domain.storage.StorageUrl
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class StorageUrlControllerTest extends PlaySpec with OneAppPerTest {
  val gson = new Gson()
  val storageUrl = StorageUrl(
    "SIT52",
    "458K",
    "Triu",
    "https://zi.com")

  "Routes" should {
    "StorageUrlController" should {

      "Create StorageUrl Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/storageUrl/create")
          .withJsonBody(Json.toJson(storageUrl)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get StorageUrl From Controller" in {
        val request = route(app, FakeRequest(GET, "/storageUrl/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:41,代码来源:StorageUrlControllerTest.scala


示例6: FileMetaControllerTest

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

import com.google.gson.Gson
import domain.storage.FileMeta
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class FileMetaControllerTest extends PlaySpec with OneAppPerTest {
  val gson = new Gson()
  val fileMeta = FileMeta(
    "SIT52",
    "Mozulla",
    "Triupa")

  "Routes" should {
    "FileMetaController" should {

      "Create FileMeta Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/fileMeta/create")
          .withJsonBody(Json.toJson(fileMeta)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get FileMeta From Controller" in {
        val request = route(app, FakeRequest(GET, "/fileMeta/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:40,代码来源:FileMetaControllerTest.scala


示例7: FileResultsControllerTest

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

import com.google.gson.Gson
import domain.storage.FileResults
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._



class FileResultsControllerTest extends PlaySpec with OneAppPerTest {
  val gson = new Gson()
  val fileResults = FileResults(
    "SIT52",
    "MO47",
    "https://tri.com",
    Option("Triupa"))

  "Routes" should {
    "FileResultsController" should {

      "Create FileResults Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/fileResults/create")
          .withJsonBody(Json.toJson(fileResults)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get FileResults From Controller" in {
        val request = route(app, FakeRequest(GET, "/fileResults/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:42,代码来源:FileResultsControllerTest.scala


示例8: UserImagesControllerTest

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

import com.google.gson.Gson
import domain.users.UserImages
import org.joda.time.DateTime
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class UserImagesControllerTest extends PlaySpec with OneAppPerTest {
  val gson = new Gson()
  val userImages = UserImages(
    "SIT52",
    "458K",
    "DO67",
    "https://zi.com",
    "Triu",
    "GHJ",
    Option("gugu"),
    new DateTime("2004-12-13T21:39:45.618-08:00"))

  "Routes" should {
    "UserImagesController" should {

      "Create UserImages Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/userImages/create")
          .withJsonBody(Json.toJson(userImages)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get UserImages From Controller" in {
        val request = route(app, FakeRequest(GET, "/userImages/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:46,代码来源:UserImagesControllerTest.scala


示例9: UserPositionControllerTest

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

import com.google.gson.Gson
import domain.users.UserPosition
import org.joda.time.DateTime
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class UserPositionControllerTest extends PlaySpec with OneAppPerTest {
  val gson = new Gson()
  val userImages = UserPosition(
    "SIT52",
    "458K",
    "DO67",
    new DateTime("2004-12-13T21:39:45.618-08:00"),
    "PO354",
    "Triu",
    "GHJ")

  "Routes" should {
    "UserPositionController" should {

      "Create UserPosition Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/userPosition/create")
          .withJsonBody(Json.toJson(userImages)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get UserPosition From Controller" in {
        val request = route(app, FakeRequest(GET, "/userPosition/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:45,代码来源:UserPositionControllerTest.scala


示例10: UserRoleControllerTest

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

import com.google.gson.Gson
import domain.users.UserRole
import org.joda.time.DateTime
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class UserRoleControllerTest extends PlaySpec with OneAppPerTest {
  val gson = new Gson()
  val userImages = UserRole(
    "SIT52",
    "458K",
    "DO67",
    "Triu",
     new DateTime("2004-12-13T21:39:45.618-08:00")
   )

  "Routes" should {
    "UserRoleController" should {

      "Create UserRole Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/userRole/create")
          .withJsonBody(Json.toJson(userImages)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get UserRole From Controller" in {
        val request = route(app, FakeRequest(GET, "/userRole/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:44,代码来源:UserRoleControllerTest.scala


示例11: JobEventControllerTest

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

import com.google.gson.Gson
import domain.job.JobEvent
import org.joda.time.DateTime
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class JobEventControllerTest  extends PlaySpec with OneAppPerTest {

  val gson = new Gson()
  val job = JobEvent(
    "1",
    "1",
    new DateTime("2016-12-13T21:39:45.618-08:00"),
    "Sandton"
  )

  "Routes" should {
    "JobEventController" should {

      "Create JobEvent Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/jobEvent/create")
          .withJsonBody(Json.toJson(job)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get JobEvent From Controller" in {
        val request = route(app, FakeRequest(GET, "/jobEvent/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:44,代码来源:JobEventControllerTest.scala


示例12: JobControllerTest

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

import com.google.gson.Gson
import domain.job.Job
import org.joda.time.DateTime
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class JobControllerTest extends PlaySpec with OneAppPerTest {

  val gson = new Gson()
  val job = Job(
    "1",
    "1",
    "1",
    "SIT52",
    "7754",
    "Triu",
    new DateTime("2016-12-13T21:39:45.618-08:00"),
    "RSA"
  )

  "Routes" should {
    "JobController" should {

      "Create Job Object in Through Controller" in {
        val request = route(app, FakeRequest(POST, "/job/create")
          .withJsonBody(Json.toJson(job)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get Job From Controller" in {
        val request = route(app, FakeRequest(GET, "/job/")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:48,代码来源:JobControllerTest.scala


示例13: newAppForTest

//设置package包名称以及导入依赖的类
import org.scalatest.{Suite, TestData}
import org.scalatestplus.play.{OneAppPerSuite, OneAppPerTest, OneServerPerSuite, OneServerPerTest}
import play.api.{BuiltInComponents, _}

trait OneAppPerTestWithComponents[T <: BuiltInComponents]
  extends OneAppPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneAppPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneAppPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>
  override implicit lazy val app: Application = newApplication
}

trait OneServerPerTestWithComponents[T <: BuiltInComponents]
  extends OneServerPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneServerPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneServerPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>

  override implicit lazy val app: Application = newApplication
} 
开发者ID:wsargent,项目名称:play-cucumber,代码行数:35,代码来源:ScalaTestWithComponents.scala


示例14: DaoTest

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

import org.scalatestplus.play.{OneAppPerTest, PlaySpec}

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

class DaoTest extends PlaySpec with OneAppPerTest {

  "CSV DAO" should {

    "number of runways should be equal to 39536" in {
      val csvDAO = new CsvDAO
      val res = Await.result(csvDAO.allRunaways(), Duration.create(10, scala.concurrent.duration.SECONDS))
      res.length mustBe 39536
    }

    "number of airports should be equal to 46505" in {
      val csvDAO = new CsvDAO
      val res = Await.result(csvDAO.allAirports(), Duration.create(10, scala.concurrent.duration.SECONDS))
      res.length mustBe 46505
    }

    "number of countries should be equal to 247" in {
      val csvDAO = new CsvDAO
      val res = Await.result(csvDAO.allCountries(), Duration.create(10, scala.concurrent.duration.SECONDS))
      res.length mustBe 247
    }

    "number of airports for russia should be equal to 920" in {
      val csvDAO = new CsvDAO
      val res = Await.result(csvDAO.findAirportsByName("russia"), Duration.create(10, scala.concurrent.duration.SECONDS))
      res.length mustBe 920
    }

    "number of airports for country should be equal to both lowercase and uppercase" in {
      val csvDAO = new CsvDAO
      val res1 = Await.result(csvDAO.findAirportsByName("netherlands"), Duration.create(10, scala.concurrent.duration.SECONDS))
      val res2 = Await.result(csvDAO.findAirportsByName("NETHERLANDS"), Duration.create(10, scala.concurrent.duration.SECONDS))
      res1.length mustBe res2.length
    }

    "number of airports for top-3 countries" in {
      val csvDAO = new CsvDAO
      val res = Await.result(csvDAO.allCountriesSortedByNumberOfAirports(), Duration.create(10, scala.concurrent.duration.SECONDS))
      res.length mustBe 247
      res.apply(0)._1.code mustBe "US"
      res.apply(0)._2 mustBe 21501
      res.apply(1)._1.code mustBe "BR"
      res.apply(1)._2 mustBe 3839
      res.apply(2)._1.code mustBe "CA"
      res.apply(2)._2 mustBe 2454
    }
  }

} 
开发者ID:MysterionRise,项目名称:airport-dangerzone,代码行数:57,代码来源:DaoTest.scala


示例15: ClassificationControllerTest

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

import domain.Classification.Classification
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class ClassificationControllerTest extends PlaySpec with OneAppPerTest {
  val classification = Classification(
    "test",
    "1",
    "test",
    "test")

  "Routes" should {



    "ClassificationController" should {

      "Create Classification Object in Through Controller" in {
        val request =  route(app, FakeRequest(POST, "/classification/create")
          .withJsonBody(Json.toJson(classification)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get Classification From Controller" in {
        val request = route(app, FakeRequest(GET, "/classification/1")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:42,代码来源:ClassificationControllerTest.scala


示例16: ItemAdditionalClassificationsControllerTest

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

import domain.Item.ItemAdditionalClassifications
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class ItemAdditionalClassificationsControllerTest extends PlaySpec with OneAppPerTest {
  val itemAdditionalClassifications = ItemAdditionalClassifications(
    "4",
    "8")

  "Routes" should {



    "ItemAdditionalClassificationsController" should {

      "Create ItemAdditionalClassifications Object in Through Controller" in {
        val request =  route(app, FakeRequest(POST, "/itemAdditionalClassifications/create")
          .withJsonBody(Json.toJson(itemAdditionalClassifications)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get ItemAdditionalClassifications From Controller" in {
        val request = route(app, FakeRequest(GET, "/itemAdditionalClassifications/4/8")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:40,代码来源:ItemAdditionalClassificationsControllerTest.scala


示例17: ItemUnitControllerTest

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

import domain.Item.ItemUnit
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class ItemUnitControllerTest extends PlaySpec with OneAppPerTest {
  val itemUnit = ItemUnit(
    "4",
    "8")

  "Routes" should {



    "ItemUnitController" should {

      "Create ItemUnit Object in Through Controller" in {
        val request =  route(app, FakeRequest(POST, "/itemUnit/create")
          .withJsonBody(Json.toJson(itemUnit)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get ItemUnit From Controller" in {
        val request = route(app, FakeRequest(GET, "/itemUnit/4/8")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:40,代码来源:ItemUnitControllerTest.scala


示例18: ItemControllerTest

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

import Item.Item
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class ItemControllerTest extends PlaySpec with OneAppPerTest {
  val item = Item(
    "1",
    "test",
    10)

  "Routes" should {



    "ItemController" should {

      "Create Item Object in Through Controller" in {
        val request =  route(app, FakeRequest(POST, "/item/create")
          .withJsonBody(Json.toJson(item)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get Item From Controller" in {
        val request = route(app, FakeRequest(GET, "/item/1")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:41,代码来源:ItemControllerTest.scala


示例19: ItemLotControllerTest

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

import domain.Item.ItemLot
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class ItemLotControllerTest extends PlaySpec with OneAppPerTest {
  val itemLot = ItemLot(
    "4",
    "8")

  "Routes" should {



    "ItemLotController" should {

      "Create ItemLot Object in Through Controller" in {
        val request =  route(app, FakeRequest(POST, "/itemLot/create")
          .withJsonBody(Json.toJson(itemLot)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get ItemLot From Controller" in {
        val request = route(app, FakeRequest(GET, "/itemLot/4/8")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:40,代码来源:ItemLotControllerTest.scala


示例20: ItemPeriodControllerTest

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

import domain.Item.ItemPeriod
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._


class ItemPeriodControllerTest extends PlaySpec with OneAppPerTest {
  val itemPeriod = ItemPeriod(
    "4",
    "8")

  "Routes" should {



    "ItemPeriodController" should {

      "Create ItemPeriod Object in Through Controller" in {
        val request =  route(app, FakeRequest(POST, "/itemPeriod/create")
          .withJsonBody(Json.toJson(itemPeriod)))
          .get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Content is ", contentAsString(request))
      }

      "Get ItemPeriod From Controller" in {
        val request = route(app, FakeRequest(GET, "/itemPeriod/4/8")
        ).get
        status(request) mustBe OK
        contentType(request) mustBe Some("application/json")
        println(" The Output", contentAsJson(request))
      }
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:40,代码来源:ItemPeriodControllerTest.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Stash类代码示例发布时间:2022-05-23
下一篇:
Scala Names类代码示例发布时间: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