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

Use assertThrows in classes ActorCreationTest and OutputStreamSinkTest #30165

Merged
merged 2 commits into from
May 5, 2021
Merged

Use assertThrows in classes ActorCreationTest and OutputStreamSinkTest #30165

merged 2 commits into from
May 5, 2021

Conversation

Captain1653
Copy link
Contributor

Thare are many lines look like that:
try ... catch in tests. It can be replaced on assertThrows

Kind regards

@akka-ci
Copy link

akka-ci commented Apr 5, 2021

Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK ΤO ΤESΤ' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged.

For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask!

@johanandren
Copy link
Member

OK TO TEST

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels Apr 6, 2021
@akka-ci
Copy link

akka-ci commented Apr 6, 2021

Test FAILed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Apr 8, 2021
@akka-ci
Copy link

akka-ci commented Apr 8, 2021

Test FAILed.

@Captain1653
Copy link
Contributor Author

Captain1653 commented Apr 9, 2021

Hm... It looks like some infrastructure error
The command "curl -Ls https://git.io/jabba | bash && . ~/.jabba/jabba.sh" failed and exited with 1 during . Am I wrong?

And some strage test testWrongAnonymousInPlaceCreator . I refactored it, saved semantics, but it failed... Really strange for me.

@johanandren
Copy link
Member

Yeah, was something temporary yesterday, I'll trigger a rebuild.

@johanandren
Copy link
Member

PLS BUILD

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Apr 9, 2021
@akka-ci
Copy link

akka-ci commented Apr 9, 2021

Test FAILed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Apr 14, 2021
@akka-ci
Copy link

akka-ci commented Apr 14, 2021

Test FAILed.

@Captain1653
Copy link
Contributor Author

I don't understand indeed. The test testWrongAnonymousInPlaceCreator failed. Why? It depends on Java 8 Lambda? Should I revert my change?

@johanandren
Copy link
Member

Unless you can figure it out and make the test pass, yes revert please.

@akka-ci akka-ci added the validating PR is currently being validated by Jenkins label Apr 19, 2021
@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Apr 19, 2021
@akka-ci
Copy link

akka-ci commented Apr 19, 2021

Test PASSed.

@Captain1653
Copy link
Contributor Author

@johanandren review it, please

@octonato
Copy link
Member

octonato commented May 3, 2021

I found why that other test was not failing. That's because the original one was also not failing:

    try {
      Props.create(
          Actor.class,
          new Creator<Actor>() {
            @Override
            public Actor create() throws Exception {
              return null;
            }
          });
      assert false;
    } catch (IllegalArgumentException e) {
      assertEquals(
          "cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level",
          e.getMessage());
    }

That won't fail, because it is using java assertions. Assertions aren't enabled by default.

So, the Props.create pass (while the test tries to prove that it should fail).

Then, the assert isn't executed and the assertEquals inside the catch block never gets executed.

Replace the assert by org.junit.Assert.fail("above code should have failed"); and that test fails.

@octonato
Copy link
Member

octonato commented May 3, 2021

@Captain1653, do you want to take a stab on it and try to fix that test? By fixing, I mean, ensure that it will indeed fail the call and throw an IllegalArgumentException?

@Captain1653
Copy link
Contributor Author

Captain1653 commented May 3, 2021

@octonato Thank you for your explanation. I didn't guess))). Yes, I can try to do it. It looks interesting. Should it be some different issue and different PR? For me - yes, because it's the different problem (not refactor). What do you think?

P.S. I tried to search places with "assert " in source code. It was used many times.
Снимок экрана 2021-05-03 в 14 30 13

Is it worth to fix it in the different issue and different PR? (replace on assertEquals or similar)

Kind regards

@octonato
Copy link
Member

octonato commented May 3, 2021

Yes, you are right. I think we should fix it on a different PR. Let's not mix things.

@johanandren johanandren merged commit 1a36631 into akka:master May 5, 2021
@Captain1653 Captain1653 deleted the test-exception-handling branch May 5, 2021 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:stream tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants