This repository has been archived by the owner on Dec 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to clone client options object (#5)
- Loading branch information
Bo Yang
authored
May 16, 2017
1 parent
0a8ca92
commit 2a0a9ad
Showing
5 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
lib/src/test/java/com/uber/cherami/client/ClientOptionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 Uber Technologies, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*******************************************************************************/ | ||
package com.uber.cherami.client; | ||
|
||
import com.uber.cherami.PutMessage; | ||
import com.uber.cherami.client.metrics.DefaultMetricsClient; | ||
import com.uber.cherami.client.metrics.MetricsClient; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Unit tests for generating and verifying ClientOptions | ||
*/ | ||
public class ClientOptionsTest { | ||
private final Logger logger = LoggerFactory.getLogger(ClientOptionsTest.class); | ||
private final PutMessage testPutMessage; | ||
private final ChecksumValidator checksumValidator; | ||
private ChecksumWriter checksumWriter; | ||
private CheramiDeliveryImpl testDelivery; | ||
|
||
public ClientOptionsTest() { | ||
this.testPutMessage = new PutMessage(); | ||
this.testPutMessage.setData("Hello, world!".getBytes()); | ||
this.checksumValidator = new ChecksumValidator(); | ||
} | ||
|
||
@Test | ||
public void testClientOptions() { | ||
ClientOptions options = new ClientOptions.Builder() | ||
.setClientAppName("client1") | ||
.setDeploymentStr("staging") | ||
.setRpcTimeout(123) | ||
.setMetricsClient(null) | ||
.build(); | ||
Assert.assertEquals("client1", options.getClientAppName()); | ||
Assert.assertEquals("staging", options.getDeploymentStr()); | ||
Assert.assertEquals(123L, options.getRpcTimeoutMillis()); | ||
Assert.assertEquals(null, options.getMetricsClient()); | ||
|
||
MetricsClient metricsClient = new DefaultMetricsClient(); | ||
options = options.copyWithMetricsClient(metricsClient); | ||
Assert.assertEquals("client1", options.getClientAppName()); | ||
Assert.assertEquals("staging", options.getDeploymentStr()); | ||
Assert.assertEquals(123L, options.getRpcTimeoutMillis()); | ||
Assert.assertEquals(metricsClient, options.getMetricsClient()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters