This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.0 by this push:
     new a6ab1d5  KAFKA-7799; Fix flaky test RestServerTest.testCORSEnabled 
(#6106)
a6ab1d5 is described below

commit a6ab1d50947d6c719aff24fc37e74cde3090614d
Author: Jason Gustafson <[email protected]>
AuthorDate: Tue Jan 8 23:47:28 2019 -0800

    KAFKA-7799; Fix flaky test RestServerTest.testCORSEnabled (#6106)
    
    The test always fails if testOptionsDoesNotIncludeWadlOutput is executed 
before testCORSEnabled. It seems the problem is the use of the system property. 
Perhaps there is some static caching somewhere.
    
    Reviewers: Randall Hauch <[email protected]>, Guozhang Wang 
<[email protected]>
---
 .../org/apache/kafka/connect/runtime/rest/RestServerTest.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
 
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
index 892693a..8fee4f4 100644
--- 
a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
+++ 
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
@@ -27,6 +27,7 @@ import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.powermock.api.easymock.PowerMock;
@@ -58,6 +59,12 @@ public class RestServerTest {
     private Plugins plugins;
     private RestServer server;
 
+    @Before
+    public void setUp() {
+        // To be able to set the Origin, we need to toggle this flag
+        System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
+    }
+
     @After
     public void tearDown() {
         server.stop();
@@ -182,13 +189,10 @@ public class RestServerTest {
     }
 
     public void checkCORSRequest(String corsDomain, String origin, String 
expectedHeader, String method) {
-        // To be able to set the Origin, we need to toggle this flag
-
         Map<String, String> workerProps = baseWorkerProps();
         workerProps.put(WorkerConfig.ACCESS_CONTROL_ALLOW_ORIGIN_CONFIG, 
corsDomain);
         workerProps.put(WorkerConfig.ACCESS_CONTROL_ALLOW_METHODS_CONFIG, 
method);
         WorkerConfig workerConfig = new DistributedConfig(workerProps);
-        System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
 
         EasyMock.expect(herder.plugins()).andStubReturn(plugins);
         EasyMock.expect(plugins.newPlugins(Collections.EMPTY_LIST,

Reply via email to