下面列出了org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#org.eclipse.core.runtime.AssertionFailedException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Switching to the default Avaloq perspective and resets it.
*/
public static void switchAndResetPerspective() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
final IWorkbench workbench = PlatformUI.getWorkbench();
final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = null;
try {
page = workbench.showPerspective("com.avaloq.ice.perspectives.Development", window);
} catch (final WorkbenchException exception) {
// Try customer perspective
try {
page = workbench.showPerspective("com.avaloq.ice.perspectives.Development", window);
} catch (final WorkbenchException second) {
// Both perspectives are missing
throw new AssertionFailedException("Could not switch to Avaloq Perspective: " + exception.getLocalizedMessage());
}
}
if (page != null) {
page.resetPerspective();
}
}
});
}
/**
* Open view.
*
* @param id
* the view id, must not be {@code null}
*/
public static void openView(final String id) {
Assert.isNotNull(id, "id");
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id);
} catch (final PartInitException exception) {
throw new AssertionFailedException("Could not open change view: " + exception.getLocalizedMessage());
}
}
});
}
private SWTBotTreeItem checkForModelExistenceUI(final SWTBotTreeItem treeItem) {
try {
treeItem.expand();
SWTBotTreeItem models = treeItem.getNode("models");
models.expand();
return models.getNode(TEST_MODEL).select();
} catch(AssertionFailedException e) {
Assert.fail(e.getMessage());
}
return null;
}
@Test(expected = AssertionFailedException.class)
public void shouldDoSave_CreateAEmptyEPackageWhenContentIsNull() throws Exception {
fileStoreUnderTest.doSave(null);
BusinessObjectModel content = fileStoreUnderTest.getContent();
assertThat(content).isNotNull();
assertThat(content.getBusinessObjects()).isEmpty();
}
@Override
@Deprecated
public void addSrcPath(final String srcPath) {
throw new AssertionFailedException("srcPath should not be used in CustomClassAwareEcoreGenerator");
}
/**
* @param script
* @return
* @throws IOException
* @throws MisconfigurationException
*/
public static String[] makeExecutableCommandStrWithVMArgs(String jythonJar, String script, String basePythonPath,
String vmArgs, String... args) throws IOException, JDTNotAvailableException, MisconfigurationException {
IInterpreterManager interpreterManager = InterpreterManagersAPI.getJythonInterpreterManager();
String javaLoc = FileUtils.getFileAbsolutePath(JavaVmLocationFinder.findDefaultJavaExecutable());
File file = new File(javaLoc);
if (file.exists() == false) {
throw new RuntimeException("The java location found does not exist. " + javaLoc);
}
if (file.isDirectory() == true) {
throw new RuntimeException("The java location found is a directory. " + javaLoc);
}
if (!new File(jythonJar).exists()) {
throw new RuntimeException(StringUtils.format(
"Error. The default configured interpreter: %s does not exist!", jythonJar));
}
InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(jythonJar,
new NullProgressMonitor());
//pythonpath is: base path + libs path.
String libs = SimpleRunner.makePythonPathEnvFromPaths(info.libs);
FastStringBuffer jythonPath = new FastStringBuffer(basePythonPath, 128);
String pathSeparator = SimpleRunner.getPythonPathSeparator();
if (jythonPath.length() != 0) {
jythonPath.append(pathSeparator);
}
jythonPath.append(libs);
//may have the dir or be null
String cacheDir = null;
try {
AstPlugin plugin = AstPlugin.getDefault();
if (plugin != null) {
IPath stateLocation = plugin.getStateLocation();
File cacheDirFile = new File(stateLocation.toFile(), "jython_cache_dir");
cacheDirFile.mkdirs();
cacheDir = PydevPrefs.getEclipsePreferences().get(IInterpreterManager.JYTHON_CACHE_DIR,
cacheDirFile.toString());
}
} catch (AssertionFailedException e) {
//this may happen while running the tests... it should be ok.
cacheDir = null;
}
if (cacheDir != null && cacheDir.trim().length() == 0) {
cacheDir = null;
}
if (cacheDir != null) {
cacheDir = "-Dpython.cachedir=" + cacheDir.trim();
}
String[] vmArgsList = ProcessUtils.parseArguments(vmArgs);
String[] s = new String[] {
"-Dpython.path=" + jythonPath.toString(),
"-classpath",
jythonJar + pathSeparator + jythonPath,
"org.python.util.jython",
script
};
List<String> asList = new ArrayList<String>();
asList.add(javaLoc);
if (cacheDir != null) {
asList.add(cacheDir);
}
asList.addAll(Arrays.asList(vmArgsList));
asList.addAll(Arrays.asList(s));
asList.addAll(Arrays.asList(args));
return asList.toArray(new String[0]);
}
@Test(expected = AssertionFailedException.class)
public void shouldConstructor_ThrowAssertionFailedException() throws Exception {
new EMFResourceUtil(null);
}
@Test(expected = AssertionFailedException.class)
public void should_build_throw_an_AssertionFailedException_if_no_builder_is_set() throws Exception {
userTaskengineContractBuilder = new TaskContractEngineDefinitionBuilder();
userTaskengineContractBuilder.build(aContract);
}
/**
* Returns the full text of the first CcomboItem found with the given prefix.
* <p>
* <em>Note</em>: Throws an AssertionError if the item could not be found.
* </p>
*
* @param ccombo
* the ccomboBox to search in, must not be {@code null}
* @param prefix
* the prefix of the item to search for, must not be {@code null}
* @return the full name of the item as string, never {@code null}
*/
public static String getCcomboItemText(final SWTBotCCombo ccombo, final String prefix) {
Assert.isNotNull(ccombo, "ccombo");
Assert.isNotNull(prefix, "prefix");
for (String ccomboItem : ccombo.items()) {
if (ccomboItem.startsWith(prefix)) {
return ccomboItem;
}
}
throw new AssertionFailedException(NLS.bind("Must have a CcomboItem named ''{0}''.", prefix));
}
/**
* Returns the nearest parent of the given class. Fails if cannot find one.
* Returns the reference itself if is an instance of the given class.
*
* @param reference
* the reference element
* @param eClass
* the type
* @return any enclosing element of the given class
*/
public static <T extends Element> T getNearest(Element reference, EClass eClass) {
Optional<T> result = findNearest(reference, eClass);
return result.orElseThrow(() -> new AssertionFailedException("No '" + eClass.getName() + "' around "));
}