Author: jim.ma
Date: 2014-09-22 05:03:32 -0400 (Mon, 22 Sep 2014)
New Revision: 18938
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncEnabledInfoInterceptor.java
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncClientTestCase.java
Log:
[JBWS-3630]:Add test case to demonstrate enable asyncclient with UseAsyncPolicy
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncClientTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncClientTestCase.java 2014-09-17
15:26:53 UTC (rev 18937)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncClientTestCase.java 2014-09-22
09:03:32 UTC (rev 18938)
@@ -33,6 +33,8 @@
import junit.framework.Test;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.wsf.test.JBossWSCXFTestSetup;
import org.jboss.wsf.test.JBossWSTest;
@@ -93,6 +95,27 @@
requestContext.put("use.async.http.conduit", Boolean.TRUE);
assertEquals("Echo:1000", proxy.echoAsync(1000).get());
}
+
+ public void testAysncClientWithPolicy () throws Exception
+ {
+ Bus bus = BusFactory.newInstance().createBus();
+ AsyncEnabledInfoInterceptor asyncInfo = new AsyncEnabledInfoInterceptor();
+ try
+ {
+ bus.setProperty("use.async.http.conduit", "ASYNC_ONLY");
+ bus.getOutInterceptors().add(asyncInfo);
+ BusFactory.setThreadDefaultBus(bus);
+ Endpoint proxy = initPort();
+ assertEquals("Echo:1000", proxy.echo(1000));
+ assertFalse("Async client is expected disabled",
asyncInfo.isAsyncEnabled());
+ assertEquals("Echo:1000", proxy.echoAsync(1000).get());
+ assertTrue("Async client is expected enabled",
asyncInfo.isAsyncEnabled());
+ }
+ finally
+ {
+ bus.shutdown(true);
+ }
+ }
private Endpoint initPort() throws Exception {
QName serviceName = new QName("http://org.jboss.ws/cxf/asyncclient",
"EndpointImplService");
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncEnabledInfoInterceptor.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncEnabledInfoInterceptor.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncEnabledInfoInterceptor.java 2014-09-22
09:03:32 UTC (rev 18938)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.asyncclient;
+
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.AbstractLoggingInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+
+public class AsyncEnabledInfoInterceptor extends AbstractLoggingInterceptor
+{
+ private static final Logger LOG =
LogUtils.getLogger(AsyncEnabledInfoInterceptor.class);
+ private static boolean asyncEnabled = false;
+
+ public AsyncEnabledInfoInterceptor () {
+ super(Phase.PREPARE_SEND_ENDING);
+ this.addAfter(MessageSenderInterceptor.class.getName());
+
this.addBefore(MessageSenderInterceptor.MessageSenderEndingInterceptor.class.getName());
+ }
+
+ public AsyncEnabledInfoInterceptor(String phase)
+ {
+ super(phase);
+ }
+ public void handleMessage(Message message) throws Fault
+ {
+ if (message.get("use.async.http.conduit") == null) {
+ asyncEnabled = false;
+ } else {
+ asyncEnabled = (Boolean)message.get("use.async.http.conduit");
+ }
+ }
+ protected Logger getLogger()
+ {
+ return LOG;
+ }
+
+ public boolean isAsyncEnabled() {
+ return asyncEnabled;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/asyncclient/AsyncEnabledInfoInterceptor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native