This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
/
ThriftSenderFactoryTest.java
83 lines (69 loc) 路 3.09 KB
/
ThriftSenderFactoryTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (c) 2018, The Jaeger Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package io.jaegertracing.thrift.internal.senders;
import static org.junit.Assert.assertTrue;
import io.jaegertracing.Configuration;
import io.jaegertracing.spi.Sender;
import org.junit.Before;
import org.junit.Test;
public class ThriftSenderFactoryTest {
@Before
public void setup() {
System.clearProperty(Configuration.JAEGER_ENDPOINT);
System.clearProperty(Configuration.JAEGER_AUTH_TOKEN);
System.clearProperty(Configuration.JAEGER_USER);
System.clearProperty(Configuration.JAEGER_PASSWORD);
System.clearProperty(Configuration.JAEGER_AGENT_HOST);
System.clearProperty(Configuration.JAEGER_AGENT_PORT);
}
@Test
public void testSenderWithEndpointWithoutAuthData() {
System.setProperty(Configuration.JAEGER_ENDPOINT, "https://jaeger-collector:14268/api/traces");
Sender sender = Configuration.SenderConfiguration.fromEnv().getSender();
assertTrue(sender instanceof HttpSender);
}
@Test
public void testSenderWithAgentDataFromEnv() {
System.setProperty(Configuration.JAEGER_AGENT_HOST, "jaeger-agent");
System.setProperty(Configuration.JAEGER_AGENT_PORT, "6832");
Sender sender = Configuration.SenderConfiguration.fromEnv().getSender();
assertTrue(sender instanceof UdpSender);
}
@Test
public void testSenderWithBasicAuthUsesHttpSender() {
Configuration.SenderConfiguration senderConfiguration = new Configuration.SenderConfiguration()
.withEndpoint("https://jaeger-collector:14268/api/traces")
.withAuthUsername("username")
.withAuthPassword("password");
assertTrue(senderConfiguration.getSender() instanceof HttpSender);
}
@Test
public void testSenderWithAuthTokenUsesHttpSender() {
Configuration.SenderConfiguration senderConfiguration = new Configuration.SenderConfiguration()
.withEndpoint("https://jaeger-collector:14268/api/traces")
.withAuthToken("authToken");
assertTrue(senderConfiguration.getSender() instanceof HttpSender);
}
@Test
public void testSenderWithAllPropertiesReturnsHttpSender() {
System.setProperty(Configuration.JAEGER_ENDPOINT, "https://jaeger-collector:14268/api/traces");
System.setProperty(Configuration.JAEGER_AGENT_HOST, "jaeger-agent");
System.setProperty(Configuration.JAEGER_AGENT_PORT, "6832");
assertTrue(Configuration.SenderConfiguration.fromEnv().getSender() instanceof HttpSender);
}
@Test
public void testDefaultConfigurationReturnsUdpSender() {
assertTrue(Configuration.SenderConfiguration.fromEnv().getSender() instanceof UdpSender);
}
}