File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed
core/src/test/java/org/dcache Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change 20
20
package org .dcache .nfs ;
21
21
22
22
import static com .google .common .net .InetAddresses .forString ;
23
- import static org .junit .Assert .* ;
24
- import static org .mockito . BDDMockito . given ;
25
- import static org .mockito . Mockito .* ;
23
+ import static org .junit .Assert .assertEquals ;
24
+ import static org .junit . Assert . assertFalse ;
25
+ import static org .junit . Assert . assertTrue ;
26
26
27
27
import java .net .InetAddress ;
28
28
import java .net .UnknownHostException ;
@@ -164,11 +164,6 @@ public void testDomainNoMatch() throws UnknownHostException {
164
164
}
165
165
166
166
private InetAddress mockInetAddress (String dnsName , String ... ips ) throws UnknownHostException {
167
-
168
- InetAddress mockedAddress = mock (InetAddress .class );
169
- given (mockedAddress .getHostName ()).willReturn (dnsName );
170
- given (mockedAddress .getCanonicalHostName ()).willReturn (dnsName );
171
-
172
- return mockedAddress ;
167
+ return InetAddress .getByAddress (dnsName , InetAddress .getByName (ips [0 ]).getAddress ());
173
168
}
174
169
}
Original file line number Diff line number Diff line change 1
1
package org .dcache .testutils ;
2
2
3
3
import java .net .InetAddress ;
4
-
5
- import org .mockito .Mockito ;
4
+ import java .net .UnknownHostException ;
6
5
7
6
public class InetAddressBuilder {
8
7
private String ipAddress ;
@@ -19,9 +18,10 @@ public InetAddressBuilder hostName(String hostName) {
19
18
}
20
19
21
20
public InetAddress build () {
22
- InetAddress address = Mockito .mock (InetAddress .class );
23
- Mockito .when (address .getHostAddress ()).thenReturn (ipAddress );
24
- Mockito .when (address .getHostName ()).thenReturn (hostName );
25
- return address ;
21
+ try {
22
+ return InetAddress .getByAddress (hostName , InetAddress .getByName (ipAddress ).getAddress ());
23
+ } catch (UnknownHostException e ) {
24
+ throw new IllegalStateException (e );
25
+ }
26
26
}
27
27
}
You can’t perform that action at this time.
0 commit comments