Commit Graph
26 Commits
Author SHA1 Message Date
Guice TeamandGuice Team b7cadc1cfa Migrate several tests to junit4 so that tests that rely on AOP can be skipped using Assume.assumeTrue.
PiperOrigin-RevId: 335755255
2020-10-06 17:18:53 -07:00
Guice TeamandGuice Team 690e189a7d Use assumeTrue to skip tests that only need to run under certain conditions.
This requires migrating some tests from JUnit3 to JUnit4.

PiperOrigin-RevId: 335094691
2020-10-02 13:55:43 -07:00
vzmandDavid P. Baker 5a69da0b6a Upgrade ModuleAnnotatedMethodScanner test to JUnit4 in preparation for some changes to scanner behavior.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=314292845
2020-06-02 13:29:27 -04:00
vzmandNick Glorioso e4db8374f0 Update test suite filtering to allow tests to be run in JUnit4
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=310603129
2020-05-08 19:23:59 -04:00
dorirandRon Shapiro bf08e9a957 Replace constants (static final CONSTANT_CASE) declaration type which use the general collection interface (e.g. List) with an immutable type (e.g. ImmutableList).
For constant field declarations, you should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List). This communicates to your callers important semantic guarantees.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149317176
2017-03-21 15:29:57 -04:00
lukesandSam Berlin 34e7c5d715 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=132718493
2016-09-13 11:47:18 -04:00
lukesandSam Berlin 3468051e9b Move the implementation classes from the multibindings package to inject/internal.
Now that the multibindings package is part of the main guice project we can do things like
* install the MultibindingsScanner by default
* rewrite multibinders to use InternalFactory objcts

But for those to work they need to be in the internal package.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130127811
2016-08-29 16:41:49 -04:00
lukesandSam Berlin a5dbde28c6 Automated g4 rollback of changelist 130106966.
*** Reason for rollback ***

breaks stuff that should be using the binding SPI

*** Original change description ***

Move the implementation classes from the multibindings package to inject/internal.

Now that the multibindings package is part of the main guice project we can do things like
* install the MultibindingsScanner by default
* rewrite multibinders to use InternalFactory objcts

But for those to work they need to be in the internal package.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130114909
2016-08-29 16:41:45 -04:00
lukesandSam Berlin c3ff26640e Move the implementation classes from the multibindings package to inject/internal.
Now that the multibindings package is part of the main guice project we can do things like
* install the MultibindingsScanner by default
* rewrite multibinders to use InternalFactory objcts

But for those to work they need to be in the internal package.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130106966
2016-08-29 16:41:41 -04:00
lukesandSam Berlin 4f75f2f585 merge multibindings into the 'core' of guice.
This deletes the maven artifact 'com.google.inject.extensions:guice-multibindings' and moves all
classes/tests into 'com.google.inject:guice'.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129637237
2016-08-29 16:40:41 -04:00
Tim Lantz d4bac74d44 Make Message.hashCode Consistent with .equals
Fixes https://github.com/google/guice/issues/940
2015-07-02 22:53:15 -04:00
sameb e18906acc3 Add some SPI methods to allow users to annotate Module methods with arbitrary
bindings and have those methods bound as Providers to specialized Keys.

This is the basis of what will be used to allow
Multibinder/MapBinder/OptionalBinder to have stuff like @SetProvides,
@MapProvides, @OptionalProvides and dagger interop support.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=85361820
2015-02-03 18:07:07 -05:00
Sam Berlin c34e0185fc Implement binding deduplication for multibinder & mapbinder in a different way.
Instead of relying on Guice binding deduplication (and hacking up RealElement
to break the annotation contract to do so, causing weirdness in WeakKeySet &
forcing us to care about "rehashing keys"), we instead deduplicate within
Multibinder.  The downside of this is that toInstance or toProvider(instance)
bindings that are deduplicated will remain in the object graph but effectively
be unreachable.  However, that's a downside I'm willing to live with to remove
this hack.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72570932
2014-08-06 15:45:28 -04:00
Sam Berlin d57f8ece55 The bug in the test that became flaky has been fixed. Note that this is not a strict rollback of the rollback - I've added protection against the NPE that would happen if there's a GC between the isBlacklisted call and the getSources call.
*** Original change description ***

Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.

This should fix https://code.google.com/p/google-guice/issues/detail?id=756.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64507759
2014-04-08 12:34:09 -04:00
Sam Berlin c013facb2a *** Reason for rollback ***
Causes an internal test to become flaky.

*** Original change description ***

Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.

