|
| 1 | +package com.amazonaws.xray.proxies.apache.http; |
| 2 | + |
| 3 | +import java.lang.reflect.Constructor; |
| 4 | +import java.lang.reflect.Modifier; |
| 5 | + |
| 6 | +import org.junit.Before; |
| 7 | +import org.junit.FixMethodOrder; |
| 8 | +import org.junit.Test; |
| 9 | +import org.junit.runners.MethodSorters; |
| 10 | +import org.mockito.Mockito; |
| 11 | + |
| 12 | +import com.amazonaws.xray.AWSXRay; |
| 13 | +import com.amazonaws.xray.AWSXRayRecorderBuilder; |
| 14 | +import com.amazonaws.xray.emitters.Emitter; |
| 15 | +import com.amazonaws.xray.proxies.apache.http.HttpClientBuilder; |
| 16 | + |
| 17 | +import static org.junit.Assert.assertEquals; |
| 18 | + |
| 19 | +@FixMethodOrder(MethodSorters.JVM) |
| 20 | +public class HttpClientBuilderTest { |
| 21 | + |
| 22 | + @Before |
| 23 | + public void setupAWSXRay() { |
| 24 | + // Prevent accidental publish to Daemon |
| 25 | + Emitter blankEmitter = Mockito.mock(Emitter.class); |
| 26 | + Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); |
| 27 | + Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); |
| 28 | + AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build()); |
| 29 | + AWSXRay.clearTraceEntity(); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void testConstructorProtected() throws NoSuchMethodException { |
| 34 | + // Since the constructor is protected and this is in the same package, we have to test this using reflection. |
| 35 | + Constructor clientBuilderConstructor = HttpClientBuilder.class.getDeclaredConstructor(); |
| 36 | + assertEquals(Modifier.PROTECTED, clientBuilderConstructor.getModifiers()); // PROTECTED = 4; |
| 37 | + } |
| 38 | +} |
0 commit comments