You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2014/08/20 07:54:57 UTC
[2/4] git commit: CURATOR-141 Changed the way we detect a working log
setup
CURATOR-141 Changed the way we detect a working log setup
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4f9d27a2
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4f9d27a2
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4f9d27a2
Branch: refs/heads/CURATOR-141
Commit: 4f9d27a2af09ce8e6825bb489ec7e77597ad178a
Parents: f2f1953
Author: Karel Vervaeke <ka...@ngdata.com>
Authored: Mon Aug 18 14:25:39 2014 +0200
Committer: Karel Vervaeke <ka...@ngdata.com>
Committed: Mon Aug 18 14:25:39 2014 +0200
----------------------------------------------------------------------
.../recipes/cache/TestPathChildrenCache.java | 32 ++++++++++++++++----
1 file changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/4f9d27a2/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
index 70156ff..b904bdc 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
@@ -24,6 +24,9 @@ import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.api.BackgroundCallback;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.Pathable;
import org.apache.curator.framework.api.UnhandledErrorListener;
import org.apache.curator.framework.imps.CuratorFrameworkImpl;
import org.apache.curator.retry.RetryOneTime;
@@ -129,13 +132,30 @@ public class TestPathChildrenCache extends BaseClassForTests
}
};
appender.setLayout(new SimpleLayout());
- Logger rootLogger = Logger.getLogger("org.apache.curator");
- rootLogger.addAppender(appender);
+ Logger logger = Logger.getLogger("org.apache.curator");
+ logger.addAppender(appender);
+
+ // Check that we can intercept error log messages from the client
+ CuratorFramework clientTestLogSetup = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+ clientTestLogSetup.start();
+ try {
+ Pathable<byte[]> callback = clientTestLogSetup.getData().inBackground(new BackgroundCallback() {
+ @Override
+ public void processResult(CuratorFramework client, CuratorEvent event) throws Exception {
+ // ignore result
+ }
+ });
+ CloseableUtils.closeQuietly(clientTestLogSetup);
+ callback.forPath("/test/aaa"); // this should cause an error log message
+ } catch (IllegalStateException ise) {
+ // ok, excpected
+ } finally {
+ CloseableUtils.closeQuietly(clientTestLogSetup);
+ }
- // Check that the logging setup didn't change in a way that breaks this test
- Logger.getLogger(CuratorFrameworkImpl.class).error("Just checking");
- Assert.assertTrue(messages.contains("Just checking"),
- "The test error message was not logged, this test may be broken");
+ Assert.assertTrue(messages.contains("Background exception was not retry-able or retry gave up"),
+ "The expected error was not logged. This is an indication that this test could be broken due to" +
+ " an incomplete logging setup.");
// try to reproduce a bunch of times because it doesn't happen reliably
for (int i = 0; i < 50; i++) {