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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -43,11 +43,7 @@ public class BundleResourceProviderTest extends DesignerTestCase {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_noSuchBundle() throws Exception {
try {
BundleResourceProvider.get("no.such.bundle");
fail();
} catch (AssertionFailedException e) {
}
assertThrows(AssertionFailedException.class, () -> BundleResourceProvider.get("no.such.bundle"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -78,13 +78,9 @@ int foo(int value) {
return value;
}
}""");
try {
evaluateSingleMethod(typeDeclaration, "foo(int)");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NO_METHOD_INVOCATION, e.getCode());
}
Throwable e_ = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "foo(int)"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NO_METHOD_INVOCATION, e.getCode());
}

/**
Expand Down Expand Up @@ -128,11 +124,7 @@ public Object evaluationFailed(Expression expression_, Throwable e) throws Excep
};
}
// evaluate, we don't return value, so evaluation failed
try {
AstEvaluationEngine.evaluate(context, expression);
fail();
} catch (Throwable e) {
}
assertThrows(Throwable.class, () -> AstEvaluationEngine.evaluate(context, expression));
assertTrue(evaluationFailed.get());
}

Expand Down Expand Up @@ -222,13 +214,9 @@ public void test_SimpleName_notFound() throws Exception {
" }",
"}"));
waitForAutoBuild();
try {
evaluateSingleMethod(typeDeclaration, "getValue()");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NO_SIMPLE_NAME_FOUND, e.getCode());
}
Throwable e_ = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "getValue()"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NO_SIMPLE_NAME_FOUND, e.getCode());
}

@Test
Expand Down Expand Up @@ -329,13 +317,9 @@ public int foo(int value) {
return value;
}
}""");
try {
evaluateSingleMethod(typeDeclaration, "foo(int)");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NO_METHOD_INVOCATION, e.getCode());
}
Throwable e_ = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "foo(int)"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NO_METHOD_INVOCATION, e.getCode());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -163,13 +163,9 @@ public Test(int a) {
public Test(double b) {
}
}""");
try {
ExecutionFlowUtils.getExecutionFlowConstructor(typeDeclaration);
fail();
} catch (MultipleConstructorsError e) {
assertSame(null, e.getEditor());
assertSame(null, e.getTypeDeclaration());
}
MultipleConstructorsError e = assertThrows(MultipleConstructorsError.class, () -> ExecutionFlowUtils.getExecutionFlowConstructor(typeDeclaration));
assertSame(null, e.getEditor());
assertSame(null, e.getTypeDeclaration());
}
/**
* {@link ExecutionFlowProvider} that selects constructor with single <code>int</code> parameter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -113,13 +113,9 @@ public int instancePublicMethod(int i) {
}
}""");
waitForAutoBuild();
try {
evaluateSingleMethod(typeDeclaration, "root()");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_LOCAL_METHOD_INVOCATION, e.getCode());
}
Throwable e_ = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "root()"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_LOCAL_METHOD_INVOCATION, e.getCode());
}

