Permalink
Browse files

Make all unit tests in voldemort.client pass with and without lazyness

  • Loading branch information...
1 parent 8ec0447 commit fe110032a60fbf442a94aa7bb73b91d01ef357d6 @afeinberg afeinberg committed Jan 5, 2011
@@ -76,7 +76,6 @@ public SocketStoreClientFactory(ClientConfig config) {
@Override
public <K, V> StoreClient<K, V> getStoreClient(final String storeName,
final InconsistencyResolver<Versioned<V>> resolver) {
- // TODO HIGH: FIX testBootstrapServerDown, testUknownStoreName
if(getConfig().isLazyEnabled())
return new LazyStoreClient<K, V>(new Callable<StoreClient<K, V>>() {
@@ -43,14 +43,19 @@
private AbstractSocketService socketService;
private final boolean useNio;
+ private final boolean useLazy;
- public SocketStoreClientFactoryTest(boolean useNio) {
+ public SocketStoreClientFactoryTest(boolean useNio, boolean useLazy) {
this.useNio = useNio;
+ this.useLazy = useLazy;
}
@Parameters
public static Collection<Object[]> configs() {
- return Arrays.asList(new Object[][] { { true }, { false } });
+ return Arrays.asList(new Object[][] { { true, true },
+ { true, false },
+ { false, true },
+ { false, false } });
}
@Override
@@ -74,13 +79,15 @@ public void tearDown() throws Exception {
@Override
protected StoreClientFactory getFactory(String... bootstrapUrls) {
- return new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrls));
+ return new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrls)
+ .setEnableLazy(useLazy));
}
@Override
protected StoreClientFactory getFactoryWithSerializer(SerializerFactory factory,
String... bootstrapUrls) {
return new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrls)
+ .setEnableLazy(useLazy)
.setSerializerFactory(factory));
}
@@ -102,4 +109,38 @@ public void testTwoFactories() throws Exception {
factories.add(getFactory(getValidBootstrapUrl()));
}
+ @Test
+ @Override
+ public void testBootstrapServerDown() throws Exception {
+ try {
+ getFactory(getValidScheme() + "://localhost:58558")
+ .getStoreClient(getValidStoreName())
+ .get("test");
+ fail("Should throw exception.");
+ } catch(BootstrapFailureException e) {
+ // this is good
+ }
+ }
+
+ @Test
+ @Override
+ public void testUnknownStoreName() throws Exception {
+ try {
+ StoreClient<String, String> client = getFactory(getValidBootstrapUrl()).getStoreClient("12345");
+ assertNotNull(client);
+ if(useLazy)
+ client.get("test");
+ fail("Bootstrapped a bad name.");
+ } catch(BootstrapFailureException e) {
+ // this is good
+ }
+ }
+
+ @Test
+ @Override
+ public void testBootstrapFailoverSucceeds() throws Exception {
+ getFactory(getValidScheme() + "://localhost:58558", getValidBootstrapUrl())
+ .getStoreClient(getValidStoreName())
+ .get("test");
+ }
}

0 comments on commit fe11003

Please sign in to comment.