File tree Expand file tree Collapse file tree 5 files changed +123
-0
lines changed
springframework/test/external/props
test/config/external/props Expand file tree Collapse file tree 5 files changed +123
-0
lines changed Original file line number Diff line number Diff line change
1
+ package guru .springframework .test .external .props ;
2
+
3
+ import guru .springframework .test .jms .FakeJmsBroker ;
4
+ import guru .test .config .external .props .ExternalPropsMultiFileS4 ;
5
+ import org .junit .Test ;
6
+ import org .junit .runner .RunWith ;
7
+ import org .springframework .beans .factory .annotation .Autowired ;
8
+ import org .springframework .test .context .ContextConfiguration ;
9
+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
10
+
11
+ import static org .junit .Assert .assertEquals ;
12
+
13
+ /**
14
+ * Created by jt on 5/7/16.
15
+ */
16
+ @ RunWith (SpringJUnit4ClassRunner .class )
17
+ @ ContextConfiguration (classes = ExternalPropsMultiFileS4 .class )
18
+ public class PropertySourceMultiFileS4Test {
19
+
20
+ @ Autowired
21
+ FakeJmsBroker fakeJmsBroker ;
22
+
23
+ @ Test
24
+ public void testPropsSet () throws Exception {
25
+ assertEquals ("10.10.10.123" , fakeJmsBroker .getUrl ());
26
+ assertEquals (3330 , fakeJmsBroker .getPort ().intValue ());
27
+ assertEquals ("Ron" , fakeJmsBroker .getUser ());
28
+ assertEquals ("&%$)(*&#^!@!@#$" , fakeJmsBroker .getPassword ());
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ package guru .springframework .test .external .props ;
2
+
3
+ import guru .springframework .test .jms .FakeJmsBroker ;
4
+ import guru .test .config .external .props .ExternalPropsMultiFile ;
5
+ import org .junit .Test ;
6
+ import org .junit .runner .RunWith ;
7
+ import org .springframework .beans .factory .annotation .Autowired ;
8
+ import org .springframework .test .context .ContextConfiguration ;
9
+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
10
+
11
+ import static org .junit .Assert .assertEquals ;
12
+
13
+ /**
14
+ * Created by jt on 5/7/16.
15
+ */
16
+ @ RunWith (SpringJUnit4ClassRunner .class )
17
+ @ ContextConfiguration (classes = ExternalPropsMultiFile .class )
18
+ public class PropertySourceMultiFileTest {
19
+
20
+ @ Autowired
21
+ FakeJmsBroker fakeJmsBroker ;
22
+
23
+ @ Test
24
+ public void testPropsSet () throws Exception {
25
+ assertEquals ("10.10.10.123" , fakeJmsBroker .getUrl ());
26
+ assertEquals (3330 , fakeJmsBroker .getPort ().intValue ());
27
+ assertEquals ("Ron" , fakeJmsBroker .getUser ());
28
+ assertEquals ("&%$)(*&#^!@!@#$" , fakeJmsBroker .getPassword ());
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ package guru .test .config .external .props ;
2
+
3
+ import guru .springframework .test .jms .FakeJmsBroker ;
4
+ import org .springframework .beans .factory .annotation .Autowired ;
5
+ import org .springframework .context .annotation .Bean ;
6
+ import org .springframework .context .annotation .Configuration ;
7
+ import org .springframework .context .annotation .PropertySource ;
8
+ import org .springframework .core .env .Environment ;
9
+
10
+ /**
11
+ * Created by jt on 5/7/16.
12
+ */
13
+ @ Configuration
14
+ @ PropertySource ({"classpath:testing.properties" , "classpath:encrypted-testing.properties" })
15
+ public class ExternalPropsMultiFile {
16
+
17
+ @ Autowired
18
+ Environment env ;
19
+
20
+ @ Bean
21
+ public FakeJmsBroker fakeJmsBrokerMulti (){
22
+ FakeJmsBroker fakeJmsBroker = new FakeJmsBroker ();
23
+ fakeJmsBroker .setUrl (env .getProperty ("guru.jms.server" ));
24
+ fakeJmsBroker .setPort (env .getRequiredProperty ("guru.jms.port" , Integer .class ));
25
+ fakeJmsBroker .setUser (env .getProperty ("guru.jms.user" ));
26
+ fakeJmsBroker .setPassword (env .getProperty ("guru.jms.encrypted.password" ));
27
+ return fakeJmsBroker ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ package guru .test .config .external .props ;
2
+
3
+ import guru .springframework .test .jms .FakeJmsBroker ;
4
+ import org .springframework .beans .factory .annotation .Autowired ;
5
+ import org .springframework .context .annotation .Bean ;
6
+ import org .springframework .context .annotation .Configuration ;
7
+ import org .springframework .context .annotation .PropertySource ;
8
+ import org .springframework .context .annotation .PropertySources ;
9
+ import org .springframework .core .env .Environment ;
10
+
11
+ /**
12
+ * Created by jt on 5/7/16.
13
+ */
14
+ @ Configuration
15
+ @ PropertySources ({
16
+ @ PropertySource ("classpath:testing.properties" ),
17
+ @ PropertySource ("classpath:encrypted-testing.properties" )
18
+ })
19
+ public class ExternalPropsMultiFileS4 {
20
+
21
+ @ Autowired
22
+ Environment env ;
23
+
24
+ @ Bean
25
+ public FakeJmsBroker fakeJmsBrokerMultiS4 (){
26
+ FakeJmsBroker fakeJmsBroker = new FakeJmsBroker ();
27
+ fakeJmsBroker .setUrl (env .getProperty ("guru.jms.server" ));
28
+ fakeJmsBroker .setPort (env .getRequiredProperty ("guru.jms.port" , Integer .class ));
29
+ fakeJmsBroker .setUser (env .getProperty ("guru.jms.user" ));
30
+ fakeJmsBroker .setPassword (env .getProperty ("guru.jms.encrypted.password" ));
31
+ return fakeJmsBroker ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ guru.jms.encrypted.password =&%$)(*&# ^!@!@#$
You can’t perform that action at this time.
0 commit comments