/** * Creates the file and set the block size in bytes. * <p> * @param file * @param blockSizeBytes * @throws IOException */ public BlockDisk( File file, int blockSizeBytes ) throws IOException { this( file, blockSizeBytes, new StandardSerializer() ); }
/** * @param obj * @return byte[] * @throws IOException * */ @Override public <T> byte[] serialize( T obj ) throws IOException { serializeCount++; return serializer.serialize( obj ); }
/** * Test serialization with a null object. Verify that we don't get an error. * <p> * @throws Exception on error */ public void testSerialize_NullInput() throws Exception { // SETUP CompressingSerializer serializer = new CompressingSerializer(); String before = null; // DO WORK byte[] serialized = serializer.serialize( before ); String after = (String) serializer.deSerialize( serialized, null ); // VERIFY assertNull( "Should have nothing. after =" + after, after ); }
/** * Test simple back and forth with a string. *<p> * @throws Exception */ public void testSimpleBackAndForth() throws Exception { // SETUP StandardSerializer serializer = new StandardSerializer(); String before = "adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdsfdsafdsafsa333 31231"; // DO WORK String after = (String) serializer.deSerialize( serializer.serialize( before ), null ); // VERIFY assertEquals( "Before and after should be the same.", before, after ); }
/** * Test serialization with a null object. Verify that we don't get an error. *<p> * @throws Exception */ public void testNullInput() throws Exception { // SETUP StandardSerializer serializer = new StandardSerializer(); String before = null; // DO WORK byte[] serialized = serializer.serialize( before ); //System.out.println( "testNullInput " + serialized ); String after = (String) serializer.deSerialize( serialized, null ); //System.out.println( "testNullInput " + after ); // VERIFY assertNull( "Should have nothing.", after ); }
/** * Verify null for null. * <p> * @throws Exception */ public void testgGetDeSerializedCacheElement_null() throws Exception { // SETUP IElementSerializer elementSerializer = new StandardSerializer(); ICacheElementSerialized<String, String> before = null; // DO WORK ICacheElement<String, String> result = SerializationConversionUtil.getDeSerializedCacheElement( before, elementSerializer ); // VERIFY assertNull( "Should get null for null", result ); }
/** * Verify null for null. * <p> * @throws IOException */ public void testgGetSerializedCacheElement_null() throws IOException { // SETUP IElementSerializer elementSerializer = new StandardSerializer(); ICacheElement<String, String> before = null; // DO WORK ICacheElementSerialized<String, String> result = SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer ); // VERIFY assertNull( "Should get null for null", result ); }
/** * Test simple back and forth with a string. * <p> * ))<=>(( * <p> * @throws Exception on error */ public void testSimpleBackAndForth() throws Exception { // SETUP CompressingSerializer serializer = new CompressingSerializer(); // DO WORK String before = "adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdsfdsafdsafsa333 31231"; String after = (String) serializer.deSerialize( serializer.serialize( before ), null ); // VERIFY assertEquals( "Before and after should be the same.", before, after ); }
/** * Verify that we don't get any erorrs for null input. * <p> * @throws ClassNotFoundException * @throws IOException */ public void testDeserialize_NullInput() throws IOException, ClassNotFoundException { // SETUP CompressingSerializer serializer = new CompressingSerializer(); // DO WORK Object result = serializer.deSerialize( null, null ); // VERIFY assertNull( "Should have nothing.", result ); }
/** * @param bytes * @return Object * @throws IOException * @throws ClassNotFoundException * */ @Override public <T> T deSerialize( byte[] bytes, ClassLoader loader ) throws IOException, ClassNotFoundException { deSerializeCount++; return serializer.deSerialize( bytes, loader ); }
/** * Test simple back and forth with a string. *<p> * @throws Exception */ public void testSimpleBackAndForth() throws Exception { // SETUP StandardSerializer serializer = new StandardSerializer(); String before = "adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdsfdsafdsafsa333 31231"; // DO WORK String after = (String) serializer.deSerialize( serializer.serialize( before ), null ); // VERIFY assertEquals( "Before and after should be the same.", before, after ); }
/** * Test serialization with a null object. Verify that we don't get an error. *<p> * @throws Exception */ public void testNullInput() throws Exception { // SETUP StandardSerializer serializer = new StandardSerializer(); String before = null; // DO WORK byte[] serialized = serializer.serialize( before ); //System.out.println( "testNullInput " + serialized ); String after = (String) serializer.deSerialize( serialized, null ); //System.out.println( "testNullInput " + after ); // VERIFY assertNull( "Should have nothing.", after ); }
/** * Verify null for null. * <p> * @throws Exception */ public void testgGetDeSerializedCacheElement_null() throws Exception { // SETUP IElementSerializer elementSerializer = new StandardSerializer(); ICacheElementSerialized<String, String> before = null; // DO WORK ICacheElement<String, String> result = SerializationConversionUtil.getDeSerializedCacheElement( before, elementSerializer ); // VERIFY assertNull( "Should get null for null", result ); }
/** * Verify null for null. * <p> * @throws IOException */ public void testgGetSerializedCacheElement_null() throws IOException { // SETUP IElementSerializer elementSerializer = new StandardSerializer(); ICacheElement<String, String> before = null; // DO WORK ICacheElementSerialized<String, String> result = SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer ); // VERIFY assertNull( "Should get null for null", result ); }
/** * Test serialization with a null object. Verify that we don't get an error. * <p> * @throws Exception on error */ public void testSerialize_NullInput() throws Exception { // SETUP CompressingSerializer serializer = new CompressingSerializer(); String before = null; // DO WORK byte[] serialized = serializer.serialize( before ); String after = (String) serializer.deSerialize( serialized, null ); // VERIFY assertNull( "Should have nothing. after =" + after, after ); }
/** * Test simple back and forth with a string. * <p> * ))<=>(( * <p> * @throws Exception on error */ public void testSimpleBackAndForth() throws Exception { // SETUP CompressingSerializer serializer = new CompressingSerializer(); // DO WORK String before = "adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdsfdsafdsafsa333 31231"; String after = (String) serializer.deSerialize( serializer.serialize( before ), null ); // VERIFY assertEquals( "Before and after should be the same.", before, after ); }
/** * Verify that we don't get any erorrs for null input. * <p> * @throws ClassNotFoundException * @throws IOException */ public void testDeserialize_NullInput() throws IOException, ClassNotFoundException { // SETUP CompressingSerializer serializer = new CompressingSerializer(); // DO WORK Object result = serializer.deSerialize( null, null ); // VERIFY assertNull( "Should have nothing.", result ); }
/** * Creates the file and set the block size in bytes. * <p> * @param file * @param blockSizeBytes * @throws FileNotFoundException */ public BlockDisk( File file, int blockSizeBytes ) throws FileNotFoundException { this( file, blockSizeBytes, new StandardSerializer() ); }
/** * @param obj * @return byte[] * @throws IOException * */ @Override public <T> byte[] serialize( T obj ) throws IOException { serializeCount++; return serializer.serialize( obj ); }
/** * @param bytes * @return Object * @throws IOException * @throws ClassNotFoundException * */ @Override public <T> T deSerialize( byte[] bytes, ClassLoader loader ) throws IOException, ClassNotFoundException { deSerializeCount++; return serializer.deSerialize( bytes, loader ); }