Commit Graph
57 Commits
Author SHA1 Message Date
Guice TeamandGuice Team ed6993aa14 Delete ant related build files.
PiperOrigin-RevId: 345749534
2020-12-04 13:51:03 -08:00
Guice TeamandGuice Team 70062306db Update BoundFieldModule description to be more specific about what it does.
PiperOrigin-RevId: 345252174
2020-12-02 09:49:56 -08:00
Guice TeamandGuice Team 383d377436 Bump snapshot version, update README & prior API xml
PiperOrigin-RevId: 339910400
2020-10-30 11:43:16 -07:00
Guice TeamandGuice Team 8b2a048a71 Fix BoundFieldModuleTest to run with Java 15.
PiperOrigin-RevId: 339039746
2020-10-26 08:09:52 -07:00
Guice TeamandGuice Team 5caa549395 Enable the new Guice error messages.
Changes include:

 - update Guice tests that asserts error messages
 - export new errors tests
 - update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests

PiperOrigin-RevId: 337602195
2020-10-16 16:55:03 -07:00
Guice TeamandGuice Team 9a8e46716e Revert previous change because it broke some tests when running with openjdk8.
PiperOrigin-RevId: 337517262
2020-10-16 09:13:55 -07:00
Guice TeamandGuice Team 2c8c7fed12 Enable the new Guice error messages.
Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests

PiperOrigin-RevId: 337401912
2020-10-15 16:06:22 -07:00
Sam BerlinandGuice Team 6586659da6 Update BoundFieldModule to mark the field as the source of the binding.
PiperOrigin-RevId: 333317842
2020-09-23 10:18:28 -07:00
Colin DeckerandGuice Team 835084290b Replace some usernames in TODOs.
PiperOrigin-RevId: 329928334
2020-09-03 09:01:02 -07:00
Guice TeamandColin Decker 83c9a329f4 Automatic code cleanup.
PiperOrigin-RevId: 328979463
2020-08-28 15:28:47 -04:00
xiaomingjiaandKurt Alfred Kluever db66b74249 Fix some unchecked and rawtypes warnings in Guice code.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=324662892
2020-08-04 11:22:03 -04:00
vzmandDavid P. Baker f1ed57d045 Add BoundFieldModule.WithPermits wrapper for granting @RestrictedBindingSource permits to instances of BoundFieldModule.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=321408556
2020-07-16 10:59:26 -04:00
samebandChris Povirk 485191facb bump snapshot version, update README & prior API xml
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=301892530
2020-03-19 17:20:52 -04:00
diamondmandDavid P. Baker c1225dcf8f Change the error message for missingConstructor() to be more similar to missingImplementation() (which is far more often the actual issue).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=263249646
2019-08-15 14:38:41 -04:00
cpovirkandRon Shapiro 159e13370d Update to Truth 0.45, and address deprecations.
Renames may include:
- containsAllOf => containsAtLeast
- containsAllIn => containsAtLeastElementsIn
- isSameAs => isSameInstanceAs
- isOrdered => isInOrder
- isStrictlyOrdered => isInStrictOrder

The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted).

Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().)

Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=251472122
2019-06-06 11:06:16 -04:00
cpovirkandRon Shapiro 553a475a2c Migrate Truth Subjects from no-arg check() to the overload that accepts a description.
The overload that accepts a description generally produces better failure messages:
- The first line of the message it produces is something like: "value of: myProto.getResponse()" (where "getResponse()" is taken from the provided description)
- The last line of the message it produces is something like: "myProto was: response: query was throttled" (the full value of myProto)
- And the existing text goes in between.

