<commit_before>package com.twitter.scrooge.java_generator

import org.specs.SpecificationWithJUnit
import com.twitter.scrooge.frontend._
import java.io._
import com.github.mustachejava.DefaultMustacheFactory
import com.twitter.mustache.ScalaObjectHandler
import org.specs.mock.Mockito
import com.google.common.base.Charsets
import com.google.common.io.CharStreams
import com.twitter.scrooge.ast._
import com.twitter.scrooge.java_generator.test.ApacheCompatibilityHelpers
import com.twitter.scrooge.frontend.{ResolvedDocument, TypeResolver}
import com.twitter.scrooge.ast.Document

/**
 * To generate the apache output for birdcage compatible thrift:
 * ~/birdcage/maven-plugins/maven-finagle-thrift-plugin/src/main/resources/thrift/thrift-finagle.osx10.6
 *     --gen java -o /tmp/thrift test_thrift/empty_struct.thrift
 */
class ApacheJavaGeneratorSpec extends SpecificationWithJUnit with Mockito {
  def generateDoc(str: String) = {
    val importer = Importer("src/test/resources/test_thrift")
    val parser = new ThriftParser(importer, true, allowOneways = true)
    val doc = parser.parse(str, parser.document)
    TypeResolver(allowStructRHS = true)(doc).document
  }

  def getGenerator(doc0: Document, genHashcode: Boolean = false) = {
    new ApacheJavaGenerator(Map(), "thrift", genHashcode = genHashcode)
  }

  def getFileContents(resource: String) = {
    val ccl = Thread.currentThread().getContextClassLoader
    val is = ccl.getResourceAsStream(resource)<commit_msg>[split] fix test breakage on sbt<commit_after>package com.twitter.scrooge.java_generator

import org.specs.SpecificationWithJUnit
import com.twitter.scrooge.frontend._
import java.io._
import com.github.mustachejava.DefaultMustacheFactory
import com.twitter.mustache.ScalaObjectHandler
import org.specs.mock.Mockito
import com.google.common.base.Charsets
import com.google.common.io.CharStreams
import com.twitter.scrooge.ast._
import com.twitter.scrooge.java_generator.test.ApacheCompatibilityHelpers
import com.twitter.scrooge.frontend.{ResolvedDocument, TypeResolver}
import com.twitter.scrooge.ast.Document

/**
 * To generate the apache output for birdcage compatible thrift:
 * ~/birdcage/maven-plugins/maven-finagle-thrift-plugin/src/main/resources/thrift/thrift-finagle.osx10.6
 *     --gen java -o /tmp/thrift test_thrift/empty_struct.thrift
 */
class ApacheJavaGeneratorSpec extends SpecificationWithJUnit with Mockito {
  def generateDoc(str: String) = {
    val importer = Importer(Seq("src/test/resources/test_thrift", "scrooge-generator/src/test/resources/test_thrift"))  
    val parser = new ThriftParser(importer, true, allowOneways = true)
    val doc = parser.parse(str, parser.document)
    TypeResolver(allowStructRHS = true)(doc).document
  }

  def getGenerator(doc0: Document, genHashcode: Boolean = false) = {
    new ApacheJavaGenerator(Map(), "thrift", genHashcode = genHashcode)
  }

  def getFileContents(resource: String) = {
    val ccl = Thread.currentThread().getContextClassLoader
    val is = ccl.getResourceAsStream(resource)
{'fraction_non_alphanumeric': 0.1011826544021025, 'fraction_numerical': 0.002628120893561104, 'mean_word_length': 5.239754098360656, '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': '6894425', 'n_tokens_mistral': 942, 'n_tokens_neox': 946, 'n_words': 179}