📄 debugplugintestcase.java
字号:
/**
* Copyright (c) 2003-2007 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.debug;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import junit.framework.TestCase;
/**
* Type description
* <p />
* Copyright (c) 2003-2007 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.1 $
* <br>
* $Date: 2006/03/03 02:22:29 $
* <br>
* @author Craig Setera
*/
public class DebugPluginTestcase extends TestCase {
private class OutputPumpThread extends Thread {
private String name;
private BufferedReader reader;
public OutputPumpThread(String name, InputStream stream) {
super(name);
this.name = name;
reader = new BufferedReader(new InputStreamReader(stream));
}
/**
* @see java.lang.Thread#run()
*/
public void run() {
String line = null;
try {
while ((line = reader.readLine()) != null) {
System.out.println("[" + name + "] " + line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/*
C:\temp>java -jar dumper.jar this is a test
4 argument count
***this***
***is***
***a***
***test***
C:\temp>java -jar dumper.jar "this is a test"
1 argument count
***this is a test***
C:\temp>java -jar dumper.jar -descriptor:"this is a test"
1 argument count
***-descriptor:this is a test***
C:\temp>java -jar dumper.jar -descriptor:\"this is a test\"
4 argument count
***-descriptor:"this***
***is***
***a***
***test"***
C:\temp>
*/
public void testDebugPluginParser() throws Exception {
String[] tests = new String[] {
"java -jar dumper.jar \"this is a test\"",
"java -jar dumper.jar -descriptor:\"this is a test\"",
"java -jar dumper.jar -descriptor:\\\"this is a test\\\"",
"java -jar dumper.jar -descriptor:\\\"\"this is a test\"\\\"",
};
for (int i = 0; i < tests.length; i++) {
String test = tests[i];
System.out.println("Testing " + test);
doTest(test);
}
}
private void doTest(String test) throws CoreException {
File workingDirectory = new File("c:/temp");
String[] args = DebugPlugin.parseArguments(test);
Process process = DebugPlugin.exec(args, workingDirectory);
new OutputPumpThread("stdout", process.getInputStream()).start();
new OutputPumpThread("stderr", process.getErrorStream()).start();
try {
System.out.println("Return code: " + process.waitFor() + "\n");
} catch (InterruptedException e) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -