mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-02-13 13:20:32 +08:00
remove dependence on internal class
This commit is contained in:
parent
ff29172a93
commit
b4d6a8357e
@ -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() {
|
||||||
|
@ -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"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user