-
Notifications
You must be signed in to change notification settings - Fork 237
/
CustomClassLoadingTest.java
77 lines (60 loc) · 1.81 KB
/
CustomClassLoadingTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (c) 2006-2015 Rogério Liesenfeld
* This file is subject to the terms of the MIT license (see LICENSE.txt).
*/
package integrationTests;
import java.util.*;
import org.junit.*;
import org.junit.runner.*;
import static org.junit.Assert.*;
import mockit.coverage.data.*;
import org.hamcrest.*;
@RunWith(CustomRunner.class)
public final class CustomClassLoadingTest extends CoverageTest
{
Object tested;
@After
public void resetFileData()
{
fileData = null;
}
@Test
public void runCodeInClassReloadedOnCustomClassLoader()
{
ClassLoader thisCL = getClass().getClassLoader();
IfElseStatements ifElse = new IfElseStatements();
ClassLoader customCL = ifElse.methodToBeCalledFromCustomRunnerTest("TEST");
assertNotSame(ClassLoader.getSystemClassLoader(), thisCL);
assertSame(thisCL, customCL);
tested = ifElse;
assertLines(189, 193, 2);
assertLine(189, 1, 1, 1);
assertLine(191, 1, 1, 1);
assertLine(195, 1, 1, 1);
findMethodData(189);
assertPaths(2, 1, 1);
assertPath(4, 0);
assertPath(5, 1);
assertInstanceFieldUncovered("instanceField");
}
@Test
public void exerciseClassThatIsOnlyUsedHere()
{
ClassLoadedByCustomLoaderOnly obj = new ClassLoadedByCustomLoaderOnly("test");
String value = obj.getValue();
assertEquals("test", value);
tested = obj;
assertLines(9, 9, 1);
assertLine(9, 1, 1, 1);
findMethodData(9);
assertPaths(1, 1, 1);
assertPath(2, 1);
}
@Test
public void exerciseClassFromNonJREJarFile()
{
CoreMatchers.anything();
Map<String, FileCoverageData> fileToFileData = CoverageData.instance().getRawFileToFileData();
assertFalse(fileToFileData.containsKey("org/hamcrest/CoreMatchers.java"));
}
}