diff --git a/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java b/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java index a6f98fe4..406ff2af 100644 --- a/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java +++ b/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 the original author or authors. + * Copyright 2011-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,6 +68,7 @@ import com.gemstone.gemfire.cache.query.CqQuery; * * @author Juergen Hoeller * @author Costin Leau + * @author Oliver Gierke * @see org.springframework.jms.listener.adapter.MessageListenerAdapter */ public class ContinuousQueryListenerAdapter implements ContinuousQueryListener { @@ -260,7 +261,6 @@ public class ContinuousQueryListenerAdapter implements ContinuousQueryListener { * @param event the incoming GemFire event * @see #handleListenerException */ - @SuppressWarnings("unchecked") public void onEvent(CqEvent event) { try { @@ -269,6 +269,7 @@ public class ContinuousQueryListenerAdapter implements ContinuousQueryListener { if (delegate != this) { if (delegate instanceof ContinuousQueryListener) { ((ContinuousQueryListener) delegate).onEvent(event); + return; } } @@ -283,7 +284,6 @@ public class ContinuousQueryListenerAdapter implements ContinuousQueryListener { + "override the 'getListenerMethodName' method."); } - invokeListenerMethod(event, methodName); } catch (Throwable th) { handleListenerException(th); diff --git a/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java b/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java index 5e43592e..a3126ce4 100644 --- a/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java +++ b/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 the original author or authors. + * Copyright 2011-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,9 @@ package org.springframework.data.gemfire.listener.adapter; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; import org.junit.Before; import org.junit.Test; @@ -31,9 +29,9 @@ import com.gemstone.gemfire.cache.query.CqEvent; import com.gemstone.gemfire.cache.query.CqQuery; import com.gemstone.gemfire.cache.query.internal.CqQueryImpl; - /** * @author Costin Leau + * @author Oliver Gierke */ public class QueryListenerAdapterTest { @@ -92,16 +90,17 @@ public class QueryListenerAdapterTest { void handleOperation(Operation op); void handleArray(byte[] ba); - + void handleKey(Object key); - + void handleKV(Object k, Object v); - + void handleEx(Throwable th); - + void handleOps(Operation base, Operation query); - void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp, Object v); + void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp, + Object v); void handleInvalid(Object o1, Object o2, Object o3); } @@ -212,4 +211,31 @@ public class QueryListenerAdapterTest { doThrow(new IllegalArgumentException()).when(mock); } + /** + * @see SGF-89 + */ + @Test + public void triggersListenerImplementingInterfaceCorrectly() { + + SampleListener listener = new SampleListener(); + + ContinuousQueryListener listenerAdapter = new ContinuousQueryListenerAdapter(listener) { + protected void handleListenerException(Throwable ex) { + throw new RuntimeException(ex); + } + }; + + listenerAdapter.onEvent(event()); + assertThat(listener.count, is(1)); + } + + class SampleListener implements ContinuousQueryListener { + + int count; + + @Override + public void onEvent(CqEvent event) { + count++; + } + } } \ No newline at end of file