1 /*
2  * Copyright (C) 2017 The Dagger Authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dagger.functional.spi;
18 
19 import static com.google.common.io.Resources.getResource;
20 import static com.google.common.truth.Truth.assertThat;
21 
22 import dagger.Component;
23 import dagger.Module;
24 import dagger.Provides;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.util.Properties;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.junit.runners.JUnit4;
31 
32 @RunWith(JUnit4.class)
33 public class SpiTest {
34 
35   @Component(modules = M.class)
36   interface C {
string()37     String string();
38   }
39 
40   @Module
41   abstract static class M {
42     @Provides
string()43     static String string() {
44       return "string";
45     }
46   }
47 
48   @Test
testPluginRuns()49   public void testPluginRuns() throws IOException {
50     Properties properties = new Properties();
51     try (InputStream stream = getResource(SpiTest.class, "SpiTest_C.properties").openStream()) {
52       properties.load(stream);
53     }
54     assertThat(properties).containsEntry("component[0]", C.class.getCanonicalName());
55   }
56 }
57