File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
src/test/java/guru/springframework/test Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
1
+ package guru .springframework .test .config ;
2
+
3
+ import org .springframework .context .annotation .ComponentScan ;
4
+ import org .springframework .context .annotation .Configuration ;
5
+
6
+ /**
7
+ * Created by jt on 5/21/16.
8
+ */
9
+ @ Configuration
10
+ @ ComponentScan ("guru.springframework.test.ds" )
11
+ public class DataSourceConfig {
12
+ }
Original file line number Diff line number Diff line change 7
7
* Created by jt on 5/21/16.
8
8
*/
9
9
@ Component
10
- @ Profile ("dev" )
10
+ @ Profile ({ "dev" , "default" } )
11
11
public class DevDataSource implements FakeDataSource {
12
12
@ Override
13
13
public String getConnectionInfo () {
Original file line number Diff line number Diff line change
1
+ package guru .springframework .test .dstest ;
2
+
3
+ /**
4
+ * Created by jt on 5/21/16.
5
+ */
6
+
7
+ import guru .springframework .test .config .DataSourceConfig ;
8
+ import guru .springframework .test .ds .FakeDataSource ;
9
+ import org .junit .Test ;
10
+ import org .junit .runner .RunWith ;
11
+ import org .springframework .beans .factory .annotation .Autowired ;
12
+ import org .springframework .boot .test .SpringApplicationConfiguration ;
13
+ import org .springframework .test .context .ActiveProfiles ;
14
+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
15
+
16
+ @ RunWith (SpringJUnit4ClassRunner .class )
17
+ @ SpringApplicationConfiguration (DataSourceConfig .class )
18
+ @ ActiveProfiles ("guru" )
19
+ public class DataSourceTest {
20
+
21
+ private FakeDataSource fakeDataSource ;
22
+
23
+ @ Autowired
24
+ public void setFakeDataSource (FakeDataSource fakeDataSource ) {
25
+ this .fakeDataSource = fakeDataSource ;
26
+ }
27
+
28
+ @ Test
29
+ public void TestDataSource () throws Exception {
30
+
31
+ System .out .println (fakeDataSource .getConnectionInfo ());
32
+
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments