This is an automated email from the ASF dual-hosted git repository.
buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new 6164978 cxf-systests-ws-rm: tune
testOnewayAnonymousAcksSuppressedAsyncExecutor
6164978 is described below
commit 6164978911c5953c9bda3d3880bfa579c8721742
Author: amarkevich <[email protected]>
AuthorDate: Wed Apr 10 15:24:52 2019 +0300
cxf-systests-ws-rm: tune testOnewayAnonymousAcksSuppressedAsyncExecutor
---
.../org/apache/cxf/systest/ws/rm/SequenceTest.java | 2 +-
.../org/apache/cxf/systest/ws/rm/suppressed.xml | 2 +-
.../apache/cxf/systest/ws/util/MessageFlow.java | 45 +++++++---------------
.../cxf/testutil/recorders/InMessageRecorder.java | 35 ++++++-----------
.../cxf/testutil/recorders/MessageRecorder.java | 26 +++++--------
.../cxf/testutil/recorders/OutMessageRecorder.java | 11 +-----
6 files changed, 38 insertions(+), 83 deletions(-)
diff --git
a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
index 1234f52..01ae591 100644
---
a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
+++
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
@@ -426,7 +426,7 @@ public class SequenceTest extends
AbstractBusClientServerTestBase {
// three application messages plus createSequence
- awaitMessages(4, 1, 2000);
+ awaitMessages(4, 1, 1000);
MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(),
inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME,
RM10Constants.NAMESPACE_URI);
diff --git
a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/suppressed.xml
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/suppressed.xml
index 91ce92c..0f601e4 100644
--- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/suppressed.xml
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/suppressed.xml
@@ -25,7 +25,7 @@
<import resource="rminterceptors.xml"/>
<wsrm-mgr:rmManager id="org.apache.cxf.ws.rm.RMManager">
<wsrm-policy:RMAssertion>
- <wsrm-policy:BaseRetransmissionInterval Milliseconds="3000"/>
+ <wsrm-policy:BaseRetransmissionInterval Milliseconds="2000"/>
<wsrm-policy:AcknowledgementInterval Milliseconds="99999999"/>
</wsrm-policy:RMAssertion>
<wsrm-mgr:destinationPolicy>
diff --git
a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
index 90c3f52..93f8c0b 100644
---
a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
+++
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
@@ -47,14 +47,12 @@ public class MessageFlow {
private final String rmNamespace;
private List<byte[]> inStreams;
private List<byte[]> outStreams;
- private List<Document> outboundMessages;
- private List<Document> inboundMessages;
+ private final List<Document> outboundMessages = new ArrayList<>();
+ private final List<Document> inboundMessages = new ArrayList<>();
public MessageFlow(List<byte[]> out, List<byte[]> in, String addrns,
String rmns) throws Exception {
addressingNamespace = addrns;
rmNamespace = rmns;
- inboundMessages = new ArrayList<>();
- outboundMessages = new ArrayList<>();
reset(out, in);
}
@@ -77,18 +75,12 @@ public class MessageFlow {
}
outStreams = out;
inboundMessages.clear();
- for (int i = 0; i < inStreams.size(); i++) {
- byte[] bytes = inStreams.get(i);
- ByteArrayInputStream is = new ByteArrayInputStream(bytes);
- Document document = StaxUtils.read(is);
- inboundMessages.add(document);
+ for (byte[] bytes : inStreams) {
+ inboundMessages.add(StaxUtils.read(new
ByteArrayInputStream(bytes)));
}
outboundMessages.clear();
- for (int i = 0; i < outStreams.size(); i++) {
- byte[] bytes = outStreams.get(i);
- ByteArrayInputStream is = new ByteArrayInputStream(bytes);
- Document document = StaxUtils.read(is);
- outboundMessages.add(document);
+ for (byte[] bytes : outStreams) {
+ outboundMessages.add(StaxUtils.read(new
ByteArrayInputStream(bytes)));
}
}
@@ -104,12 +96,11 @@ public class MessageFlow {
Document doc = outbound ? outboundMessages.get(i) :
inboundMessages.get(i);
String action = getAction(doc);
if (null == expectedActions[i]) {
- assertNull((outbound ? "Outbound " : "Inbound") + " message "
+ i
- + " has unexpected action: " + action, action);
+ assertNull((outbound ? "Outbound " : "Inbound") + " message "
+ i + " has unexpected action: " + action,
+ action);
} else {
assertEquals((outbound ? "Outbound " : "Inbound") + " message
" + i
- + " does not contain expected action header"
- + System.getProperty("line.separator"),
expectedActions[i], action);
+ + " does not contain expected action header",
expectedActions[i], action);
}
}
}
@@ -344,7 +335,7 @@ public class MessageFlow {
getHeaderElement(d, name.getNamespaceURI(), name.getLocalPart()));
}
- protected String getAction(Document document) throws Exception {
+ private String getAction(Document document) throws Exception {
Element e = getHeaderElement(document, addressingNamespace, "Action");
if (null != e) {
return getText(e);
@@ -386,7 +377,7 @@ public class MessageFlow {
return getHeaderElement(document, rmNamespace, name);
}
- private Element getHeaderElement(Document document, String namespace,
String localName)
+ private static Element getHeaderElement(Document document, String
namespace, String localName)
throws Exception {
Element envelopeElement = document.getDocumentElement();
Element headerElement = null;
@@ -525,19 +516,15 @@ public class MessageFlow {
return !(null != bodyElement && bodyElement.hasChildNodes());
}
- String dump(List<byte[]> streams) {
+ static String dump(List<byte[]> streams) {
StringBuilder buf = new StringBuilder();
try {
- buf.append(System.getProperty("line.separator"));
for (int i = 0; i < streams.size(); i++) {
- buf.append('[');
- buf.append(i);
- buf.append("] : ");
- buf.append(new String(streams.get(i)));
buf.append(System.getProperty("line.separator"));
+ buf.append('[').append(i).append("] : ").append(new
String(streams.get(i)));
}
} catch (Exception ex) {
- return "";
+ return ex.getMessage();
}
return buf.toString();
@@ -552,8 +539,4 @@ public class MessageFlow {
return null;
}
- protected QName getNodeName(Node nd) {
- return new QName(nd.getNamespaceURI(), nd.getLocalName());
- }
-
}
diff --git
a/testutils/src/main/java/org/apache/cxf/testutil/recorders/InMessageRecorder.java
b/testutils/src/main/java/org/apache/cxf/testutil/recorders/InMessageRecorder.java
index 57ac0ec..68b0d3e 100644
---
a/testutils/src/main/java/org/apache/cxf/testutil/recorders/InMessageRecorder.java
+++
b/testutils/src/main/java/org/apache/cxf/testutil/recorders/InMessageRecorder.java
@@ -26,8 +26,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -36,36 +34,25 @@ import org.apache.cxf.phase.Phase;
public class InMessageRecorder extends AbstractPhaseInterceptor<Message> {
private static final Logger LOG =
LogUtils.getLogger(InMessageRecorder.class);
- private List<byte[]> inbound;
+ private final List<byte[]> inbound = new CopyOnWriteArrayList<>();
public InMessageRecorder() {
super(Phase.RECEIVE);
- inbound = new CopyOnWriteArrayList<>();
}
public void handleMessage(Message message) throws Fault {
- InputStream is = message.getContent(InputStream.class);
-
- if (is == null) {
- return;
- }
-
- LoadingByteArrayOutputStream bos = new LoadingByteArrayOutputStream();
- try {
- IOUtils.copy(is, bos);
- is.close();
- bos.close();
- byte[] bytes = bos.toByteArray();
- synchronized (this) {
- inbound.add(bytes);
- }
- if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("inbound: " + bos.toString());
+ try (InputStream is = message.getContent(InputStream.class)) {
+ if (is != null) {
+ byte[] b = new byte[is.available()];
+ is.read(b);
+ inbound.add(b);
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("inbound: " + new String(b));
+ }
+ message.setContent(InputStream.class, new
ByteArrayInputStream(b));
}
- ByteArrayInputStream bis = bos.createInputStream();
- message.setContent(InputStream.class, bis);
} catch (Exception ex) {
- ex.printStackTrace();
+ throw new Fault(ex);
}
}
diff --git
a/testutils/src/main/java/org/apache/cxf/testutil/recorders/MessageRecorder.java
b/testutils/src/main/java/org/apache/cxf/testutil/recorders/MessageRecorder.java
index a30e643..e7405a6 100644
---
a/testutils/src/main/java/org/apache/cxf/testutil/recorders/MessageRecorder.java
+++
b/testutils/src/main/java/org/apache/cxf/testutil/recorders/MessageRecorder.java
@@ -38,17 +38,13 @@ public class MessageRecorder {
int nOut = 0;
int nIn = 0;
while (waited <= timeout) {
- synchronized (outRecorder) {
- nOut = outRecorder.getOutboundMessages().size();
- }
- synchronized (inRecorder) {
- nIn = inRecorder.getInboundMessages().size();
- }
+ nOut = outRecorder.getOutboundMessages().size();
+ nIn = inRecorder.getInboundMessages().size();
if (nIn >= nExpectedIn && nOut >= nExpectedOut) {
return;
}
try {
- Thread.sleep(100);
+ Thread.sleep(100L);
} catch (InterruptedException ex) {
// ignore
}
@@ -61,8 +57,8 @@ public class MessageRecorder {
System.out.println("\nMessages actually received:\n");
List<byte[]> inbound = inRecorder.getInboundMessages();
for (byte[] b : inbound) {
- System.out.println(new String(b) + "\n");
- System.out.println("----------------\n");
+ System.out.println(new String(b));
+ System.out.println("----------------");
}
}
if (nExpectedOut != nOut) {
@@ -72,16 +68,12 @@ public class MessageRecorder {
System.out.println("\nMessages actually sent:\n");
List<byte[]> outbound = outRecorder.getOutboundMessages();
for (byte[] b : outbound) {
- System.out.println(new String(b) + "\n");
- System.out.println("----------------\n");
+ System.out.println(new String(b));
+ System.out.println("----------------");
}
}
- if (nExpectedIn > nIn) {
- assertEquals("Did not receive expected number of inbound
messages", nExpectedIn, nIn);
- }
- if (nExpectedOut > nOut) {
- assertEquals("Did not send expected number of outbound messages",
nExpectedOut, nOut);
- }
+ assertEquals("Did not receive expected number of inbound messages",
nExpectedIn, nIn);
+ assertEquals("Did not send expected number of outbound messages",
nExpectedOut, nOut);
}
}
diff --git
a/testutils/src/main/java/org/apache/cxf/testutil/recorders/OutMessageRecorder.java
b/testutils/src/main/java/org/apache/cxf/testutil/recorders/OutMessageRecorder.java
index 4ed0b87..025d27d 100644
---
a/testutils/src/main/java/org/apache/cxf/testutil/recorders/OutMessageRecorder.java
+++
b/testutils/src/main/java/org/apache/cxf/testutil/recorders/OutMessageRecorder.java
@@ -35,17 +35,13 @@ import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-/**
- *
- */
public class OutMessageRecorder extends AbstractPhaseInterceptor<Message> {
private static final Logger LOG =
LogUtils.getLogger(OutMessageRecorder.class);
- private List<byte[]> outbound;
+ private final List<byte[]> outbound = new CopyOnWriteArrayList<>();
public OutMessageRecorder() {
super(Phase.PREPARE_SEND);
- outbound = new CopyOnWriteArrayList<>();
addAfter(MessageSenderInterceptor.class.getName());
}
@@ -84,10 +80,7 @@ public class OutMessageRecorder extends
AbstractPhaseInterceptor<Message> {
public void onClose(CachedOutputStream cos) {
// bytes were already copied after flush
try {
- byte[] bytes = cos.getBytes();
- synchronized (this) {
- outbound.add(bytes);
- }
+ outbound.add(cos.getBytes());
} catch (Exception e) {
LOG.fine("Can't record message from output stream class: "
+ cos.getOut().getClass().getName());