Changed the usage of test from (junit 3 to 4) from extend to @Test.
parent
6d807cdd4d
commit
4fac4bbb8c
|
@ -125,14 +125,14 @@ public class Registry implements VoterRegistry{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getPersonIDDetails(VoterID voterID, RegistryCallBack callback) {
|
||||
public void getVoter(VoterID voterID, RegistryCallBack callback) {
|
||||
List<String> addVoterTags = new ArrayList<String>() {{
|
||||
add(RegistryTags.ID_TAG + voterID.getId());
|
||||
add(RegistryTags.VOTER_ENTRY_TAG);
|
||||
}};
|
||||
|
||||
bulletinBoardClient.readMessages(MessageCollectionUtils.generateFiltersFromTags(addVoterTags),
|
||||
new LatestMessagesCallBack(callback, signers, "getPersonIDDetails"));
|
||||
new LatestMessagesCallBack(callback, signers, "getVoter"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,7 +76,7 @@ public interface VoterRegistry {
|
|||
* @param callBack when the adding voter done callBack.handleResult will be called
|
||||
* @return list of strings (empty list if the lookup failed)
|
||||
*/
|
||||
void getPersonIDDetails(VoterID voterID, RegistryCallBack callBack);
|
||||
void getVoter(VoterID voterID, RegistryCallBack callBack);
|
||||
|
||||
/**
|
||||
* Checks if the given voter (by his id) have already voted
|
||||
|
|
|
@ -58,7 +58,7 @@ public class LatestMessagesCallBack implements FutureCallback<List<BulletinBoard
|
|||
case "getGroups" :
|
||||
callback.handleResult(GetListOfTags(messages, RegistryTags.GROUP_ID_TAG));
|
||||
break;
|
||||
case "getPersonIDDetails" : callback.handleResult(lastAddedMessage);
|
||||
case "getVoter" : callback.handleResult(lastAddedMessage);
|
||||
break;
|
||||
case "hasVoted" :
|
||||
callback.handleResult(findTagWithPrefix(lastAddedMessage,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import junit.framework.TestCase;
|
||||
import meerkat.Registry;
|
||||
import meerkat.bulletinboard.AsyncBulletinBoardClient;
|
||||
import meerkat.bulletinboard.ThreadedBulletinBoardClient;
|
||||
|
@ -14,6 +13,7 @@ import meerkat.protobuf.VoterRegistry.VoterInfo;
|
|||
import meerkat.protobuf.Voting;
|
||||
import meerkat.registry.MessageCollectionUtils;
|
||||
import meerkat.registry.RegistryTags;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -25,6 +25,8 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static meerkat.util.BulletinBoardUtils.findTagWithPrefix;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +39,7 @@ import static meerkat.util.BulletinBoardUtils.findTagWithPrefix;
|
|||
* NOTE: for most of this tests to pass there should run BulletinBoardServer
|
||||
* that should be reachable on BULLETIN_BOARD_SERVER_ADDRESS
|
||||
*/
|
||||
public class SimpleRegistryTest extends TestCase {
|
||||
public class SimpleRegistryTest /**extends TestCase**/ {
|
||||
|
||||
private Collection<DigitalSignature> signers;
|
||||
private AsyncBulletinBoardClient bulletinBoardClient;
|
||||
|
@ -123,6 +125,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
/**
|
||||
* Initialize registry object
|
||||
*/
|
||||
@Before
|
||||
public void setUp() {
|
||||
SetSigner();
|
||||
CommunicatorSetup();
|
||||
|
@ -320,7 +323,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
* Test that the personal data outputted about the user is right
|
||||
*/
|
||||
@Test
|
||||
public void testGetPersonalIDDetails() throws InterruptedException {
|
||||
public void testGetVoter() throws InterruptedException {
|
||||
DummyRegistryCallBackHandler<List<BulletinBoardMessage>> handler =
|
||||
new DummyRegistryCallBackHandler<>();
|
||||
|
||||
|
@ -336,7 +339,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
assertEquals("The callback handler hasn't been called yet", 1, handler.counter );
|
||||
|
||||
DummyRegistryCallBackHandler<BulletinBoardMessage> personalHandler = new DummyRegistryCallBackHandler<>();
|
||||
registry.getPersonIDDetails(VoterID.newBuilder().setId(id).build(), personalHandler);
|
||||
registry.getVoter(VoterID.newBuilder().setId(id).build(), personalHandler);
|
||||
|
||||
jobSemaphore.acquire(1);
|
||||
assertEquals("The voter id doesn't match the created on ",
|
||||
|
@ -345,7 +348,11 @@ public class SimpleRegistryTest extends TestCase {
|
|||
findTagWithPrefix(personalHandler.data, data) != null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests that the hasVoted method of registry works
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Test
|
||||
public void testHasVoted () throws InterruptedException {
|
||||
DummyRegistryCallBackHandler<Boolean> handler = new DummyRegistryCallBackHandler<>();
|
||||
String id = generateString();
|
||||
|
@ -361,6 +368,5 @@ public class SimpleRegistryTest extends TestCase {
|
|||
jobSemaphore.acquire(1);
|
||||
assertTrue("The voter hasn't voted yet.", personalHandler.data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue