Also, if you check out Shiro's trunk and run 'mvn install', does it
pass for you?

If so, you could alter the SimpleSessionTest and see if your
alterations cause a failure - I can't seem to reproduce the issue,
even after cutting-and-pasting your toBytes/fromBytes implementations
:/

On Thu, Sep 16, 2010 at 12:50 AM, Les Hazlewood <[email protected]> wrote:
> Hi Mike,
>
> The full test is here:
>
> https://svn.apache.org/repos/asf/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/SimpleSessionTest.java
>
> If I change the serializeAndDeserialize helper method and use the code
> that you pasted instead of the code that is there, the test still
> passes for me.
>
> I'm on Windows 7 w/ 64-bit JDK 1.6
>
> Les
>
> On Thu, Sep 16, 2010 at 12:01 AM, Mike K <[email protected]> wrote:
>>
>> Les the following test is failing for me (java 1.6 on os x):
>>
>> package semantica.enterprise.service;
>>
>> import static org.junit.Assert.*;
>>
>> import java.io.ByteArrayInputStream;
>> import java.io.ByteArrayOutputStream;
>> import java.io.IOException;
>> import java.io.ObjectInputStream;
>> import java.io.ObjectOutputStream;
>> import java.util.Date;
>>
>> import org.apache.shiro.cache.CacheException;
>> import org.apache.shiro.session.mgt.SimpleSession;
>> import org.junit.Test;
>>
>>
>> public class SessionTest {
>>
>>        private byte[] toBytes(Object value) {
>>                try {
>>                        ByteArrayOutputStream baos = new 
>> ByteArrayOutputStream() ;
>>                        ObjectOutputStream oos = new ObjectOutputStream(baos);
>>                    oos.writeObject(value);
>>                   //
>> oos.writeObject("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbffffffffffffffffffffffffffffffffffffffffjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
>>                    oos.flush();
>>                    oos.close();
>>                    // Get the bytes of the serialized object
>>                    byte[] buf  = baos.toByteArray();
>>                    return buf;
>>                } catch (IOException io) {
>>                        throw new CacheException(io);
>>                }
>>        }
>>
>>        //@SuppressWarnings("unchecked")
>>        private Object fromBytes(byte[] bytes) {
>>                try {
>>                        ObjectInputStream ois = new ObjectInputStream(new
>> ByteArrayInputStream(bytes));
>>                        Object value =  ois.readObject();
>>                    ois.close();
>>                    return value;
>>                } catch (ClassNotFoundException e) {
>>                        throw new CacheException(e);
>>                } catch (IOException e) {
>>                        throw new CacheException(e);
>>                } catch (ClassCastException e) {
>>                        throw new CacheException(e);
>>                }
>>        }
>>
>>
>>       �...@test
>>    public void testDefaultSerialization() throws Exception {
>>        SimpleSession session = new SimpleSession();
>>        long timeout = session.getTimeout();
>>        Date start = session.getStartTimestamp();
>>        Date lastAccess = session.getLastAccessTime();
>>
>>        byte[] serialized = toBytes(session);
>>        SimpleSession deserialized = (SimpleSession)fromBytes(serialized);
>>
>>        assertEquals(timeout, deserialized.getTimeout());
>>        assertEquals(start, deserialized.getStartTimestamp());
>>        assertEquals(lastAccess, deserialized.getLastAccessTime());
>>    }
>>
>> }
>>
>>
>>
>>
>> --
>> View this message in context: 
>> http://shiro-user.582556.n2.nabble.com/serialization-problem-with-SimpleSession-tp5537015p5537266.html
>> Sent from the Shiro User mailing list archive at Nabble.com.
>>
>

Reply via email to