|
| 1 | +/* |
| 2 | + * Copyright 2010 The myBatis Team |
| 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 | +package sample; |
| 17 | + |
| 18 | +import org.junit.Assert; |
| 19 | +import org.junit.Test; |
| 20 | +import org.junit.runner.RunWith; |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; |
| 22 | +import org.springframework.test.context.ContextConfiguration; |
| 23 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| 24 | + |
| 25 | +/** |
| 26 | + * Example of MyBatis-Spring integration usage |
| 27 | + * |
| 28 | + * @version $Id$ |
| 29 | + */ |
| 30 | +@ContextConfiguration(locations = {"classpath:sample/context.xml"}) |
| 31 | +@RunWith(SpringJUnit4ClassRunner.class) |
| 32 | +public class MyBatisSampleTest { |
| 33 | + |
| 34 | + @Autowired |
| 35 | + private FooService fooService1; |
| 36 | + @Autowired |
| 37 | + private FooService fooService2; |
| 38 | + @Autowired |
| 39 | + private FooService fooService3; |
| 40 | + |
| 41 | + public void setFooService1(FooService fooService1) { |
| 42 | + this.fooService1 = fooService1; |
| 43 | + } |
| 44 | + |
| 45 | + public void setFooService2(FooService fooService2) { |
| 46 | + this.fooService2 = fooService2; |
| 47 | + } |
| 48 | + |
| 49 | + public void setFooService3(FooService fooService3) { |
| 50 | + this.fooService3 = fooService3; |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + public void testFooService1() throws Exception { |
| 55 | + User user = this.fooService1.doSomeBusinessStuff("u1"); |
| 56 | + Assert.assertNotNull(user); |
| 57 | + Assert.assertEquals("Pocoyo",user.getName()); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + public void testFooService2() throws Exception { |
| 62 | + User user = this.fooService2.doSomeBusinessStuff("u1"); |
| 63 | + Assert.assertNotNull(user); |
| 64 | + Assert.assertEquals("Pocoyo",user.getName()); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + public void testFooService3() throws Exception { |
| 69 | + User user = this.fooService3.doSomeBusinessStuff("u1"); |
| 70 | + Assert.assertNotNull(user); |
| 71 | + Assert.assertEquals("Pocoyo",user.getName()); |
| 72 | + } |
| 73 | +} |
0 commit comments