发布 v1.10 #5
@@ -1,5 +1,6 @@
|
|||||||
package tech.easyflow.skill.gitimport;
|
package tech.easyflow.skill.gitimport;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import tech.easyflow.common.web.exceptions.BusinessException;
|
import tech.easyflow.common.web.exceptions.BusinessException;
|
||||||
|
|
||||||
@@ -28,10 +29,17 @@ public class GitRepositoryAccessPolicy {
|
|||||||
*
|
*
|
||||||
* @param properties Git 导入配置
|
* @param properties Git 导入配置
|
||||||
*/
|
*/
|
||||||
|
@Autowired
|
||||||
public GitRepositoryAccessPolicy(SkillGitImportProperties properties) {
|
public GitRepositoryAccessPolicy(SkillGitImportProperties properties) {
|
||||||
this(properties, InetAddress::getAllByName);
|
this(properties, InetAddress::getAllByName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建可替换主机解析器的 Git 地址访问策略。
|
||||||
|
*
|
||||||
|
* @param properties Git 导入配置
|
||||||
|
* @param hostResolver 主机解析器
|
||||||
|
*/
|
||||||
GitRepositoryAccessPolicy(SkillGitImportProperties properties, HostResolver hostResolver) {
|
GitRepositoryAccessPolicy(SkillGitImportProperties properties, HostResolver hostResolver) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.hostResolver = hostResolver;
|
this.hostResolver = hostResolver;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package tech.easyflow.skill.gitimport;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import tech.easyflow.common.web.exceptions.BusinessException;
|
import tech.easyflow.common.web.exceptions.BusinessException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -11,6 +12,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,6 +32,20 @@ public class GitRepositoryAccessPolicyTest {
|
|||||||
policy = new GitRepositoryAccessPolicy(properties);
|
policy = new GitRepositoryAccessPolicy(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring 容器应选择生产构造器完成组件实例化。
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void springContextUsesProductionConstructor() {
|
||||||
|
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
|
||||||
|
context.registerBean(SkillGitImportProperties.class, SkillGitImportProperties::new);
|
||||||
|
context.register(GitRepositoryAccessPolicy.class);
|
||||||
|
context.refresh();
|
||||||
|
|
||||||
|
assertNotNull(context.getBean(GitRepositoryAccessPolicy.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库地址允许省略 .git 后缀并移除结尾斜线。
|
* 仓库地址允许省略 .git 后缀并移除结尾斜线。
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user