remove dependence on internal class

This commit is contained in:
金戟 2020-11-28 19:50:00 +08:00
parent ff29172a93
commit b4d6a8357e
2 changed files with 9 additions and 6 deletions

View File

@ -1,9 +1,10 @@
package com.alibaba.testable.demo; package com.alibaba.testable.demo;
import com.alibaba.testable.demo.model.BlackBox; import com.alibaba.testable.demo.model.BlackBox;
import sun.net.www.http.HttpClient;
import java.net.URL; import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;
public class DemoMock { public class DemoMock {
@ -48,7 +49,7 @@ public class DemoMock {
} }
private String innerFunc(String s) throws Exception { private String innerFunc(String s) throws Exception {
return HttpClient.New(new URL("http:/xxx/" + s)).getURLFile(); return Files.readAllLines(Paths.get("/a-not-exist-file")).stream().collect(Collectors.joining());
} }
private String callFromDifferentMethod() { private String callFromDifferentMethod() {

View File

@ -2,8 +2,8 @@ package com.alibaba.testable.demo
import com.alibaba.testable.demo.model.BlackBox import com.alibaba.testable.demo.model.BlackBox
import com.alibaba.testable.demo.model.ColorBox import com.alibaba.testable.demo.model.ColorBox
import sun.net.www.http.HttpClient import java.nio.file.Files
import java.net.URL import java.nio.file.Paths
class DemoMock { class DemoMock {
@ -47,7 +47,9 @@ class DemoMock {
return callFromDifferentMethod() return callFromDifferentMethod()
} }
private fun innerFunc(s: String) = HttpClient.New(URL("http:/xxx/$s")).urlFile private fun innerFunc(s: String): String {
return Files.readAllLines(Paths.get("/a-not-exist-file")).joinToString()
}
private fun callFromDifferentMethod() = "realOne" private fun callFromDifferentMethod() = "realOne"
} }