public class StubTest extends Test
Stub
.
These tests are best performed after SkeletonTest
.
The tests performed are:
null
arguments to
Stub.create
.equals
and
hashCode
.toString
method.Modifier and Type | Class and Description |
---|---|
private class |
StubTest.ConnectionCheckThread
Thread listening for a connection.
|
Modifier and Type | Field and Description |
---|---|
private java.net.InetSocketAddress |
address
Socket address used for the creation of stubs.
|
private boolean |
listening
When
false , the connection check test is complete. |
static java.lang.String |
notice
Test notice.
|
static java.lang.Class[] |
prerequisites
Prerequisites.
|
private Skeleton<TestInterface> |
skeleton
Dummy skeleton used during the construction of stubs.
|
private java.net.ServerSocket |
socket
Server socket used by the listening thread for the connection check.
|
Constructor and Description |
---|
StubTest() |
Modifier and Type | Method and Description |
---|---|
protected void |
clean()
Stops the dummy skeleton and testing server.
|
private void |
ensureClassRejected()
Ensures that a
Stub cannot be created from a class rather
than an interface. |
private void |
ensureLocalMethods()
Ensures that stubs for the same skeleton are equal and have the same
hash code, and stubs have a string representation.
|
private void |
ensureNonRemoteInterfaceRejected()
Ensures that a
Stub cannot be created from a non-remote
interface. |
private void |
ensureNullPointerExceptions()
Ensures that both
Stub.create methods throw
NullPointerException when given null for any
parameters. |
private void |
ensureStubConnects()
Checks that a stub connects to the server for which it was created.
|
private void |
ensureUnknownHostRejected()
Ensures that a stub cannot be created from a skeleton whose address has
not been determined.
|
protected void |
initialize()
Initializes the test.
|
protected void |
perform()
Performs the test.
|
cleanupFailure, cleanupSuccess, failure, success, task, task
public static final java.lang.String notice
public static final java.lang.Class[] prerequisites
private java.net.InetSocketAddress address
private Skeleton<TestInterface> skeleton
private java.net.ServerSocket socket
private boolean listening
false
, the connection check test is complete.protected void initialize() throws TestFailed
This method creates the listening socket and dummy skeleton used in the test.
initialize
in class Test
TestFailed
protected void perform() throws TestFailed
perform
in class Test
TestFailed
private void ensureStubConnects() throws TestFailed
TestFailed
- If the stub does not connect.protected void clean()
private void ensureUnknownHostRejected() throws TestFailed
This method should be used before the test skeleton is started.
TestFailed
- If IllegalStateException
is not thrown.private void ensureClassRejected() throws TestFailed
Stub
cannot be created from a class rather
than an interface.TestFailed
- If a Stub
is created from a class, or if
an unexpected exception occurs.private void ensureNonRemoteInterfaceRejected() throws TestFailed
Stub
cannot be created from a non-remote
interface.TestFailed
- If a Stub
is created from a non-remote
interface, or if an unexpected exception occurs.private void ensureNullPointerExceptions() throws TestFailed
Stub.create
methods throw
NullPointerException
when given null
for any
parameters.TestFailed
- If null
is given as a parameter but the
correct exception is not thrown.private void ensureLocalMethods() throws TestFailed
TestFailed
- If the test fails.