/**
 * 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.mina.session;

import static org.mockito.Mockito.mock;

import java.net.SocketAddress;

import junit.framework.Assert;

import org.apache.mina.api.IoFuture;
import org.apache.mina.api.IoService;
import org.apache.mina.api.IoSessionConfig;
import org.junit.Test;

public class AbstractIoSessionTest {

    private static final class DummySession extends AbstractIoSession {
        private DummySession(IoService service) {
            super(service, null);
        }

        @Override
        public IoFuture<Void> close(boolean immediately) {
            return null;
        }

        @Override
        public IoSessionConfig getConfig() {
            return null;
        }

        @Override
        public SocketAddress getLocalAddress() {
            return null;
        }

        @Override
        public SocketAddress getRemoteAddress() {
            return null;
        }

        @Override
        public boolean isClosing() {
            return false;
        }

        @Override
        public boolean isConnected() {
            return false;
        }

        @Override
        public boolean isReadSuspended() {
            return false;
        }

        @Override
        public boolean isWriteSuspended() {
            return false;
        }

        @Override
        public void resumeRead() {
        }

        @Override
        public void resumeWrite() {
        }

        @Override
        public void suspendRead() {
        }

        @Override
        public void suspendWrite() {
        }
    }

    @Test
    public void testGetId() {
        Assert.assertNotSame((new DummySession(mock(IoService.class))).getId(),
                (new DummySession(mock(IoService.class))).getId());

    }

    @Test
    public void testCreationTime() {
        long before = System.currentTimeMillis();
        long creation = (new DummySession(mock(IoService.class))).getCreationTime();
        long after = System.currentTimeMillis();
        Assert.assertTrue(creation <= after);
        Assert.assertTrue(creation >= before);
    }

    @Test
    public void testAttachment() {
        AbstractIoSession aio = new DummySession(mock(IoService.class));
        String value = "value";
        Assert.assertNull(aio.getAttribute("test"));
        Assert.assertEquals(null, aio.setAttribute("test", value));
        Assert.assertTrue(aio.containsAttribute("test"));
        Assert.assertEquals(aio.getAttributeNames().size(), 1);
        Assert.assertEquals(value, aio.setAttribute("test", value));
        Assert.assertEquals(aio.getAttributeNames().size(), 1);
        Assert.assertTrue(aio.containsAttribute("test"));
        Assert.assertEquals(value, aio.getAttribute("test"));
        Assert.assertEquals(value, aio.removeAttribute("test"));
        Assert.assertEquals(aio.getAttributeNames().size(), 0);
        Assert.assertFalse(aio.containsAttribute("test"));

        Assert.assertEquals(null, aio.getAttribute("test"));
        Assert.assertNotNull(aio.getService());
    }

}

@@ -870,20 +870,17 @@
 Mockito.
-mock
+*
 ;%0A%0Aimpor
@@ -938,16 +938,53 @@
 ssert;%0A%0A
+import org.apache.mina.api.IoFilter;%0A
 import o
@@ -1050,16 +1050,16 @@
 ervice;%0A
-
 import o
@@ -1094,16 +1094,41 @@
 Config;%0A
+import org.junit.Before;%0A
 import o
@@ -2408,32 +2408,223 @@
        %7D%0A    %7D%0A%0A
+    private IoService service = null;%0A%0A    @Before%0A    public void setup() %7B%0A        service = mock(IoService.class);%0A        when(service.getFilters()).thenReturn(new IoFilter%5B%5D %7B%7D);%0A    %7D%0A%0A
     @Test%0A    pu
@@ -2643,24 +2643,25 @@
 stGetId() %7B%0A
+%0A
         Asse
@@ -2699,96 +2699,52 @@
 ion(
-mock(IoService.class))).getId(),%0A                (new DummySession(mock(IoService.class)
+service)).getId(), (new DummySession(service
 )).g
@@ -2899,37 +2899,23 @@
 Session(
-mock(IoService.class)
+service
 )).getCr
@@ -3171,37 +3171,23 @@
 Session(
-mock(IoService.class)
+service
 );%0A     

fix test fix..