1 7 package org.jboss.cache.marshall; 8 9 import junit.framework.TestCase; 10 import org.jboss.cache.RegionManager; 11 import org.jboss.cache.Version; 12 13 import java.io.ObjectInputStream ; 14 15 20 public class VersionAwareMarshallerTest extends TestCase 21 { 22 public void testMarshallerSelection() 23 { 24 VersionAwareMarshaller marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "2.0.0.GA"); 25 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 26 27 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.4.0.GA"); 28 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 29 30 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.5.0.GA"); 31 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 32 33 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.3.0.GA"); 34 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 35 36 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.3.0.SP2"); 37 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 38 39 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.3.1.GA"); 40 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 41 42 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.2.4.SP2"); 43 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 44 45 marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "1.2.3"); 46 assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass()); 47 } 48 49 public void testVersionHeaderDefaultCurrent() throws Exception 50 { 51 VersionAwareMarshaller marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, Version.getVersionString(Version.getVersionShort())); 52 byte[] bytes = marshaller.objectToByteBuffer("Hello"); 53 54 ObjectInputStream in = ObjectSerializationFactory.createObjectInputStream(bytes); 56 assertEquals("Version header short should be '20'", 20, in.readShort()); 57 } 58 59 public void testVersionHeader200() throws Exception 60 { 61 VersionAwareMarshaller marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, "2.0.0.GA"); 62 byte[] bytes = marshaller.objectToByteBuffer("Hello"); 63 64 ObjectInputStream in = ObjectSerializationFactory.createObjectInputStream(bytes); 66 assertEquals("Version header short should be '20'", 20, in.readShort()); 67 } 68 69 } 70 | Popular Tags |