• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockitoutil;
6 
7 import java.lang.management.ManagementFactory;
8 import java.util.List;
9 
10 import static org.junit.Assume.assumeFalse;
11 import static org.junit.Assume.assumeTrue;
12 
13 public class VmArgAssumptions {
assumeVmArgPresent(String vmArg)14     public static void assumeVmArgPresent(String vmArg) {
15         assumeTrue(assertEnabled(vmArg));
16     }
17 
assumeVmArgNotPresent(String vmArg)18     public static void assumeVmArgNotPresent(String vmArg) {
19         assumeFalse(assertEnabled(vmArg));
20     }
21 
assertEnabled(String vmArg)22     private static boolean assertEnabled(String vmArg) {
23         List<String> inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
24         for (String inputArgument : inputArguments) {
25             if (inputArgument.contains(vmArg)) {
26                 return true;
27             }
28         }
29         return false;
30     }
31 
32 }
33