Before

1/* -*-mode:scala; c-basic-offset:2; indent-tabs-mode:nil -*- */
2package com.jcraft.jzlib
3
4import org.scalatest._
5import org.scalatest.matchers.ShouldMatchers
6
7import java.io._
8
9import JZlib._
10
11class GZIPIOStreamTest extends FlatSpec with BeforeAndAfter with ShouldMatchers {
12
13 before {
14 }
15
16 after {
17 }
18
19 behavior of "GZipOutputStream and GZipInputStream"
20
21 it can "deflate and infate data." in {
22
23 val comment = "hi"
24 val name = "/tmp/foo"
25
…lines 26–49 unchanged (24 lines)
50
51 val crc32 = new CRC32
52 crc32.update(content, 0, content.length)
53
54 crc32.getValue should equal(gis.getCRC.asInstanceOf[Long])
55 }
56}
57

After

1/* -*-mode:scala; c-basic-offset:2; indent-tabs-mode:nil -*- */
2package com.jcraft.jzlib
3
4import org.scalatest._
5import org.scalatest.matchers.ShouldMatchers
6
7import java.io._
8import java.util.zip.CheckedOutputStream
9import java.util.zip.CheckedInputStream
10import java.util.zip.{GZIPInputStream => juzGZIPInputStream}
11import java.util.zip.{CRC32 => juzCRC32}
12
13import JZlib._
14
15class GZIPIOStreamTest extends FlatSpec with BeforeAndAfter with ShouldMatchers {
16
17 before {
18 }
19
20 after {
21 }
22
23 behavior of "GZIPOutputStream and GZIPInputStream"
24
25 it can "deflate and infate data." in {
26
27 val comment = "hi"
28 val name = "/tmp/foo"
29
…lines 30–54 unchanged (25 lines)
55 val crc32 = new CRC32
56 crc32.update(content, 0, content.length)
57
58 crc32.getValue should equal(gis.getCRC.asInstanceOf[Long])
59 }
60
61 behavior of "GZIPOutputStream"
62
63 // https://github.com/ymnk/jzlib/issues/9
64 // https://github.com/jglick/jzlib-9-demo
65 it can "deflate some file without AIOOBE." in {
66 val pos = new PipedOutputStream()
67 val pis = new PipedInputStream(pos)
68 val csOut = new juzCRC32()
69 val gos = new GZIPOutputStream(pos)
70 val cos = new CheckedOutputStream(gos, csOut)
71
72 val t = new Thread() {
73 override def run = {
74 val fail = "/jzlib.fail.gz".fromResource
75 val fis = new juzGZIPInputStream(new ByteArrayInputStream(fail))
76 fis -> cos
77 cos.close()
78 }
79 }
80 t.start();
81
82 val gis = new GZIPInputStream(pis)
83 val csIn = new juzCRC32();
84 new CheckedInputStream(gis, csIn) -> new ByteArrayOutputStream()
85
86 t.join()
87
88 csIn.getValue() should equal(csOut.getValue)
89 }
90}
91

Before

compilation_unit
block_comment
/* "/*"
*/ " */"
package_clause
package "package"
package_identifier
identifier "com"
. "."
identifier "jcraft"
. "."
identifier "jzlib"
import_declaration
import "import"
identifier "org"
. "."
identifier "scalatest"
. "."
namespace_wildcard
_ "_"
import_declaration
import "import"
identifier "org"
. "."
identifier "scalatest"
. "."
identifier "matchers"
. "."
identifier "ShouldMatchers"
import_declaration
import "import"
identifier "java"
. "."
identifier "io"
. "."
namespace_wildcard
_ "_"
import_declaration
import "import"
identifier "JZlib"
. "."
namespace_wildcard
_ "_"
class_definition
class "class"
identifier "GZIPIOStreamTest"
extends_clause
extends "extends"
type_identifier "FlatSpec"
with "with"
type_identifier "BeforeAndAfter"
with "with"
type_identifier "ShouldMatchers"
template_body
{ "{"
call_expression
identifier "before"
block
{ "{"
} "}"
call_expression
identifier "after"
block
{ "{"
} "}"
infix_expression
identifier "behavior"
identifier "of"
string "\"GZipOutputStream and GZipInputStream\""
infix_expression (+263 nodes collapsed)
} "}"

After

compilation_unit
block_comment
/* "/*"
*/ " */"
package_clause
package "package"
package_identifier
identifier "com"
. "."
identifier "jcraft"
. "."
identifier "jzlib"
import_declaration
import "import"
identifier "org"
. "."
identifier "scalatest"
. "."
namespace_wildcard
_ "_"
import_declaration
import "import"
identifier "org"
. "."
identifier "scalatest"
. "."
identifier "matchers"
. "."
identifier "ShouldMatchers"
import_declaration
import "import"
identifier "java"
. "."
identifier "io"
. "."
namespace_wildcard
_ "_"
import_declaration
import "import"
identifier "java"
. "."
identifier "util"
. "."
identifier "zip"
. "."
identifier "CheckedOutputStream"
import_declaration
import "import"
identifier "java"
. "."
identifier "util"
. "."
identifier "zip"
. "."
identifier "CheckedInputStream"
import_declaration
import "import"
identifier "java"
. "."
identifier "util"
. "."
identifier "zip"
. "."
namespace_selectors
{ "{"
arrow_renamed_identifier
identifier "GZIPInputStream"
=> "=>"
identifier "juzGZIPInputStream"
} "}"
import_declaration
import "import"
identifier "java"
. "."
identifier "util"
. "."
identifier "zip"
. "."
namespace_selectors
{ "{"
arrow_renamed_identifier
identifier "CRC32"
=> "=>"
identifier "juzCRC32"
} "}"
import_declaration
import "import"
identifier "JZlib"
. "."
namespace_wildcard
_ "_"
class_definition
class "class"
identifier "GZIPIOStreamTest"
extends_clause
extends "extends"
type_identifier "FlatSpec"
with "with"
type_identifier "BeforeAndAfter"
with "with"
type_identifier "ShouldMatchers"
template_body
{ "{"
call_expression
identifier "before"
block
{ "{"
} "}"
call_expression
identifier "after"
block
{ "{"
} "}"
infix_expression
identifier "behavior"
identifier "of"
string "\"GZIPOutputStream and GZIPInputStream\""
infix_expression (+263 nodes collapsed)
infix_expression
identifier "behavior"
identifier "of"
string "\"GZIPOutputStream\""
comment
// "//"
comment
// "//"
infix_expression
infix_expression
identifier "it"
identifier "can"
string "\"deflate some file without AIOOBE.\""
identifier "in"
block
{ "{"
val_definition
val "val"
identifier "pos"
= "="
instance_expression
new "new"
type_identifier "PipedOutputStream"
arguments
( "("
) ")"
val_definition
val "val"
identifier "pis"
= "="
instance_expression
new "new"
type_identifier "PipedInputStream"
arguments
( "("
identifier "pos"
) ")"
val_definition
val "val"
identifier "csOut"
= "="
instance_expression
new "new"
type_identifier "juzCRC32"
arguments
( "("
) ")"
val_definition
val "val"
identifier "gos"
= "="
instance_expression
new "new"
type_identifier "GZIPOutputStream"
arguments
( "("
identifier "pos"
) ")"
val_definition
val "val"
identifier "cos"
= "="
instance_expression
new "new"
type_identifier "CheckedOutputStream"
arguments
( "("
identifier "gos"
, ","
identifier "csOut"
) ")"
val_definition
val "val"
identifier "t"
= "="
instance_expression
new "new"
type_identifier "Thread"
arguments
( "("
) ")"
template_body
{ "{"
function_definition
modifiers
override "override"
def "def"
identifier "run"
= "="
block
{ "{"
val_definition
val "val"
identifier "fail"
= "="
field_expression
string "\"/jzlib.fail.gz\""
. "."
identifier "fromResource"
val_definition
val "val"
identifier "fis"
= "="
instance_expression
new "new"
type_identifier "juzGZIPInputStream"
arguments
( "("
instance_expression
new "new"
type_identifier "ByteArrayInputStream"
arguments
( "("
identifier "fail"
) ")"
) ")"
infix_expression
identifier "fis"
operator_identifier "->"
identifier "cos"
call_expression
field_expression
identifier "cos"
. "."
identifier "close"
arguments
( "("
) ")"
} "}"
} "}"
call_expression
field_expression
identifier "t"
. "."
identifier "start"
arguments
( "("
) ")"
; ";"
val_definition
val "val"
identifier "gis"
= "="
instance_expression
new "new"
type_identifier "GZIPInputStream"
arguments
( "("
identifier "pis"
) ")"
val_definition
val "val"
identifier "csIn"
= "="
instance_expression
new "new"
type_identifier "juzCRC32"
arguments
( "("
) ")"
; ";"
infix_expression
instance_expression
new "new"
type_identifier "CheckedInputStream"
arguments
( "("
identifier "gis"
, ","
identifier "csIn"
) ")"
operator_identifier "->"
instance_expression
new "new"
type_identifier "ByteArrayOutputStream"
arguments
( "("
) ")"
call_expression
field_expression
identifier "t"
. "."
identifier "join"
arguments
( "("
) ")"
infix_expression
call_expression
field_expression
identifier "csIn"
. "."
identifier "getValue"
arguments
( "("
) ")"
identifier "should"
call_expression
identifier "equal"
arguments
( "("
field_expression
identifier "csOut"
. "."
identifier "getValue"
) ")"
} "}"
} "}"