Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Export-Package: org.eclipse.e4.ui.tests.css.core;x-internal:=true,
org.eclipse.e4.ui.tests.css.core.util;x-internal:=true
Automatic-Module-Name: org.eclipse.e4.ui.tests.css.core
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)",
org.w3c.css.sac;version="1.3.0"
Bundle-Vendor: %Bundle-Vendor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil;
Expand Down Expand Up @@ -69,12 +67,7 @@ void testAttributeSelector() throws Exception {
}

@Test
void testErrorAttributeSelector() throws IOException {
try {
engine.parseSelectors("*[class='Class1'"); // missing ']'
fail("Parser should have errored on missing bracket");
} catch (CSSParseException e) {
// ignore
}
void testErrorAttributeSelector() {
assertThrows(CSSParseException.class, () -> engine.parseSelectors("*[class='Class1'")); // missing ']'
}
}
1 change: 1 addition & 0 deletions tests/org.eclipse.e4.ui.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Import-Package: jakarta.annotation,
jakarta.inject,
org.osgi.service.event,
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)",
org.opentest4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
******************************************************************************/
package org.eclipse.e4.ui.tests.application;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -259,26 +259,9 @@ public void testFindElements_NullCheck() {
EModelService modelService = application.getContext().get(EModelService.class);
assertNotNull(modelService);

try {
modelService.find("a", null);
fail("An exception should have prevented a null parameter to find(*)");
} catch (IllegalArgumentException e) {
// expected
}

try {
modelService.findElements(null, null, null);
fail("An exception should have prevented a null parameter to findElements(*)");
} catch (IllegalArgumentException e) {
// expected
}

try {
modelService.findElements(null, null, null, null, EModelService.ANYWHERE);
fail("An exception should have prevented a null parameter to findElements(*)");
} catch (IllegalArgumentException e) {
// expected
}
assertThrows(IllegalArgumentException.class, () -> modelService.find("a", null));
assertThrows(IllegalArgumentException.class, () -> modelService.findElements(null, null, null));
assertThrows(IllegalArgumentException.class, () -> modelService.findElements(null, null, null, null, EModelService.ANYWHERE));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.List;
import org.eclipse.e4.ui.internal.workbench.E4XMIResource;
Expand All @@ -41,12 +41,8 @@ public void testLoadingInvalidContainments() {
ResourceSet set = new ResourceSetImpl();
Resource resource = null;

try {
resource = set.getResource(uri, true);
fail("This should have thrown an exception");
} catch (Exception e) {
resource = set.getResource(uri, false);
}
assertThrows(Exception.class, () -> set.getResource(uri, true));
resource = set.getResource(uri, false);

assertNotNull(resource);
assertEquals(E4XMIResource.class, resource.getClass());
Expand Down Expand Up @@ -75,17 +71,10 @@ public void testAddingInvalidElements() {
MApplication app = MApplicationFactory.INSTANCE.createApplication();
List l = app.getChildren();
l.add(MBasicFactory.INSTANCE.createWindow());
try {
l.add(MBasicFactory.INSTANCE.createPart());
fail("The adding of this should have failed");
} catch (IllegalArgumentException | ArrayStoreException | ClassCastException e) {
// EList.add says this is the expected exception, although testing
// indicates its one of the two previous exceptions that is really
// thrown.
// See bug 407539
} catch (Exception e) {
throw new RuntimeException(e);
}
// EList.add says IllegalArgumentException is the expected exception, although
// testing indicates ArrayStoreException or ClassCastException may be thrown.
// See bug 407539
assertThrows(RuntimeException.class, () -> l.add(MBasicFactory.INSTANCE.createPart()));

l.add(MBasicFactory.INSTANCE.createWindow());
assertEquals(2, l.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.io.StringReader;
Expand Down Expand Up @@ -455,14 +455,9 @@ private static void testPutAndGetWithTitle(DialogSettingsChecker dialogSettingsC
}

@Test
@SuppressWarnings("resource")
public void testSaveWithIOException() {
final DialogSettings settings = new DialogSettings("test");
try {
settings.save(new BrokenWriter());
fail("IOException expected");
} catch (IOException e) {
}
assertThrows(IOException.class, () -> settings.save(new BrokenWriter()));
}

private static class BrokenWriter extends Writer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.jface.resource.JFaceResources;
Expand Down Expand Up @@ -238,12 +238,7 @@ public void testGetDecorationContext() {

@Test
public void testSetDecorationContext() {
try {
getDecoratingStyledLabelProvider().setDecorationContext(null);
fail("DecoratingStyledCellLabelProvider.setDecorationContext did not throw an exception when passed null");
} catch (AssertionFailedException e) {
// A Good Thing.
}
assertThrows(AssertionFailedException.class, () -> getDecoratingStyledLabelProvider().setDecorationContext(null));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package org.eclipse.jface.tests.labelProviders;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
Expand Down Expand Up @@ -141,12 +141,7 @@ public void testDefaultContextIsUsed() {
@Test
public void testSetDecorationContextNull() {
DecoratingStyledCellLabelProvider label = getDecoratingStyledCellLabelProvider(false);
try {
label.setDecorationContext(null);
fail("DecoratingStyledCellLabelProvider.setDecorationContext did not throw an exception when passed null");
} catch (AssertionFailedException e) {
// A Good Thing.
}
assertThrows(AssertionFailedException.class, () -> label.setDecorationContext(null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -1256,23 +1256,17 @@ public void testApplyTextPresentation() {
public void testIterator() {
// Test read over iterator end
Iterator<StyleRange> e= fTextPresentation.getAllStyleRangeIterator();
try {
assertThrows(NoSuchElementException.class, () -> {
for (int i= 0; i < 1000; i++) {
e.next();
}
fail("Iterator has no end.");
} catch (NoSuchElementException ex) {
// expected
}
e= fTextPresentation.getNonDefaultStyleRangeIterator();
try {
});
Iterator<StyleRange> e2= fTextPresentation.getNonDefaultStyleRangeIterator();
assertThrows(NoSuchElementException.class, () -> {
for (int i= 0; i < 1000; i++) {
e.next();
e2.next();
}
fail("Iterator has no end.");
} catch (NoSuchElementException ex) {
// expected
}
});
}

// helper method required as long as TextPresentation methods manipulate given arguments
Expand Down
Loading
Loading