diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/WebSocketServerHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/WebSocketServerHandler.java index 92493feabe..62c41d3d51 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/WebSocketServerHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/WebSocketServerHandler.java @@ -110,7 +110,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler ctx.writeAndFlush(new PongWebSocketFrame(frame.content().retain())); return false; } - else if (!(frame instanceof TextWebSocketFrame)) { + else if (!(frame instanceof TextWebSocketFrame) && !(frame instanceof BinaryWebSocketFrame)) { throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass().getName())); } return true; @@ -153,4 +153,4 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler } } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/AbstractStompOverWebsocketTest.java similarity index 95% rename from tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java rename to tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/AbstractStompOverWebsocketTest.java index 38e9e69ba8..ba760fb9c8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/AbstractStompOverWebsocketTest.java @@ -31,14 +31,13 @@ import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; -import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; import io.netty.handler.codec.http.websocketx.WebSocketFrame; import io.netty.handler.codec.http.websocketx.WebSocketVersion; import io.netty.handler.codec.string.StringDecoder; -public class StompOverWebsocketTest extends StompTest { +public abstract class AbstractStompOverWebsocketTest extends StompTest { private ChannelPromise handshakeFuture; @@ -112,8 +111,7 @@ public class StompOverWebsocketTest extends StompTest { public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { try { if (msg instanceof String) { - TextWebSocketFrame frame = new TextWebSocketFrame((String) msg); - ctx.write(frame, promise); + ctx.write(createFrame((String) msg), promise); } else { super.write(ctx, msg, promise); @@ -124,4 +122,6 @@ public class StompOverWebsocketTest extends StompTest { } } } + + abstract WebSocketFrame createFrame(String msg); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketBinaryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketBinaryTest.java new file mode 100644 index 0000000000..f0d37825a3 --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketBinaryTest.java @@ -0,0 +1,30 @@ +/* + * 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.activemq.artemis.tests.integration.stomp; + +import java.nio.charset.Charset; + +import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketFrame; +import io.netty.buffer.Unpooled; + +public class StompOverWebsocketBinaryTest extends AbstractStompOverWebsocketTest { + + protected WebSocketFrame createFrame(String msg) { + return new BinaryWebSocketFrame(Unpooled.copiedBuffer(msg, Charset.forName("UTF-8"))); + } +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTextTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTextTest.java new file mode 100644 index 0000000000..ac11d71542 --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTextTest.java @@ -0,0 +1,27 @@ +/* + * 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.activemq.artemis.tests.integration.stomp; + +import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketFrame; + +public class StompOverWebsocketTextTest extends AbstractStompOverWebsocketTest { + + protected WebSocketFrame createFrame(String msg) { + return new TextWebSocketFrame(msg); + } +}