JavaApiDBTest.java 1.51 KB
package com.monitor;

import com.model.JavaApiInfo;
import com.monitor.cmdb.service.IJavaApiInfoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

/**
 * Created by fruwei on 2016/6/17.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
        "classpath*:META-INF/spring/spring*.xml"})
@PropertySource({"classpath:jdbc.properties",
        "classpath:*.properties"})
public class JavaApiDBTest {
    Logger logger = LoggerFactory.getLogger("test");
    @Autowired
    IJavaApiInfoService javaApiInfoService;


    @Test
    public void testAdd() {
        JavaApiInfo javaApiInfo = new JavaApiInfo();
        javaApiInfo.setApiName("test");
        javaApiInfo.setServiceType(1);
        javaApiInfo.setApiUrl("1111111");
        javaApiInfoService.saveJavaApiInfo(javaApiInfo);
    }

    @Test
    public void testQuery() {
        List<JavaApiInfo> list = javaApiInfoService.queryJavaApiInfo();
        for (JavaApiInfo javaApiInfo : list) {
            logger.info(javaApiInfo.getApiName());
        }
    }


    @Test
    public void testDel() {

    }

    @Test
    public void testUpdate() {
        javaApiInfoService.delJavaApiInfo(1);
    }


}