org.eclipse.core.runtime.AssertionFailedException Java Examples

The following examples show how to use org.eclipse.core.runtime.AssertionFailedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
      }
    }
  });
}
 
Example #2
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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());
      }
    }
  });
}
 
Example #3
Source File: RenameSpecHandlerTest.java    From tlaplus with MIT License 5 votes vote down vote up
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;
}
 
Example #4
Source File: BusinessObjectModelFileStoreTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test(expected = AssertionFailedException.class)
public void shouldDoSave_CreateAEmptyEPackageWhenContentIsNull() throws Exception {
    fileStoreUnderTest.doSave(null);
    BusinessObjectModel content = fileStoreUnderTest.getContent();
    assertThat(content).isNotNull();
    assertThat(content.getBusinessObjects()).isEmpty();
}
 
Example #5
Source File: CustomClassAwareEcoreGenerator.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Deprecated
public void addSrcPath(final String srcPath) {
  throw new AssertionFailedException("srcPath should not be used in CustomClassAwareEcoreGenerator");
}
 
Example #6
Source File: SimpleJythonRunner.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @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]);
}
 
Example #7
Source File: EMFResourceUtilTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected = AssertionFailedException.class)
public void shouldConstructor_ThrowAssertionFailedException() throws Exception {
    new EMFResourceUtil(null);
}
 
Example #8
Source File: ContractEngineDefinitionBuilderTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected = AssertionFailedException.class)
public void should_build_throw_an_AssertionFailedException_if_no_builder_is_set() throws Exception {
    userTaskengineContractBuilder = new TaskContractEngineDefinitionBuilder();
    userTaskengineContractBuilder.build(aContract);
}
 
Example #9
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * 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));
}
 
Example #10
Source File: MDDUtil.java    From textuml with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * 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 "));
}