TNS Internal:NDR/Testing

From NSDLWiki

Jump to: navigation, search



NDR Testing

Repository Testing

Source Code Location: repository/trunk/src/java/org/nsdl/repository
Test Code Location: repository/trunk/test/java/org/nsdl/repository

/AllUnitTests -- will runs AllUnitTests in each subdirectory which runs AllUnitTests in each subdirectory, etc.

ex. api/AllUnitTests runs tests in api direapi/auth/AllUnitTests

approximately 275 tests total in 50 test files

Coverage: approximately 60%-70%

Immulating Fedora

lib/h2.jsp - embedded database to hold triples that allows for MPT Store queries

/impl/fedora - holds mocked up NDR objects for use with tests

/impl/fedora/MockFedoraNDRAccess - creates Map objects of a bunch of NDR objects

  MockMutableObject creates the objects

calls fedora.getRI() which comes from MockFedoraAccess used to create mock triples

  purge() - removes all the triples

/impl/fedora/MockFedoraAccess - creates RISearchEngine

Any class beginning with Mock means the class is used to simulate Fedora or some other core functionality setting state, etc.

Typical Test

@BeforeClass -- executed when this file of tests runs

  • creates filter = HandleManagementFilter -- This is the class that is being tested.
  • creates ndr = MockFedoraNDRAccess -- mocked up object stuff for testing only

@Before -- executed before each individual test in the file

  • creates HandleProbeInterface -- used to mock up handle processing
    • processes getHandle() calls
    • processes deleteHandle() calls
  • filter.setHandleFactory -- makes real live filter being tested use our mock handle processor


  • MockFilterClass -- used to setup the state simulating a new object
  • NDRObject o = ndr.newObject(Type.Resource) -- example of creating a new mock object (mock because ndr is mock)

Java Toolkit Testing

Source Code Location: toolkit/trunk/src/java/org/nsdl/repository
Test Code Location: repository/branches/test/junit/org/nsdl/repository

  • repository acess is real
  • it may use mock java objects in certain places
Personal tools