|
| 1 | +/** |
| 2 | + * Scaffolding file used to store all the setups needed to run |
| 3 | + * tests automatically generated by EvoSuite |
| 4 | + * Mon Mar 23 00:25:39 GMT 2026 |
| 5 | + */ |
| 6 | + |
| 7 | +package org.apache.commons.cli; |
| 8 | + |
| 9 | +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; |
| 10 | +import org.junit.BeforeClass; |
| 11 | +import org.junit.Before; |
| 12 | +import org.junit.After; |
| 13 | +import org.junit.AfterClass; |
| 14 | +import org.evosuite.runtime.sandbox.Sandbox; |
| 15 | +import org.evosuite.runtime.sandbox.Sandbox.SandboxMode; |
| 16 | + |
| 17 | +import static org.evosuite.shaded.org.mockito.Mockito.*; |
| 18 | +@EvoSuiteClassExclude |
| 19 | +public class CommandLine_ESTest_scaffolding { |
| 20 | + |
| 21 | + @org.junit.Rule |
| 22 | + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); |
| 23 | + |
| 24 | + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); |
| 25 | + |
| 26 | + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); |
| 27 | + |
| 28 | + |
| 29 | + @BeforeClass |
| 30 | + public static void initEvoSuiteFramework() { |
| 31 | + org.evosuite.runtime.RuntimeSettings.className = "org.apache.commons.cli.CommandLine"; |
| 32 | + org.evosuite.runtime.GuiSupport.initialize(); |
| 33 | + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; |
| 34 | + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; |
| 35 | + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; |
| 36 | + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; |
| 37 | + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); |
| 38 | + org.evosuite.runtime.classhandling.JDKClassResetter.init(); |
| 39 | + setSystemProperties(); |
| 40 | + initializeClasses(); |
| 41 | + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); |
| 42 | + try { initMocksToAvoidTimeoutsInTheTests(); } catch(ClassNotFoundException e) {} |
| 43 | + } |
| 44 | + |
| 45 | + @AfterClass |
| 46 | + public static void clearEvoSuiteFramework(){ |
| 47 | + Sandbox.resetDefaultSecurityManager(); |
| 48 | + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); |
| 49 | + } |
| 50 | + |
| 51 | + @Before |
| 52 | + public void initTestCase(){ |
| 53 | + threadStopper.storeCurrentThreads(); |
| 54 | + threadStopper.startRecordingTime(); |
| 55 | + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); |
| 56 | + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); |
| 57 | + setSystemProperties(); |
| 58 | + org.evosuite.runtime.GuiSupport.setHeadless(); |
| 59 | + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); |
| 60 | + org.evosuite.runtime.agent.InstrumentingAgent.activate(); |
| 61 | + } |
| 62 | + |
| 63 | + @After |
| 64 | + public void doneWithTestCase(){ |
| 65 | + threadStopper.killAndJoinClientThreads(); |
| 66 | + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); |
| 67 | + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); |
| 68 | + resetClasses(); |
| 69 | + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); |
| 70 | + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); |
| 71 | + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); |
| 72 | + } |
| 73 | + |
| 74 | + public static void setSystemProperties() { |
| 75 | + |
| 76 | + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); |
| 77 | + java.lang.System.setProperty("file.encoding", "UTF-8"); |
| 78 | + java.lang.System.setProperty("java.awt.headless", "true"); |
| 79 | + java.lang.System.setProperty("java.io.tmpdir", "/var/folders/z3/st24ttp10vxbf_1j6tstwvy80000gn/T/"); |
| 80 | + java.lang.System.setProperty("user.country", "CA"); |
| 81 | + java.lang.System.setProperty("user.dir", "/Users/anthonykap/Documents/GitHub/commons-cli"); |
| 82 | + java.lang.System.setProperty("user.home", "/Users/anthonykap"); |
| 83 | + java.lang.System.setProperty("user.language", "en"); |
| 84 | + java.lang.System.setProperty("user.name", "anthonykap"); |
| 85 | + java.lang.System.setProperty("user.timezone", "America/Toronto"); |
| 86 | + } |
| 87 | + |
| 88 | + private static void initializeClasses() { |
| 89 | + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CommandLine_ESTest_scaffolding.class.getClassLoader() , |
| 90 | + "org.apache.commons.cli.DeprecatedAttributes", |
| 91 | + "org.apache.commons.text.Builder", |
| 92 | + "org.apache.commons.text.StringTokenizer", |
| 93 | + "org.apache.commons.text.TextStringBuilder$TextStringBuilderReader", |
| 94 | + "org.apache.commons.text.TextStringBuilder", |
| 95 | + "org.apache.commons.cli.Option$Builder", |
| 96 | + "org.apache.commons.text.matcher.StringMatcher", |
| 97 | + "org.apache.commons.cli.TypeHandler", |
| 98 | + "org.apache.commons.lang3.StringUtils", |
| 99 | + "org.apache.commons.text.TextStringBuilder$TextStringBuilderWriter", |
| 100 | + "org.apache.commons.text.TextStringBuilder$TextStringBuilderTokenizer", |
| 101 | + "org.apache.commons.cli.Converter", |
| 102 | + "org.apache.commons.cli.CommandLine$Builder", |
| 103 | + "org.apache.commons.cli.AlreadySelectedException", |
| 104 | + "org.apache.commons.cli.ParseException", |
| 105 | + "org.apache.commons.cli.OptionValidator", |
| 106 | + "org.apache.commons.cli.OptionGroup", |
| 107 | + "org.apache.commons.cli.CommandLine", |
| 108 | + "org.apache.commons.cli.Option", |
| 109 | + "org.apache.commons.cli.Util" |
| 110 | + ); |
| 111 | + } |
| 112 | + private static void initMocksToAvoidTimeoutsInTheTests() throws ClassNotFoundException { |
| 113 | + mock(Class.forName("java.util.function.Supplier", false, CommandLine_ESTest_scaffolding.class.getClassLoader())); |
| 114 | + } |
| 115 | + |
| 116 | + private static void resetClasses() { |
| 117 | + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CommandLine_ESTest_scaffolding.class.getClassLoader()); |
| 118 | + |
| 119 | + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( |
| 120 | + "org.apache.commons.cli.CommandLine", |
| 121 | + "org.apache.commons.cli.CommandLine$Builder", |
| 122 | + "org.apache.commons.cli.Util", |
| 123 | + "org.apache.commons.cli.Option", |
| 124 | + "org.apache.commons.cli.OptionGroup", |
| 125 | + "org.apache.commons.text.TextStringBuilder", |
| 126 | + "org.apache.commons.cli.OptionValidator", |
| 127 | + "org.apache.commons.cli.Option$Builder", |
| 128 | + "org.apache.commons.cli.Converter", |
| 129 | + "org.apache.commons.cli.TypeHandler", |
| 130 | + "org.apache.commons.cli.DeprecatedAttributes", |
| 131 | + "org.apache.commons.cli.DeprecatedAttributes$Builder", |
| 132 | + "org.apache.commons.lang3.StringUtils", |
| 133 | + "org.apache.commons.text.similarity.HammingDistance", |
| 134 | + "org.apache.commons.text.similarity.SimilarityCharacterInput", |
| 135 | + "org.apache.commons.text.TextStringBuilder$TextStringBuilderReader", |
| 136 | + "org.apache.commons.text.similarity.LongestCommonSubsequenceDistance", |
| 137 | + "org.apache.commons.text.similarity.LongestCommonSubsequence", |
| 138 | + "org.apache.commons.io.filefilter.IOFileFilter", |
| 139 | + "org.apache.commons.cli.ParseException" |
| 140 | + ); |
| 141 | + } |
| 142 | +} |
0 commit comments