Copilot commented on code in PR #7220: URL: https://github.com/apache/texera/pull/7220#discussion_r3694801325
########## amber/src/test/scala/org/apache/texera/web/resource/WebsocketPayloadSizeTunerSpec.scala: ########## @@ -0,0 +1,57 @@ +/* + * 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.texera.web.resource + +import org.scalamock.scalatest.MockFactory +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +import javax.servlet.{ServletContext, ServletContextEvent} +import javax.websocket.server.ServerContainer + +class WebsocketPayloadSizeTunerSpec extends AnyFlatSpec with Matchers with MockFactory { + + private def eventWith(container: ServerContainer): ServletContextEvent = { + val servletContext = mock[ServletContext] + (servletContext + .getAttribute(_: String)) + .expects(classOf[ServerContainer].getName) + .returning(container) + .once() + new ServletContextEvent(servletContext) + } + + "contextInitialized" should "look up the server container by its class name and tune both limits" in { + val maxKB = 64 + val container = mock[ServerContainer] + (container.setDefaultMaxTextMessageBufferSize(_: Int)).expects(maxKB * 1024).once() + (container.setDefaultMaxBinaryMessageBufferSize(_: Int)).expects(maxKB * 1024).once() Review Comment: `maxKB` is used with a `* 1024` conversion and the test description refers to KiB; using “KB” here is ambiguous (1000 vs 1024). Rename the local variable to `maxKiB` (or similar) to make the unit explicit and match the test intent. -- 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]
