Skip to content

Instantly share code, notes, and snippets.

@nremond
Created October 17, 2012 19:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nremond/3907686 to your computer and use it in GitHub Desktop.
Save nremond/3907686 to your computer and use it in GitHub Desktop.
/**
* Copyright 2011-2012 eBusiness Information, Groupe Excilys (www.excilys.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.excilys.ebi.gatling.core.check.extractor.jsonpath
import scala.io.Source
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
object JsonExtractorSpec2 {
val document = """
{
"name":"The system 21450001-000001",
"applications":
[
{
"uid":"cdb6c07c2e544f4e83846185364efce0",
"name":"perf-msci-app-6668fc842f5a46418c45caf3773da9f1",
"revision":"V1.0"
}
],
"gateway":
{
"imei":"21450001-000001",
"macAddress":null,
"serialNumber":"21450001-000001",
"type":null,
"uid":"c0ca8e6a6ffc4fc2860bb77898539e4b",
"state":"INVENTORY"
},
"uid":"553e68f54455486b87d846e462118a47",
"state":"INVENTORY",
"activityState":"ACTIVATED"
}
""".getBytes
val extractor = new JsonPathExtractor(document)
}
@RunWith(classOf[JUnitRunner])
class JsonExtractorSpec2 extends Specification {
"extractMultiple" should {
"find only one expression matching /uid path" in {
JsonExtractorSpec2.extractor.extractMultiple("/uid") must beEqualTo(List("553e68f54455486b87d846e462118a47"))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment