forked from mockito/mockito
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci maven-central-release] Merge pull request mockito#2023 from mocki…
…to/explicit-initializer Initializes classes prior to instrumentation to avoid uncontrolled code execution.
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
subprojects/inline/src/test/java/org/mockitoinline/InitializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2020 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitoinline; | ||
|
||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
public class InitializationTest { | ||
|
||
@Test | ||
public void assure_initialization_prior_to_instrumentation() { | ||
@SuppressWarnings("unused") | ||
SampleEnum mock = Mockito.mock(SampleEnum.class); | ||
SampleEnum[] values = SampleEnum.values(); | ||
assertEquals("VALUE", values[0].name()); | ||
} | ||
|
||
public enum SampleEnum { | ||
VALUE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters