Small tweak on test: Using Parameterized instead of exension
This commit is contained in:
parent
f64c435727
commit
f0fd89f24f
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* 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")));
|
||||
}
|
||||
}
|
|
@ -18,8 +18,13 @@ package org.apache.activemq.artemis.tests.integration.stomp;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -31,16 +36,33 @@ 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;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
public abstract class AbstractStompOverWebsocketTest extends StompTest {
|
||||
@RunWith(Parameterized.class)
|
||||
public class StompOverWebsocketTest extends StompTest {
|
||||
|
||||
private ChannelPromise handshakeFuture;
|
||||
|
||||
private final boolean useBinaryFrames;
|
||||
|
||||
@Parameterized.Parameters(name = "useBinaryFrames={0}")
|
||||
public static Collection<Object[]> data() {
|
||||
List<Object[]> list = Arrays.asList(new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}});
|
||||
return list;
|
||||
}
|
||||
|
||||
public StompOverWebsocketTest(Boolean useBinaryFrames) {
|
||||
super();
|
||||
this.useBinaryFrames = useBinaryFrames;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChannelHandlers(SocketChannel ch) throws URISyntaxException {
|
||||
ch.pipeline().addLast("http-codec", new HttpClientCodec());
|
||||
|
@ -123,5 +145,14 @@ public abstract class AbstractStompOverWebsocketTest extends StompTest {
|
|||
}
|
||||
}
|
||||
|
||||
abstract WebSocketFrame createFrame(String msg);
|
||||
|
||||
protected WebSocketFrame createFrame(String msg) {
|
||||
if (useBinaryFrames) {
|
||||
return new BinaryWebSocketFrame(Unpooled.copiedBuffer(msg, Charset.forName("UTF-8")));
|
||||
}
|
||||
else {
|
||||
return new TextWebSocketFrame(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue