Skip to content

Commit

Permalink
o Added the Mockito dependency
Browse files Browse the repository at this point in the history
o Switched the IoServiceListenerSupport to Mockito
o Modified the ByteArray interfaces to simplify it
o Started using Mockito for ByteAccess tests
  • Loading branch information
elecharny committed Sep 14, 2024
1 parent 6731bad commit dd4cf26
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 182 deletions.
6 changes: 6 additions & 0 deletions mina-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ public void fireSessionCreated(IoSession session) {

// Fire session events.
IoFilterChain filterChain = session.getFilterChain();

// Should call handler.sessionCreated()
filterChain.fireSessionCreated();

// Should call handler.sessionOpened()
filterChain.fireSessionOpened();

int managedSessionCount = managedSessions.size();
Expand All @@ -227,9 +231,9 @@ public void fireSessionCreated(IoSession session) {
cumulativeManagedSessionCount.incrementAndGet();

// Fire listener events.
for (IoServiceListener l : listeners) {
for (IoServiceListener listener : listeners) {
try {
l.sessionCreated(session);
listener.sessionCreated(session);
} catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,19 @@
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public interface ByteArray extends IoAbsoluteReader, IoAbsoluteWriter {

/**
* {@inheritDoc}
* @return the index of the first byte that can be accessed.
*/
@Override
int first();

/**
* {@inheritDoc}
* @return the index after the last byte that can be accessed.
*/
@Override
int last();

/**
* {@inheritDoc}
* @return the order of the bytes.
*/
@Override
ByteOrder order();

/**
Expand Down Expand Up @@ -88,24 +84,6 @@ public interface ByteArray extends IoAbsoluteReader, IoAbsoluteWriter {
@Override
boolean equals(Object other);

/**
* {@inheritDoc}
*/
@Override
byte get(int index);

/**
* {@inheritDoc}
*/
@Override
void get(int index, IoBuffer bb);

/**
* {@inheritDoc}
*/
@Override
int getInt(int index);

/**
* @return a cursor starting at index 0 (which may not be the start of the array).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.apache.mina.util.byteaccess;

import java.nio.ByteOrder;

import org.apache.mina.core.buffer.IoBuffer;

/**
Expand All @@ -29,17 +27,6 @@
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public interface IoAbsoluteReader {

/**
* @return the index of the first byte that can be accessed.
*/
int first();

/**
* @return the index after the last byte that can be accessed.
*/
int last();

/**
* @return the total number of bytes that can be accessed.
*/
Expand All @@ -54,11 +41,6 @@ public interface IoAbsoluteReader {
*/
ByteArray slice(int index, int length);

/**
* @return the order of the bytes.
*/
ByteOrder order();

/**
* @param index The starting position
* @return a <code>byte</code> from the given index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.apache.mina.util.byteaccess;

import java.nio.ByteOrder;

import org.apache.mina.core.buffer.IoBuffer;

/**
Expand All @@ -29,22 +27,6 @@
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public interface IoAbsoluteWriter {

/**
* @return the index of the first byte that can be accessed.
*/
int first();

/**
* @return the index after the last byte that can be accessed.
*/
int last();

/**
* @return the order of the bytes.
*/
ByteOrder order();

/**
* Puts a <code>byte</code> at the given index.
*
Expand Down
Loading

0 comments on commit dd4cf26

Please sign in to comment.