This should fix https://code.google.com/p/google-guice/issues/detail?id=756.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64181193
2014-04-08 12:33:48 -04:00
Christian Edward Gruber bab9b6082f Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.
This should fix https://code.google.com/p/google-guice/issues/detail?id=756.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64083354
2014-04-01 15:36:38 -07:00
Christian Edward Gruber 2e39ef748a Print out the modules that led to a binding during error reporting, but
only if there's >1 module (otherwise it's just noise).  The format is
Some normal messaging about the fact that something terrible happened
at <the normal source> (via modules: A -> B -> C)

So, for example, exposing something that isn't bound would show up as:
1) Could not expose() Foo, it must be explicitly bound.
at FooExposerModule.configure(FooExposerModule.java:211) (via modules: ParentModule -> FooExposerModule)

.. and a duplicate binding would show up as:
A binding to DuplicatedThing was already configured at ModuleA.configure(ModuleA.java:36) (via modules: ParentModule -> FooModule -> ModuleA)
at ModuleA.configure(ModuleA.java:36) (via modules: ParentModule -> BarModule -> ModuleA)

All the tests passed as-is (because this is just new information), so I made a bunch of tests stricter to explicitly look for this new information.

I also cleaned up some other errors regarding scopes & some other stuff.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=53039251
2013-10-05 14:11:20 -07:00
Christian Edward Gruber 96e81ba554 An alternative way to support ShareableModule, Modules.override and Multibinder: use annotations that compare equal iff the binding strategy matches, so Guice will dedupe for us.
This CL includes a noteworthy adaptation of an earlier attempt which caused timeouts in some client tests, forcing a rollback ([]). Because Key caches its hashCode, we were inadvertently inserting every binding for a given multibound set into the same hashmap bucket, causing at best O(n^2) behaviour (and possibly worse, depending on how HashMap is implemented). To fix this, this CL adds changes to core Guice to recompute the Key's hashCode at injector construction time. (In fact, at the end of every Elements.getElements call, so any SPI-based code gets the same benefits.)
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=51233981
2013-09-18 15:05:35 -07:00
Christian Edward Gruber 605bd086d3 Updates the internals of an Element's source to keep track of the Modules that installed it, as well as the complete stack trace leading to the binding. The data is not yet exposed in Element.getSource(), but will be exposed in a future CL.
Technical details:
1) The call stack data is only available for elements created by the binder (excepting Message objects). So, elements that are created at injection time (e.g, JIT bindings, Stage, Injector, Logger, etc.) will not contain these data.
For elements affected, ElementSource.getDeclaringSource() should return what is returned by getSource() currently.
2) In the case of binding builder, similar to the current implementation, ElementSource provides the call stack of builder creation not 'element addition to the binder's elements.'

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=50247441
2013-08-09 11:30:48 -07:00
Sam Berlin c756777526 Add Binder.requireAtInjectOnConstructors, to force Guice to require @Inject annotations on constructors.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=4906
2012-05-31 19:54:04 -04:00
sberlin b7a02b02d8 * Remove unused imports
* Sort imports
* Convert tabs to spaces
* Fix the ant no_aop build


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2532


git-svn-id: https://google-guice.googlecode.com/svn/trunk@1572 d779f126-a31b-0410-b53b-1d3aecad763e
2011-07-08 00:34:16 +00:00
sberlin d9c913acca switch Guice from manually repackaging Guava to depending on Guava. it's still jarjar'd right now, which is causing a ~400k increase in guice-snapshot.jar. next step is to switch to ProGuard to remove the unnecessary code and cut it back down (even further?!). this will let people build from Guice source and depend directly on Guava code without having to worry about hiding internal/util.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1558 d779f126-a31b-0410-b53b-1d3aecad763e
2011-06-26 21:02:54 +00:00
sberlin 86142556d3 refactor removeSuppressedTests out of AllTests, to remove the circular dependency between it & StrictContainerTestSuite.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1557 d779f126-a31b-0410-b53b-1d3aecad763e
2011-06-25 05:05:23 +00:00
sberlin 132a5db7c6 issue 78 - provision interception. this only lets you listen to provisions (both before & after provisioning occurs), it does not let you change the return value of the provision.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1551 d779f126-a31b-0410-b53b-1d3aecad763e
2011-06-05 18:32:05 +00:00
mcculls ac4cdbe137 Issue 561: fix no_aop build by munging away all aop-related references
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1304 d779f126-a31b-0410-b53b-1d3aecad763e
2010-10-21 22:05:58 +00:00
mcculls 74d714c1e7 Issue 552: (step 1) move core code to its own subdirectory
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1300 d779f126-a31b-0410-b53b-1d3aecad763e
2010-10-21 19:10:16 +00:00