Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testThrowingFullLayout failed #71

Closed
AresEkb opened this issue May 13, 2020 · 8 comments
Closed

testThrowingFullLayout failed #71

AresEkb opened this issue May 13, 2020 · 8 comments

Comments

@AresEkb
Copy link
Contributor

AresEkb commented May 13, 2020

Hi

I cloned the repository and initiated a build process gradlew build.

I've got a failed testThrowingFullLayout:

org.junit.ComparisonFailure: expected:<...ullPointerException)[
]
> but was:<...ullPointerException)[]
>
	at org.junit.Assert.assertEquals(Assert.java:115)
	at org.junit.Assert.assertEquals(Assert.java:144)
	at org.eclipse.sprotty.DefaultDiagramServerTest.testThrowingFullLayout(DefaultDiagramServerTest.java:369)

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 of testThrowingFullLayout and commented out assertEquals. But I can't build the project:
Execution failed for task ':org.eclipse.sprotty.layout:generateTestXtext'.
caused by
java.lang.NoSuchMethodError: 'void com.google.common.base.Throwables.throwIfUnchecked(java.lang.Throwable)'

Could you please help to fix it?

@spoenemann
Copy link
Contributor

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)

@AresEkb
Copy link
Contributor Author

AresEkb commented May 13, 2020

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.

@AresEkb
Copy link
Contributor Author

AresEkb commented May 13, 2020

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.

@spoenemann
Copy link
Contributor

I have no idea either :-(

@AresEkb
Copy link
Contributor Author

AresEkb commented May 13, 2020

The same error here: eclipse/xtext#1391
Asked Xtext team: eclipse/xtext#1772

@AresEkb
Copy link
Contributor Author

AresEkb commented May 13, 2020

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"]
]>

@spoenemann
Copy link
Contributor

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?

@AresEkb
Copy link
Contributor Author

AresEkb commented May 13, 2020

Thanks! All tests are passed now. I created a pull request #72

@AresEkb AresEkb closed this as completed May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants