File tree Expand file tree Collapse file tree 7 files changed +23
-13
lines changed Expand file tree Collapse file tree 7 files changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,4 @@ include ':shark-cli'
12
12
include ' :shark-graph'
13
13
include ' :shark-hprof'
14
14
include ' :shark-log'
15
+ include ' :shark-test'
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ dependencies {
12
12
13
13
testImplementation deps. assertj_core
14
14
testImplementation deps. junit
15
+ testImplementation project(' :shark-test' )
15
16
}
16
17
17
18
apply from : rootProject. file(' gradle/gradle-mvn-push.gradle' )
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ dependencies {
12
12
13
13
testImplementation deps. assertj_core
14
14
testImplementation deps. junit
15
+ testImplementation project(' :shark-test' )
15
16
}
16
17
17
18
apply from : rootProject. file(' gradle/gradle-mvn-push.gradle' )
Original file line number Diff line number Diff line change
1
+ package shark
2
+
1
3
import org.assertj.core.api.Assertions.assertThat
2
4
import org.junit.Rule
3
5
import org.junit.Test
4
- import shark.Hprof
5
- import shark.HprofRecord
6
- import shark.OnHprofRecordListener
7
6
import kotlin.text.Charsets.UTF_8
8
7
9
8
class HprofReaderPrimitiveArrayTest {
@@ -24,7 +23,9 @@ class HprofReaderPrimitiveArrayTest {
24
23
25
24
@Test
26
25
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 )
28
29
29
30
val heapDump = heapDumpRule.dumpHeap()
30
31
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change 1
- import com.sun.management.HotSpotDiagnosticMXBean
1
+ package shark
2
+
2
3
import org.junit.rules.ExternalResource
3
4
import org.junit.rules.TemporaryFolder
4
-
5
5
import java.io.File
6
6
import java.io.IOException
7
- import java.lang.management.ManagementFactory
8
7
import java.util.UUID
9
8
10
9
class HeapDumpRule : ExternalResource () {
@@ -21,13 +20,8 @@ class HeapDumpRule : ExternalResource() {
21
20
22
21
@Throws(IOException ::class )
23
22
fun dumpHeap (): File {
24
- val hotSpotDiag = ManagementFactory .newPlatformMXBeanProxy(
25
- ManagementFactory .getPlatformMBeanServer(),
26
- " com.sun.management:type=HotSpotDiagnostic" ,
27
- HotSpotDiagnosticMXBean ::class .java
28
- )
29
23
val hprof = File (temporaryFolder.root, " heapDump" + UUID .randomUUID() + " .hprof" )
30
- hotSpotDiag .dumpHeap(hprof.absolutePath, true )
24
+ JvmTestHeapDumper .dumpHeap(hprof.absolutePath)
31
25
return hprof
32
26
}
33
27
}
File renamed without changes.
You can’t perform that action at this time.
0 commit comments