/**
Expand Down Expand Up @@ -158,18 +154,14 @@ public int instancePublicMethod() {
}""");
waitForAutoBuild();
//
try {
evaluateSingleMethod(typeDeclaration, "root()");
fail();
} catch (Throwable e) {
{
Throwable rootCause = DesignerExceptionUtils.getRootCause(e);
Assertions.assertThat(rootCause).isExactlyInstanceOf(ArithmeticException.class);
}
{
DesignerException de = DesignerExceptionUtils.getDesignerException(e);
assertEquals(ICoreExceptionConstants.EVAL_LOCAL_METHOD_INVOCATION, de.getCode());
}
Throwable e = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "root()"));
{
Throwable rootCause = DesignerExceptionUtils.getRootCause(e);
Assertions.assertThat(rootCause).isExactlyInstanceOf(ArithmeticException.class);
}
{
DesignerException de = DesignerExceptionUtils.getDesignerException(e);
assertEquals(ICoreExceptionConstants.EVAL_LOCAL_METHOD_INVOCATION, de.getCode());
}
}

Expand Down Expand Up @@ -258,14 +250,10 @@ public long callMe() {

@Test
public void test_methodInvocation_invalidArguments() throws Exception {
try {
m_ignoreModelCompileProblems = true;
evaluateExpression("Runtime.getRuntime().totalMemory(123)", "long");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_METHOD, e.getCode());
}
m_ignoreModelCompileProblems = true;
Throwable e_ = assertThrows(Throwable.class, () -> evaluateExpression("Runtime.getRuntime().totalMemory(123)", "long"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_METHOD, e.getCode());
}

@Test
Expand All @@ -277,13 +265,9 @@ public int root() {
return obj.hashCode();
}
}""");
try {
evaluateSingleMethod(typeDeclaration, "root()");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NULL_INVOCATION_EXPRESSION, e.getCode());
}
Throwable e_ = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "root()"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_NULL_INVOCATION_EXPRESSION, e.getCode());
}

@Test
Expand Down Expand Up @@ -558,9 +542,7 @@ public void test_InvocationEvaluatorInterceptor_rewriteException() throws Except
"<interceptor class='" + interceptorClass.getName() + "'/>");
testBundle.install();
try {
evaluateExpression("new MyObject()", "Object");
fail();
} catch (Throwable e) {
Throwable e = assertThrows(Throwable.class, () -> evaluateExpression("new MyObject()", "Object"));
e = DesignerExceptionUtils.getRootCause(e);
assertEquals("rewrite", e.getMessage());
} finally {
Expand Down Expand Up @@ -588,14 +570,10 @@ public void test_creation_2() throws Exception {

@Test
public void test_creation_invalidArguments() throws Exception {
try {
m_ignoreModelCompileProblems = true;
evaluateExpression("new java.util.ArrayList(-3)", "java.lang.Object");
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_CONSTRUCTOR, e.getCode());
}
m_ignoreModelCompileProblems = true;
Throwable e_ = assertThrows(Throwable.class, () -> evaluateExpression("new java.util.ArrayList(-3)", "java.lang.Object"));
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_CONSTRUCTOR, e.getCode());
}

@Test
Expand Down Expand Up @@ -859,12 +837,8 @@ public Object foo() {
};
}
}""");
try {
evaluateSingleMethod(typeDeclaration, "foo()");
fail();
} catch (Throwable e) {
assertTrue(AnonymousEvaluationError.is(e));
}
Throwable e = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "foo()"));
assertTrue(AnonymousEvaluationError.is(e));
}

/**
Expand Down Expand Up @@ -1063,13 +1037,9 @@ public Object foo() {
}
}""");
// evaluate, but default constructor (used in interceptor) throws exception
try {
evaluateSingleMethod(typeDeclaration, "foo()");
fail();
} catch (Throwable e_) {
Throwable e = DesignerExceptionUtils.getRootCause(e_);
assertInstanceOf(IllegalStateException.class, e);
}
Throwable e_ = assertThrows(Throwable.class, () -> evaluateSingleMethod(typeDeclaration, "foo()"));
Throwable e = DesignerExceptionUtils.getRootCause(e_);
assertInstanceOf(IllegalStateException.class, e);
} finally {
testBundle.uninstall();
}
Expand Down Expand Up @@ -1196,14 +1166,10 @@ public void test_SuperMethodInvocation_withException() throws Exception {
"}"));
waitForAutoBuild();
// validate
try {
m_ignoreModelCompileProblems = true;
test_SuperMethodInvocation2();
fail();
} catch (Throwable e_) {
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_SUPER_METHOD, e.getCode());
}
m_ignoreModelCompileProblems = true;
Throwable e_ = assertThrows(Throwable.class, () -> test_SuperMethodInvocation2());
DesignerException e = DesignerExceptionUtils.getDesignerException(e_);
assertEquals(ICoreExceptionConstants.EVAL_SUPER_METHOD, e.getCode());
}

private Object test_SuperMethodInvocation2() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -568,11 +568,7 @@ public void test_broadcast_ObjectEventListener_refresh() throws Exception {
parent.addBroadcastListener(listener);
// case 1: only root can be refreshed
{
try {
child.refresh();
fail();
} catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class, child::refresh);
//
inOrder.verifyNoMoreInteractions();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -29,11 +29,7 @@ public class ObjectReferenceInfoTest extends DesignerTestCase {
*/
@Test
public void test_notNull() throws Exception {
try {
new TestObjectInfo(null);
fail();
} catch (Throwable e) {
}
assertThrows(NullPointerException.class, () -> new ObjectReferenceInfo(null));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -58,31 +58,15 @@ public void test() throws Exception {
assertSame(button, association.getJavaInfo());
assertTrue(association.canDelete());
// no getSource()
try {
association.getSource();
fail();
} catch (NotImplementedException e) {
}
assertThrows(NotImplementedException.class, association::getSource);
// no getStatement()
assertNull(association.getStatement());
// can not be moved
try {
association.move(null);
fail();
} catch (NotImplementedException e) {
}
assertThrows(NotImplementedException.class, () -> association.move(null));
// can not be reparented
try {
association.setParent(null);
fail();
} catch (NotImplementedException e) {
}
assertThrows(NotImplementedException.class, () -> association.setParent(null));
// can not be morphed
try {
association.getCopy();
fail();
} catch (NotImplementedException e) {
}
assertThrows(NotImplementedException.class, association::getCopy);
// can not be removed
{
association.remove();
Expand Down
Loading
Loading