use of dagger.internal.TestingLoader in project dagger by square.
the class UnusedProviderTest method unusedSetBinding.
@Test
public void unusedSetBinding() throws Exception {
@Module
class TestModule {
@Provides(type = Provides.Type.SET)
String provideA() {
throw new AssertionError();
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
try {
graph.validate();
fail();
} catch (IllegalStateException expected) {
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class UnusedProviderTest method unusedSetValuesBinding.
@Test
public void unusedSetValuesBinding() throws Exception {
@Module
class TestModule {
@Provides(type = Provides.Type.SET_VALUES)
Set<String> provideA() {
throw new AssertionError();
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
try {
graph.validate();
fail();
} catch (IllegalStateException expected) {
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class UnusedProviderTest method unusedProviderMethod_whenNotLibraryModule_fails.
@Test
public void unusedProviderMethod_whenNotLibraryModule_fails() throws Exception {
class EntryPoint {
}
class BagOfMoney {
}
@Module(injects = EntryPoint.class)
class TestModule {
@Provides
BagOfMoney providesMoney() {
return new BagOfMoney();
}
}
try {
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
graph.validate();
fail("Validation should have exploded!");
} catch (IllegalStateException expected) {
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class UnusedProviderTest method whenLibraryModulePlussedToNecessaryModule_shouldNotFailOnUnusedLibraryModule.
@Test
public void whenLibraryModulePlussedToNecessaryModule_shouldNotFailOnUnusedLibraryModule() throws Exception {
class EntryPoint {
}
class BagOfMoney {
}
@Module(injects = EntryPoint.class, library = true)
class ExampleLibraryModule {
@Provides
BagOfMoney providesMoney() {
return new BagOfMoney();
}
}
@Module(injects = EntryPoint.class)
class TestModule {
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
graph = graph.plus(new ExampleLibraryModule());
graph.validate();
}
use of dagger.internal.TestingLoader in project dagger by square.
the class ThreadSafetyTest method concurrentSingletonAccess.
@Test
public void concurrentSingletonAccess() throws Exception {
final List<Future<Long>> futures = new ArrayList<Future<Long>>();
final ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new LatchingModule(latch));
for (int i = 0; i < THREAD_COUNT; i++) {
futures.add(es.submit(new Callable<Long>() {
@Override
public Long call() {
latch.countDown();
return graph.get(Long.class);
}
}));
}
latch.countDown();
for (Future<Long> future : futures) {
assertThat(future.get(1, TimeUnit.SECONDS)).named("Lock failure - count should never increment").isEqualTo(0);
}
}
Aggregations