Class TestingUtil

java.lang.Object
com.e1c.langtool.testing.TestingUtil

public class TestingUtil extends Object
  • Field Details

  • Method Details

    • assertFvEquals

      public static void assertFvEquals(FeatureValue fv, String key, String value, boolean isComputedValue, FeatureSettings FeatureSettings, String res, int localStringsSize)
      Assert that FeatureValue is equals expected values of fields.
      Parameters:
      fv - the Feature Value
      key - the feature key
      value - the value
      isComputedValue - the is computed value or not
      FeatureSettings - the feature settings
      res - the resource ID path
      localStringsSize - the local strings size
    • printCollectorResultCheckCode

      public static String printCollectorResultCheckCode(List<FeatureValue> result, String reourceIdConstantName, Class<?>... featureSettingsliteralClass)
      Prints the collector result check code.
      
              String checkText = TestingUtil.printCollectorResultCheckCode(result, "TEST_RESOURCE", Literals.class);
              System.out.println("// Method: " + Thread.currentThread().getStackTrace()[1].getMethodName()); //$NON-NLS-1$
              System.out.println(checkText);
              
      Parameters:
      result - the result
      reourceIdConstantName - the reource id constant name
      featureSettingsliteralClass - the feature settingsliteral classes
      Returns:
      the string
    • readTestDataFile

      public static String readTestDataFile(String filePath) throws IOException
      Read test data file string lines.
      Parameters:
      filePath - the file path to read, cannot be null.
      Returns:
      the string of UTF-8 content with current system line separators.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • readFileContent

      public static String readFileContent(org.eclipse.core.resources.IFile file) throws org.eclipse.core.runtime.CoreException, IOException
      Read workspace file content with system line separator.
      Parameters:
      file - the file, cannot be null.
      Returns:
      the string in UTF-8
      Throws:
      org.eclipse.core.runtime.CoreException - the core exception
      IOException - Signals that an I/O exception has occurred.
    • readResourceContent

      public static String readResourceContent(String filePath, Class<?> clazz) throws org.eclipse.core.runtime.CoreException, IOException
      Read file resource content of some bundle.
      Parameters:
      filePath - the file path in the resource bundle, cannot be null.
      clazz - any class of the bundle, cannot be null.
      Returns:
      the string in UTF-8 with system line separator
      Throws:
      org.eclipse.core.runtime.CoreException - the core exception
      IOException - Signals that an I/O exception has occurred.
    • setFileContentFromString

      public static void setFileContentFromString(org.eclipse.core.resources.IFile file, String content) throws Exception
      Sets the workspace file content from string.
      Parameters:
      file - the file to set content, cannot be null.
      content - the content, cannot be null.
      Throws:
      Exception - the exception
    • replaceFileContent

      public static void replaceFileContent(org.eclipse.core.resources.IFile oldFile, File newFile) throws Exception
      Replace workspace file content with content from any other file.
      Parameters:
      oldFile - the old file, cannot be null.
      newFile - the new file, cannot be null.
      Throws:
      Exception - the exception
    • updateFileContent

      public static void updateFileContent(org.eclipse.core.resources.IFile file, InputStream stream) throws Exception
      Update workspace file content from stream and wait until the workspace reacts on refresh.
      Parameters:
      file - the file, cannot be null.
      stream - the stream, cannot be null.
      Throws:
      Exception - the exception
    • copyResource

      public static void copyResource(String sourceName, org.eclipse.core.resources.IProject project, String targetName, Class<?> clazz) throws Exception
      Copy bundle resource file content to any workspace file.
      Parameters:
      sourceName - the source name of the file in the bundle, cannot be null.
      project - the target project, cannot be null.
      targetName - the target name of the file in the project, cannot be null.
      clazz - any class of the bundle that contains the source file, cannot be null.
      Throws:
      Exception - the exception