summaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestTestCase.java
blob: a7269aec9e90e694d9eca67559f5f0c7c8f2b02e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.test;

import com.google.inject.AbstractModule;
import com.google.inject.Key;
import com.google.inject.name.Names;
import com.yahoo.jdisc.Request;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;


/**
 * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
 */
public class NonWorkingRequestTestCase {

    @Test
    public void requireThatFactoryMethodWorks() {
        assertNotNull(NonWorkingRequest.newInstance("scheme://host/path"));
    }

    @Test
    public void requireThatGuiceModulesAreInjected() {
        Request request = NonWorkingRequest.newInstance("scheme://host/path", new AbstractModule() {

            @Override
            protected void configure() {
                bind(String.class).annotatedWith(Names.named("foo")).toInstance("bar");
            }
        });
        assertEquals("bar", request.container().getInstance(Key.get(String.class, Names.named("foo"))));
    }
}