Skip to content

Conversation

@hiranya911
Copy link
Contributor

@hiranya911 hiranya911 commented Apr 17, 2017

Remove Redundant Utils

Following classes from the internal package have been removed.

  • Base64 and Base64Utils
  • Preconditions
  • Objects

Invocations of these utils have been replaced by calls to the Guava library, which implements more or less the same APIs.

Async Error Checks for Integration Tests

Two new methods have been introduced to TestHelpers:

  • wrapForErrorHandling(app)
  • assertAndUnwrapErrorHandlers(app)

First method registers some error handlers with the RunLoop and EventTarget of FirebaseDatabase. Second method checks whether the error handlers were fired, and if so throws the exception wrapped in a RuntimeException. By calling the above two methods in appropriate test fixtures (@Before and @After respectively), we can detect any async errors that may occur during integration tests, and force the corresponding test case to fail.

Hiranya Jayathilaka and others added 30 commits April 5, 2017 19:12
* Reformatted all source files * Separated unit and integration tests * Added maven checkstyle plugin * Got the basic build and unit tests working * Scrubbed the codebase for private keys, certificates etc.
Hiranya Jayathilaka and others added 21 commits April 12, 2017 17:36
…tps://github.com/google/guava/wiki/Release21); Excluding the transitive dependency on Guava 17 from Google API client to prevent having 2 versions of Guava in the classpath
Copy link

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Basically LGTM. A couple questions / comments.

// TODO: should we set an uncaught exception handler here? Probably want
// to let
// exceptions happen...
threadInitializer.setUncaughtExceptionHandler(thread, ThreadPoolEventTarget.this);

Choose a reason for hiding this comment

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

Thanks for tackling this! For future reference, it'd be nice to keep unrelated changes like this in a separate PR for easier reviewing... especially since the rest of this PR is pretty mechanical... but now that I've seen a non-mechanical change, I'm paranoid there may be others I should watch out for (in other words, it's usually better to keep "pure refactoring" PRs separate from "behavior change" PRs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

FirebaseOptions options2 =
new FirebaseOptions.Builder()
.setCredential(credential)
.setDatabaseUrl("http://test.firebaseio.com")

Choose a reason for hiding this comment

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

Generally speaking, firebase URLs should always use https://. Doesn't really matter in this context, but I'd prefer avoid setting (or extending?) a bad precedent and we seem to have a bunch of http:// URLs in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return thread;
}
});
public static void wrapForErrorHandling(FirebaseApp app) {

Choose a reason for hiding this comment

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

Maybe comment these guys? I guess every test is supposed to call them in their @before / @after ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

private static class TestRunLoop extends DefaultRunLoop {
private static class ErrorHandlingRunLoop extends DefaultRunLoop {

Choose a reason for hiding this comment

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

It seems weird that you're both wrapping and extending DefaultRunLoop. If this is really intentional, maybe add a comment explaining what's going on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the decorator pattern in use. I added a comment to explain.

@hiranya911 hiranya911 assigned hiranya911 and unassigned mikelehen Apr 17, 2017
@hiranya911 hiranya911 merged commit a3a6269 into master Apr 17, 2017
@hiranya911 hiranya911 deleted the hkj-remove-utils branch April 17, 2017 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants