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


Scala Scope类代码示例

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


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

示例1: JsonLeumiCardMerchantParserTest

//设置package包名称以及导入依赖的类
package com.wix.pay.leumicard

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class JsonLeumiCardMerchantParserTest extends SpecWithJUnit {

  "stringify and then parse" should {
    "yield a merchant similar to the original one" in new Context {
      val someMerchant = LeumiCardMerchant(masof = "012345678")

      val merchantKey = merchantParser.stringify(someMerchant)

      merchantParser.parse(merchantKey) must beEqualTo(someMerchant)
    }
  }

  trait Context extends Scope {
    val merchantParser: LeumiCardMerchantParser = new JsonLeumiCardMerchantParser
  }
} 
开发者ID:wix,项目名称:libpay-leumicard,代码行数:22,代码来源:JsonLeumiCardMerchantParserTest.scala

示例2: JsonLeumiCardAuthorizationParserTest

//设置package包名称以及导入依赖的类
package com.wix.pay.leumicard

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class JsonLeumiCardAuthorizationParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val authorizationParser: LeumiCardAuthorizationParser = new JsonLeumiCardAuthorizationParser
  }

  "stringify and then parse" should {
    "yield an authorization similar to the original one" in new Ctx {
      val someAuthorization = LeumiCardAuthorization(
        transactionId = "0123456"
      )

      val authorizationKey = authorizationParser.stringify(someAuthorization)
      authorizationParser.parse(authorizationKey) must beEqualTo(someAuthorization)
    }
  }
} 
开发者ID:wix,项目名称:libpay-leumicard,代码行数:22,代码来源:JsonLeumiCardAuthorizationParserTest.scala

示例3: ResponseParserTest

//设置package包名称以及导入依赖的类
package com.wix.sms.nexmo.model

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class ResponseParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val someResponse = Response(
      `message-count` = "1",
      messages = Seq(Message(
        status = Statuses.success,
        to = Some("some to")
      ))
    )

    val parser = new ResponseParser
  }

  "stringify and then parse" should {
    "yield an object similar to the original one" in new Ctx {
      val json = parser.stringify(someResponse)
      parser.parse(json) must beEqualTo(someResponse)
    }
  }
} 
开发者ID:wix,项目名称:libsms-nexmo,代码行数:26,代码来源:ResponseParserTest.scala

示例4: PaginatedResponseRetrieverSpec

//设置package包名称以及导入依赖的类
package com.dwolla.awssdk.utils

import com.amazonaws.services.ecs.AmazonECSAsync
import com.amazonaws.services.ecs.model.{ListClustersRequest, ListClustersResult, ListContainerInstancesRequest, ListContainerInstancesResult}
import com.dwolla.awssdk.AmazonAsyncMockingImplicits._
import com.dwolla.awssdk.utils.PaginatedResponseRetriever._
import org.specs2.concurrent.ExecutionEnv
import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
import org.specs2.specification.Scope

import scala.collection.JavaConverters._

class PaginatedResponseRetrieverSpec(implicit ee: ExecutionEnv) extends Specification with Mockito {

  trait Setup extends Scope {
    val mockEcsClient = mock[AmazonECSAsync]
  }

  "PaginatedResponseRetriever" should {
    "make all the requests necessary to fetch all paginated results" in new Setup {
      def reqWithNextToken(x: Option[Int]) = new ListContainerInstancesRequest().withCluster("cluster1").withNextToken(x.map(i ? s"next-token-$i").orNull)

      def res(x: Int, y: Option[Int] = None) = Right(new ListContainerInstancesResult().withContainerInstanceArns(s"arn$x").withNextToken(y.map(i ? s"next-token-$i").orNull))

      val pages = 1 to 50
      val pairs = pages.sliding(2).toSeq.map {
        case Vector(1, y) ? reqWithNextToken(None) ? res(1, Option(y))
        case Vector(x, y) if x > 1 && y < pages.last ? reqWithNextToken(Option(x)) ? res(x, Option(y))
        case Vector(x, _) ? reqWithNextToken(Option(x)) ? res(x, None)
      }

      mockedMethod(mockEcsClient.listContainerInstancesAsync) answers (pairs: _*)

      val output = fetchAll(() ? new ListContainerInstancesRequest().withCluster("cluster1"),mockEcsClient.listContainerInstancesAsync)
        .map(_.flatMap(_.getContainerInstanceArns.asScala.toList))

      output must containTheSameElementsAs(pages.dropRight(1).map(x ? s"arn$x")).await
    }

    "support default request factory" in new Setup {
      new ListClustersResult() completes mockEcsClient.listClustersAsync

      val output = fetchAllWithDefaultRequestsVia(mockEcsClient.listClustersAsync)

      output must contain(new ListClustersResult()).await
    }

    "support builder syntax with factory as initial parameter" in new Setup {
      new ListClustersResult() completes mockEcsClient.listClustersAsync

      val output = fetchAllWithRequestsLike(() ? new ListClustersRequest).via(mockEcsClient.listClustersAsync)

      output must contain(new ListClustersResult()).await
    }
  }
} 
开发者ID:Dwolla,项目名称:scala-aws-utils,代码行数:58,代码来源:PaginatedResponseRetrieverSpec.scala

示例5: PaloParserTest

//设置package包名称以及导入依赖的类
package com.wix.sms.cellact.model

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

import scala.collection.JavaConversions._

class PaloParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val parser = new PaloParser
  }

  "stringify and then parse" should {
    val palo = new Palo

    palo.HEAD = new Head
    palo.HEAD.FROM = "some from"
    palo.HEAD.APP = new App
    palo.HEAD.APP.USER = "some user"
    palo.HEAD.APP.PASSWORD = "some password"
    palo.HEAD.CMD = "some cmd"

    palo.BODY = new Body
    palo.BODY.CONTENT = "some content"
    palo.BODY.DEST_LIST = new DestList
    palo.BODY.DEST_LIST.TO = Seq("some to 1", "some to 2")

    palo.OPTIONAL = new Optional
    palo.OPTIONAL.CALLBACK = "some callback"

    "yield an object similar to the original one" in new Ctx {
      val xml = parser.stringify(palo)
      parser.parse(xml) must beEqualTo(palo)
    }
  }
} 
开发者ID:wix,项目名称:libsms-cellact,代码行数:37,代码来源:PaloParserTest.scala

示例6: ResponseParserTest

//设置package包名称以及导入依赖的类
package com.wix.sms.cellact.model

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class ResponseParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val parser = new ResponseParser
  }

  "stringify and then parse" should {
    val response = new Response
    response.BLMJ = "some blmj"
    response.RESULTCODE = "123"
    response.RESULTMESSAGE = "some resultmessage"

    "yield an object similar to the original one" in new Ctx {
      val xml = parser.stringify(response)
      parser.parse(xml) must beEqualTo(response)
    }
  }
} 
开发者ID:wix,项目名称:libsms-cellact,代码行数:23,代码来源:ResponseParserTest.scala

示例7: RSAUtilsTest

//设置package包名称以及导入依赖的类
package com.wix.pay.twocheckout.tokenization

import java.security.spec.RSAPublicKeySpec
import java.security.{KeyFactory, KeyPairGenerator}
import javax.crypto.Cipher

import org.apache.commons.codec.binary.Base64
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class RSAUtilsTest extends SpecWithJUnit {

  "RSAUtils" should {

    "encrypt data with provided key in base64 format" in new Ctx {
      val encrypted = RSAUtils.rsaEncrypt(publicKey, someMessage)
      decryptBase64(encrypted) mustEqual someMessage
    }

    "encrypt empty string with provided key in base64 format" in new Ctx {
      val encrypted = RSAUtils.rsaEncrypt(publicKey, emptyMessage)
      decryptBase64(encrypted) mustEqual emptyMessage
    }
  }

  trait Ctx extends Scope {
    val factory = KeyPairGenerator.getInstance("RSA")
    factory.initialize(2048)

    val keys = factory.genKeyPair()
    val publicKeySpec = KeyFactory.getInstance("RSA").getKeySpec(keys.getPublic, classOf[RSAPublicKeySpec])
    val publicKey = RSAPublicKey(
      Base64.encodeBase64String(publicKeySpec.getModulus.toByteArray),
      Base64.encodeBase64String(publicKeySpec.getPublicExponent.toByteArray)
    )
    println(publicKey)
    val someMessage = "some message hello"
    val emptyMessage = ""

    def decryptBase64(encrypted: String): String = {
      val bytes = Base64.decodeBase64(encrypted)
      val cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING")
      cipher.init(Cipher.DECRYPT_MODE, keys.getPrivate)
      new String(cipher.doFinal(bytes), "utf-8")
    }
  }

} 
开发者ID:wix,项目名称:libpay-2checkout,代码行数:49,代码来源:RSAUtilsTest.scala

示例8: RealTwocheckoutTokenizerTest

//设置package包名称以及导入依赖的类
package com.wix.pay.twocheckout.tokenizer

import com.wix.pay.PaymentErrorException
import com.wix.pay.creditcard.{CreditCard, CreditCardOptionalFields, YearMonth}
import com.wix.pay.twocheckout.model.{TwocheckoutEnvironment, TwocheckoutSettings}
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class RealTwocheckoutTokenizerTest extends SpecWithJUnit {
  skipAll

  "HttpTwocheckoutTokenizer" should {
    "obtain token on valid credentials" in new Ctx {
      tokenizer.tokenize(sellerId, publishableKey, testCreditCard, true) must beSuccessfulTry[String]
    }

    "fail on invalid credentials" in new Ctx {
      tokenizer.tokenize(wrongSellerId, publishableKey, testCreditCard, true) must beFailedTry(beAnInstanceOf[PaymentErrorException])
    }
  }

  trait Ctx extends Scope {
    val settings = TwocheckoutSettings(
      production = TwocheckoutEnvironment("https://www.2checkout.com", "https://www.2checkout.com/checkout/api/2co.min.js"),
      sandbox = TwocheckoutEnvironment("https://sandbox.2checkout.com", "https://sandbox.2checkout.com/checkout/api/2co.min.js")
    )
    val tokenizer = new HttpTwocheckoutTokenizer(settings)

    
    val sellerId = "901338726"
    val publishableKey = "19CFABDB-BA94-45B8-935A-E3A1B2469F1F"

    val wrongSellerId = "11111111"

    val testCreditCard = CreditCard("4000000000000002", YearMonth(2019, 1),
      Some(CreditCardOptionalFields.withFields(csc = Some("471"), holderName = Some("John Doe"))))
  }
} 
开发者ID:wix,项目名称:libpay-2checkout,代码行数:39,代码来源:RealTwocheckoutTokenizerTest.scala

示例9: JsonTwocheckoutMerchantParserTest

//设置package包名称以及导入依赖的类
package com.wix.pay.twocheckout


import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope


class JsonTwocheckoutMerchantParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val parser: TwocheckoutMerchantParser = JsonTwocheckoutMerchantParser
  }

  "stringify and then parse" should {
    "yield a merchant similar to the original one" in new Ctx {
      val someMerchant = TwocheckoutMerchant(
        sellerId = "some seller ID",
        publishableKey = "some publishable key",
        privateKey = "some private key",
        sandboxMode = true
      )

      val merchantKey = parser.stringify(someMerchant)
      parser.parse(merchantKey) must beEqualTo(someMerchant)
    }

    "parse credentials without explicit mode" in new Ctx {
      val someMerchantStr = """{"sellerId":"sellerId","publishableKey":"publishableKey","privateKey":"privateKey"}"""
      val someMerchant = TwocheckoutMerchant(
        sellerId = "sellerId",
        publishableKey = "publishableKey",
        privateKey = "privateKey",
        sandboxMode = false
      )

      parser.parse(someMerchantStr) must beEqualTo(someMerchant)
    }
  }
} 
开发者ID:wix,项目名称:libpay-2checkout,代码行数:39,代码来源:JsonTwocheckoutMerchantParserTest.scala

示例10: JsonTwocheckoutAuthorizationParserTest

//设置package包名称以及导入依赖的类
package com.wix.pay.twocheckout


import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope


class JsonTwocheckoutAuthorizationParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val parser: TwocheckoutAuthorizationParser = JsonTwocheckoutAuthorizationParser
  }

  "stringify and then parse" should {
    "yield a merchant similar to the original one" in new Ctx {
      val someAuthorization = TwocheckoutAuthorization()

      val authorizationKey = parser.stringify(someAuthorization)
      parser.parse(authorizationKey) must beEqualTo(someAuthorization)
    }
  }
} 
开发者ID:wix,项目名称:libpay-2checkout,代码行数:22,代码来源:JsonTwocheckoutAuthorizationParserTest.scala

示例11: NetworkBrokerSpec

//设置package包名称以及导入依赖的类
package net.ruippeixotog.scalafbp.runtime

import akka.actor.Props
import akka.testkit.TestProbe
import org.specs2.specification.Scope
import spray.json.DefaultJsonProtocol._

import net.ruippeixotog.akka.testkit.specs2.mutable.AkkaSpecification
import net.ruippeixotog.scalafbp.component.PortDataMarshaller
import net.ruippeixotog.scalafbp.component.core.Repeat

abstract class NetworkBrokerSpec extends AkkaSpecification {

  class SingleNodeGraph extends GraphTemplate {
    val n1 = node[String](1, 1)
  }

  class TwoNodeGraph extends GraphTemplate {
    val n1, n2 = node[String](1, 1)
  }

  class ThreeNodeGraph extends GraphTemplate {
    val n1, n2, n3 = node[String](1, 1)
  }

  class ChainGraph[A: PortDataMarshaller] extends GraphTemplate {
    val inNode = node(Repeat)
    val outNode = node[A](1, 1)
    initial("init") ~> (inNode, "in")
    (inNode, "out") ~> (outNode, 1)
  }

  class TwoToTwoGraph extends GraphTemplate {
    val inNode1, inNode2, outNode1, outNode2 = node[String](1, 1)
    (inNode1, 1) ~> (outNode1, 1) <~ (inNode2, 1)
    (inNode1, 1) ~> (outNode2, 1) <~ (inNode2, 1)
  }

  abstract class BrokerInstance(dynamic: Boolean = false) extends Scope {
    def _graph: GraphTemplate
    def externalProbe: TestProbe = null

    val lifeProbe, outputProbe = TestProbe()
    val broker = system.actorOf(Props(
      new NetworkBroker(_graph, dynamic, outputProbe.ref, Option(externalProbe).map(_.ref))))

    lifeProbe.watch(broker)
  }
} 
开发者ID:ruippeixotog,项目名称:scalafbp,代码行数:50,代码来源:NetworkBrokerSpec.scala

示例12: SmsResponseParserTest

//设置package包名称以及导入依赖的类
package com.wix.sms.twilio.model

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class SmsResponseParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val someSmsResponse = SmsResponse(
      sid = Some("some sid")
    )
  }

  "stringify and then parse" should {
    "yield an object similar to the original one" in new Ctx {
      val json = SmsResponseParser.stringify(someSmsResponse)
      SmsResponseParser.parse(json) must beEqualTo(someSmsResponse)
    }
  }
} 
开发者ID:wix,项目名称:libsms-twilio,代码行数:20,代码来源:SmsResponseParserTest.scala

示例13: HomeControllerSpec

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

import models.UsersRepository
import org.specs2.execute.{AsResult, Result}
import org.specs2.mutable.Around
import org.specs2.specification.Scope
import play.api.Application
import play.api.mvc._
import play.api.test.{FakeRequest, PlaySpecification}

class HomeControllerSpec extends PlaySpecification with Results {

  abstract class WithTestApplication extends Around with Scope with TestEnvironment {
    lazy val app: Application = fakeApp
    lazy val controller = new HomeController(knolxControllerComponent)

    override def around[T: AsResult](t: => T): Result = {
      TestHelpers.running(app)(AsResult.effectively(t))
    }
  }

  "HomeController" should {

    "redirect index page to sessions page" in new WithTestApplication {
      val result = controller.index(FakeRequest())

      status(result) must be equalTo SEE_OTHER
    }

  }

} 
开发者ID:knoldus,项目名称:knolx-portal,代码行数:33,代码来源:HomeControllerSpec.scala

示例14: CreditCardMapperTest

//设置package包名称以及导入依赖的类
package com.wix.pay.stripe

import com.wix.pay.creditcard.{CreditCard, CreditCardOptionalFields, PublicCreditCardOptionalFields, YearMonth}
import com.wix.pay.stripe.drivers.StripeMatchers
import org.specs2.mutable.SpecificationWithJUnit
import org.specs2.specification.Scope

class CreditCardMapperTest extends SpecificationWithJUnit with StripeMatchers {
  "CreditCardMapper" should {
    "create params with all relevant fields " in new ctx{
      CreditCardMapper.cardToParams(someCreditCard) must haveFieldParams(expectedFields)
    }

    "return params without address and zip code as they are empty Strings " in new ctx {
      CreditCardMapper.cardToParams(emptyFieldsCreditCard) must not(haveAnyEmptyFields)
    }
  }

  trait ctx extends Scope {
    val holderId: Some[String] = Some("some holder id")
    val holderName: Some[String] = Some("some holder name")
    val billingAddress: Some[String] = Some("some address")
    val billingPostalCode: Some[String] = Some("some postal Code")

    val someCreditCard = CreditCard(
      "4012888818888",
      YearMonth(2020, 12),
      additionalFields = Some(CreditCardOptionalFields.withFields(
        csc = Some("123"),
        holderId = holderId,
        holderName = holderName,
        billingAddress = billingAddress,
        billingPostalCode = billingPostalCode)))

    val emptyFieldsCreditCard = CreditCard(
      "4012888818888",
      YearMonth(2020, 12),
      additionalFields = Some(CreditCardOptionalFields.withFields(
        csc = Some("123"),
        holderId = holderId,
        holderName = holderName,
        billingAddress = Some(""),
        billingPostalCode = Some(""))))

    val expectedFields = PublicCreditCardOptionalFields(holderId, holderName, billingAddress, billingPostalCode)
  }
} 
开发者ID:wix,项目名称:libpay-stripe,代码行数:48,代码来源:CreditCardMapperTest.scala

示例15: StripeAdditionalInfoMapperTest

//设置package包名称以及导入依赖的类
package com.wix.pay.stripe

import com.wix.pay.stripe.drivers.{StripeAdditionalInfoDomain, StripeMatchers}
import org.specs2.matcher.Matchers
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope


class StripeAdditionalInfoMapperTest extends SpecWithJUnit with Matchers with StripeMatchers {

  trait Ctx extends Scope with StripeAdditionalInfoDomain {
    val mapper = new StripeAdditionalInfoMapper()

  }

  "Stripe additional info mapper" should {
    "map additional Info into a map" in new Ctx {
      val map: MappedParams = mapper.createMap(someCreditCard, someCustomer, someDeal)
      map must {
        containBillingAddress(billingAddress.get) and
          containCustomer(someCustomer.get) and
          containInvoiceId(someInvoiceId.get) and
          containShippingAddress(someShippingAddress.get) and
          containOrderItems(orderItems) and
          containIncludedCharges(includedCharges.get)
      }

    }
  }
} 
开发者ID:wix,项目名称:libpay-stripe,代码行数:31,代码来源:StripeAdditionalInfoMapperTest.scala


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