[Feature] add for new
This commit is contained in:
@@ -16,11 +16,20 @@
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>lock-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>lock-spring</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>test-spring</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.github.houbb.lock.test.config;
|
||||
|
||||
|
||||
import com.github.houbb.lock.spring.annotation.EnableLock;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configurable
|
||||
@ComponentScan(basePackages = "com.github.houbb.lock.test.service")
|
||||
@EnableLock
|
||||
public class SpringConfig {
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.github.houbb.lock.test.model;
|
||||
|
||||
public class User {
|
||||
|
||||
private String name;
|
||||
|
||||
private String id;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"name='" + name + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.github.houbb.lock.test.service;
|
||||
|
||||
import com.github.houbb.lock.spring.annotation.Lock;
|
||||
import com.github.houbb.lock.test.model.User;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
@Lock
|
||||
public String queryUserName(Long userId) {
|
||||
return userId+"-name";
|
||||
}
|
||||
|
||||
@Lock(value = "#arg0.name")
|
||||
public void queryUserName2(User user) {
|
||||
System.out.println("user: " + user.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.github.houbb.lock.test.spring;
|
||||
|
||||
|
||||
import com.github.houbb.lock.test.config.SpringConfig;
|
||||
import com.github.houbb.lock.test.model.User;
|
||||
import com.github.houbb.lock.test.service.UserService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ContextConfiguration(classes = SpringConfig.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SpringServiceTest {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Test
|
||||
public void queryLogTest() {
|
||||
final String key = "name";
|
||||
final String value = userService.queryUserName(1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryUserNameTest() {
|
||||
User user = new User();
|
||||
user.setId("001");
|
||||
user.setName("u-001");
|
||||
userService.queryUserName2(user);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user