Methods Summary |
---|
private javax.swing.JComponent | buildConfigurationPanel()
JPanel returnValue = new JPanel(new GridLayout(1, 5));
_numberOfThreadsField = new JTextField();
_numberOfOperationsField = new JTextField();
_testButton = new JButton("Perform Test");
_testButton.addActionListener(new TestLauncher());
returnValue.add(new JLabel("Number of Clients"));
returnValue.add(_numberOfThreadsField);
returnValue.add(new JLabel("Number of Operations"));
returnValue.add(_numberOfOperationsField);
returnValue.add(_testButton);
returnValue.setBorder(BorderFactory.createEtchedBorder());
return returnValue;
|
protected void | buildGUI()
setTitle("Chapter 12 Testing Application");
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(buildConfigurationPanel(), BorderLayout.NORTH);
mainPanel.add(buildResultsWindow(), BorderLayout.CENTER);
setSize(600, 400);
setContentPane(mainPanel);
|
private javax.swing.JComponent | buildResultsWindow()
JPanel returnValue = new JPanel(new BorderLayout());
_resultsArea = new JTextArea();
_accountChooser = new JComboBox();
returnValue.add(_accountChooser, BorderLayout.NORTH);
returnValue.add(new JScrollPane(_resultsArea), BorderLayout.CENTER);
return returnValue;
|
private void | computeSummaryForChosenAccount(java.lang.String accountName)
ResultsSummary summaryObject = new ResultsSummary();
summarize(summaryObject, _testResultHolder.getResultsForAccount(accountName), true);
displaySummary(summaryObject);
|
private void | computeSummaryforAllAccounts()
ResultsSummary summaryObject = new ResultsSummary();
Iterator i = (_testResultHolder.getAccountNames()).iterator();
while (i.hasNext()) {
String nextAccountName = (String) i.next();
summarize(summaryObject, _testResultHolder.getResultsForAccount(nextAccountName), false);
}
displaySummary(summaryObject);
|
private void | displaySummary(com.ora.rmibook.chapter13.bank.applications.TestAppFrame$ResultsSummary summaryObject)
String partialString = "Number of operations : " + summaryObject.numberOfTests + "\n"
+ "\tAverage operation time: " + (summaryObject.totalTime / summaryObject.numberOfTests) + " milliseconds.\n"
+ "\tLongest operation time: " + summaryObject.longestTime + " milliseconds.\n"
+ "\tNumber of successes : " + summaryObject.numberOfSuccesses + ".\n"
+ "\tNumber of failures : " + summaryObject.numberOfFailures + ".\n"
+ "\tNumber of locks : " + summaryObject.numberOfLocks + ".\n"
+ "\tNumber of remote exceptions : " + summaryObject.numberOfRemoteExceptions + ".\n"
+ "\tNumber of unable to connects : " + summaryObject.numberOfUnableToConnects + ".\n";
if (summaryObject.resultsString.equals("")) {
summaryObject.resultsString = partialString;
} else {
summaryObject.resultsString = partialString
+ "\n\n" + "Detailed Results \n ==================\n\n"
+ summaryObject.resultsString;
}
_resultsArea.setText(summaryObject.resultsString);
_resultsArea.scrollRectToVisible(_upperLeftCorner);
|
private void | reset()
_testResultHolder = new TestResultHolder();
_numberOfFinishedThreads = 0;
|
private void | resetGUI()
_testResultHolder.sortResults();
_accountChooser.removeActionListener(_chooserListener);
_accountChooser.removeAllItems();
_accountChooser.addItem(ALL_ACCOUNTS);
Iterator i = (_testResultHolder.getAccountNames()).iterator();
while (i.hasNext()) {
_accountChooser.addItem(i.next());
}
_resultsArea.setText("");
_accountChooser.addActionListener(_chooserListener);
computeSummaryforAllAccounts();
|
protected synchronized boolean | someThreadsNotFinished()
return _numberOfFinishedThreads < _numberOfThreads;
|
private void | summarize(com.ora.rmibook.chapter13.bank.applications.TestAppFrame$ResultsSummary summaryObject, java.util.Collection tests, boolean addDescriptions)
Iterator i = tests.iterator();
while (i.hasNext()) {
Test nextTest = (Test) i.next();
summaryObject.totalTime += nextTest.duration;
summaryObject.numberOfTests++;
if (addDescriptions) {
summaryObject.resultsString += nextTest.describeOutcome();
}
if (summaryObject.longestTime < nextTest.duration) {
summaryObject.longestTime = nextTest.duration;
}
if (nextTest.status == Test.FAILURE) {
summaryObject.numberOfFailures++;
}
if (nextTest.status == Test.ACCOUNT_WAS_LOCKED) {
summaryObject.numberOfLocks++;
}
if (nextTest.status == Test.REMOTE_EXCEPTION_THROWN) {
summaryObject.numberOfRemoteExceptions++;
}
if (nextTest.status == Test.UNABLE_TO_CONNECT) {
summaryObject.numberOfUnableToConnects++;
}
if (nextTest.status == Test.SUCCESS) {
summaryObject.numberOfSuccesses++;
}
}
|
protected synchronized void | testThreadFinished(TestThread testThread)
_numberOfFinishedThreads++;
|