@@ -34,6 +34,7 @@ public class ProxyConfigurationTest {
34
34
private static final Random RNG = new Random ();
35
35
private static final String TEST_HOST = "foo.com" ;
36
36
private static final int TEST_PORT = 7777 ;
37
+ private static final String TEST_NON_PROXY_HOST = "bar.com" ;
37
38
private static final String TEST_USER = "testuser" ;
38
39
private static final String TEST_PASSWORD = "123" ;
39
40
@@ -55,10 +56,13 @@ public void build_setsAllProperties() {
55
56
@ Test
56
57
public void build_systemPropertyDefault () {
57
58
setProxyProperties ();
59
+ Set <String > nonProxyHost = new HashSet <>();
60
+ nonProxyHost .add ("bar.com" );
58
61
ProxyConfiguration config = ProxyConfiguration .builder ().build ();
59
62
60
63
assertThat (config .host ()).isEqualTo (TEST_HOST );
61
64
assertThat (config .port ()).isEqualTo (TEST_PORT );
65
+ assertThat (config .nonProxyHosts ()).isEqualTo (nonProxyHost );
62
66
assertThat (config .username ()).isEqualTo (TEST_USER );
63
67
assertThat (config .password ()).isEqualTo (TEST_PASSWORD );
64
68
assertThat (config .scheme ()).isNull ();
@@ -67,10 +71,13 @@ public void build_systemPropertyDefault() {
67
71
@ Test
68
72
public void build_systemPropertyEnabled () {
69
73
setProxyProperties ();
74
+ Set <String > nonProxyHost = new HashSet <>();
75
+ nonProxyHost .add ("bar.com" );
70
76
ProxyConfiguration config = ProxyConfiguration .builder ().useSystemPropertyValues (Boolean .TRUE ).build ();
71
77
72
78
assertThat (config .host ()).isEqualTo (TEST_HOST );
73
79
assertThat (config .port ()).isEqualTo (TEST_PORT );
80
+ assertThat (config .nonProxyHosts ()).isEqualTo (nonProxyHost );
74
81
assertThat (config .username ()).isEqualTo (TEST_USER );
75
82
assertThat (config .password ()).isEqualTo (TEST_PASSWORD );
76
83
assertThat (config .scheme ()).isNull ();
@@ -79,15 +86,20 @@ public void build_systemPropertyEnabled() {
79
86
@ Test
80
87
public void build_systemPropertyDisabled () {
81
88
setProxyProperties ();
89
+ Set <String > nonProxyHost = new HashSet <>();
90
+ nonProxyHost .add ("test.com" );
91
+
82
92
ProxyConfiguration config = ProxyConfiguration .builder ()
83
93
.host ("localhost" )
84
94
.port (8888 )
95
+ .nonProxyHosts (nonProxyHost )
85
96
.username ("username" )
86
97
.password ("password" )
87
98
.useSystemPropertyValues (Boolean .FALSE ).build ();
88
99
89
100
assertThat (config .host ()).isEqualTo ("localhost" );
90
101
assertThat (config .port ()).isEqualTo (8888 );
102
+ assertThat (config .nonProxyHosts ()).isEqualTo (nonProxyHost );
91
103
assertThat (config .username ()).isEqualTo ("username" );
92
104
assertThat (config .password ()).isEqualTo ("password" );
93
105
assertThat (config .scheme ()).isNull ();
@@ -96,15 +108,20 @@ public void build_systemPropertyDisabled() {
96
108
@ Test
97
109
public void build_systemPropertyOverride () {
98
110
setProxyProperties ();
111
+ Set <String > nonProxyHost = new HashSet <>();
112
+ nonProxyHost .add ("test.com" );
113
+
99
114
ProxyConfiguration config = ProxyConfiguration .builder ()
100
115
.host ("localhost" )
101
116
.port (8888 )
117
+ .nonProxyHosts (nonProxyHost )
102
118
.username ("username" )
103
119
.password ("password" )
104
120
.build ();
105
121
106
122
assertThat (config .host ()).isEqualTo ("localhost" );
107
123
assertThat (config .port ()).isEqualTo (8888 );
124
+ assertThat (config .nonProxyHosts ()).isEqualTo (nonProxyHost );
108
125
assertThat (config .username ()).isEqualTo ("username" );
109
126
assertThat (config .password ()).isEqualTo ("password" );
110
127
assertThat (config .scheme ()).isNull ();
@@ -210,13 +227,15 @@ private Set<String> randomSet() {
210
227
private void setProxyProperties () {
211
228
System .setProperty ("http.proxyHost" , TEST_HOST );
212
229
System .setProperty ("http.proxyPort" , Integer .toString (TEST_PORT ));
230
+ System .setProperty ("http.nonProxyHosts" , TEST_NON_PROXY_HOST );
213
231
System .setProperty ("http.proxyUser" , TEST_USER );
214
232
System .setProperty ("http.proxyPassword" , TEST_PASSWORD );
215
233
}
216
234
217
235
private static void clearProxyProperties () {
218
236
System .clearProperty ("http.proxyHost" );
219
237
System .clearProperty ("http.proxyPort" );
238
+ System .clearProperty ("http.nonProxyHosts" );
220
239
System .clearProperty ("http.proxyUser" );
221
240
System .clearProperty ("http.proxyPassword" );
222
241
}
0 commit comments