Additional motivation: We are deleting the no-arg overload externally (and probably internally thereafter).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247095743
2019-05-08 10:35:03 -04:00
cpovirkandRon Shapiro ea179b962f Instead of calling Subject.actual(), store the actual value in a field, and read that.
actual() is being removed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247039297
2019-05-08 10:35:03 -04:00
samebandRon Shapiro 7e7ac3e602 Add a note in isTransparentProvider that folks who trace through the code & detect that their binding isn't working because of this call should use @Bind(lazy=true) instead.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=241948208
2019-04-08 10:00:09 -04:00
samebandRon Shapiro 04219a2537 bump snapshot version, update README & prior api xml
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219159125
2018-10-31 11:16:55 -04:00
samebandColin Decker 67369fbf05 Post 4.2.1 release tasks: bump snapshot version, update README & prior API xml.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214011694
2018-09-28 12:16:58 -04:00
jlavalleeandRon Shapiro f734770aa6 Migrated from Subject.failWithRawMessage to Subject.failWithoutActual
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205720194
2018-09-17 15:15:15 -04:00
cpovirkandColin Decker 12692cbe89 Update to Truth 0.41, and expect a single failure-message format instead of the current multiple possibilities.
Also, update the bundled-for-Ant JUnit from JUnit 3-something to JUnit 4.11. This matches the dependency used by the Maven build. It's necessary to avoid the problem "java.lang.ClassNotFoundException: org.junit.ComparisonFailure." Truth was already using that type as of 0.36[*], so I suspect that we were just getting away with the JUnit 3 dependency because of the vagaries of class loading. Presumably, if a test had ever actually failed in a way that should have produced a ComparisonFailure, the current build setup would have produces the same error.

[*] https://github.com/google/truth/blob/release_0_36/core/src/main/java/com/google/common/truth/Platform.java#L24

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=200574789
2018-07-02 16:36:45 -04:00
hapaandRon Shapiro 0451111076 Make BoundFieldInfo public
And discover the bound fields when constructing the module, but deferring the errors to configure() time.

This enables using BoundFieldModule with custom scoping in GuiceBerry/Acai using TestScopeListener/TestingService to reflectively reset the instance before tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196814191
2018-05-16 18:49:52 -04:00
cpovirkandRon Shapiro 48b3f62aa1 Migrate off failWithRawMessageAndCause, which is being deprecated.
I'm sorry that the replacement is so ugly. Our reason for not supporting this directly is partially that it's needed by only ~1% of subjects. But mostly, we've over time taken the position that Truth is intended for only the "assert" phases of the "arrange, act, assert" testing process. Exceptions, on the other hand, usually come from the earlier phases.

Unfortunately, I still owe everyone a long explanation of *why* we have come to this position. If it's bugging you now, let me know, and I can make it happen.

(And yes, in this particular case, we're basically arguing that Your Subject Is Wrong. Sorry: I'm not trying to get you to delete it or recant or anything; I'm just trying to explain where we're coming from.)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192278109
2018-04-11 13:37:20 -04:00
cpovirkandRon Shapiro 44c65c164d Update tests for upcoming changes to Truth's failure message format.
We now accept (sigh) 3 versions:
- The version generated by the latest open-source release of Truth.
- The version generated by the current internal version of Truth.
- The version that will be generated once I submit CL 185043225.

I continue to promise to reduce this back to expecting a single version once I release a version of Truth that contains CL 185043225.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190771332
2018-04-03 12:08:37 -04:00
alanouandRon Shapiro 59f227bd1d Updates javadoc to make the use of binding annotations on @Bind more clear.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190471018
2018-03-27 10:21:11 -04:00
cpovirkandRon Shapiro b56a8561a9 Update tests for when withMessage() messages are displayed on separate lines from the main failure message.
Before:
some messsage: the main message

After:
some message
the main message

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189625749
2018-03-20 18:25:51 -04:00
Sam Berlin c9dda9d100 bump snapshot version. 2018-02-28 14:14:01 -05:00
ronshapiroandRon Shapiro fe67d047ff Add Automatic-Module-Names to Guice and all of the extensions
https://github.com/google/guice/issues/1085

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184283324
2018-02-02 14:44:26 -05:00
tsummerfieldandRon Shapiro d5ecbf2446 Expand BoundFieldModule javadoc to define a use case of @Bind(lazy = true) in addition to the code example.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175586941
2018-01-25 11:12:58 -05:00
jijiangandRon Shapiro df9cbea927 Replace truth.FailureStrategy with truth.FailureMetadata in custom Subjects.
Also changed truth.SubjectFactory to truth.Subject.Factory (plain renaming) and use method reference instead of anonymous class to create the factory when applicable.

