IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.patterns.framework.test
Class AbstractTestSetup

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.extensions.TestDecorator
          extended byjunit.extensions.TestSetup
              extended bycom.ibm.xtools.patterns.framework.test.AbstractTestSetup
All Implemented Interfaces:
junit.framework.Test

public abstract class AbstractTestSetup
extends junit.extensions.TestSetup

This is the base class for all pattern test setup classes. This class will create a test project with a UML model in the runtime workspace. It will create a package in a class model, and create an instance of the pattern to be tested in the package. The "target" for the instance varies according to the PatternInstanceTargetCreationStrategy employed. The default implementation in this class creates the instance using the created package as the target. All setup classes that extend this class must provide the following information by implementing their corresponding abstract methods: Test Project Name: The name of the Eclipse project used to run the tests. This setup class requires that a modelling project with this name exists in the location of the test plug-in. This project will be copied to the runtime workspace location during setup. Test Target Java Project name: The name of the project where Java classes will be generated to. Test Model Name: Name of the model used to run the tests. Test Case: The test case that this class sets up for. If setup classes that extend this class want to create a pattern instance using something other than a package as a target, the classes should override getPatternInstanceTargetCreationStrategy with the strategy of their choice. Implementations of PatternInstanceTargetCreationStrategies can be found in: com.ibm.xtools.patterns.framework.test.strategies


Nested Class Summary
protected  class AbstractTestSetup.TestPreferences
           
 
Field Summary
 
Fields inherited from class junit.extensions.TestDecorator
fTest
 
Constructor Summary
AbstractTestSetup(junit.framework.Test a_test, ITestDataFactory a_dataFactory, AbstractTestUtil testUtil)
           
 
Method Summary
 void cleanTargetJavaProject()
          Removes the test package contained in the test Java project.
static EObject getFirstRoot(Resource resource)
          Gets the first root object in the resource.
 AbstractPatternInstance getPatternInstance()
           
 com.ibm.xtools.patterns.framework.test.strategies.PatternInstanceTargetCreationStrategy getPatternInstanceTargetCreationStrategy()
          Set the class that is used to make the target for the pattern instance
 IParameterDescriptor[] getPatternParameters()
           
protected abstract  AbstractTestCase getTestCase()
           
 TestDataManager getTestDataManager()
           
protected abstract  String getTestModelName()
           
 Package getTestPackage()
           
 AbstractTestSetup.TestPreferences getTestPreferences()
           
protected abstract  String getTestProjectName()
           
 org.eclipse.jdt.core.IJavaProject getTestTargetJavaProject()
           
protected abstract  String getTestTargetJavaProjectName()
           
 Model getUML2Model()
           
protected  void setUp()
          Sets up the fixture.
protected  void tearDown()
          Tears down the fixture.
 
Methods inherited from class junit.extensions.TestSetup
run
 
Methods inherited from class junit.extensions.TestDecorator
basicRun, countTestCases, getTest, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTestSetup

public AbstractTestSetup(junit.framework.Test a_test,
                         ITestDataFactory a_dataFactory,
                         AbstractTestUtil testUtil)
Method Detail

cleanTargetJavaProject

public void cleanTargetJavaProject()
Removes the test package contained in the test Java project.


getPatternInstance

public AbstractPatternInstance getPatternInstance()
Returns:
The pattern instance created by this setup class

getTestCase

protected abstract AbstractTestCase getTestCase()
Returns:
The test case that is being setup.

getTestModelName

protected abstract String getTestModelName()
Returns:
Name of the model for this test case.

getTestPackage

public Package getTestPackage()
Returns:
the Package this test case.

getTestProjectName

protected abstract String getTestProjectName()
Returns:
Name of test project for this test case.

getTestTargetJavaProject

public org.eclipse.jdt.core.IJavaProject getTestTargetJavaProject()
Returns:
The project where Java codes will be generated to.

getTestTargetJavaProjectName

protected abstract String getTestTargetJavaProjectName()
Returns:
Name of test project for this test case.

getUML2Model

public Model getUML2Model()
Returns:
The UML2 Model in the test project.

getPatternInstanceTargetCreationStrategy

public com.ibm.xtools.patterns.framework.test.strategies.PatternInstanceTargetCreationStrategy getPatternInstanceTargetCreationStrategy()
Set the class that is used to make the target for the pattern instance


getFirstRoot

public static EObject getFirstRoot(Resource resource)
Gets the first root object in the resource.

Parameters:
resource - The resource.
Returns:
The first object.

setUp

protected void setUp()
              throws Exception
Description copied from class: junit.extensions.TestSetup
Sets up the fixture. Override to set up additional fixture state.

Throws:
Exception
See Also:
TestCase.setUp()

tearDown

protected void tearDown()
                 throws Exception
Description copied from class: junit.extensions.TestSetup
Tears down the fixture. Override to tear down the additional fixture state.

Throws:
Exception
See Also:
TestCase.tearDown()

getTestDataManager

public TestDataManager getTestDataManager()
Returns:
Returns the m_testDataManager.

getPatternParameters

public IParameterDescriptor[] getPatternParameters()

getTestPreferences

public AbstractTestSetup.TestPreferences getTestPreferences()

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.