<commit_before>package com.dius.pact.model

import org.specs2.mutable.Specification
import java.io.{File, StringWriter, PrintWriter}
import org.json4s.DefaultFormats

class PactSerializerSpec extends Specification {
   "PactSerializer" should {
     "serialize pact" in {
       val sw = new StringWriter()
       val pactString = io.Source.fromFile(new File("src/test/resources/test_pact.json")).mkString

       Fixtures.pact.serialize(new PrintWriter(sw))
       val json = sw.toString
       json must beEqualTo(pactString)
     }

     "deserialize pact" in {
       val pact = Pact.from(new File("src/test/resources/test_pact.json"))
       pact must beEqualTo(Fixtures.pact)
     }
   }
}<commit_msg>load test resource with classloader so tests can run as sub-project<commit_after>package com.dius.pact.model

import org.specs2.mutable.Specification
import java.io.{InputStream, StringWriter, PrintWriter}

class PactSerializerSpec extends Specification {

  def loadTestFile(name: String): InputStream = {
    this.getClass.getClassLoader.getResourceAsStream(name)
  }

   "PactSerializer" should {
     "serialize pact" in {
       val sw = new StringWriter()
       val pactString = io.Source.fromInputStream(loadTestFile("test_pact.json")).mkString

       Fixtures.pact.serialize(new PrintWriter(sw))
       val json = sw.toString
       json must beEqualTo(pactString)
     }

     "deserialize pact" in {
       val pact = Pact.from(loadTestFile("test_pact.json"))
       pact must beEqualTo(Fixtures.pact)
     }
   }
}
{'fraction_non_alphanumeric': 0.0984354628422425, 'fraction_numerical': 0.001955671447196871, 'mean_word_length': 3.4752186588921283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6645345', 'n_tokens_mistral': 481, 'n_tokens_neox': 475, 'n_words': 101}