|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.pulsar.common.policies.data; |
| 20 | + |
| 21 | +import static org.testng.Assert.assertEquals; |
| 22 | +import static org.testng.Assert.assertNotSame; |
| 23 | + |
| 24 | +import org.apache.pulsar.client.api.ProxyProtocol; |
| 25 | +import org.testng.annotations.Test; |
| 26 | + |
| 27 | +import java.util.LinkedHashSet; |
| 28 | + |
| 29 | +public class ClusterDataImplTest { |
| 30 | + |
| 31 | + @Test |
| 32 | + public void verifyClone() { |
| 33 | + ClusterDataImpl originalData = ClusterDataImpl.builder() |
| 34 | + .serviceUrl("pulsar://test") |
| 35 | + .serviceUrlTls("pulsar+ssl://test") |
| 36 | + .brokerServiceUrl("pulsar://test:6650") |
| 37 | + .brokerServiceUrlTls("pulsar://test:6651") |
| 38 | + .proxyServiceUrl("pulsar://proxy:6650") |
| 39 | + .authenticationPlugin("test-plugin") |
| 40 | + .authenticationParameters("test-params") |
| 41 | + .proxyProtocol(ProxyProtocol.SNI) |
| 42 | + .peerClusterNames(new LinkedHashSet<>()) |
| 43 | + .brokerClientTlsEnabled(true) |
| 44 | + .tlsAllowInsecureConnection(false) |
| 45 | + .brokerClientTlsEnabledWithKeyStore(true) |
| 46 | + .brokerClientTlsTrustStoreType("JKS") |
| 47 | + .brokerClientTlsTrustStore("/my/trust/store") |
| 48 | + .brokerClientTlsTrustStorePassword("some-password") |
| 49 | + .brokerClientTlsKeyStoreType("PCKS12") |
| 50 | + .brokerClientTlsKeyStore("/my/key/store") |
| 51 | + .brokerClientTlsKeyStorePassword("a-different-password") |
| 52 | + .brokerClientTrustCertsFilePath("/my/trusted/certs") |
| 53 | + .brokerClientKeyFilePath("/my/key/file") |
| 54 | + .brokerClientCertificateFilePath("/my/cert/file") |
| 55 | + .listenerName("a-listener") |
| 56 | + .migrated(true) |
| 57 | + .migratedClusterUrl(new ClusterData.ClusterUrl("pulsar://remote", "pulsar+ssl://remote")) |
| 58 | + .build(); |
| 59 | + |
| 60 | + ClusterDataImpl clone = originalData.clone().build(); |
| 61 | + |
| 62 | + assertEquals(clone, originalData, "Clones should have object equality."); |
| 63 | + assertNotSame(clone, originalData, "Clones should not be the same reference."); |
| 64 | + } |
| 65 | +} |
0 commit comments