1 19 20 package org.netbeans.lib.cvsclient; 21 22 import junit.framework.TestCase; 23 24 import java.io.File ; 25 import java.io.InputStream ; 26 27 import org.netbeans.lib.cvsclient.command.GlobalOptions; 28 import org.netbeans.lib.cvsclient.command.status.StatusCommand; 29 import org.netbeans.lib.cvsclient.connection.Connection; 30 import org.netbeans.lib.cvsclient.connection.PServerConnection; 31 import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; 32 33 39 public class ErrorHandlingTest extends TestCase { 40 41 46 public void test56552() throws Exception { 47 48 File tmpDir = TestKit.createTmpFolder("serverAbortTest"); 49 String protocolLog = new File (tmpDir, "protocol").getAbsolutePath(); 50 System.setProperty("cvsClientLog", protocolLog); 51 System.out.println(protocolLog); 52 53 InputStream in = getClass().getResourceAsStream("protocol/iz56552.in"); 54 final PseudoCvsServer cvss = new PseudoCvsServer(in); 55 new Thread (cvss).start(); 56 57 String cvsRoot = cvss.getCvsRoot(); 58 CVSRoot root = CVSRoot.parse(cvsRoot); 59 final GlobalOptions gtx = new GlobalOptions(); 60 gtx.setCVSRoot(cvsRoot); 61 Connection connection = new PServerConnection(root); 62 final Client client = new Client(connection, new StandardAdminHandler()); 63 client.setLocalPath(tmpDir.getAbsolutePath()); 64 65 final StatusCommand status = new StatusCommand(); 66 File [] files = new File [] {new File (tmpDir, "placeholder")}; 67 status.setFiles(files); 68 69 final Exception testException[] = new Exception [1]; 70 final boolean completedFlag[] = new boolean[] {false}; 71 Runnable run = new Runnable () { 72 public void run() { 73 try { 74 try { 75 client.executeCommand(status, gtx); 76 synchronized(completedFlag) { 77 completedFlag[0] = true; 78 completedFlag.notifyAll(); 79 } 80 } finally { 81 cvss.stop(); 82 } 83 } catch (Exception ex) { 84 testException[0] = ex; 85 } 86 } 87 }; 88 89 91 Thread t = new Thread (run); 92 t.start(); 93 synchronized(completedFlag) { 94 if (completedFlag[0] == false) { 95 completedFlag.wait(1000); } 97 } 98 t.interrupt(); 99 if (testException[0] != null) { 100 throw testException[0]; 101 } 102 assertTrue(completedFlag[0]); 103 104 TestKit.deleteRecursively(tmpDir); 105 } 106 107 108 } 109 | Popular Tags |