Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c44b7c7

Browse files
authored
Merge pull request square#1581 from bric3/shark-test-module
Introduces a Shark test module
2 parents dbd9be8 + adb3392 commit c44b7c7

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ include ':shark-cli'
1212
include ':shark-graph'
1313
include ':shark-hprof'
1414
include ':shark-log'
15+
include ':shark-test'

shark-graph/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies {
1212

1313
testImplementation deps.assertj_core
1414
testImplementation deps.junit
15+
testImplementation project(':shark-test')
1516
}
1617

1718
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

shark-hprof/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies {
1212

1313
testImplementation deps.assertj_core
1414
testImplementation deps.junit
15+
testImplementation project(':shark-test')
1516
}
1617

1718
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

shark-hprof/src/test/java/HprofReaderPrimitiveArrayTest.kt renamed to shark-hprof/src/test/java/shark/HprofReaderPrimitiveArrayTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
package shark
2+
13
import org.assertj.core.api.Assertions.assertThat
24
import org.junit.Rule
35
import org.junit.Test
4-
import shark.Hprof
5-
import shark.HprofRecord
6-
import shark.OnHprofRecordListener
76
import kotlin.text.Charsets.UTF_8
87

98
class HprofReaderPrimitiveArrayTest {
@@ -24,7 +23,9 @@ class HprofReaderPrimitiveArrayTest {
2423

2524
@Test
2625
fun reads_primitive_arrays_correctly() {
27-
val byteArray = "mybytes".toByteArray(UTF_8)
26+
val byteArray = ("Sharks also have a sensory organ called the \"ampullae of Lorenzini\" " +
27+
"which they use to \"feel\" the electrical field coming from its prey.")
28+
.toByteArray(UTF_8)
2829

2930
val heapDump = heapDumpRule.dumpHeap()
3031

shark-test/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apply plugin: 'java-library'
2+
apply plugin: 'kotlin'
3+
4+
sourceCompatibility = JavaVersion.VERSION_1_7
5+
targetCompatibility = JavaVersion.VERSION_1_7
6+
7+
dependencies {
8+
implementation deps.kotlin.stdlib
9+
implementation deps.assertj_core
10+
implementation deps.junit
11+
}
12+
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import com.sun.management.HotSpotDiagnosticMXBean
1+
package shark
2+
23
import org.junit.rules.ExternalResource
34
import org.junit.rules.TemporaryFolder
4-
55
import java.io.File
66
import java.io.IOException
7-
import java.lang.management.ManagementFactory
87
import java.util.UUID
98

109
class HeapDumpRule : ExternalResource() {
@@ -21,13 +20,8 @@ class HeapDumpRule : ExternalResource() {
2120

2221
@Throws(IOException::class)
2322
fun dumpHeap(): File {
24-
val hotSpotDiag = ManagementFactory.newPlatformMXBeanProxy(
25-
ManagementFactory.getPlatformMBeanServer(),
26-
"com.sun.management:type=HotSpotDiagnostic",
27-
HotSpotDiagnosticMXBean::class.java
28-
)
2923
val hprof = File(temporaryFolder.root, "heapDump" + UUID.randomUUID() + ".hprof")
30-
hotSpotDiag.dumpHeap(hprof.absolutePath, true)
24+
JvmTestHeapDumper.dumpHeap(hprof.absolutePath)
3125
return hprof
3226
}
3327
}
File renamed without changes.

0 commit comments

Comments
 (0)