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

Scala SpecWithJUnit类代码示例

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

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



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

示例1: CurrencyToCoinConverterTest

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

import org.specs2.mutable.SpecWithJUnit

class CurrencyToCoinConverterTest extends SpecWithJUnit {
  val converter = new CurrencyToCoinConverter

  "CurrencyToCoinConverter" should {
    "return the matching coin value for a given currency" in {
      converter.currencyToCoin("ILS") must beEqualTo("1")
      converter.currencyToCoin("USD") must beEqualTo("2")
      converter.currencyToCoin("EUR") must beEqualTo("3")
      converter.currencyToCoin("GBP") must beEqualTo("4")
    }

    "fail for not supported currency" in {
      converter.currencyToCoin("AAA") must throwA[IllegalCurrencyException]
    }
  }
} 
开发者ID:wix,项目名称:libpay-leumicard,代码行数:21,代码来源:CurrencyToCoinConverterTest.scala


示例2: 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


示例3: 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


示例4: 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


示例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: 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


示例12: 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


示例13: SendMessageRequestParserTest

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

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

class SendMessageRequestParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val someSendMessageRequest = SendMessageRequest(
      src = "some src",
      dst = "some dst",
      text = "some text"
    )
  }

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


示例14: SendMessageResponseParserTest

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

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

class SendMessageResponseParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val someSendMessageResponse = SendMessageResponse(
      api_id = "some api id",
      error = Some("some error"),
      message_uuid = Some(Seq("1", "2"))
    )
  }

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


示例15: JsonTranzilaAuthorizationParserTest

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


import com.wix.pay.tranzila.TranzilaMatchers._
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope


class JsonTranzilaAuthorizationParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val authorizationParser: TranzilaAuthorizationParser = new JsonTranzilaAuthorizationParser
  }

  "stringify and then parse" should {
    "yield an authorization similar to the original one" in new Ctx {
      val someAuthorization = TranzilaAuthorization(
        index = "some index",
        confirmationCode = "some confirmation code"
      )

      val authorizationKey = authorizationParser.stringify(someAuthorization)
      authorizationParser.parse(authorizationKey) must beAuthorization(
        index = ===(someAuthorization.index),
        confirmationCode = ===(someAuthorization.confirmationCode)
      )
    }
  }
} 
开发者ID:wix,项目名称:libpay-tranzila,代码行数:29,代码来源:JsonTranzilaAuthorizationParserTest.scala


示例16: JsonTranzilaMerchantParserTest

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


import com.wix.pay.tranzila.TranzilaMatchers._
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope


class JsonTranzilaMerchantParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val merchantParser: TranzilaMerchantParser = new JsonTranzilaMerchantParser
  }


  "stringify and then parse" should {
    "yield a merchant similar to the original one" in new Ctx {
      val someMerchant = TranzilaMerchant(
        username = "some username"
      )

      val merchantKey = merchantParser.stringify(someMerchant)
      merchantParser.parse(merchantKey) must beMerchant(
        username = ===(someMerchant.username)
      )
    }
  }
} 
开发者ID:wix,项目名称:libpay-tranzila,代码行数:28,代码来源:JsonTranzilaMerchantParserTest.scala


示例17: JsonWorldpayEnterpriseMerchantParserTest

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

import com.wix.pay.worldpay.enterprise.parsers.JsonWorldpayEnterpriseMerchantParser
import org.specs2.mutable.SpecWithJUnit



class JsonWorldpayEnterpriseMerchantParserTest extends SpecWithJUnit {
  val parser = new JsonWorldpayEnterpriseMerchantParser
  val merchantCode = "someMerchant"
  val merchantPassword = "somePass"

  "stringify and then parse" should {
    "return an order similar to the original one" in {
      val merchant = WorldpayEnterpriseMerchant(merchantCode, merchantPassword)
      val merchantKey = parser.stringify(merchant)

      parser.parse(merchantKey) must be_==(merchant)
    }
  }
} 
开发者ID:wix,项目名称:libpay-worldpay-enterprise,代码行数:22,代码来源:JsonWorldpayEnterpriseMerchantParserTest.scala


示例18: JsonWorldpayEnterpriseAuthorizationParserTest

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

import com.wix.pay.worldpay.enterprise.parsers.JsonWorldpayEnterpriseAuthorizationParser
import org.specs2.mutable.SpecWithJUnit



class JsonWorldpayEnterpriseAuthorizationParserTest extends SpecWithJUnit {
  val parser = new JsonWorldpayEnterpriseAuthorizationParser
  val orderCode = "123"
  val orderCurrency = "USD"

  "stringify and then parse" should {
    "return an order similar to the original one" in {
      val authorization = WorldpayEnterpriseAuthorization(orderCode, orderCurrency)
      val authorizationKey = parser.stringify(authorization)

      parser.parse(authorizationKey) must be_==(authorization)
    }
  }
} 
开发者ID:wix,项目名称:libpay-worldpay-enterprise,代码行数:22,代码来源:JsonWorldpayEnterpriseAuthorizationParserTest.scala


示例19: JsonDengionlineAuthorizationParserTest

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

import com.wix.pay.dengionline.DengionlineMatchers._
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope

class JsonDengionlineAuthorizationParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val authorizationParser: DengionlineAuthorizationParser = new JsonDengionlineAuthorizationParser

    val someAuthorization = DengionlineAuthorization(
      transactionId = "some transaction ID"
    )
  }

  "stringify and then parse" should {
    "yield an authorization similar to the original one" in new Ctx {
      val authorizationKey = authorizationParser.stringify(someAuthorization)
      authorizationParser.parse(authorizationKey) must beAuthorization(
        transactionId = ===(someAuthorization.transactionId)
      )
    }
  }
} 
开发者ID:wix,项目名称:libpay-dengionline,代码行数:25,代码来源:JsonDengionlineAuthorizationParserTest.scala


示例20: JsonDengionlineMerchantParserTest

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


import org.specs2.matcher.MustMatchers._
import org.specs2.matcher.{AlwaysMatcher, Matcher}
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope


class JsonDengionlineMerchantParserTest extends SpecWithJUnit {
  trait Ctx extends Scope {
    val merchantParser: DengionlineMerchantParser = new JsonDengionlineMerchantParser

    def beDengionlineMerchant(siteId: Matcher[String] = AlwaysMatcher(),
                              salt: Matcher[String] = AlwaysMatcher()): Matcher[DengionlineMerchant] = {
      siteId ^^ { (_: DengionlineMerchant).siteId aka "siteId" } and
        salt ^^ { (_: DengionlineMerchant).salt aka "salt" }
    }

    val someMerchant = DengionlineMerchant(
      siteId = "some site ID",
      salt = "some salt"
    )
  }

  "stringify and then parse" should {
    "yield a merchant similar to the original one" in new Ctx {
      val merchantKey = merchantParser.stringify(someMerchant)
      merchantParser.parse(merchantKey) must beDengionlineMerchant(
        siteId = ===(someMerchant.siteId),
        salt = ===(someMerchant.salt)
      )
    }
  }
} 
开发者ID:wix,项目名称:libpay-dengionline,代码行数:36,代码来源:JsonDengionlineMerchantParserTest.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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