Package com.e1c.langtool.testing
Class TestingUtil
java.lang.Object
com.e1c.langtool.testing.TestingUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final booleanstatic final ICollectingParametersstatic final ICollectingParameters -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertFvEquals(FeatureValue fv, String key, String value, boolean isComputedValue, FeatureSettings FeatureSettings, String res, int localStringsSize) Assert thatFeatureValueis equals expected values of fields.static voidcopyResource(String sourceName, org.eclipse.core.resources.IProject project, String targetName, Class<?> clazz) Copy bundle resource file content to any workspace file.static StringprintCollectorResultCheckCode(List<FeatureValue> result, String reourceIdConstantName, Class<?>... featureSettingsliteralClass) Prints the collector result check code.static StringreadFileContent(org.eclipse.core.resources.IFile file) Read workspace file content with system line separator.static StringreadResourceContent(String filePath, Class<?> clazz) Read file resource content of some bundle.static StringreadTestDataFile(String filePath) Read test data file string lines.static voidreplaceFileContent(org.eclipse.core.resources.IFile oldFile, File newFile) Replace workspace file content with content from any other file.static voidsetFileContentFromString(org.eclipse.core.resources.IFile file, String content) Sets the workspace file content from string.static voidupdateFileContent(org.eclipse.core.resources.IFile file, InputStream stream) Update workspace file content from stream and wait until the workspace reacts on refresh.
-
Field Details
-
PARAMS_FULL
-
PARAMS_OBJECT_ONLY
-
AUTOCOMPUTED
public static final boolean AUTOCOMPUTED- See Also:
-
NOT_AUTOCOMPUTED
public static final boolean NOT_AUTOCOMPUTED- See Also:
-
-
Method Details
-
assertFvEquals
public static void assertFvEquals(FeatureValue fv, String key, String value, boolean isComputedValue, FeatureSettings FeatureSettings, String res, int localStringsSize) Assert thatFeatureValueis equals expected values of fields.- Parameters:
fv- the Feature Valuekey- the feature keyvalue- the valueisComputedValue- the is computed value or notFeatureSettings- the feature settingsres- the resource ID pathlocalStringsSize- 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 resultreourceIdConstantName- the reource id constant namefeatureSettingsliteralClass- the feature settingsliteral classes- Returns:
- the string
-
readTestDataFile
Read test data file string lines.- Parameters:
filePath- the file path to read, cannot benull.- 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 benull.- Returns:
- the string in UTF-8
- Throws:
org.eclipse.core.runtime.CoreException- the core exceptionIOException- 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 benull.clazz- any class of the bundle, cannot benull.- Returns:
- the string in UTF-8 with system line separator
- Throws:
org.eclipse.core.runtime.CoreException- the core exceptionIOException- 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 benull.content- the content, cannot benull.- 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 benull.newFile- the new file, cannot benull.- 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 benull.stream- the stream, cannot benull.- 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 benull.project- the target project, cannot benull.targetName- the target name of the file in the project, cannot benull.clazz- any class of the bundle that contains the source file, cannot benull.- Throws:
Exception- the exception
-