net.curre.prefcount.test
Class BaseTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by net.curre.prefcount.test.BaseTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AllEventsTest, DialogInnerPanelTest, GeneralTest, LafThemeServiceTest, LocaleExtTest, PrefCountRegistryTest, PrefSkinsTest, ResultServiceTest, SettingsServiceTest, UtilitiesTest

public abstract class BaseTestCase
extends junit.framework.TestCase

Object of this class represents a base test case for all unit tests and contains a set of prefcount specific assertions and common utilities.

Created date: Nov 27, 2007

Author:
Yevgeny Nyden

Field Summary
protected static java.lang.String SETTINGS_FILE
          Test settings file path relative to the root project directory.
 
Constructor Summary
BaseTestCase()
           
 
Method Summary
static void assertButtonValues(java.lang.String message, javax.swing.JButton button, boolean isEnabled, boolean isSelected)
          Asserts that the given JButton is not null, is selected/unselected, and is enabled/disabled according to the passed values.
static void assertMapNotNullValues(java.util.Map map, java.util.List<java.lang.String> keys)
          Asserts that the given map has not null values that for the given keys.
static void assertMapNullValues(java.util.Map map, java.util.List<java.lang.String> keys)
          Asserts that the given map does not have values for the given keys.
static void assertNotBlankAndVisible(java.lang.String message, javax.swing.JLabel label)
          Asserts that given label is not null and it's text field is not blank.
static void assertNotVisible(java.awt.Component component)
          Asserts that the given component is not visible.
static void assertNotVisible(java.lang.String message, java.awt.Component component)
          Asserts that the given component is not visible.
static void assertTextBlank(java.lang.String message, javax.swing.JLabel label)
          Asserts that the given label is not null and its text string is blank (null or empty).
static void assertTextNotBlank(java.lang.String message, javax.swing.JLabel label)
          Asserts that the given label is not null and its text string is not blank (not null and not empty).
static void assertValidResource(java.lang.String msg, java.lang.String key)
          Asserts the resource key is not null, not empty, and valid (has corresponding string for all available locales).
static void assertVisible(java.awt.Component component)
          Asserts that the given component is visible.
static void assertVisible(java.lang.String message, java.awt.Component component)
          Asserts that the given component is visible.
protected static net.curre.prefcount.bean.PlayerStatistics createPlayerStatHelper(net.curre.prefcount.bean.GameResultBean rBean, int ind, java.lang.String name, java.lang.Integer bullet, java.lang.Integer mountain, java.lang.String... vists)
          Creates player statistics object and initializes it with the passed data.
protected  void deleteTestSettingsFile()
          Deletes test settings file.
protected static void setTextFields(java.util.Collection<javax.swing.JTextField> fields, java.lang.String... text)
          Sets all JTextField text fileds with the given value.
protected static void setTextFields(java.awt.Component[] comps, java.lang.String... text)
          Sets all JTextField text fileds with the given value.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SETTINGS_FILE

protected static final java.lang.String SETTINGS_FILE
Test settings file path relative to the root project directory.

See Also:
Constant Field Values
Constructor Detail

BaseTestCase

public BaseTestCase()
Method Detail

assertValidResource

public static void assertValidResource(java.lang.String msg,
                                       java.lang.String key)
Asserts the resource key is not null, not empty, and valid (has corresponding string for all available locales).

Parameters:
msg - Error message.
key - Resource key to test.

assertNotBlankAndVisible

public static void assertNotBlankAndVisible(java.lang.String message,
                                            javax.swing.JLabel label)
Asserts that given label is not null and it's text field is not blank.

Parameters:
message - Error message to display.
label - Label object to test.

assertButtonValues

public static void assertButtonValues(java.lang.String message,
                                      javax.swing.JButton button,
                                      boolean isEnabled,
                                      boolean isSelected)
Asserts that the given JButton is not null, is selected/unselected, and is enabled/disabled according to the passed values.

Parameters:
message - Message that identifies this button.
button - Button to test.
isEnabled - True if the button is expected to be enabled; false otherwise.
isSelected - True if the button is expected to be selected; false otherwise.

assertMapNullValues

public static void assertMapNullValues(java.util.Map map,
                                       java.util.List<java.lang.String> keys)
Asserts that the given map does not have values for the given keys.

Parameters:
map - Map to test.
keys - Keys to test against the given map.

assertMapNotNullValues

public static void assertMapNotNullValues(java.util.Map map,
                                          java.util.List<java.lang.String> keys)
Asserts that the given map has not null values that for the given keys.

Parameters:
map - Map to test.
keys - Keys to test against the given map.

assertVisible

public static void assertVisible(java.lang.String message,
                                 java.awt.Component component)
Asserts that the given component is visible.

Parameters:
component - Component to test.
message - Error message to display.

assertVisible

public static void assertVisible(java.awt.Component component)
Asserts that the given component is visible.

Parameters:
component - Component to test.

assertNotVisible

public static void assertNotVisible(java.lang.String message,
                                    java.awt.Component component)
Asserts that the given component is not visible.

Parameters:
component - Component to test.
message - Error message to display.

assertNotVisible

public static void assertNotVisible(java.awt.Component component)
Asserts that the given component is not visible.

Parameters:
component - Component to test.

assertTextBlank

public static void assertTextBlank(java.lang.String message,
                                   javax.swing.JLabel label)
Asserts that the given label is not null and its text string is blank (null or empty).

Parameters:
message - Error message to display.
label - Label to test.

assertTextNotBlank

public static void assertTextNotBlank(java.lang.String message,
                                      javax.swing.JLabel label)
Asserts that the given label is not null and its text string is not blank (not null and not empty).

Parameters:
message - Error message to display.
label - Label to test.

deleteTestSettingsFile

protected void deleteTestSettingsFile()
Deletes test settings file.


setTextFields

protected static void setTextFields(java.util.Collection<javax.swing.JTextField> fields,
                                    java.lang.String... text)
Sets all JTextField text fileds with the given value.

Parameters:
fields - Array of text fields.
text - Text to set.

setTextFields

protected static void setTextFields(java.awt.Component[] comps,
                                    java.lang.String... text)
Sets all JTextField text fileds with the given value.

Parameters:
comps - Array of components.
text - Text to set.

createPlayerStatHelper

protected static net.curre.prefcount.bean.PlayerStatistics createPlayerStatHelper(net.curre.prefcount.bean.GameResultBean rBean,
                                                                                  int ind,
                                                                                  java.lang.String name,
                                                                                  java.lang.Integer bullet,
                                                                                  java.lang.Integer mountain,
                                                                                  java.lang.String... vists)
Creates player statistics object and initializes it with the passed data.

Parameters:
rBean - Game result bean to set.
ind - Player index.
name - Player name.
bullet - Player bullet.
mountain - Player mountain.
vists - Vists against other players.
Returns:
Created and initialized player statistics object.


Copyright © 2008. All Rights Reserved.