Added:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ReflectionUtilsTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ReflectionUtilsTest.java?rev=778764&view=auto
==============================================================================
---
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ReflectionUtilsTest.java
(added)
+++
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ReflectionUtilsTest.java
Tue May 26 15:46:33 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.bean.support;
+
+import javax.annotation.PostConstruct;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for {...@link ReflectionUtils}
+ */
+public class ReflectionUtilsTest extends TestCase {
+
+ public void testInvoke() throws Exception {
+ Pojo pojo = new Pojo();
+ assertFalse(pojo.constructed);
+ ReflectionUtils.callLifecycleMethod(pojo, PostConstruct.class);
+ assertTrue(pojo.constructed);
+ }
+
+ private static final class Pojo {
+
+ private boolean constructed;
+
+ @PostConstruct
+ public void doSomething() {
+ constructed = true;
+ }
+ }
+}
Propchange:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ReflectionUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/RequestTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/RequestTest.java?rev=778764&r1=778763&r2=778764&view=diff
==============================================================================
---
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/RequestTest.java
(original)
+++
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/RequestTest.java
Tue May 26 15:46:33 2009
@@ -16,6 +16,9 @@
*/
package org.apache.servicemix.bean.support;
+import java.lang.reflect.Method;
+import java.util.Map;
+
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
@@ -67,6 +70,14 @@
assertEquals("We shouldn't have duplicate MessageExchange instances",
1, request.getExchanges().size());
}
+ public void testLazyCreateCallbacks() throws Exception {
+ MessageExchange exchange = createMockExchange("my-exchange-id");
+ Request request = new Request("my-correlation-id", new Object(),
exchange);
+ Map<Method, Boolean> callbacks = request.getCallbacks();
+ assertNotNull(callbacks);
+ assertSame(callbacks, request.getCallbacks());
+ }
+
private MessageExchange createMockExchange(String id) {
MockMessageExchange exchange = new MockMessageExchange();
exchange.setExchangeId(id);
Added:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ResolverUtilTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ResolverUtilTest.java?rev=778764&view=auto
==============================================================================
---
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ResolverUtilTest.java
(added)
+++
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ResolverUtilTest.java
Tue May 26 15:46:33 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.bean.support;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.bean.Endpoint;
+import org.apache.servicemix.bean.beans.AutoDeployedBean;
+import org.apache.servicemix.bean.beans.ListenerBean;
+import org.apache.servicemix.bean.beans.PlainBean;
+import org.apache.servicemix.bean.support.ResolverUtil.AnnotatedWith;
+import org.apache.servicemix.bean.support.ResolverUtil.IsA;
+import org.apache.servicemix.jbi.listener.MessageExchangeListener;
+
+/**
+ * Test cases for {...@link ResolverUtil}
+ */
+public class ResolverUtilTest extends TestCase {
+
+ public void testIsA() throws Exception {
+ IsA test = new IsA(MessageExchangeListener.class);
+ assertFalse(test.matches(PlainBean.class));
+ assertTrue(test.matches(ListenerBean.class));
+ }
+
+ public void testAnnotatedWith() throws Exception {
+ AnnotatedWith test = new AnnotatedWith(Endpoint.class);
+ assertFalse(test.matches(PlainBean.class));
+ assertTrue(test.matches(AutoDeployedBean.class));
+ }
+
+ public void testFindImplementations() throws Exception {
+ ResolverUtil util = new ResolverUtil();
+ util.findImplementations(MessageExchangeListener.class,
"org.apache.servicemix.bean.beans");
+ // should have found 3 implementations
+ assertEquals(2, util.getClasses().size());
+ // and make sure we don't break by omitting the package to search
+ util.findImplementations(MessageExchangeListener.class, null);
+ assertEquals(2, util.getClasses().size());
+ }
+
+ public void testFindImplementationsInJar() throws Exception {
+ ResolverUtil util = new ResolverUtil();
+ util.findImplementations(MessageExchangeListener.class,
"org.apache.servicemix.common");
+ // should have found some implementations
+ assertNotNull(util.getClasses());
+ assertFalse(util.getClasses().isEmpty());
+ }
+
+ public void testFindAnnotated() throws Exception {
+ ResolverUtil util = new ResolverUtil();
+ util.findAnnotated(Endpoint.class, "org.apache.servicemix.bean.beans");
+ // should have found 1 implementation
+ assertEquals(1, util.getClasses().size());
+ // and make sure we don't break by omitting the package to search
+ util.findAnnotated(Endpoint.class, null);
+ assertEquals(1, util.getClasses().size());
+ }
+}
Propchange:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/support/ResolverUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native