FailureMetadata, an opaque object to its users, is introduced to replace FailureStrategy in in custom Subject in order to resolve some existing flaws of FailureStrategy as well as enable new features to be added to Truth.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171466733
2018-01-25 11:12:58 -05:00
cpovirkandRon Shapiro 50b2764654 Migrate from fail* calls on deprecated this.failureStrategy to equivalent this.fail* calls.
The new this.fail* methods are available in Truth 0.36, which I've imported into the [] Maven repository for people who use that. If I could find a pom/build.xml for your open-source project, this CL updates it.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169571495
2018-01-25 11:12:58 -05:00
jijiangandRon Shapiro e5e459f4c5 Migrate from old *Verb* classes to new *SubjectBuilder* classes.
This migration does not change any behavior.

RELNOTES: n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167901418
2018-01-25 11:12:58 -05:00
jijiangandRon Shapiro 5eb69b2af6 Update Truth to 0.34 and migrate TestVerb.withFailureMessage to withMessage for third_party/guice/throwingproviders.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161972427
2018-01-25 11:12:58 -05:00
diamondmandRon Shapiro 7ca9173c22 Update Truth to 0.33. Migrate CheckedProviderSubjectTest to ExpectFailure, clean up CheckedProviderSubject.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157059098
2018-01-25 11:12:58 -05:00
lukesandRon Shapiro dcf7bdacc2 remove unnecessary explicit type parameters now that we are on java7
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145716288
2017-03-21 15:28:23 -04:00
lukesandSam Berlin 751b555176 Run google-java-format on all Guice code.
configure a presubmit to ensure that it stays formatted.

Highlights include:
* simplified import order
* method annotations are now consistently defined on the preceding line
* javadoc reformatted to 100 chars column width

One test that contained line numbers in error messages had to be modified and
the formatter didn't like some of the more complicated preprocessor directives
(MOE and AOP).

To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132692207
2016-09-13 11:47:18 -04:00
sameb aba3795cff Need to specify throwingproviders as a dependency of testlib now, and also need to explicitly say that truth is in compile scope, since the guice parent pom puts it in the test scope by default.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131623677
2016-08-29 16:42:38 -04:00
sameb 9b042f4f16 Remove diamond operator
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131623598
2016-08-29 16:42:34 -04:00
sameb 2c23a622f2 AssertionError(string, throwable) was added in java7 :-/
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131618952
2016-08-29 16:42:31 -04:00
eatnumber1andSam Berlin 801d90f196 Add a CheckedProviders class
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130319606
2016-08-29 16:41:58 -04:00
Sam Berlin abf12145c1 update versions. 2016-06-17 16:37:46 -04:00
Sam Berlin b8fe1a3a8e Catch ConfigurationException, not ProvisionException. 2016-06-13 18:00:10 -04:00
lukesandSam Berlin 6c269743c8 Add support for @Bind(lazy=true) Provider<T> fields.
This is useful for testing behavior of bindings when they fail with provision
exceptions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124735046
2016-06-13 17:14:13 -04:00
geiersbachandSam Berlin 97695d94f4 Remove dep on //third_party/java/jsr305_annotations accidentally added
earlier.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124175277
2016-06-13 17:14:09 -04:00
geiersbachandSam Berlin 1a2c47caa5 Address remaining comments from earlier change.
-Rename a test case for consistency
-Add a test for a nullable non-transparent Provider
-Use BoundFieldInfo#allowsNull and consolidate getting a field value in getFieldValue(), regardless of whether the field type is a simple field or a "transparent provider".
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123686167
2016-06-13 17:13:53 -04:00
geiersbachandSam Berlin c92acd701c Respect @Nullable in BoundFieldModule.
Fields annotated with some @Nullable annotation are allowed to have null values bound for testing, following how Guice works with null (https://github.com/google/guice/wiki/UseNullable)

This allows for easy testing of null cases without resorting to SettableProvider.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123677621
2016-06-13 17:13:30 -04:00
evanwhitfieldandSam Berlin 4fd9a4f49f Minor documentation edit.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=119328467
2016-06-13 17:09:29 -04:00
timonvoandSam Berlin fcbc3e0e98 Cast provider fields values to the right Provider class in BoundFieldModule.
Before this patch a ClassCastException would be thrown if a
javax.inject.Provider was used with @Bind, because the code would try to cast it
to com.google.inject.Provider.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=105098115
2015-10-28 13:33:07 -04:00
timonvoandSam Berlin 43d61da39c Fix missing fail() assertions in BoundFieldModuleTest found by ErrorProne.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=105097289
2015-10-28 13:33:07 -04:00