TestByteArrayCacheEntrySerializer.java (httpcomponents-client-5.0.2-src) | : | TestByteArrayCacheEntrySerializer.java (httpcomponents-client-5.0.3-src) | ||
---|---|---|---|---|
skipping to change at line 37 | skipping to change at line 37 | |||
package org.apache.hc.client5.http.impl.cache; | package org.apache.hc.client5.http.impl.cache; | |||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertThat; | import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | |||
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | import java.io.IOException; | |||
import java.io.ObjectOutputStream; | import java.io.ObjectOutputStream; | |||
import java.math.BigDecimal; | ||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | |||
import java.util.Date; | import java.util.Date; | |||
import java.util.HashMap; | import java.util.HashMap; | |||
import java.util.Map; | import java.util.Map; | |||
import org.apache.hc.client5.http.cache.HttpCacheEntry; | import org.apache.hc.client5.http.cache.HttpCacheEntry; | |||
import org.apache.hc.client5.http.cache.HttpCacheStorageEntry; | import org.apache.hc.client5.http.cache.HttpCacheStorageEntry; | |||
import org.apache.hc.client5.http.cache.Resource; | import org.apache.hc.client5.http.cache.Resource; | |||
import org.apache.hc.core5.http.Header; | import org.apache.hc.core5.http.Header; | |||
import org.apache.hc.core5.http.HttpStatus; | import org.apache.hc.core5.http.HttpStatus; | |||
import org.apache.hc.core5.http.message.BasicHeader; | import org.apache.hc.core5.http.message.BasicHeader; | |||
import org.apache.hc.core5.http.message.StatusLine; | import org.apache.hc.core5.http.message.StatusLine; | |||
import org.junit.Before; | import org.junit.Before; | |||
import org.junit.Test; | import org.junit.Test; | |||
import com.sun.rowset.JdbcRowSetImpl; | ||||
public class TestByteArrayCacheEntrySerializer { | public class TestByteArrayCacheEntrySerializer { | |||
private ByteArrayCacheEntrySerializer impl; | private ByteArrayCacheEntrySerializer impl; | |||
@Before | @Before | |||
public void setUp() { | public void setUp() { | |||
impl = new ByteArrayCacheEntrySerializer(); | impl = new ByteArrayCacheEntrySerializer(); | |||
} | } | |||
@Test | @Test | |||
skipping to change at line 242 | skipping to change at line 241 | |||
private static void assertIsAllowedClassNameTrue(final String className) { | private static void assertIsAllowedClassNameTrue(final String className) { | |||
assertTrue(ByteArrayCacheEntrySerializer.RestrictedObjectInputStream.isA llowedClassName(className)); | assertTrue(ByteArrayCacheEntrySerializer.RestrictedObjectInputStream.isA llowedClassName(className)); | |||
} | } | |||
private static void assertIsAllowedClassNameFalse(final String className) { | private static void assertIsAllowedClassNameFalse(final String className) { | |||
assertFalse(ByteArrayCacheEntrySerializer.RestrictedObjectInputStream.is AllowedClassName(className)); | assertFalse(ByteArrayCacheEntrySerializer.RestrictedObjectInputStream.is AllowedClassName(className)); | |||
} | } | |||
private byte[] serializeProhibitedObject() throws IOException { | private byte[] serializeProhibitedObject() throws IOException { | |||
final JdbcRowSetImpl jdbcRowSet = new JdbcRowSetImpl(); | final BigDecimal bigDecimal = new BigDecimal("1000.00"); | |||
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
final ObjectOutputStream oos = new ObjectOutputStream(baos); | final ObjectOutputStream oos = new ObjectOutputStream(baos); | |||
try { | try { | |||
oos.writeObject(jdbcRowSet); | oos.writeObject(bigDecimal); | |||
} finally { | } finally { | |||
oos.close(); | oos.close(); | |||
} | } | |||
return baos.toByteArray(); | return baos.toByteArray(); | |||
} | } | |||
public void readWriteVerify(final HttpCacheStorageEntry writeEntry) throws E xception { | public void readWriteVerify(final HttpCacheStorageEntry writeEntry) throws E xception { | |||
// write the entry | // write the entry | |||
final byte[] bytes = impl.serialize(writeEntry); | final byte[] bytes = impl.serialize(writeEntry); | |||
// read the entry | // read the entry | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 3 lines changed or added |