Package gda

Class TestHelpers

java.lang.Object
gda.TestHelpers

public class TestHelpers extends Object
Collection of utility functions to assist testing.
  • Method Details

    • setUpTest

      public static String setUpTest(Class<?> testClass, String nameOfTest, boolean makedir) throws Exception
      Sets up of environment for the a test Set property so that output is to Nexus format file Uses MockJythonServerFacade and MockJythonServer to configure InterfaceProvider
      Parameters:
      testClass - e.g. gda.data.nexus.ScanToNexusTest
      nameOfTest - name of test method which the testClass e.g. testCreateScanFile
      makedir - if true the scratch dir is deleted and constructed
      Returns:
      The directory into which output will be sent
      Throws:
      Exception - if setup fails
    • setUpTest

      public static String setUpTest(Class<?> testClass, String nameOfTest, boolean makedir, Class<? extends DataWriter> dataWriterClass) throws Exception
      Throws:
      Exception
    • createTestScannable

      public static Scannable createTestScannable(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, String[] units)
    • createTestScannableGaussianXY

      public static Scannable createTestScannableGaussianXY(String name, Double xPosition, String xName, String yName, Double center, Double width, Double magnitude, Double pcNoise, int level, String outputFormatx, String outputFormaty, String unitsx, String unitsy)
    • createTestScannableSine

      public static Scannable createTestScannableSine(String name, Double xPosition, Double magnitude, Double pcNoise, String xName, String yName, int level, String outputFormatx, String outputFormaty, String unitsx, String unitsy)
    • createTestDetector

      public static Detector createTestDetector(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, NexusGroupData data, String filename, String description, String detectorID, String detectorType)
    • createTestCounterTimer

      public static Detector createTestCounterTimer(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, NexusGroupData data, String filename, String description, String detectorID, String detectorType, String[] channelNames)
    • createTestFileDetector

      public static Detector createTestFileDetector(String name, int level, String fileNameFormat, int[] dim, String description, String detectorID, String detectorType)
    • createTestISubDetector

      public static NexusDetector createTestISubDetector(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, NexusGroupData data, String filename, String description, String detectorID, String detectorType)
    • createTestNexusGroupData

      public static NexusGroupData createTestNexusGroupData(Class<? extends org.eclipse.january.dataset.Dataset> clazz, int[] shape, boolean useSuperToString)
    • createTestFactory

      public static Factory createTestFactory()
      Returns:
      Factory implementation that can be used for testing - simply add findables and add to Finder instance
    • deserialiseDocument

      public static final <T> T deserialiseDocument(String resourcePath, Class<T> documentClass) throws GDAException
      Deserialise a simple class from a JSON document. The class should not require custom deserialiser.
      Type Parameters:
      T - the Class of the object to deserialise
      Parameters:
      resourcePath - the source relative path where the file is
      documentClass - the Class representing the document to deserialise
      Returns:
      the deserialised object class
      Throws:
      GDAException - if an IOException occours