Closed AresEkb closed 4 years ago
Are you working on Windows? If yes I guess it's a line ending issue. Does the test work if you append .trim
like this?
assertEquals('''
ERROR: Exception while processing ComputedBoundsAction. (java.lang.NullPointerException)
'''.toString.trim, logger.toString.trim)
Thanks for the answer! Yes, I use Windows. I can't add trim
and test it because in that case I get:
Execution failed for task ':org.eclipse.sprotty.layout:generateTestXtext'.
Caused by: java.lang.NoSuchMethodError: 'void com.google.common.base.Throwables.throwIfUnchecked(java.lang.Throwable)'
at org.eclipse.xtext.xbase.typesystem.internal.DefaultReentrantTypeResolver.reentrantResolve(DefaultReentrantTypeResolver.java:145)
at org.eclipse.xtext.xbase.typesystem.internal.CompoundReentrantTypeResolver.reentrantResolve(CompoundReentrantTypeResolver.java:79)
I don't understand yet how to fix it.
Throwables.throwIfUnchecked(java.lang.Throwable)
is available in guava since version 20.0.
org.eclipse.sprotty
project depends on guava 27.1-jre. I have no idea why the method is unavailable.
I have no idea either :-(
The same error here: https://github.com/eclipse/xtext/issues/1391 Asked Xtext team: https://github.com/eclipse/xtext/issues/1772
Thanks for help!
You are right. Addition of trim
solved the issue.
My 2nd issue with Xtext was caused by JAVA_HOME set to JDK 13. Old version of Xtext doesn't support this JDK. So switching JAVA_HOME to JDK 1.8 solved the error.
The following tests are failed now:
ElkLayoutEngineTest.testLayoutCrossHierarchyEdge1
ElkLayoutEngineTest.testLayoutCrossHierarchyEdge2
ElkLayoutEngineTest.testLayoutCrossHierarchyEdge3
ElkLayoutEngineTest.testLayoutCrossHierarchyEdge4
Errors for all tests are similar:
org.junit.ComparisonFailure: expected:<SEdge [[
sourceId = "g/node0/node0"
targetId = "g/node1/node0"
routingPoints = ArrayList (
Point [
x = -20.0
y = 10.0
],
Point [
x = -5.0
y = 15.0
],
Point [
x = 10.0
y = 10.0
]
)
selected = false
type = "edge"
id = "g/node1/edge1"
]
]> but was:<SEdge [[
sourceId = "g/node0/node0"
targetId = "g/node1/node0"
routingPoints = ArrayList (
Point [
x = -20.0
y = 10.0
],
Point [
x = -5.0
y = 15.0
],
Point [
x = 10.0
y = 10.0
]
)
selected = false
type = "edge"
id = "g/node1/edge1"]
]>
The visible difference between the results is the following (maybe line endings are different too):
id = "g/node1/edge1"
]
]>
id = "g/node1/edge1"]
]>
Yes, probably the same line ending problem. But if there are line endings in the middle of the string, trim
won't help. It could be solved with a utility function like this:
def String toUnixLineEndings(String s) {
s.replaceAll('\\r\\n', '\\n')
}
@AresEkb could you try that, and if it helps would you like to create a pull request fixing the tests on Windows?
Thanks! All tests are passed now. I created a pull request https://github.com/eclipse/sprotty-server/pull/72
Hi
I cloned the repository and initiated a build process
gradlew build
.I've got a failed
testThrowingFullLayout
:Expected and actual values are trimmed. However I guess that NPE was thrown as expected. The problem is that exception text differs, maybe because of different JDK version.
I tried to change file https://github.com/eclipse/sprotty-server/blob/master/org.eclipse.sprotty/src/test/java/org/eclipse/sprotty/DefaultDiagramServerTest.xtend
Added
println(logger.toString)
to the end oftestThrowingFullLayout
and commented outassertEquals
. But I can't build the project:Execution failed for task ':org.eclipse.sprotty.layout:generateTestXtext'.
caused byjava.lang.NoSuchMethodError: 'void com.google.common.base.Throwables.throwIfUnchecked(java.lang.Throwable)'
Could you please help to fix it?