|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.util.TestUtil
public class TestUtil
A helper class for the code to determine if it is being run in test mode or not. If the code is run in test mode, it shouldn't spawn unneeded background threads or otherwise use resources intended solely for a live environment.
| Field Summary | |
|---|---|
static boolean |
addFileToolAutoRecoverFromOOM
Flag to simulate how a tool might recover from an OutOfMemoryError. |
static boolean |
addFileToolSimulateOOM
Flag to simulate an OutOfMemoryError. |
| Constructor Summary | |
|---|---|
TestUtil()
|
|
| Method Summary | |
|---|---|
static boolean |
addListener(TestUtilListener tul)
Add TestUtilListener to TestUtil. |
static void |
addServerToHostTestMap(java.lang.String host,
java.lang.String trancheURL)
Add a map entry for a single server. |
static void |
assertDirectoriesEquivalent(java.io.File dir1,
java.io.File dir2)
|
static void |
assertFilesAreEqual(java.io.File fileA,
java.io.File fileB)
|
static void |
assertFilesAreEquivalent(java.io.File fileA,
java.io.File fileB)
|
static void |
clearFFTSForURL()
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork. |
static void |
clearListeners()
Clear all TestUtilListener objects. |
static void |
clearServerToHostTestMap()
Clears the collection. |
static FlatFileTrancheServer |
getFFTSForURL(java.lang.String url)
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork. |
static java.lang.String |
getOstensibleHostForURL(java.lang.String url)
Returns the ostensible host for a Tranche server given its actual url. |
static java.lang.String |
getServerTestURL(java.lang.String host)
Returns a Tranche url for an (ostensible) host. |
static java.util.Map<java.lang.String,java.lang.String> |
getServerToHostTestMap()
Returns unmodifiable map. |
static boolean |
isAddFileToolChunkFailOnce()
If set to true, every chunk in batch uploads will fail once: fail first time, but retry should succeed. |
static boolean |
isAddFileToolChunkFailTwice()
If set to true, every chunk in batch uploads will fail twice: fail first time, and fail retry. |
static boolean |
isTesting()
Flag to determine whether tests are running. |
static boolean |
isTestingActivityLogs()
If testing, activity logs won't be recorded unless this is set. |
static boolean |
isTestingHashSpanFixingThread()
Can turn the HashSpanFixingThread on or off. |
static boolean |
isTestingManualNetworkStatusTable()
If set to true, then the network status table is being tested. |
static boolean |
isTestingServerStartupThread()
If testing, the Server won't start the ServerStartupThread unless this is set. |
static boolean |
isTestingServerTracker()
If set to true, the ServerTracker in ServerUtil will run for tests. |
static boolean |
isTestingTargetHashSpan()
TargetHashSpanThread only runs if true. |
static boolean |
isTestingTimeout()
If testing timeout, want to make sure scavengar thread can operate. |
static boolean |
isTestingTurnOffProjectFindingThread()
Used to turn off project-finding thread. |
static boolean |
isTestUsingFakeCoreServers()
Flag to simulate core servers. |
static void |
printRecursiveDirectoryStructure(java.io.File root)
Prints out breadth-first directory structure for humans. |
static void |
printTitle(java.lang.String title)
|
static FlatFileTrancheServer |
removeFFTSForURL(java.lang.String url)
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork. |
static boolean |
removeListener(TestUtilListener tul)
Remove specific TestUtilListener from TestUtil. |
static void |
setAddFileToolChunkFailOnce(boolean aAddFileToolChunkFailOnce)
If set to true, every chunk in batch uploads will fail once: fail first time, but retry should succeed. |
static void |
setAddFileToolChunkFailTwice(boolean aAddFileToolChunkFailTwice)
If set to true, every chunk in batch uploads will fail twice: fail first time, and fail retry. |
static void |
setFFTSForURL(java.lang.String url,
FlatFileTrancheServer ffts)
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork. |
static void |
setTesting(boolean testing)
Flag to determine whether tests are running. |
static void |
setTestingActivityLogs(boolean aTestingActivityLogs)
If testing, activity logs won't be recorded unless this is set. |
static void |
setTestingHashSpanFixingThread(boolean aTestingHashSpanFixingThread)
Can turn the HashSpanFixingThread on or off. |
static void |
setTestingManualNetworkStatusTable(boolean aTestingManualNetworkStatusTable)
If set to true, then the network status table is being tested. |
static void |
setTestingServerStartupThread(boolean aTestingServerStartupThread)
If testing, the Server won't start the ServerStartupThread unless this is set. |
static void |
setTestingServerTracker(boolean aTestingServerTracker)
If set to true, the ServerTracker in ServerUtil will run for tests. |
static void |
setTestingTargetHashSpan(boolean aTestingTargetHashSpan)
TargetHashSpanThread only runs if true. |
static void |
setTestingTimeout(boolean aTestingTimeout)
If testing timeout, want to make sure scavengar thread can operate. |
static void |
setTestingTurnOffProjectFindingThread(boolean aTestingTurnOffProjectFindingThread)
Used to turn off project-finding thread. |
static void |
setTestUsingFakeCoreServers(boolean aTestUsingFakeCoreServers)
Flag to simulate core servers. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean addFileToolSimulateOOM
Flag to simulate an OutOfMemoryError.
public static boolean addFileToolAutoRecoverFromOOM
Flag to simulate how a tool might recover from an OutOfMemoryError.
| Constructor Detail |
|---|
public TestUtil()
| Method Detail |
|---|
public static boolean isTesting()
Flag to determine whether tests are running.
public static void setTesting(boolean testing)
Flag to determine whether tests are running.
testing - public static boolean isTestUsingFakeCoreServers()
Flag to simulate core servers. Tests can add servers.
public static void setTestUsingFakeCoreServers(boolean aTestUsingFakeCoreServers)
Flag to simulate core servers. Tests can add servers.
aTestUsingFakeCoreServers - public static boolean isTestingHashSpanFixingThread()
Can turn the HashSpanFixingThread on or off. By default, it is off (false).
public static void setTestingHashSpanFixingThread(boolean aTestingHashSpanFixingThread)
Can turn the HashSpanFixingThread on or off. By default, it is off (false).
aTestingHashSpanFixingThread - public static boolean isTestingTurnOffProjectFindingThread()
Used to turn off project-finding thread. Useful if want to test healing thread's capability for fixing broken data blocks.
public static void setTestingTurnOffProjectFindingThread(boolean aTestingTurnOffProjectFindingThread)
Used to turn off project-finding thread. Useful if want to test healing thread's capability for fixing broken data blocks.
aTestingTurnOffProjectFindingThread - public static boolean isAddFileToolChunkFailOnce()
If set to true, every chunk in batch uploads will fail once: fail first time, but retry should succeed.
public static void setAddFileToolChunkFailOnce(boolean aAddFileToolChunkFailOnce)
If set to true, every chunk in batch uploads will fail once: fail first time, but retry should succeed.
aAddFileToolChunkFailOnce - public static boolean isAddFileToolChunkFailTwice()
If set to true, every chunk in batch uploads will fail twice: fail first time, and fail retry.
public static void setAddFileToolChunkFailTwice(boolean aAddFileToolChunkFailTwice)
If set to true, every chunk in batch uploads will fail twice: fail first time, and fail retry.
aAddFileToolChunkFailTwice - public static boolean isTestingServerTracker()
If set to true, the ServerTracker in ServerUtil will run for tests.
public static void setTestingServerTracker(boolean aTestingServerTracker)
If set to true, the ServerTracker in ServerUtil will run for tests.
aTestingServerTracker - public static boolean isTestingTimeout()
If testing timeout, want to make sure scavengar thread can operate.
public static void setTestingTimeout(boolean aTestingTimeout)
If testing timeout, want to make sure scavengar thread can operate.
aTestingTimeout - public static boolean isTestingActivityLogs()
If testing, activity logs won't be recorded unless this is set.
public static void setTestingActivityLogs(boolean aTestingActivityLogs)
If testing, activity logs won't be recorded unless this is set.
aTestingActivityLogs - public static boolean isTestingServerStartupThread()
If testing, the Server won't start the ServerStartupThread unless this is set.
public static void setTestingServerStartupThread(boolean aTestingServerStartupThread)
If testing, the Server won't start the ServerStartupThread unless this is set.
aTestingServerStartupThread - public static boolean isTestingManualNetworkStatusTable()
If set to true, then the network status table is being tested. Automatic updates to the table will be disabled.
public static void setTestingManualNetworkStatusTable(boolean aTestingManualNetworkStatusTable)
If set to true, then the network status table is being tested. Automatic updates to the table will be disabled.
aTestingManualNetworkStatusTable - public static boolean addListener(TestUtilListener tul)
Add TestUtilListener to TestUtil.
tul -
public static boolean removeListener(TestUtilListener tul)
Remove specific TestUtilListener from TestUtil.
tul -
public static void clearListeners()
Clear all TestUtilListener objects.
public static final void printTitle(java.lang.String title)
title -
public static void addServerToHostTestMap(java.lang.String host,
java.lang.String trancheURL)
Add a map entry for a single server.
Holds a map of hosts to Tranche urls. This is done so can unit test.
Note that there is a maximum of one host per JVM. This is done so port and other information can be changed.
When test, need more than one server. This allows us to do this.
Only works when TestUtil.isTestingManualNetworkStatusTable() returns true. For this to work, must manually create status table.
host - The ostensible host nametrancheURL - The actual Tranche server URLpublic static java.util.Map<java.lang.String,java.lang.String> getServerToHostTestMap()
Returns unmodifiable map.
Holds a map of hosts to Tranche urls. This is done so can unit test.
Note that there is a maximum of one host per JVM. This is done so port and other information can be changed.
When test, need more than one server. This allows us to do this.
Only works when TestUtil.isTestingManualNetworkStatusTable() returns true. For this to work, must manually create status table.
public static void clearServerToHostTestMap()
Clears the collection.
Holds a map of hosts to Tranche urls. This is done so can unit test.
Note that there is a maximum of one host per JVM. This is done so port and other information can be changed.
When test, need more than one server. This allows us to do this.
Only works when TestUtil.isTestingManualNetworkStatusTable() returns true. For this to work, must manually create status table.
public static java.lang.String getServerTestURL(java.lang.String host)
Returns a Tranche url for an (ostensible) host. If doesn't exist, returns null.
Holds a map of hosts to Tranche urls. This is done so can unit test.
Note that there is a maximum of one host per JVM. This is done so port and other information can be changed.
When test, need more than one server. This allows us to do this.
Only works when TestUtil.isTestingManualNetworkStatusTable() returns true. For this to work, must manually create status table.
host -
public static java.lang.String getOstensibleHostForURL(java.lang.String url)
Returns the ostensible host for a Tranche server given its actual url. If doesn't exist, returns null.
Holds a map of hosts to Tranche urls. This is done so can unit test.
Note that there is a maximum of one host per JVM. This is done so port and other information can be changed.
When test, need more than one server. This allows us to do this.
Only works when TestUtil.isTestingManualNetworkStatusTable() returns true. For this to work, must manually create status table.
url -
public static final void assertDirectoriesEquivalent(java.io.File dir1,
java.io.File dir2)
throws java.lang.Exception
dir1 - dir2 -
java.lang.Exception
public static void assertFilesAreEqual(java.io.File fileA,
java.io.File fileB)
throws java.lang.Exception
fileA - fileB -
java.lang.Exception
public static void assertFilesAreEquivalent(java.io.File fileA,
java.io.File fileB)
throws java.lang.Exception
fileA - fileB -
java.lang.Exceptionpublic static boolean isTestingTargetHashSpan()
TargetHashSpanThread only runs if true.
public static void setTestingTargetHashSpan(boolean aTestingTargetHashSpan)
TargetHashSpanThread only runs if true.
aTestingTargetHashSpan -
public static void setFFTSForURL(java.lang.String url,
FlatFileTrancheServer ffts)
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork.
This is needed to test propagation in tests. If server items use remote server when propagating, might end up behind another request from client (clients and servers share remote connections), and will hence time out.
url - ffts - public static FlatFileTrancheServer getFFTSForURL(java.lang.String url)
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork.
This is needed to test propagation in tests. If server items use remote server when propagating, might end up behind another request from client (clients and servers share remote connections), and will hence time out.
url -
public static FlatFileTrancheServer removeFFTSForURL(java.lang.String url)
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork.
This is needed to test propagation in tests. If server items use remote server when propagating, might end up behind another request from client (clients and servers share remote connections), and will hence time out.
url -
public static void clearFFTSForURL()
Map of URL (e.g., tranche://127.0.0.1:1501) to associated FlatFileTrancheServer instance from a running TestNetwork.
This is needed to test propagation in tests. If server items use remote server when propagating, might end up behind another request from client (clients and servers share remote connections), and will hence time out.
public static void printRecursiveDirectoryStructure(java.io.File root)
Prints out breadth-first directory structure for humans. Nice to see files quickly.
root -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||