~mwhudson/hudson/2.x

« back to all changes in this revision

Viewing changes to hudson-inject/src/test/java/com/sonatype/matrix/smoothie/injecto/InjectomaticAwareTest.java

  • Committer: Jason van Zyl
  • Date: 2011-02-17 14:40:01 UTC
  • mfrom: (9408.1.3)
  • Revision ID: git-v1:06a570a521abbbe3a889b27f8fcb6445a39246bf
Merge remote branch 'mcculls-jsr330/JSR330' into JSR330

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * The MIT License
 
3
 *
 
4
 * Copyright (c) 2010 Sonatype, Inc. All rights reserved.
 
5
 *
 
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
7
 * of this software and associated documentation files (the "Software"), to deal
 
8
 * in the Software without restriction, including without limitation the rights
 
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
10
 * copies of the Software, and to permit persons to whom the Software is
 
11
 * furnished to do so, subject to the following conditions:
 
12
 *
 
13
 * The above copyright notice and this permission notice shall be included in
 
14
 * all copies or substantial portions of the Software.
 
15
 *
 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
22
 * THE SOFTWARE.
 
23
 */
 
24
 
 
25
package com.sonatype.matrix.smoothie.injecto;
 
26
 
 
27
import com.google.inject.Key;
 
28
import com.sonatype.matrix.smoothie.Smoothie;
 
29
import com.sonatype.matrix.smoothie.TestSupport;
 
30
import org.junit.Test;
 
31
 
 
32
import javax.inject.Named;
 
33
import javax.inject.Singleton;
 
34
 
 
35
import static org.junit.Assert.*;
 
36
 
 
37
/**
 
38
 * Tests for {@link InjectomaticAware}.
 
39
 *
 
40
 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
 
41
 */
 
42
public class InjectomaticAwareTest
 
43
    extends TestSupport
 
44
{
 
45
    @Test
 
46
    public void testInjectoAware() {
 
47
        Injectomatic injecto = Smoothie.getContainer().get(Key.get(Injectomatic.class));
 
48
        assertNotNull(injecto);
 
49
 
 
50
        TestInjectomaticAware aware = Smoothie.getContainer().get(Key.get(TestInjectomaticAware.class));
 
51
        assertNotNull(aware.injecto);
 
52
        assertEquals(injecto, aware.injecto);
 
53
    }
 
54
 
 
55
    @Named
 
56
    @Singleton
 
57
    public static class TestInjectomaticAware
 
58
        implements InjectomaticAware
 
59
    {
 
60
        Injectomatic injecto;
 
61
 
 
62
        public void setInjectomatic(Injectomatic injecto) {
 
63
            this.injecto = injecto;
 
64
        }
 
65
    }
 
66
}
 
 
b'\\ No newline at end of file'