|
1 | 1 | /* |
2 | | - * Copyright (c) 2021 VMware, Inc. or its affiliates, All Rights Reserved. |
| 2 | + * Copyright (c) 2021-2025 VMware, Inc. or its affiliates, All Rights Reserved. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -28,27 +28,30 @@ class ChannelBindExceptionTest { |
28 | 28 | @Test |
29 | 29 | void testFailBindExceptionCause() { |
30 | 30 |
|
31 | | - UnsupportedOperationException cause = new UnsupportedOperationException(); |
| 31 | + Exception cause = new UnsupportedOperationException(); |
32 | 32 | ChannelBindException ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), cause); |
33 | 33 | assertThat(ex.getCause()).isEqualTo(cause); |
34 | 34 | assertThat(ex.localHost()).isEqualTo("test"); |
35 | 35 | assertThat(ex.localPort()).isEqualTo(4956); |
36 | 36 |
|
37 | | - ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), new BindException("Address already in use")); |
38 | | - assertThat(ex.getCause()).isEqualTo(null); |
| 37 | + cause = new BindException("Address already in use"); |
| 38 | + ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), cause); |
| 39 | + assertThat(ex.getCause()).isEqualTo(cause); |
39 | 40 | assertThat(ex.localHost()).isEqualTo("test"); |
40 | 41 | assertThat(ex.localPort()).isEqualTo(4956); |
41 | 42 |
|
42 | 43 | // Not possible to mock io.netty.channel.unix.Errors.NativeIoException or create a new instance because of Jni errors |
43 | 44 | // java.lang.UnsatisfiedLinkError: 'int io.netty.channel.unix.ErrorsStaticallyReferencedJniMethods.errnoENOENT()' |
44 | | - ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), new IOException("bind(..) failed: Address already in use")); |
45 | | - assertThat(ex.getCause()).isEqualTo(null); |
| 45 | + cause = new IOException("bind(..) failed: Address already in use"); |
| 46 | + ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), cause); |
| 47 | + assertThat(ex.getCause()).isEqualTo(cause); |
46 | 48 | assertThat(ex.localHost()).isEqualTo("test"); |
47 | 49 | assertThat(ex.localPort()).isEqualTo(4956); |
48 | 50 |
|
49 | 51 | // Issue-1668 |
50 | | - ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), new IOException("bind(..) failed: Die Adresse wird bereits verwendet")); |
51 | | - assertThat(ex.getCause()).isEqualTo(null); |
| 52 | + cause = new IOException("bind(..) failed: Die Adresse wird bereits verwendet"); |
| 53 | + ex = ChannelBindException.fail(new InetSocketAddress("test", 4956), cause); |
| 54 | + assertThat(ex.getCause()).isEqualTo(cause); |
52 | 55 | assertThat(ex.localHost()).isEqualTo("test"); |
53 | 56 | assertThat(ex.localPort()).isEqualTo(4956); |
54 | 57 |
|
|
0 commit comments