Home | History | Annotate | Download | only in mockitoutil
      1 package org.mockitoutil;
      2 
      3 import java.lang.management.ManagementFactory;
      4 import java.util.List;
      5 
      6 import static org.junit.Assume.assumeFalse;
      7 import static org.junit.Assume.assumeTrue;
      8 
      9 public class VmArgAssumptions {
     10     public static void assumeVmArgPresent(String vmArg) {
     11         assumeTrue(assertEnabled(vmArg));
     12     }
     13 
     14     public static void assumeVmArgNotPresent(String vmArg) {
     15         assumeFalse(assertEnabled(vmArg));
     16     }
     17 
     18     private static boolean assertEnabled(String vmArg) {
     19         List<String> inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
     20         for (String inputArgument : inputArguments) {
     21             if (inputArgument.contains(vmArg)) {
     22                 return true;
     23             }
     24         }
     25         return false;
     26     }
     27 
     28 }
     29