org.ccnx.ccn.test.CCNTestHelper Class Reference

Utility class to provide facilities to be used by all of the CCN tests, most importantly a standardized namespace for them to write their data into. More...

List of all members.

Public Member Functions

 CCNTestHelper (String testClassName)
 Create a test helper for a named unit test class.
 CCNTestHelper (ContentName externalPrefix, String testClassName)
 CCNTestHelper (Class<?> unitTestClass)
 Create a test helper for a specified unit test class.
 CCNTestHelper (ContentName externalPrefix, Class<?> unitTestClass)
 Create a test helper for a specified unit test class.
ContentName getClassNamespace ()
 Retrieve the timestamped, top-level name for data generated by this set of test cases.
ContentName getClassChildName (String childName)
 Helper method to build child names for the class under test.
ContentName getTestNamespace (String testName)
 Retrieve a name for data for a specific test.
ContentName getTestChildName (String testName, String childName)
 Helper method to build child names for a specific test.
CCNTime getTestTime ()
 Get the timestamp used for this test run.

Protected Member Functions

ContentName testPrefix ()

Static Protected Attributes

static final String TEST_PREFIX_STRING = "/ccnx.org/test"
static ContentName TEST_PREFIX

Static Package Functions

 [static initializer]

Package Attributes

ContentName _testNamespace
String _testName
CCNTime _testTime

Detailed Description

Utility class to provide facilities to be used by all of the CCN tests, most importantly a standardized namespace for them to write their data into.

Given a unit test class named UnitTestClass, we name all the data generated by that test class as /ccnx.org/test/UnitTestClass-TIMESTAMP

for a unit test UnitTest in that class, ideally the data for that specific unit test will be stored under /ccnx.org/test/UnitTestClass-TIMESTAMP/UnitTest

To use, make a static CCNTestHelper in your test class, e.g.:

static CCNTestHelper testHelper = new CCNTestHelper(TestClass.class);

and then in a test called TestFoo, get the name prefix to use for generated data by:

ContentName dataPrefix = testHelper.getTestNamespace("TestFoo");

for data shared across tests, use the class-level name prefix:

ContentName sharedFileName = ContentName.fromNative(testHelper.getClassNamespace(), "shared_file.txt");


Constructor & Destructor Documentation

org.ccnx.ccn.test.CCNTestHelper.CCNTestHelper ( String  testClassName  ) 

Create a test helper for a named unit test class.

Parameters:
testClassName The class name, if the package is included it will be stripped.
org.ccnx.ccn.test.CCNTestHelper.CCNTestHelper ( Class<?>  unitTestClass  ) 

Create a test helper for a specified unit test class.

Parameters:
unitTestClass The class containing the unit tests.
org.ccnx.ccn.test.CCNTestHelper.CCNTestHelper ( ContentName  externalPrefix,
Class<?>  unitTestClass 
)

Create a test helper for a specified unit test class.

Parameters:
unitTestClass The class containing the unit tests.

Member Function Documentation

ContentName org.ccnx.ccn.test.CCNTestHelper.getClassNamespace (  ) 

Retrieve the timestamped, top-level name for data generated by this set of test cases.

Returns:
the name prefix to use for data shared across this set of unit tests.
ContentName org.ccnx.ccn.test.CCNTestHelper.getTestNamespace ( String  testName  ) 

Retrieve a name for data for a specific test.

Parameters:
testName the name of the test method, as a string
Returns:
the name prefix to use for data generated by that test
CCNTime org.ccnx.ccn.test.CCNTestHelper.getTestTime (  ) 

Get the timestamp used for this test run.

All data is gathered under the same timestamp.

Returns:
the timestamp

The documentation for this class was generated from the following file:
Generated on Fri May 13 16:27:51 2011 for Content-Centric Networking in Java by  doxygen 1.6.3