diff --git a/pom.xml b/pom.xml index 677dd39..dfda6f1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.meituan-dianping.lyrebird.sdk lyrebird-java-client - 1.1.4 + 1.1.5 lyrebird-java-client https://github.com/Meituan-Dianping/lyrebird-java-client diff --git a/src/main/java/com/meituan/lyrebird/client/listeners/Junit4Listener.java b/src/main/java/com/meituan/lyrebird/client/listeners/Junit4Listener.java index c95c9f5..a9a110d 100644 --- a/src/main/java/com/meituan/lyrebird/client/listeners/Junit4Listener.java +++ b/src/main/java/com/meituan/lyrebird/client/listeners/Junit4Listener.java @@ -8,9 +8,7 @@ public class Junit4Listener extends RunListener { @Override - public void testStarted(Description description) - throws NoSuchMethodException, SecurityException, LyrebirdClientException { - Lyrebird lyrebird = new Lyrebird(Lyrebird.getRemoteAddress()); - lyrebird.activate(description.getTestClass().getMethod(description.getMethodName())); + public void testStarted(Description description) throws SecurityException { + } } diff --git a/src/main/java/com/meituan/lyrebird/client/listeners/TestNGListener.java b/src/main/java/com/meituan/lyrebird/client/listeners/TestNGListener.java index b46c18d..7763836 100644 --- a/src/main/java/com/meituan/lyrebird/client/listeners/TestNGListener.java +++ b/src/main/java/com/meituan/lyrebird/client/listeners/TestNGListener.java @@ -1,7 +1,5 @@ package com.meituan.lyrebird.client.listeners; -import com.meituan.lyrebird.Lyrebird; -import com.meituan.lyrebird.client.exceptions.LyrebirdClientException; import org.testng.ITestContext; import org.testng.ITestListener; import org.testng.ITestResult; @@ -10,12 +8,7 @@ public class TestNGListener implements ITestListener { @Override public void onTestStart(ITestResult result) { - Lyrebird lyrebird = new Lyrebird(Lyrebird.getRemoteAddress()); - try { - lyrebird.activate(result.getMethod().getConstructorOrMethod().getMethod()); - } catch (LyrebirdClientException e) { - System.out.println(e); - } + } @Override diff --git a/src/test/java/com/meituan/lyrebird/test/TestJunit4Listener.java b/src/test/java/com/meituan/lyrebird/test/TestJunit4Listener.java deleted file mode 100644 index 4fc7b56..0000000 --- a/src/test/java/com/meituan/lyrebird/test/TestJunit4Listener.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.meituan.lyrebird.test; - -import com.google.gson.Gson; -import com.meituan.lyrebird.client.MockData; -import com.meituan.lyrebird.client.api.*; -import com.meituan.lyrebird.client.listeners.*; -import com.meituan.lyrebird.client.exceptions.LyrebirdClientException; -import okhttp3.mockwebserver.*; -import org.junit.*; -import org.junit.runner.RunWith; - -import java.io.IOException; - -@RunWith(Junit4Runner.class) -public class TestJunit4Listener { - private static MockWebServer mockServer; - private static Gson gson; - - @BeforeClass - public static void setup() throws IOException { - gson = new Gson(); - mockServer = new MockWebServer(); - mockServer.start(9090); - makeSuccessResponse(); - } - - @AfterClass - public static void teardown() throws IOException { - if (mockServer!=null) { - mockServer.close(); - mockServer = null; - } - } - - private static void makeSuccessResponse(){ - BaseResponse resp = new BaseResponse(); - resp.setCode(1000); - resp.setMessage("success"); - mockServer.enqueue(new MockResponse().setBody(gson.toJson(resp))); - } - - @Test - @MockData(groupID = "89e0426c-9cf9-454a-bbe0-94246fc23b04", groupName = "首页") - public void testActivate() throws InterruptedException, LyrebirdClientException { - RecordedRequest req = mockServer.takeRequest(); - Assert.assertEquals("request path not match", "/api/mock/89e0426c-9cf9-454a-bbe0-94246fc23b04/activate", req.getPath()); - } -} \ No newline at end of file diff --git a/src/test/java/com/meituan/lyrebird/test/TestTestNGListener.java b/src/test/java/com/meituan/lyrebird/test/TestTestNGListener.java deleted file mode 100644 index de6287e..0000000 --- a/src/test/java/com/meituan/lyrebird/test/TestTestNGListener.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.meituan.lyrebird.test; - -import com.google.gson.Gson; -import com.meituan.lyrebird.Lyrebird; -import com.meituan.lyrebird.client.MockData; -import com.meituan.lyrebird.client.api.*; -import com.meituan.lyrebird.client.listeners.*; -import com.meituan.lyrebird.client.exceptions.LyrebirdClientException; -import okhttp3.mockwebserver.*; - -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Listeners; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.lang.reflect.Method; - -@MockData(groupID = "89e0426c-9cf9-454a-bbe0-94246fc23b04", groupName = "首页") -@Listeners(TestNGListener.class) -public class TestTestNGListener { - private MockWebServer mockServer; - private Gson gson; - - @BeforeMethod(alwaysRun = true) - public void init(Method method) throws LyrebirdClientException, IOException { - this.gson = new Gson(); - this.mockServer = new MockWebServer(); - this.mockServer.start(); - Lyrebird.setRemoteAddress(String.format("http://%s:%d", this.mockServer.getHostName(), this.mockServer.getPort())); - makeSuccessResponse(); - } - - @AfterClass(alwaysRun = true) - public void teardown() throws IOException { - if(this.mockServer != null) { - this.mockServer.close(); - } - } - - private void makeSuccessResponse(){ - BaseResponse resp = new BaseResponse(); - resp.setCode(1000); - resp.setMessage("success"); - this.mockServer.enqueue(new MockResponse().setBody(gson.toJson(resp))); - } - - @Test - public void testActivate() throws InterruptedException, LyrebirdClientException { - RecordedRequest req = mockServer.takeRequest(); - Assert.assertEquals(req.getPath(), "/api/mock/89e0426c-9cf9-454a-bbe0-94246fc23b04/activate", "request path not match"); - } -} \ No newline at end of file