// Path: src/test/java/ysoserial/test/CustomTest.java
// public interface CustomTest extends CustomPayloadArgs {
// 
//     void run (Callable<Object> payload) throws Exception;
// }
// 
// Path: src/test/java/ysoserial/test/util/Files.java
// public class Files {
//     public static void waitForFile(File file, int timeoutMs) throws InterruptedException {
//         long timeout = System.currentTimeMillis() + timeoutMs;
//         while (! file.exists() && System.currentTimeMillis() < timeout) {
//             Thread.sleep(10);
//         }
//     }
// }
// 
// Path: src/test/java/ysoserial/test/util/OS.java
// public enum OS {
//     WINDOWS,
//     LINUX,
//     OSX,
//     OTHER;
// 
//     private static final OS os = determineOs();
// 
//     public static OS get() {
//         return os;
//     }
// 
//     private static OS determineOs() {
//         String osName = System.getProperty("os.name", "other").toLowerCase();
//         if (osName.contains("windows")) {
//             return WINDOWS;
//         } else if (osName.contains("mac os x")) {
//             return OSX;
//         } else if (osName.contains("linux")) {
//             return LINUX;
//         } else {
//             return OTHER;
//         }
//     }
// 
//     public static String getTmpDir() {
//         return System.getProperty("java.io.tmpdir");
//     }
// }


import org.junit.Assert;
import ysoserial.test.CustomTest;
import ysoserial.test.util.Files;
import ysoserial.test.util.OS;
import java.io.File;
import java.util.UUID;
import java.util.concurrent.Callable;
package ysoserial.test.payloads;



public class CommandExecTest implements CustomTest {
    private final File testFile =
        new File(OS.getTmpDir(), "ysoserial-test-" + UUID.randomUUID().toString().replaceAll("-", ""));

    @Override
    public void run(Callable<Object> payload) throws Exception {
        Assert.assertFalse("test file should not exist", testFile.exists());
        try {
            payload.call();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Files.waitForFile(testFile, 5000);
        Assert.assertTrue("test file should exist", testFile.exists());
        testFile.deleteOnExit();
    }

    @Override
    public String getPayloadArgs() {
        switch (OS.get()) {
            case OSX:
            case LINUX: return "touch " + testFile;
// Path: src/test/java/ysoserial/test/CustomTest.java
// public interface CustomTest extends CustomPayloadArgs {
// 
//     void run (Callable<Object> payload) throws Exception;
// }
// 
// Path: src/test/java/ysoserial/test/util/Files.java
// public class Files {
//     public static void waitForFile(File file, int timeoutMs) throws InterruptedException {
//         long timeout = System.currentTimeMillis() + timeoutMs;
//         while (! file.exists() && System.currentTimeMillis() < timeout) {
//             Thread.sleep(10);
//         }
//     }
// }
// 
// Path: src/test/java/ysoserial/test/util/OS.java
// public enum OS {
//     WINDOWS,
//     LINUX,
//     OSX,
//     OTHER;
// 
//     private static final OS os = determineOs();
// 
//     public static OS get() {
//         return os;
//     }
// 
//     private static OS determineOs() {
//         String osName = System.getProperty("os.name", "other").toLowerCase();
//         if (osName.contains("windows")) {
//             return WINDOWS;
//         } else if (osName.contains("mac os x")) {
//             return OSX;
//         } else if (osName.contains("linux")) {
//             return LINUX;
//         } else {
//             return OTHER;
//         }
//     }
// 
//     public static String getTmpDir() {
//         return System.getProperty("java.io.tmpdir");
//     }
// }


// Path: src/test/java/ysoserial/test/payloads/CommandExecTest.java
import org.junit.Assert;
import ysoserial.test.CustomTest;
import ysoserial.test.util.Files;
import ysoserial.test.util.OS;
import java.io.File;
import java.util.UUID;
import java.util.concurrent.Callable;

package ysoserial.test.payloads;



public class CommandExecTest implements CustomTest {
    private final File testFile =
        new File(OS.getTmpDir(), "ysoserial-test-" + UUID.randomUUID().toString().replaceAll("-", ""));

    @Override
    public void run(Callable<Object> payload) throws Exception {
        Assert.assertFalse("test file should not exist", testFile.exists());
        try {
            payload.call();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Files.waitForFile(testFile, 5000);
        Assert.assertTrue("test file should exist", testFile.exists());
        testFile.deleteOnExit();
    }

    @Override
    public String getPayloadArgs() {
        switch (OS.get()) {
            case OSX:
            case LINUX: return "touch " + testFile;
            case WINDOWS: return "powershell -command new-item -type file " + testFile;