org.netbeans.modules.nbjunit/1 1.75

org.netbeans.junit
Class NbModuleSuite.Configuration

java.lang.Object
  extended by org.netbeans.junit.NbModuleSuite.Configuration
Enclosing class:
NbModuleSuite

public static final class NbModuleSuite.Configuration
extends Object

Settings object that allows one to configure execution of whole NbModuleSuite.

Since:
1.48

Method Summary
 NbModuleSuite.Configuration addStartupArgument(String... arguments)
          Appends one or more command line arguments which will be used to start the application.
 NbModuleSuite.Configuration addTest(Class<? extends junit.framework.Test> test)
          Add new Test to run.
 NbModuleSuite.Configuration addTest(Class<? extends junit.framework.TestCase> test, String... testNames)
          Adds new test class to run, together with a list of its methods that shall be executed.
 NbModuleSuite.Configuration addTest(String... testNames)
          Adds new test name, or array of names into the configuration.
 NbModuleSuite.Configuration clusters(String regExp)
          Regular expression to match clusters that shall be enabled.
 NbModuleSuite.Configuration enableClasspathModules(boolean enable)
          By default all modules on classpath are enabled (so you can link with modules that you compile against), this method allows you to disable this feature, which is useful if the test is known to not link against any of classpath classes.
 NbModuleSuite.Configuration enableModules(String regExp)
          By default only modules on classpath of the test are enabled, the rest are just autoloads.
 NbModuleSuite.Configuration enableModules(String clusterRegExp, String moduleRegExp)
          By default only modules on classpath of the test are enabled, the rest are just autoloads.
 NbModuleSuite.Configuration failOnException(Level level)
          Fails if there is an exception reported to Logger with appropriate level or higher during the test run execution.
 NbModuleSuite.Configuration failOnMessage(Level level)
          Fails if there is a message sent to Logger with appropriate level or higher during the test run execution.
 NbModuleSuite.Configuration gui(boolean gui)
          Should the system run with GUI or without? The default behaviour does not prevent any module to show UI.
 NbModuleSuite.Configuration hideExtraModules(boolean hide)
          Allows to limit what modules get enabled in the system.
 NbModuleSuite.Configuration honorAutoloadEager(boolean honor)
          By default the enableModules(java.lang.String) method converts all autoloads into regular modules and enables them.
 NbModuleSuite.Configuration reuseUserDir(boolean reuse)
          Enables or disables userdir reuse.
 junit.framework.Test suite()
          Creates a test suite from this configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clusters

public NbModuleSuite.Configuration clusters(String regExp)
Regular expression to match clusters that shall be enabled. To enable all cluster, one can use ".*". To enable ide and java clusters, it is handy to pass in "ide|java". There is no need to request presence of platform cluster, as that is available all the time by default.

Since version 1.55 this method can be called multiple times.

Parameters:
regExp - regular expression to match cluster names
Returns:
clone of this configuration with cluster set to regExp value

enableModules

public NbModuleSuite.Configuration enableModules(String regExp)
By default only modules on classpath of the test are enabled, the rest are just autoloads. If you need to enable more, you can specify that with this method. To enable all available modules in all clusters pass in ".*". Since 1.55 this method is cummulative.

Parameters:
regExp - regular expression to match code name base of modules
Returns:
clone of this configuration with enable modules set to regExp value

enableModules

public NbModuleSuite.Configuration enableModules(String clusterRegExp,
                                                 String moduleRegExp)
By default only modules on classpath of the test are enabled, the rest are just autoloads. If you need to enable more, you can specify that with this method. To enable all available modules in one cluster, use this method and pass ".*" as list of modules. This method is cumulative.

Parameters:
clusterRegExp - regular expression to match clusters
moduleRegExp - regular expression to match code name base of modules
Returns:
clone of this configuration with enable modules set to regExp value
Since:
1.55

addStartupArgument

