Skip to content

Commit

Permalink
整合MyBatis
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc87112 committed Aug 19, 2016
1 parent 41fa06b commit ae68a47
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions Chapter3-2-7/src/test/java/com/didispace/ApplicationTests.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.didispace;

import com.didispace.domain.User;
import com.didispace.domain.UserMapper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
public class ApplicationTests {

@Autowired
private UserMapper userMapper;

@Test
@Rollback
public void findByName() throws Exception {
userMapper.insert("AAA", 20);
User u = userMapper.findByName("AAA");
Assert.assertEquals(20, u.getAge().intValue());
}

}
package com.didispace;

import com.didispace.domain.User;
import com.didispace.domain.UserMapper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@Transactional
public class ApplicationTests {

@Autowired
private UserMapper userMapper;

@Test
@Rollback
public void findByName() throws Exception {
userMapper.insert("AAA", 20);
User u = userMapper.findByName("AAA");
Assert.assertEquals(20, u.getAge().intValue());
}

}

0 comments on commit ae68a47

Please sign in to comment.