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.CommandException; 29 import org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand; 30 import org.netbeans.lib.cvsclient.connection.Connection; 31 import org.netbeans.lib.cvsclient.connection.PServerConnection; 32 import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; 33 34 39 public class CheckoutTest extends TestCase { 40 41 47 public void test56552_21126() throws Exception { 48 49 final File tmpDir = TestKit.createTmpFolder("checkoutDropTest"); 50 String protocolLog = new File (tmpDir, "protocol").getAbsolutePath(); 51 System.setProperty("cvsClientLog", protocolLog); 52 System.out.println(protocolLog); 53 54 final InputStream in = getClass().getResourceAsStream("protocol/iz56552_21126.in"); 55 if (in == null) { 56 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 57 in.markSupported(); 58 } 59 60 64 final Exception expectedException[] = new Exception [1]; 65 final Exception testException[] = new Exception [1]; 66 Runnable run = new Runnable () { 67 public void run() { 68 try { 69 PseudoCvsServer cvss = new PseudoCvsServer(in); 70 try { 71 cvss.simulateNetworkFailure(1000, -1); 72 new Thread (cvss).start(); 73 74 String cvsRoot = cvss.getCvsRoot(); 75 CVSRoot root = CVSRoot.parse(cvsRoot); 76 GlobalOptions gtx = new GlobalOptions(); 77 gtx.setCVSRoot(cvsRoot); 78 Connection connection = new PServerConnection(root); 79 Client client = new Client(connection, new StandardAdminHandler()); 80 client.setLocalPath(tmpDir.getAbsolutePath()); 81 82 CheckoutCommand checkout = new CheckoutCommand(); 83 checkout.setModule("a11y"); 84 85 client.executeCommand(checkout, gtx); 86 expectedException.notify(); 87 } catch (CommandException ex) { 88 synchronized(expectedException) { 90 expectedException[0] = ex; 91 expectedException.notify(); 92 } 93 } finally { 94 cvss.stop();; 95 } 96 } catch (Exception ex) { 97 testException[0] = ex; 98 } 99 } 100 }; 101 102 Thread t = new Thread (run); 103 t.start(); 104 synchronized(expectedException) { 105 if (expectedException[0] == null) { 106 expectedException.wait(1000); } 108 } 109 t.interrupt(); 110 if (testException[0] != null) { 111 throw testException[0]; 112 } 113 assertTrue(expectedException[0] != null); 114 TestKit.deleteRecursively(tmpDir); 115 116 } 117 118 119 120 } 121 | Popular Tags |