public NbModuleSuite.Configuration addStartupArgument(String... arguments)
Appends one or more command line arguments which will be used to start the application. Arguments which take a parameter should usually be specified as two separate strings. Also note that this method cannot handle arguments which must be passed directly to the JVM (such as memory settings or system properties), those should be instead specified in the test.run.args property (e.g. in the module's project.properties file).

Parameters:
arguments - command line arguments to append; each value specified here will be passed a separate argument when starting the application under test.
Returns:
clone of this configuration object with the specified command line arguments appended to any which may have already been present
Since:
1.67

addTest

public NbModuleSuite.Configuration addTest(String... testNames)
Adds new test name, or array of names into the configuration. By default the suite executes all testXYZ methods present in the test class (the one passed into create(java.lang.Class) method). However if there is a need to execute just some of them, one can use this method to explicitly enumerate them by subsequent calls to addTest method.

Parameters:
testNames - list names to add to the test execution
Returns:
clone of this configuration with testNames test added to the list of executed tests

addTest

public NbModuleSuite.Configuration addTest(Class<? extends junit.framework.TestCase> test,
                                           String... testNames)
Adds new test class to run, together with a list of its methods that shall be executed. The list can be empty and if so, the the suite executes all testXYZ methods present in the test class.

Parameters:
test - the class to also execute in this suite
testNames - list names to add to the test execution
Returns:
clone of this configuration with testNames test added to the list of executed tests
Since:
1.50

addTest

public NbModuleSuite.Configuration addTest(Class<? extends junit.framework.Test> test)
Add new Test to run. The implementation must have no parameter constructor. TastCase can be also passed as an argument of this method than it's delegated to addTest(java.lang.Class, java.lang.String[])

Parameters:
test - Test implementation to add
Returns:
clone of this configuration with new Test added to the list of executed tests
Since:
1.50

enableClasspathModules

public NbModuleSuite.Configuration enableClasspathModules(boolean enable)
By default all modules on classpath are enabled (so you can link with modules that you compile against), this method allows you to disable this feature, which is useful if the test is known to not link against any of classpath classes.

Parameters:
enable - pass false to ignore modules on classpath
Returns:
new configuration clone
Since:
1.56

honorAutoloadEager

public NbModuleSuite.Configuration honorAutoloadEager(boolean honor)
By default the enableModules(java.lang.String) method converts all autoloads into regular modules and enables them. This is maybe useful in certain situations, but does not really mimic the real behaviour of the system when it is executed. Those who need to as closely as possible simulate the real run, can use honorAutoloadEager(true).

Parameters:
honor - true in case autoloads shall remain autoloads and eager modules eager
Returns:
new configuration filled with this data
Since:
1.57

hideExtraModules

public NbModuleSuite.Configuration hideExtraModules(boolean hide)
Allows to limit what modules get enabled in the system. The original purpose of NbModuleSuite was to enable as much of modules as possible. This was believed to resemble the real situation in the running application the best. However it turned out there are situations when too much modules can break the system and it is necessary to prevent loading some of them. This method can achieve that.

The primary usage is for Ant based harness. It usually contains full installation of various clusters and the application picks just certain modules from that configuration. hideExtraModules(true) allows exclusion of these modules as well.

The usefulness of this method in Maven based environment is not that big. Usually the nbm plugin makes only necessary JARs available. In combination with enableClasspathModules(false), it may give you a subset of the Platform loaded in a test. In a Maven-based app declaring a dependency on the whole org.netbeans.cluster:platform use the following suite expression:

 NbModuleSuite.createConfiguration(ApplicationTest.class).
     gui(true).
     hideExtraModules(true).
     enableModules("(?!org.netbeans.modules.autoupdate|org.netbeans.modules.core.kit|org.netbeans.modules.favorites).*").
     enableClasspathModules(false).
     suite();
 

Parameters:
hide - true if all enabled not explicitly requested modules should be hidden
Returns:
new configuration with holds the provided parameter
Since:
1.72

failOnMessage

public NbModuleSuite.Configuration failOnMessage(Level level)
Fails if there is a message sent to Logger with appropriate level or higher during the test run execution.

Parameters:
level - the minimal level of the message
Returns:
new configuration filled with this data
Since:
1.58

failOnException

public NbModuleSuite.Configuration failOnException(Level level)
Fails if there is an exception reported to Logger with appropriate level or higher during the test run execution.

Parameters:
level - the minimal level of the message
Returns:
new configuration filled with this data
Since:
1.58

gui

public NbModuleSuite.Configuration gui(boolean gui)
Should the system run with GUI or without? The default behaviour does not prevent any module to show UI. If false is used, then the whole system is instructed with --nogui option that it shall run as much as possible in invisible mode. As a result, the main window is not shown after the start, for example.

Parameters:
gui - true or false
Returns:
clone of this configuration with gui mode associated

reuseUserDir

public NbModuleSuite.Configuration reuseUserDir(boolean reuse)
Enables or disables userdir reuse. By default it is disabled.

Parameters:
reuse - true or false
Returns:
clone of this configuration with userdir reuse mode associated
Since:
1.52

suite

public junit.framework.Test suite()
Creates a test suite from this configuration. Same as NbModuleSuite.create(org.netbeans.junit.NbModuleSuite.Configuration) but more fluid.

Returns:
a suite ready for returning from a public static Test suite() method
Since:
org.netbeans.modules.junit/1 1.70

org.netbeans.modules.nbjunit/1 1.75

Built on May 24 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.