KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > checkout > ProxySettingsUITest


1 /*
2  * ProxySettingsUITest.java
3  *
4  * Created on 10 May 2006, 11:04
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.test.subversion.main.checkout;
11
12 import junit.textui.TestRunner;
13 import org.netbeans.jellytools.JellyTestCase;
14 import org.netbeans.jemmy.JemmyProperties;
15 import org.netbeans.jemmy.TimeoutExpiredException;
16 import org.netbeans.jemmy.operators.Operator;
17 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
18 import org.netbeans.junit.NbTestSuite;
19 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
20 import org.netbeans.test.subversion.operators.ProxyConfigurationOperator;
21 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
22
23 /**
24  *
25  * @author peter
26  */

27 public class ProxySettingsUITest extends JellyTestCase {
28     
29     String JavaDoc os_name;
30     Operator.DefaultStringComparator comOperator;
31     Operator.DefaultStringComparator oldOperator;
32     
33     /** Creates a new instance of ProxySettingsUITest */
34     public ProxySettingsUITest(String JavaDoc name) {
35         super(name);
36     }
37     
38     protected void setUp() throws Exception JavaDoc {
39         os_name = System.getProperty("os.name");
40         //System.out.println(os_name);
41
System.out.println("### "+getName()+" ###");
42         
43     }
44     
45     protected boolean isUnix() {
46         boolean unix = false;
47         if (os_name.indexOf("Windows") == -1) {
48             unix = true;
49         }
50         return unix;
51     }
52     
53     public static void main(String JavaDoc[] args) {
54         // TODO code application logic here
55
TestRunner.run(suite());
56     }
57     
58     public static NbTestSuite suite() {
59         NbTestSuite suite = new NbTestSuite();
60         suite.addTest(new ProxySettingsUITest("testProxySettings"));
61         suite.addTest(new ProxySettingsUITest("testProxyBeforeUrl"));
62         return suite;
63     }
64     
65     public void testProxySettings() {
66         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
67
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
68
comOperator = new Operator.DefaultStringComparator(true, true);
69         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
70         Operator.setDefaultStringComparator(comOperator);
71         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
72         Operator.setDefaultStringComparator(oldOperator);
73         RepositoryStepOperator co1so = new RepositoryStepOperator();
74         co1so.setRepositoryURL(RepositoryStepOperator.ITEM_HTTPS + "localhost");
75         ProxyConfigurationOperator pco = co1so.invokeProxy();
76         pco.verify();
77         pco.useSystemProxySettings();
78         pco.noProxyDirectConnection();
79         pco.hTTPProxy();
80         pco.setProxyHost("host");// NOI18N
81
pco.setPort("8080");
82         pco.checkProxyServerRequiresLogin(true);
83         pco.setName("name");// NOI18N
84
pco.setPassword("password");// NOI18N
85
pco.ok();
86         co.btCancel().pushNoBlock();
87     }
88     
89     public void testProxyBeforeUrl() throws Exception JavaDoc {
90         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
91
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
92
comOperator = new Operator.DefaultStringComparator(true, true);
93         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
94         Operator.setDefaultStringComparator(comOperator);
95         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
96         Operator.setDefaultStringComparator(oldOperator);
97         RepositoryStepOperator co1so = new RepositoryStepOperator();
98         co1so.setRepositoryURL(RepositoryStepOperator.ITEM_HTTPS);
99                 
100         TimeoutExpiredException tee = null;
101         try {
102             co1so.invokeProxy();
103         } catch (Exception JavaDoc e) {
104             tee = (TimeoutExpiredException) e;
105             //e.printStackTrace();
106
}
107         assertNotNull(tee);
108         
109         co1so.setRepositoryURL(RepositoryStepOperator.ITEM_HTTP);
110         tee = null;
111         try {
112             co1so.invokeProxy();
113         } catch (Exception JavaDoc e) {
114             tee = (TimeoutExpiredException) e;
115             //e.printStackTrace();
116
}
117         assertNotNull(tee);
118         
119         co1so.setRepositoryURL(RepositoryStepOperator.ITEM_SVN);
120         tee = null;
121         try {
122             co1so.invokeProxy();
123         } catch (Exception JavaDoc e) {
124             tee = (TimeoutExpiredException) e;
125             //e.printStackTrace();
126
}
127         assertNotNull(tee);
128         
129         co1so.setRepositoryURL(RepositoryStepOperator.ITEM_SVNSSH);
130         tee = null;
131         try {
132             co1so.invokeProxy();
133         } catch (Exception JavaDoc e) {
134             tee = (TimeoutExpiredException) e;
135             //e.printStackTrace();
136
}
137         assertNotNull(tee);
138         co.btCancel().pushNoBlock();
139     }
140 }
141
Popular Tags