|
| 1 | +// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Universal Permissive License v 1.0 as shown at |
| 3 | +// http://oss.oracle.com/licenses/upl. |
| 4 | + |
| 5 | +package oracle.kubernetes.operator.wlsconfig; |
| 6 | + |
| 7 | +import static org.hamcrest.CoreMatchers.is; |
| 8 | +import static org.junit.Assert.*; |
| 9 | + |
| 10 | +import org.junit.Test; |
| 11 | + |
| 12 | +public class WlsServerConfigTest { |
| 13 | + |
| 14 | + static final int LISTEN_PORT = 8001; |
| 15 | + static final int SSL_LISTEN_PORT = 8002; |
| 16 | + static final int ADMIN_PORT = 9002; |
| 17 | + static final int NAP_ADMIN_PORT = 8082; |
| 18 | + static final int NAP_NON_ADMIN_PORT = 8081; |
| 19 | + |
| 20 | + @Test |
| 21 | + public void verify_getLocalAdminProtocolChannelPort_returnsListenPort() { |
| 22 | + WlsServerConfig wlsServerConfig = createConfigWithOnlyListenPort(); |
| 23 | + assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(LISTEN_PORT)); |
| 24 | + assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(false)); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void verify_getLocalAdminProtocolChannelPort_returnsSslListenPort() { |
| 29 | + WlsServerConfig wlsServerConfig = createConfigWithListenPortAndSslListenPort(); |
| 30 | + assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(SSL_LISTEN_PORT)); |
| 31 | + assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true)); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + public void verify_getLocalAdminProtocolChannelPort_returnsAdminPort() { |
| 36 | + WlsServerConfig wlsServerConfig = createConfigWithAllListenPorts(); |
| 37 | + assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(ADMIN_PORT)); |
| 38 | + assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true)); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void verify_getLocalAdminProtocolChannelPort_withAdminNAP_returnsNapAdminPort() { |
| 43 | + WlsServerConfig wlsServerConfig = createConfigWithAdminNAP(); |
| 44 | + assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(NAP_ADMIN_PORT)); |
| 45 | + assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true)); |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + public void verify_getLocalAdminProtocolChannelPort_withNonAdminNAP_returnsAdminPort() { |
| 50 | + WlsServerConfig wlsServerConfig = createConfigWithNonAdminNAP(); |
| 51 | + assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(ADMIN_PORT)); |
| 52 | + assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true)); |
| 53 | + } |
| 54 | + |
| 55 | + WlsServerConfig createConfigWithOnlyListenPort() { |
| 56 | + WlsServerConfig wlsServerConfig = new WlsServerConfig(); |
| 57 | + wlsServerConfig.setListenPort(LISTEN_PORT); |
| 58 | + return wlsServerConfig; |
| 59 | + } |
| 60 | + |
| 61 | + WlsServerConfig createConfigWithListenPortAndSslListenPort() { |
| 62 | + WlsServerConfig wlsServerConfig = createConfigWithOnlyListenPort(); |
| 63 | + wlsServerConfig.setSslListenPort(SSL_LISTEN_PORT); |
| 64 | + return wlsServerConfig; |
| 65 | + } |
| 66 | + |
| 67 | + WlsServerConfig createConfigWithAllListenPorts() { |
| 68 | + WlsServerConfig wlsServerConfig = createConfigWithListenPortAndSslListenPort(); |
| 69 | + wlsServerConfig.setAdminPort(ADMIN_PORT); |
| 70 | + return wlsServerConfig; |
| 71 | + } |
| 72 | + |
| 73 | + WlsServerConfig createConfigWithAdminNAP() { |
| 74 | + WlsServerConfig wlsServerConfig = createConfigWithAllListenPorts(); |
| 75 | + wlsServerConfig.addNetworkAccessPoint( |
| 76 | + new NetworkAccessPoint("admin-channel", "admin", NAP_ADMIN_PORT, null)); |
| 77 | + return wlsServerConfig; |
| 78 | + } |
| 79 | + |
| 80 | + WlsServerConfig createConfigWithNonAdminNAP() { |
| 81 | + WlsServerConfig wlsServerConfig = createConfigWithAllListenPorts(); |
| 82 | + wlsServerConfig.addNetworkAccessPoint( |
| 83 | + new NetworkAccessPoint("non-admin-channel", "t3", NAP_NON_ADMIN_PORT, null)); |
| 84 | + return wlsServerConfig; |
| 85 | + } |
| 86 | +} |
0 commit comments