ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/ha/session/TestDeltaRequest.java

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

      
    
Rootfs path

      
    
Size
3121 (3.0 KB)
MD5
94bf30a88551f1b1e667efe903874ece
SHA1
90ff1b317951b7941351a3e426d6bc91db79a0c5
SHA256
5877be75509c2f0e4d125bc1dceaca191b67d12f9a11394f95b607017599147c
SHA512

      
    
SHA1_git
2fefb231183897f5fd74ebc108bdc5fc6ab8aa3a
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestDeltaRequest.java | 3.0 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.catalina.ha.session; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.Manager; import org.apache.catalina.session.StandardManager; import org.apache.tomcat.unittest.TesterContext; public class TestDeltaRequest { /* * Mostly interested in whether the attributes transfer correctly as the AttributeInfo class does not have a public * no-arg constructor. This shouldn't be necessary for a package private class (CheckStyle flags the use of a public * modifier as redundant) but SpotBugs complains as the class implements Externalizable. The purpose of this test is * to confirm that the SpotBugs warning is a false positive. */ @Test public void testSerialization() throws Exception { // Create original request DeltaRequest original = new DeltaRequest(); original.setSessionId("1234"); original.setAttribute("A", "One"); original.setAttribute("B", "Two"); // Serialize original request byte[] bytes; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { oos.writeObject(original); bytes = baos.toByteArray(); } // Deserialize original request ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DeltaRequest copyRequest = (DeltaRequest) ois.readObject(); // Apply DeltaRequest so we can test that the attributes transferred correctly DeltaSession copySession = new DeltaSession(); Manager manager = new StandardManager(); manager.setContext(new TesterContext()); copySession.setManager(manager); copySession.setId("1234", false); copySession.setValid(true); copyRequest.execute(copySession, false); // Test for the attributes Assert.assertEquals("One", copySession.getAttribute("A")); Assert.assertEquals("Two", copySession.getAttribute("B")); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
35.1
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