// Path: src/main/java/ysoserial/payloads/util/CmdExecuteHelper.java
// public class CmdExecuteHelper {
// 	
// 	private String terminalType;
// 	
// 	private String[] commandArray;
// 	
// 	private String command;
// 
// 	public CmdExecuteHelper(String terminalType, String command) {
// 		super();
// 		this.terminalType = terminalType;
// 		this.command = command;
// 		
// 		switch (terminalType) {
// 		case "cmd":
// 			this.commandArray = new String[]{"cmd.exe","/c", command};
// 			break;
// 		case "bash":
// 			this.commandArray = new String[]{"/bin/bash","-c", command};
// 			break;
// 		case "powershell":
// 			this.commandArray = new String[]{"powershell.exe","-c", command};
// 			break;
// 		default:
// 			this.commandArray = new String[]{command};
// 			break;
// 		}
// 	}
// 
// 	public String[] getCommandArray() {
// 		return commandArray;
// 	}
// 
// 	public void setCommandArray(String[] commandArray) {
// 		this.commandArray = commandArray;
// 	}
// 
// 	public String getCommand() {
// 		return command;
// 	}
// 
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getTerminalType() {
// 		return terminalType;
// 	}
// 
// 	public void setTerminalType(String terminalType) {
// 		this.terminalType = terminalType;
// 	}
// 
// }


import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import ysoserial.payloads.util.CmdExecuteHelper;
package ysoserial.payloads;




public class TestHarnessTest {
	// make sure test harness fails properly
	@Test
	public void testHarnessExecFail() throws Exception {
		try {
			PayloadsTest.testPayload(NoopMockPayload.class, new Class[0]);
			Assert.fail("should have failed");
		} catch (AssertionError e) {
			Assert.assertThat(e.getMessage(), CoreMatchers.containsString("but was:<class java.lang.AssertionError>"));

		}
	}

	// make sure test harness fails properly
	@Test
	public void testHarnessClassLoaderFail() throws Exception {
		try {
			PayloadsTest.testPayload(ExecMockPayload.class, new Class[0]);
			Assert.fail("should have failed");
		} catch (AssertionError e) {
			Assert.assertThat(e.getMessage(), CoreMatchers.containsString("ClassNotFoundException"));
		}
	}

	// make sure test harness passes properly with trivial execution gadget
	@Test
	public void testHarnessExecPass() throws Exception {
		PayloadsTest.testPayload(ExecMockPayload.class, new Class[] { ExecMockSerializable.class });
	}

	public static class ExecMockPayload implements ObjectPayload<ExecMockSerializable> {
// Path: src/main/java/ysoserial/payloads/util/CmdExecuteHelper.java
// public class CmdExecuteHelper {
// 	
// 	private String terminalType;
// 	
// 	private String[] commandArray;
// 	
// 	private String command;
// 
// 	public CmdExecuteHelper(String terminalType, String command) {
// 		super();
// 		this.terminalType = terminalType;
// 		this.command = command;
// 		
// 		switch (terminalType) {
// 		case "cmd":
// 			this.commandArray = new String[]{"cmd.exe","/c", command};
// 			break;
// 		case "bash":
// 			this.commandArray = new String[]{"/bin/bash","-c", command};
// 			break;
// 		case "powershell":
// 			this.commandArray = new String[]{"powershell.exe","-c", command};
// 			break;
// 		default:
// 			this.commandArray = new String[]{command};
// 			break;
// 		}
// 	}
// 
// 	public String[] getCommandArray() {
// 		return commandArray;
// 	}
// 
// 	public void setCommandArray(String[] commandArray) {
// 		this.commandArray = commandArray;
// 	}
// 
// 	public String getCommand() {
// 		return command;
// 	}
// 
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getTerminalType() {
// 		return terminalType;
// 	}
// 
// 	public void setTerminalType(String terminalType) {
// 		this.terminalType = terminalType;
// 	}
// 
// }


// Path: src/test/java/ysoserial/payloads/TestHarnessTest.java
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import ysoserial.payloads.util.CmdExecuteHelper;

package ysoserial.payloads;




public class TestHarnessTest {
	// make sure test harness fails properly
	@Test
	public void testHarnessExecFail() throws Exception {
		try {
			PayloadsTest.testPayload(NoopMockPayload.class, new Class[0]);
			Assert.fail("should have failed");
		} catch (AssertionError e) {
			Assert.assertThat(e.getMessage(), CoreMatchers.containsString("but was:<class java.lang.AssertionError>"));

		}
	}

	// make sure test harness fails properly
	@Test
	public void testHarnessClassLoaderFail() throws Exception {
		try {
			PayloadsTest.testPayload(ExecMockPayload.class, new Class[0]);
			Assert.fail("should have failed");
		} catch (AssertionError e) {
			Assert.assertThat(e.getMessage(), CoreMatchers.containsString("ClassNotFoundException"));
		}
	}

	// make sure test harness passes properly with trivial execution gadget
	@Test
	public void testHarnessExecPass() throws Exception {
		PayloadsTest.testPayload(ExecMockPayload.class, new Class[] { ExecMockSerializable.class });
	}

	public static class ExecMockPayload implements ObjectPayload<ExecMockSerializable> {
		public ExecMockSerializable getObject(CmdExecuteHelper cmdHelper) throws Exception {