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

improved tests for BaseUtilities.toFile & BaseUtitities.toURI #3902

Merged
merged 1 commit into from
Apr 14, 2022
Merged

improved tests for BaseUtilities.toFile & BaseUtitities.toURI #3902

merged 1 commit into from
Apr 14, 2022

Conversation

lbownik
Copy link
Contributor

@lbownik lbownik commented Mar 31, 2022

improved tests for BaseUtilities.toFile & BaseUtitities.toURI

split "testFileURI" method into multiple seperated methods
added tests checking whether exception are thrown properly
removed "testFieURI"

Copy link
Contributor

@vieiro vieiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner now, thanks!
Maybe we want to drop some return statements in the test?

toFile(new URI("http://example.com"));
fail();
} catch (final IllegalArgumentException e) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to remove this "return" here, so tests proceeds with statements below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my mistake - I realized it as well

toFile(new URI("mailto:person@example.com"));
fail();
} catch (final IllegalArgumentException e) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my mistake

@mbien mbien added this to the NB14 milestone Apr 1, 2022
Copy link
Contributor

@vieiro vieiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good now, but travis keeps on failing on this test:

=================== JUnit Report Summary / failed tests ===================

org.openide.util.BaseUtilitiesTest
      failed: test_toFile_returnsFile_whenGivenCorrectURI

====================== JUnit failure details ===============================

Suite: org.openide.util.BaseUtilitiesTest
      test_toFile_returnsFile_whenGivenCorrectURI FAILED :  expected:<C:\some\path #1> but was:</C:/some/path #1>
          junit.framework.AssertionFailedError: expected:<C:\some\path #1> but was:</C:/some/path #1>
          	at org.openide.util.BaseUtilitiesTest.test_toFile_returnsFile_whenGivenCorrectURI(BaseUtilitiesTest.java:173)
          	at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:77)
          	at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:476)
          	at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:402)
          	at java.lang.Thread.run(Thread.java:748)
------------- End suite org.openide.util.BaseUtilitiesTest ------------

======================= End of JUnit report ===============================

@vieiro
Copy link
Contributor

vieiro commented Apr 12, 2022

Travis build reports failing tests:

travis_fold:start:after_failure.1
�[0Ktravis_time:start:1bcf37e0
�[0K$ nbbuild/travis/print-junit-report.sh
=================== JUnit Report Summary / failed tests ===================

org.openide.util.BaseUtilitiesTest
      failed: test_toURI_producesURI_wchichResolvesAndWrapsProperly
      failed: test_toFile_returnsFile_whenGivenCorrectURI

====================== JUnit failure details ===============================

Suite: org.openide.util.BaseUtilitiesTest
      test_toURI_producesURI_wchichResolvesAndWrapsProperly FAILED :  The java.nio.file.Path.toUri is inconsistent with java.io.File.toURI expected:<file:///home/travis/build/apache/netbeans/k%C3%BC%C3%B1> but was:<file:/home/travis/build/apache/netbeans/küñ>
          junit.framework.AssertionFailedError: The java.nio.file.Path.toUri is inconsistent with java.io.File.toURI expected:<file:///home/travis/build/apache/netbeans/k%C3%BC%C3%B1> but was:<file:/home/travis/build/apache/netbeans/küñ>
          	at org.openide.util.BaseUtilitiesTest.test_toURI_producesURI_wchichResolvesAndWrapsProperly(BaseUtilitiesTest.java:296)
          	at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:77)
          	at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:476)
          	at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:402)
          	at java.lang.Thread.run(Thread.java:748)
      test_toFile_returnsFile_whenGivenCorrectURI FAILED :  expected:<C:\some\path #1> but was:</C:/some/path #1>
          junit.framework.AssertionFailedError: expected:<C:\some\path #1> but was:</C:/some/path #1>
          	at org.openide.util.BaseUtilitiesTest.test_toFile_returnsFile_whenGivenCorrectURI(BaseUtilitiesTest.java:175)
          	at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:77)
          	at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:476)
          	at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:402)
          	at java.lang.Thread.run(Thread.java:748)
------------- End suite org.openide.util.BaseUtilitiesTest ------------

======================= End of JUnit report ===============================
travis_time:end:1bcf37e0:start=1649735074301154712,finish=1649735074406306220,duration=105151508,event=after_failure
�[0Ktravis_fold:end:after_failure.1
�[0Ktravis_fold:start:after_failure.2
�[0Ktravis_time:start:02074a67
�[0K$ sleep 3
travis_time:end:02074a67:start=1649735074411606532,finish=1649735077416529493,duration=3004922961,event=after_failure
�[0Ktravis_fold:end:after_failure.2

- removed bogus "return" statements
- separated "os-dependent" and "os-independent" tests
- added cases to "toObjectArray" and "toPrimitiveArray"
- fixed Travis issues (I hope)
@vieiro
Copy link
Contributor

vieiro commented Apr 13, 2022

Looks sane to me now, and all tests pass properly. @mbien would you please take a second look?

Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked every single assert but it seems to contain everything what the other version had, plus additional cases for more coverage.

looks good to me.

@vieiro vieiro merged commit 5a49cd3 into apache:master Apr 14, 2022
@vieiro
Copy link
Contributor

vieiro commented Apr 14, 2022

Thank you @lbownik !

@lbownik
Copy link
Contributor Author

lbownik commented Oct 11, 2022 via email

@lbownik
Copy link
Contributor Author

lbownik commented Oct 11, 2022 via email

@mbien mbien added the Platform [ci] enable platform tests (platform/*) label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code cleanup Platform [ci] enable platform tests (platform/*) tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants