ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/websocket/TestWsSession.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/websocket/TestWsSession.java
Status
scanned
Type
file
Name
TestWsSession.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3250 (3.2 KB)
MD5
520130fe90a84a104c63abebcd2c68ac
SHA1
ef5dc2146eb3945fe0cbeeec317ce7d18f12bdc4
SHA256
fdfce806006c22a04f6fc77ced7375521a6aaa6a8d49e6919d45fc3684329382
SHA512

      
    
SHA1_git
80c5659a1702e09c09aa1e07f2ebac2ac9185a83
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestWsSession.java | 3.2 KB |

/* * 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.tomcat.websocket; import java.nio.ByteBuffer; import org.junit.Assert; import org.junit.Test; public class TestWsSession { @Test public void testAppendCloseReasonWithTruncation01() { doTestAppendCloseReasonWithTruncation(100); } @Test public void testAppendCloseReasonWithTruncation02() { doTestAppendCloseReasonWithTruncation(119); } @Test public void testAppendCloseReasonWithTruncation03() { doTestAppendCloseReasonWithTruncation(120); } @Test public void testAppendCloseReasonWithTruncation04() { doTestAppendCloseReasonWithTruncation(121); } @Test public void testAppendCloseReasonWithTruncation05() { doTestAppendCloseReasonWithTruncation(122); } @Test public void testAppendCloseReasonWithTruncation06() { doTestAppendCloseReasonWithTruncation(123); } @Test public void testAppendCloseReasonWithTruncation07() { doTestAppendCloseReasonWithTruncation(124); } @Test public void testAppendCloseReasonWithTruncation08() { doTestAppendCloseReasonWithTruncation(125); } @Test public void testAppendCloseReasonWithTruncation09() { doTestAppendCloseReasonWithTruncation(150); } private void doTestAppendCloseReasonWithTruncation(int reasonLength) { StringBuilder reason = new StringBuilder(reasonLength); for (int i = 0; i < reasonLength; i++) { reason.append('a'); } ByteBuffer buf = ByteBuffer.allocate(256); WsSession.appendCloseReasonWithTruncation(buf, reason.toString()); // Check the position and contents if (reasonLength <= 123) { Assert.assertEquals(reasonLength, buf.position()); for (int i = 0; i < reasonLength; i++) { Assert.assertEquals('a', buf.get(i)); } } else { // Must have been truncated Assert.assertEquals(123, buf.position()); for (int i = 0; i < 120; i++) { Assert.assertEquals('a', buf.get(i)); } Assert.assertEquals(0xE2, buf.get(120) & 0xFF); Assert.assertEquals(0x80, buf.get(121) & 0xFF); Assert.assertEquals(0xA6, buf.get(122) & 0xFF); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
41.18
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9