提交 0e6d7095 编写于 作者: C Captain.B

update .gitignore

上级 0fa7a87c
......@@ -26,6 +26,7 @@ yarn-error.log*
src/main/resources/static
src/main/resources/templates
src/test/
target
.settings
.project
......
package io.metersphere;
import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.mapper.UserMapper;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.utils.CompressUtils;
import io.metersphere.service.RegistryParamService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ApplicationTests {
@Resource
UserMapper userMapper;
@Resource
private RegistryParamService registryParamService;
@Test
public void test1() {
final Object test = CompressUtils.zip("test".getBytes());
final Object unzip = CompressUtils.unzip(test);
System.out.println(new String((byte[]) unzip));
}
@Test
public void test2() {
List<SystemParameter> registry = registryParamService.getRegistry(ParamConstants.Classify.REGISTRY.getValue());
System.out.println(registry);
for (SystemParameter sp : registry) {
if ("registry.password".equals(sp.getParamKey())) {
sp.setParamValue("Calong@2015");
}
if ("registry.url".equals(sp.getParamKey())) {
sp.setParamValue("registry.fit2cloud.com");
}
if ("registry.repo".equals(sp.getParamKey())) {
sp.setParamValue("metersphere");
}
if ("registry.username".equals(sp.getParamKey())) {
sp.setParamValue("developer");
}
}
registryParamService.updateRegistry(registry);
}
}
package io.metersphere;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.PodList;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.junit.Before;
import org.junit.Test;
public class BaseTest {
protected KubernetesClient kubernetesClient;
@Before
public void before() {
try {
ConfigBuilder configBuilder = new ConfigBuilder();
configBuilder.withMasterUrl("https://172.16.10.93:6443");
kubernetesClient = new DefaultKubernetesClient(configBuilder.build());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
@Test
public void test1() {
PodList list = kubernetesClient.pods().list();
for (Pod item : list.getItems()) {
System.out.println(item);
}
}
}
package io.metersphere;
import io.metersphere.report.base.Statistics;
import org.junit.Test;
import java.lang.reflect.Field;
public class ResultDataParseTest {
String[] s = {"1","2","3","4","5","6","7","8","9","10","11","12","13"};
public static <T> T setParam(Class<T> clazz, Object[] args)
throws Exception {
if (clazz == null || args == null) {
throw new IllegalArgumentException();
}
T t = clazz.newInstance();
Field[] fields = clazz.getDeclaredFields();
if (fields == null || fields.length > args.length) {
throw new IndexOutOfBoundsException();
}
for (int i = 0; i < fields.length; i++) {
fields[i].setAccessible(true);
fields[i].set(t, args[i]);
}
return t;
}
@Test
public void test() throws Exception {
Statistics statistics = setParam(Statistics.class, s);
System.out.println(statistics.toString());
}
}
package io.metersphere.service;
import io.metersphere.base.domain.TestCaseNode;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TestCaseTest {
@Resource
TestCaseNodeService testCaseNodeService;
@Test
public void addNode() {
TestCaseNode node = new TestCaseNode();
node.setName("node01");
node.setProjectId("2ade216b-01a6-43d0-b48c-4a3898306096");
node.setCreateTime(System.currentTimeMillis());
node.setUpdateTime(System.currentTimeMillis());
testCaseNodeService.addNode(node);
}
}
package io.metersphere.service;
import io.metersphere.controller.request.resourcepool.QueryResourcePoolRequest;
import io.metersphere.dto.TestResourcePoolDTO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TestResourcePoolServiceTest {
@Resource
private TestResourcePoolService testResourcePoolService;
@Test
public void listResourcePools() {
List<TestResourcePoolDTO> list = testResourcePoolService.listResourcePools(new QueryResourcePoolRequest());
System.out.println(list.size());
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册