couchbase/CouchbaseMock — Issue #1: MemcachedServers created by CouchbaseMock not working?
Author: magro
Created: 2011-10-16 23:09:33+00:00
State: open

Hi,

I'm just checking out CouchbaseMock as it seems to be useful for integration testing. Unfortunately I don't get it to work when I'm running a simple test with spymemcached (2.7.3), a stored (set) value is null when requested (get) afterwards.

This is the test I'm running:

```java
public static void main(final String[] args) throws IOException, URISyntaxException, InterruptedException, ExecutionException {
final CouchbaseMock instance = new CouchbaseMock("localhost", 18091, 1, 1);
final Thread thread = new Thread(instance);
thread.start();
Thread.sleep(500);
MemcachedClient mc = null;
try {
final URI base = new URI("http://localhost:18091/pools");
mc = new MemcachedClient(Arrays.asList(base), "default", "");

final Boolean setResult = mc.set("hello", 1000, "world").get();
System.out.println("Result from set: " + setResult);
final String result = (String) mc.get("hello");
System.out.println("Got hello " + result);
} finally {
System.out.println("Stopping services...");
mc.shutdown();
thread.interrupt();
instance.close();
}
}
```

This results in the following output:

```
2011-10-17 01:05:58.625 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=localhost/127.0.0.1:60034, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2011-10-17 01:05:58.757 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@4e99353f
Result from set: true
Got hello null
Stopping services...
2011-10-17 01:05:58.775 INFO net.spy.memcached.MemcachedClient: Shut down memcached client
Exception in thread "Thread-0" java.nio.channels.ClosedSelectorException
at sun.nio.ch.SelectorImpl.selectedKeys(SelectorImpl.java:57)
at org.couchbase.mock.http.HttpServer.serve(HttpServer.java:81)
at org.couchbase.mock.CouchbaseMock.run(CouchbaseMock.java:486)
at java.lang.Thread.run(Thread.java:662)
```

I also tried starting the MemcachedServer created by CouchbaseMock (by invoking MemcachedServer.startup), but this does not fix it.

Is there anything else to do to be able to actually use the created MemcachedServers?

Thanx && cheers,
Martin