@Test
public void testUnfencedRemoteGateway() throws Exception {

	final UUID initialFencingToken = UUID.randomUUID();
	final String value = "foobar";
	final FencedTestingEndpoint fencedTestingEndpoint = new FencedTestingEndpoint(rpcService, value, initialFencingToken);
	try {
		fencedTestingEndpoint.start();
		FencedTestingGateway unfencedGateway = rpcService.connect(fencedTestingEndpoint.getAddress(), FencedTestingGateway.class)
			.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
		try {
			unfencedGateway.foobar(timeout).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
			fail("This should have failed because we have an unfenced gateway.");
		} catch (ExecutionException e) {
			assertTrue(ExceptionUtils.stripExecutionException(e) instanceof RpcException);
		}
		try {
			unfencedGateway.getFencingToken();
			fail("We should not be able to call getFencingToken on an unfenced gateway.");
		} catch (UnsupportedOperationException ignored) {
			// we should not be able to call getFencingToken on an unfenced gateway
		}
	} finally {
		fencedTestingEndpoint.shutDown();
		fencedTestingEndpoint.getTerminationFuture().get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
	}
}