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


Scala SpecWithJUnit类代码示例

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


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


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