public class HubTester extends Tester
Modifier and Type | Class and Description |
---|---|
private static class |
HubTester.ClientWatcher
CallableClient implementation which watches hub.event messages
concerning the registration and attributes of other clients.
|
private static class |
HubTester.TestCallableClient
CallableClient implementation for testing.
|
private static class |
HubTester.WatchedClient
Struct-type utility class which aggregates mutable information about
a client, to be updated in response to hub event messages.
|
Modifier and Type | Field and Description |
---|---|
private static char[] |
ALPHA_CHARS |
private HubTester.ClientWatcher |
clientWatcher_ |
private static java.lang.String |
ECHO_MTYPE |
private static java.lang.String |
ERROR_KEY |
private static java.lang.String |
FAIL_MTYPE |
private static char[] |
GENERAL_CHARS |
private java.lang.String |
hubId_ |
private Client[] |
ignoreClients_ |
private static java.util.logging.Logger |
logger_ |
private static java.lang.String |
METADATA_MTYPE |
private static java.lang.String |
MSGIDQUERY_KEY |
private static java.lang.String |
PING_MTYPE |
private java.util.Set |
privateKeys_ |
private ClientProfile |
profile_ |
private java.util.Random |
random_ |
private static java.lang.String |
REGISTER_MTYPE |
private java.util.Set |
selfIds_ |
private static java.lang.String |
SUBSCRIPTIONS_MTYPE |
private static java.lang.String |
UNREGISTER_MTYPE |
private static java.lang.String |
WAITMILLIS_KEY |
Constructor and Description |
---|
HubTester(ClientProfile profile)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertTestClients(HubConnection conn,
java.lang.String[] otherIds)
Assert that the given list of registered clients has a certain content.
|
private static char[] |
createAlphaCharacters()
Returns a character array containing each distinct alphanumeric
character.
|
private static char[] |
createGeneralCharacters()
Returns a character array containing every character which is legal
for inclusion in a SAMP
string . |
java.lang.Object |
createRandomObject(int level,
boolean ugly)
Generates an object with random content for transmission using SAMP.
|
java.lang.String |
createRandomString(boolean ugly)
Creates a new random string for transmission using SAMP.
|
private static void |
delay(int millis)
Waits for a given number of milliseconds.
|
static void |
main(java.lang.String[] args)
Main method.
|
private HubConnection |
register()
Registers with the hub, performing various checks.
|
void |
run()
Perform a wide variety of tests on a running hub.
|
static int |
runMain(java.lang.String[] args)
Does the work for the main method.
|
private void |
testClients()
Performs a wide variety of tests on a running hub from a limited
number of clients.
|
private void |
testLockInfo(LockInfo lockInfo)
Does tests on a LockInfo object used by the profile.
|
private void |
testStandardLockfile()
Tests the content of the SAMP Standard Profile lockfile.
|
private void |
testStress()
Runs a lot of clients throwing a lot of messages at each other
simultaneously.
|
assertEquals, assertEquals, assertTrue, fail
private final ClientProfile profile_
private final java.lang.String hubId_
private final Client[] ignoreClients_
private final java.util.Set selfIds_
private final java.util.Set privateKeys_
private final HubTester.ClientWatcher clientWatcher_
private final java.util.Random random_
private static final java.lang.String WAITMILLIS_KEY
private static final java.lang.String MSGIDQUERY_KEY
private static final java.lang.String ECHO_MTYPE
private static final java.lang.String PING_MTYPE
private static final java.lang.String FAIL_MTYPE
private static final java.lang.String REGISTER_MTYPE
private static final java.lang.String UNREGISTER_MTYPE
private static final java.lang.String METADATA_MTYPE
private static final java.lang.String SUBSCRIPTIONS_MTYPE
private static final java.lang.String ERROR_KEY
private static final char[] ALPHA_CHARS
private static final char[] GENERAL_CHARS
private static java.util.logging.Logger logger_
public HubTester(ClientProfile profile) throws java.io.IOException
profile
- hub discovery objectjava.io.IOException
private HubConnection register() throws SampException
SampException
public void run() throws java.io.IOException
java.io.IOException
private void testStandardLockfile() throws java.io.IOException
java.io.IOException
private void testLockInfo(LockInfo lockInfo) throws java.io.IOException
lockInfo
- lock info object describing a running hubjava.io.IOException
private void testClients() throws java.io.IOException
java.io.IOException
private void testStress() throws java.io.IOException
java.io.IOException
private void assertTestClients(HubConnection conn, java.lang.String[] otherIds) throws java.io.IOException
conn
- connection from which to call getRegisteredClientsotherIds
- array of client public IDs that getRegisteredClients
should return - will not contain ID associated with
conn
itselfjava.io.IOException
public java.lang.Object createRandomObject(int level, boolean ugly)
level
- maximum level of nesting (how deeply lists/maps
may appear within other lists/maps)ugly
- if true, any legal SAMP content will be used;
if false, the returned object should be reasonably
human-readable if printed (toString)public java.lang.String createRandomString(boolean ugly)
ugly
- if true, any legal SAMP content will be used;
if false, the returned object should be reasonably
human-readable if printed (toString)private static void delay(int millis)
millis
- number of millisecondsprivate static char[] createAlphaCharacters()
private static char[] createGeneralCharacters()
string
.public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
public static int runMain(java.lang.String[] args) throws java.io.IOException
java.io.IOException