moresandeep commented on code in PR #639:
URL: https://github.com/apache/knox/pull/639#discussion_r985869754
##########
pom.xml:
##########
@@ -280,7 +284,13 @@
<xml-matchers.version>0.10</xml-matchers.version>
<zookeeper.version>3.5.7</zookeeper.version>
</properties>
-
+ <repositories>
+ <repository>
+ <id>jcenter</id>
Review Comment:
This is for pty4j. Interestingly, [Pty4j was not part of maven central until
Nov 2021 ](https://mvnrepository.com/artifact/org.jetbrains.pty4j/pty4j)(when
this was introduced). I can now see [Pty4j in maven central
](https://mvnrepository.com/artifact/org.jetbrains.pty4j/pty4j)
I'll use the new version of Pty4j from maven central and see if it works.
Thank you soo much for catching this!
##########
pom.xml:
##########
@@ -248,13 +249,16 @@
<mina.version>2.0.22</mina.version>
<netty.version>4.1.77.Final</netty.version>
<nimbus-jose-jwt.version>8.14.1</nimbus-jose-jwt.version>
- <nodejs.version>v12.18.2</nodejs.version>
+ <nodejs.version>v12.20.2</nodejs.version>
<okhttp.version>2.7.5</okhttp.version>
<opensaml.version>3.4.5</opensaml.version>
<pac4j.version>4.5.6</pac4j.version>
<postgresql.version>42.3.3</postgresql.version>
<mysql.version>8.0.28</mysql.version>
<protobuf.version>3.16.1</protobuf.version>
+ <powermock.version>2.0.9</powermock.version>
+ <purejavacomm.version>0.0.11.1</purejavacomm.version>
+ <pty4j.version>0.11.4</pty4j.version>
Review Comment:
Thanks, I thought I had checked the license. Let me add those entries.
##########
pom.xml:
##########
@@ -248,13 +249,16 @@
<mina.version>2.0.22</mina.version>
<netty.version>4.1.77.Final</netty.version>
<nimbus-jose-jwt.version>8.14.1</nimbus-jose-jwt.version>
- <nodejs.version>v12.18.2</nodejs.version>
+ <nodejs.version>v12.20.2</nodejs.version>
<okhttp.version>2.7.5</okhttp.version>
<opensaml.version>3.4.5</opensaml.version>
<pac4j.version>4.5.6</pac4j.version>
<postgresql.version>42.3.3</postgresql.version>
<mysql.version>8.0.28</mysql.version>
<protobuf.version>3.16.1</protobuf.version>
+ <powermock.version>2.0.9</powermock.version>
+ <purejavacomm.version>0.0.11.1</purejavacomm.version>
+ <pty4j.version>0.11.4</pty4j.version>
Review Comment:
So, we already have Eclipse license for Jetty, I just added Pty4j to the
list using that license (without duplicating the entire license text)
##########
gateway-server/src/test/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandlerTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.knox.gateway.websockets;
+
+import org.apache.knox.gateway.audit.api.AuditService;
+import org.apache.knox.gateway.audit.api.AuditServiceFactory;
+import org.apache.knox.gateway.audit.api.Auditor;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.GatewaySpiMessages;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.provider.federation.jwt.JWTMessages;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.webshell.WebshellWebSocketAdapter;
+import org.easymock.EasyMock;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.net.URI;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.easymock.EasyMock.isA;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({JWTValidatorFactory.class, MessagesFactory.class,
GatewayWebsocketHandler.class, AuditServiceFactory.class})
+public class GatewayWebsocketHandlerTest {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // setup MessageFactory for static variable
+ PowerMock.mockStatic(MessagesFactory.class);
Review Comment:
This was a frustrating exercise :( we have MessagesFactory referenced in
statically which was causing tests to blow up (NPEs)
##########
gateway-server/src/test/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandlerTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.knox.gateway.websockets;
+
+import org.apache.knox.gateway.audit.api.AuditService;
+import org.apache.knox.gateway.audit.api.AuditServiceFactory;
+import org.apache.knox.gateway.audit.api.Auditor;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.GatewaySpiMessages;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.provider.federation.jwt.JWTMessages;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.webshell.WebshellWebSocketAdapter;
+import org.easymock.EasyMock;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
+import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.net.URI;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.easymock.EasyMock.isA;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({JWTValidatorFactory.class, MessagesFactory.class,
GatewayWebsocketHandler.class, AuditServiceFactory.class})
+public class GatewayWebsocketHandlerTest {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // setup MessageFactory for static variable
+ PowerMock.mockStatic(MessagesFactory.class);
+
EasyMock.expect(MessagesFactory.get(GatewaySpiMessages.class)).andReturn(EasyMock.createNiceMock(GatewaySpiMessages.class)).anyTimes();
+
EasyMock.expect(MessagesFactory.get(JWTMessages.class)).andReturn(EasyMock.createNiceMock(JWTMessages.class)).anyTimes();
+
EasyMock.expect(MessagesFactory.get(WebsocketLogMessages.class)).andReturn(EasyMock.createNiceMock(WebsocketLogMessages.class)).anyTimes();
+ PowerMock.replay(MessagesFactory.class);
+ // setup Auditor for static variable
+ PowerMock.mockStatic(AuditServiceFactory.class);
Review Comment:
Same as above.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]