Skip to content

Commit

Permalink
Implementing read-only methods in MemcachedNodeROImpl - issue86
Browse files Browse the repository at this point in the history
Change-Id: I3437c4a69d9673d3fc7a2d0611012389b28e3d2f
Reviewed-on: https://review.northscale.com:8443/1287
Reviewed-by: Dustin Sallings <dustin@spy.net>
Tested-by: Dustin Sallings <dustin@spy.net>
  • Loading branch information
gkim authored and dustin committed Apr 7, 2010
1 parent efb3e58 commit da151b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/spy/memcached/MemcachedNodeROImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void fixupOps() {
}

public int getBytesRemainingToWrite() {
throw new UnsupportedOperationException();
return root.getBytesRemainingToWrite();
}

public SocketChannel getChannel() {
Expand All @@ -71,11 +71,11 @@ public ByteBuffer getRbuf() {
}

public int getReconnectCount() {
throw new UnsupportedOperationException();
return root.getReconnectCount();
}

public int getSelectionOps() {
throw new UnsupportedOperationException();
return root.getSelectionOps();
}

public SelectionKey getSk() {
Expand All @@ -91,15 +91,15 @@ public ByteBuffer getWbuf() {
}

public boolean hasReadOp() {
throw new UnsupportedOperationException();
return root.hasReadOp();
}

public boolean hasWriteOp() {
throw new UnsupportedOperationException();
return root.hasReadOp();
}

public boolean isActive() {
throw new UnsupportedOperationException();
return root.isActive();
}

public void reconnecting() {
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/net/spy/memcached/MemcachedNodeROImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
Expand All @@ -23,10 +26,13 @@ public void testReadOnliness() throws Exception {
assertSame(sa, node.getSocketAddress());
assertEquals(m.proxy().toString(), node.toString());

Set<String> acceptable = new HashSet<String>(Arrays.asList(
"toString", "getSocketAddress", "getBytesRemainingToWrite",
"getReconnectCount", "getSelectionOps", "hasReadOp",
"hasWriteOp", "isActive"));

for(Method meth : MemcachedNode.class.getMethods()) {
if(meth.getName().equals("toString")) {
// ok
} else if(meth.getName().equals("getSocketAddress")) {
if(acceptable.contains(meth.getName())) {
// ok
} else {
Object[] args=new Object[meth.getParameterTypes().length];
Expand All @@ -35,7 +41,8 @@ public void testReadOnliness() throws Exception {
meth.invoke(node, args);
fail("Failed to break on " + meth.getName());
} catch(InvocationTargetException e) {
assertSame(UnsupportedOperationException.class,
assertSame("Fail at " + meth.getName(),
UnsupportedOperationException.class,
e.getCause().getClass());
}
}
Expand Down

0 comments on commit da151b8

Please sign in to comment.