[
https://issues.apache.org/jira/browse/TOMEE-2976?focusedWorklogId=562887&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-562887
]
ASF GitHub Bot logged work on TOMEE-2976:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Mar/21 08:18
Start Date: 09/Mar/21 08:18
Worklog Time Spent: 10m
Work Description: rzo1 commented on a change in pull request #765:
URL: https://github.com/apache/tomee/pull/765#discussion_r590059284
##########
File path:
examples/junit5-arquillian-simple-websockets/src/test/java/resources/arquillian.xml
##########
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+-->
+<arquillian xmlns="http://jboss.org/schema/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://jboss.org/schema/arquillian
+ http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="serverXml">src/main/conf/server.xml</property>
+ <property name="httpPort">8081</property>
Review comment:
You are right. If CI executes multiple jobs in parallel, it might clash
with ports. We normally work with Gitlab CI and isolated containers. Nice
catch! I fixed this.
##########
File path:
examples/junit5-arquillian-simple-websockets/src/test/java/org/superbiz/websockets/WebSocketResourceTest.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.superbiz.websockets;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit5.ArquillianExtension;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import javax.websocket.*;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+@RunAsClient
+@ExtendWith(ArquillianExtension.class)
+public class WebSocketResourceTest {
+
+ private static final int PORT = 8081;
+
+ @ArquillianResource()
+ private URL base;
+
+ @Deployment(testable = false)
+ public static final WebArchive app() {
+ return ShrinkWrap.create(WebArchive.class, "demo.war")
+ .addClasses(WebSocketResource.class)
+ .addAsWebInfResource(new
File("src/main/webapp/WEB-INF/web.xml"), "web.xml")
+ .addAsWebInfResource(new
File("src/main/resources/META-INF/beans.xml"), "beans.xml");
+ }
+
+ @Test
+ public void testConnectAndReceiveMessage() throws Exception {
+ Session session = connectToServer(MyWebSocketClientObject.class);
+ assertNotNull(session);
+
+ assertTrue(MyWebSocketClientObject.latch.await(2, TimeUnit.SECONDS));
+ assertEquals("Successfully opened session",
MyWebSocketClientObject.response);
+
+ session.close();
+ }
+
+ @Test
+ public void testConnectAndSendPayload() throws Exception {
+
+ String payload = "I am the payload sent to this resource.";
+ Session session = connectToServer(MyWebSocketClientObject.class);
+ assertNotNull(session);
+
+ assertTrue(MyWebSocketClientObject.latch.await(2, TimeUnit.SECONDS));
+ assertEquals("Successfully opened session",
MyWebSocketClientObject.response);
+
+ session.getBasicRemote().sendText(payload);
+
+ assertTrue(MyWebSocketClientObject.payloadLatch.await(2,
TimeUnit.SECONDS));
+ assertEquals("Received: " + payload, MyWebSocketClientObject.response);
+
+ session.close();
+ }
+
+ /**
+ * Method used to supply connection to the server by passing the naming of
+ * the websocket endpoint
+ */
+ public Session connectToServer(Class<?> endpoint) throws
DeploymentException, IOException, URISyntaxException {
+ WebSocketContainer container =
ContainerProvider.getWebSocketContainer();
+ assertNotNull(container);
+ return container.connectToServer(endpoint, new URI("ws",
base.getUserInfo(), "localhost", PORT,"/api/socket",null, null));
Review comment:
Fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 562887)
Time Spent: 0.5h (was: 20m)
> Provide Examples for TomEE Arquillian with JUnit 5
> --------------------------------------------------
>
> Key: TOMEE-2976
> URL: https://issues.apache.org/jira/browse/TOMEE-2976
> Project: TomEE
> Issue Type: Improvement
> Components: Examples and Documentation
> Reporter: Richard Zowalla
> Assignee: Richard Zowalla
> Priority: Minor
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> We had a question related to Arquillian and JUnit 5 on the mailing list.
>
> http://mail-archives.apache.org/mod_mbox/tomee-dev/202103.mbox/%3C1615057870806-0.post%40n4.nabble.com%3E
--
This message was sent by Atlassian Jira
(v8.3.4#803005)