Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sutra committed Jun 22, 2023
1 parent a5fb4e0 commit ad01092
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package us.codecraft.webmagic.proxy;

import org.junit.Test;
import org.mockito.Mockito;

import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Task;

Expand All @@ -20,11 +23,12 @@ public void test_get_proxy() throws Exception {
Proxy originProxy1 = new Proxy("127.0.0.1", 1087);
Proxy originProxy2 = new Proxy("127.0.0.1", 1088);
SimpleProxyProvider proxyProvider = SimpleProxyProvider.from(originProxy1, originProxy2);
Proxy proxy = proxyProvider.getProxy(null, TASK);
Request request = Mockito.mock(Request.class);
Proxy proxy = proxyProvider.getProxy(request, TASK);
assertThat(proxy).isEqualTo(originProxy1);
proxy = proxyProvider.getProxy(TASK);
proxy = proxyProvider.getProxy(request, TASK);
assertThat(proxy).isEqualTo(originProxy2);
proxy = proxyProvider.getProxy(TASK);
proxy = proxyProvider.getProxy(request, TASK);
assertThat(proxy).isEqualTo(originProxy1);
}
}

0 comments on commit ad01092

Please sign in to comment.