Revision: 1591
Author: [email protected]
Date: Sun Oct 16 15:34:21 2011
Log:
Fix flaky service test. The whole AsyncService thing probably should just
be rm'd, but fixing the test for now.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=3475
http://code.google.com/p/google-guice/source/detail?r=1591
Added:
/trunk/extensions/persist/src/log4j.properties
Deleted:
/trunk/extensions/persist/test/log4j.properties
Modified:
/trunk/core/src/com/google/inject/Guice.java
/trunk/core/src/com/google/inject/spi/ConvertedConstantBinding.java
/trunk/extensions/service/test/com/google/inject/service/SingleServiceIntegrationTest.java
/trunk/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java
=======================================
--- /dev/null
+++ /trunk/extensions/persist/src/log4j.properties Sun Oct 16 15:34:21 2011
@@ -0,0 +1,6 @@
+log4j.rootLogger=warn, console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.Target=System.out
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%p [%c{1}] - %m %n
=======================================
--- /trunk/extensions/persist/test/log4j.properties Sun Oct 16 09:29:20 2011
+++ /dev/null
@@ -1,6 +0,0 @@
-log4j.rootLogger=warn, console
-
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.Target=System.out
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%p [%c{1}] - %m %n
=======================================
--- /trunk/core/src/com/google/inject/Guice.java Sun Oct 16 09:26:00 2011
+++ /trunk/core/src/com/google/inject/Guice.java Sun Oct 16 15:34:21 2011
@@ -52,8 +52,7 @@
private Guice() {}
/**
- * Creates an injector for the given set of modules. This is equivalent
to
- * calling {@link #createInjector(Stage, Module...)} with
Stage.DEVELOPMENT.
+ * Creates an injector for the given set of modules.
*
* @throws CreationException if one or more errors occur during injector
* construction
@@ -63,8 +62,7 @@
}
/**
- * Creates an injector for the given set of modules. This is equivalent
to
- * calling {@link #createInjector(Stage, Iterable)} with
Stage.DEVELOPMENT.
+ * Creates an injector for the given set of modules.
*
* @throws CreationException if one or more errors occur during injector
* creation
=======================================
--- /trunk/core/src/com/google/inject/spi/ConvertedConstantBinding.java Sun
Oct 16 09:38:42 2011
+++ /trunk/core/src/com/google/inject/spi/ConvertedConstantBinding.java Sun
Oct 16 15:34:21 2011
@@ -43,7 +43,7 @@
TypeConverterBinding getTypeConverterBinding();
/**
- * Returns the key for the source binding. That binding can be retrieved
from an injector using
+ * Returns the key for the source binding. That binding can e retrieved
from an injector using
* {@link com.google.inject.Injector#getBinding(Key)
Injector.getBinding(key)}.
*/
Key<String> getSourceKey();
=======================================
---
/trunk/extensions/service/test/com/google/inject/service/SingleServiceIntegrationTest.java
Thu Jul 7 17:34:16 2011
+++
/trunk/extensions/service/test/com/google/inject/service/SingleServiceIntegrationTest.java
Sun Oct 16 15:34:21 2011
@@ -7,6 +7,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -17,7 +18,7 @@
public class SingleServiceIntegrationTest extends TestCase {
- public final void testAsyncServiceLifecycle() throws
InterruptedException {
+ public final void testAsyncServiceLifecycle() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
final CountDownLatch startLatch = new CountDownLatch(1);
@@ -38,9 +39,14 @@
}
};
- service.start();
- // This should not pass!
+ Future<?> future = service.start();
+ // This should not pass! TODO(sameb): Why? Looks like it should to me
assertTrue(startLatch.await(2, TimeUnit.SECONDS));
+ // onStart() is called before the state is set to STARTED, so we need
+ // to wait until the Future finishes to guarantee it really was
started.
+ // This still manages to test what we want because the startLatch check
+ // is before this.
+ future.get(1, TimeUnit.SECONDS);
service.stop();
assertTrue(stopLatch.await(2, TimeUnit.SECONDS));
=======================================
---
/trunk/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java
Sun Oct 16 08:55:38 2011
+++
/trunk/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java
Sun Oct 16 15:34:21 2011
@@ -78,8 +78,6 @@
+ "in your web application. If this is deliberate, you may safely "
+ "ignore this message. If this is NOT deliberate however, "
+ "your application may not work as expected.";
-
- private static final Logger LOGGER =
Logger.getLogger(GuiceFilter.class.getName());
//VisibleForTesting
@Inject
@@ -88,7 +86,7 @@
// This can happen if you create many injectors and they all have
their own
// servlet module. This is legal, caveat a small warning.
if (GuiceFilter.pipeline instanceof ManagedFilterPipeline) {
- LOGGER.warning(MULTIPLE_INJECTORS_WARNING);
+
Logger.getLogger(GuiceFilter.class.getName()).warning(MULTIPLE_INJECTORS_WARNING);
}
// We overwrite the default pipeline
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en.