Permalink
Browse files

Fixed unit tests.

  • Loading branch information...
bbansal committed Nov 16, 2009
1 parent d88e17c commit 63a078ec6b338942c5472bb7756657dc91b70d08
View
@@ -282,7 +282,7 @@
<target name="junit" depends="build, buildtest" description="Run junit tests.">
<replace-dir dir="${testreport.dir}" />
<replace-dir dir="${testhtml.dir}" />
- <junit printsummary="yes" showoutput="true">
+ <junit printsummary="yes" showoutput="true" maxmemory="128M">
<classpath refid="test-classpath" />
<formatter type="xml" />
<batchtest fork="yes" todir="${testreport.dir}">
@@ -100,12 +100,25 @@ public static AbstractSocketService getSocketService(boolean useNio,
String storesXml,
String storeName,
int port) {
- RequestHandlerFactory factory = new SocketRequestHandlerFactory(getStores(storeName,
- clusterXml,
- storesXml));
+ RequestHandlerFactory factory = getSocketRequestHandlerFactory(clusterXml,
+ storesXml,
+ getStores(storeName,
+ clusterXml,
+ storesXml));
return getSocketService(useNio, factory, port, 5, 10, 10000);
}
+ public static RequestHandlerFactory getSocketRequestHandlerFactory(String clusterXml,
+ String storesXml,
+ StoreRepository storeRepsitory) {
+
+ return new SocketRequestHandlerFactory(storeRepsitory,
+ createMetadataStore(new ClusterMapper().readCluster(new StringReader(clusterXml)),
+ new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml))),
+ null,
+ null);
+ }
+
public static AbstractSocketService getSocketService(boolean useNio,
RequestHandlerFactory requestHandlerFactory,
int port,
@@ -158,7 +171,7 @@ public static Context getJettyServer(String clusterXml,
server.setSendServerVersion(false);
Context context = new Context(server, "/", Context.NO_SESSIONS);
- RequestHandler handler = new SocketRequestHandlerFactory(repository).getRequestHandler(requestFormat);
+ RequestHandler handler = getSocketRequestHandlerFactory(clusterXml, storesXml, repository).getRequestHandler(requestFormat);
context.addServlet(new ServletHolder(new StoreServlet(handler)), "/stores");
server.start();
return context;
@@ -370,4 +383,8 @@ public static ProtoBuffAdminClientRequestFormat getAdminClient(String bootstrapU
return new ProtoBuffAdminClientRequestFormat(bootstrapURL, config);
}
+ public static RequestHandlerFactory getSocketRequestHandlerFactory(StoreRepository repository) {
+ return new SocketRequestHandlerFactory(repository, null, null, null);
+ }
+
}
@@ -34,7 +34,6 @@
import voldemort.server.StoreRepository;
import voldemort.server.http.HttpService;
import voldemort.server.protocol.RequestHandlerFactory;
-import voldemort.server.protocol.SocketRequestHandlerFactory;
import voldemort.store.Store;
import voldemort.store.http.HttpStore;
import voldemort.store.memory.InMemoryStorageEngine;
@@ -101,7 +100,7 @@ public void doOperation(int i) {
RequestFormatType.VOLDEMORT_V1),
socketPool,
false);
- RequestHandlerFactory factory = new SocketRequestHandlerFactory(repository);
+ RequestHandlerFactory factory = ServerTestUtils.getSocketRequestHandlerFactory(repository);
AbstractSocketService socketService = ServerTestUtils.getSocketService(useNio,
factory,
6666,
@@ -4,7 +4,6 @@
import junit.framework.TestCase;
import voldemort.client.protocol.RequestFormatType;
-import voldemort.server.protocol.RequestHandlerFactory;
import voldemort.server.protocol.SocketRequestHandlerFactory;
import voldemort.server.socket.SocketServer;
import voldemort.socketpool.AbstractSocketPoolTest.TestStats;
@@ -65,7 +64,15 @@ protected String getRequestKey() throws Exception {
public void testSocketPoolLimitSomeTimeout() throws Exception {
// start a dummy server
- SocketServer server = new SocketServer(7666, 50, 50, 1000, new SocketRequestHandlerFactory(null), "test");
+ SocketServer server = new SocketServer(7666,
+ 50,
+ 50,
+ 1000,
+ new SocketRequestHandlerFactory(null,
+ null,
+ null,
+ null),
+ "test");
server.start();
final ResourcePoolConfig config = new ResourcePoolConfig().setTimeout(50,
@@ -120,10 +120,6 @@ public void testUpdateAsStreamWithFilter() {
public static class VoldemortFilterImpl implements VoldemortFilter {
- public VoldemortFilterImpl() {
- System.out.println("instantiating voldemortFilter");
- }
-
public boolean accept(Object key, Versioned<?> value) {
String keyString = ByteUtils.getString(((ByteArray) key).get(), "UTF-8");
if(Integer.parseInt(keyString) % 10 == 3) {
@@ -16,6 +16,7 @@
package voldemort.client;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,6 +29,9 @@
import java.util.concurrent.TimeUnit;
import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+
import voldemort.ServerTestUtils;
import voldemort.TestUtils;
import voldemort.client.protocol.admin.AdminClient;
@@ -83,9 +87,9 @@ public void setUp() throws IOException {
@Override
public void tearDown() throws IOException, InterruptedException {
+ adminClient.stop();
server.stop();
-
- // TODO : release sockets held by AdminClient
+ FileUtils.deleteDirectory(new File(server.getVoldemortConfig().getVoldemortHome()));
}
public AdminClient getAdminClient() {
@@ -16,11 +16,14 @@
package voldemort.client;
+import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.Map.Entry;
+import org.apache.commons.io.FileUtils;
+
import voldemort.ServerTestUtils;
import voldemort.TestUtils;
import voldemort.client.protocol.admin.AdminClient;
@@ -66,6 +69,7 @@ public void setUp() throws IOException {
public void tearDown() throws IOException, InterruptedException {
adminClient.stop();
server.stop();
+ FileUtils.deleteDirectory(new File(server.getVoldemortConfig().getVoldemortHome()));
}
@Override
Oops, something went wrong.

0 comments on commit 63a078e

Please sign in to comment.