X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FWebOfTrustUpdaterTest.java;h=7529fc6d03a35a77db166f611a9602d3ee0a5215;hb=10d9eb5fcea8440b9ea06a3732678b286090934f;hp=ff646b05e44e6939131e2b30aa7a1228b09aa0de;hpb=fd2ae87f8dbc9fa0214dbbd9a6b803f81846a23c;p=Sone.git
diff --git a/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java b/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java
index ff646b0..7529fc6 100644
--- a/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java
+++ b/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java
@@ -6,24 +6,22 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import net.pterodactylus.sone.core.WebOfTrustUpdater.AddContextJob;
-import net.pterodactylus.sone.core.WebOfTrustUpdater.RemoveContextJob;
-import net.pterodactylus.sone.core.WebOfTrustUpdater.SetPropertyJob;
-import net.pterodactylus.sone.core.WebOfTrustUpdater.SetTrustJob;
-import net.pterodactylus.sone.core.WebOfTrustUpdater.WebOfTrustContextUpdateJob;
-import net.pterodactylus.sone.core.WebOfTrustUpdater.WebOfTrustUpdateJob;
+
+import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.AddContextJob;
+import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.RemoveContextJob;
+import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.SetPropertyJob;
+import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.SetTrustJob;
+import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.WebOfTrustContextUpdateJob;
+import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.WebOfTrustUpdateJob;
import net.pterodactylus.sone.freenet.plugin.PluginException;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
@@ -36,7 +34,7 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
- * Unit test for {@link WebOfTrustUpdater} and its subclasses.
+ * Unit test for {@link WebOfTrustUpdaterImpl} and its subclasses.
*
* @author David âBombeâ Roden
*/
@@ -48,7 +46,7 @@ public class WebOfTrustUpdaterTest {
private static final String TRUST_COMMENT = "set in a test";
private static final String PROPERTY_NAME = "test-property";
private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class);
- private final WebOfTrustUpdater webOfTrustUpdater = new WebOfTrustUpdater(webOfTrustConnector);
+ private final WebOfTrustUpdaterImpl webOfTrustUpdater = new WebOfTrustUpdaterImpl(webOfTrustConnector);
private final OwnIdentity ownIdentity = when(mock(OwnIdentity.class).getId()).thenReturn("own-identity-id").getMock();
private final WebOfTrustUpdateJob successfulWebOfTrustUpdateJob = createWebOfTrustUpdateJob(true);
private final WebOfTrustUpdateJob failingWebOfTrustUpdateJob = createWebOfTrustUpdateJob(false);
@@ -365,30 +363,6 @@ public class WebOfTrustUpdaterTest {
}
@Test
- public void multipleCallsToAddContextAreCollapsed() throws InterruptedException, PluginException {
- final AtomicInteger errorCount = new AtomicInteger();
- final CountDownLatch addContextsFinished = new CountDownLatch(2);
- for (int i = 1; i <= 2; i++) {
- /* this is so fucking volatile. */
- if (i > 1) {
- sleep(200);
- }
- new Thread(new Runnable() {
- public void run() {
- if (!webOfTrustUpdater.addContextWait(ownIdentity, CONTEXT)) {
- errorCount.incrementAndGet();
- }
- addContextsFinished.countDown();
- }
- }).start();
- }
- webOfTrustUpdater.start();
- assertThat(addContextsFinished.await(1, SECONDS), is(true));
- verify(ownIdentity).addContext(eq(CONTEXT));
- assertThat(errorCount.get(), is(0));
- }
-
- @Test
public void removeContextRemovesAContext() throws InterruptedException, PluginException {
webOfTrustUpdater.start();
final CountDownLatch removeContextTrigger = new CountDownLatch(1);
@@ -434,7 +408,7 @@ public class WebOfTrustUpdaterTest {
@Test
public void setTrustSetsTrust() throws InterruptedException, PluginException {
- final CountDownLatch trustSetTrigger =new CountDownLatch(1);
+ final CountDownLatch trustSetTrigger = new CountDownLatch(1);
doAnswer(new Answer() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {