1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package org.apache.commons.httpclient;
32
33 import junit.framework.Test;
34 import junit.framework.TestCase;
35 import junit.framework.TestSuite;
36
37 /***
38 * Unit tests for {@link Credentials}.
39 *
40 * @author Rodney Waldhoff
41 * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
42 * @version $Id: TestCredentials.java 155418 2005-02-26 13:01:52Z dirkv $
43 */
44 public class TestCredentials extends TestCase {
45
46
47 public TestCredentials(String testName) {
48 super(testName);
49 }
50
51
52 public static void main(String args[]) {
53 String[] testCaseName = { TestCredentials.class.getName() };
54 junit.textui.TestRunner.main(testCaseName);
55 }
56
57
58
59 public static Test suite() {
60 return new TestSuite(TestCredentials.class);
61 }
62
63 public void testCredentialConstructors() {
64 try {
65 new UsernamePasswordCredentials(null, null);
66 fail("IllegalArgumentException should have been thrown");
67 } catch (IllegalArgumentException e) {
68
69 }
70 try {
71 new NTCredentials("user", "password", null, null);
72 fail("IllegalArgumentException should have been thrown");
73 } catch (IllegalArgumentException e) {
74
75 }
76 try {
77 new NTCredentials("user", "password", "host", null);
78 fail("IllegalArgumentException should have been thrown");
79 } catch (IllegalArgumentException e) {
80
81 }
82 NTCredentials creds = new NTCredentials("user", null, "host", "domain");
83 assertNotNull(creds.getUserName());
84 assertNull(creds.getPassword());
85 assertNotNull(creds.getDomain());
86 assertNotNull(creds.getHost());
87 }
88
89 }