zoukankan      html  css  js  c++  java
  • Spring 测试

    1. pom.xml ==> Depency

    <!-- Test -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <scope>test</scope>
    </dependency>
    
    <!-- Spring-beans -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>

    2. BaseTest.java

    package com.ctrip.arch.titanqconfig;
    
    import junit.framework.TestCase;
    import org.junit.runner.RunWith;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    
    
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "classpath:applicationContext.xml" })
    public class BaseTest extends TestCase {
    
    
    }

    3. Sample

    package com.ctrip.arch.titanqconfig.crypto;
    
    import org.apache.logging.log4j.util.Strings;
    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;
    
    
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(classes = {Soa2KeyService.class, DefaultDataSourceCrypto.class})
    public class KeyServiceTester {
        @Autowired
        Soa2KeyService service;
    
        @Test
        public void testGetKey() throws Exception {
            String sslCode = "TT00000000000123";
            String key = service.getKeyInfo(sslCode).getKey();
            System.out.println("key=" + key);
            assert(Strings.isNotBlank(key));
        }
        
    }
  • 相关阅读:
    【转】【VS2008无法启动asp.net development server】的解决
    C#运用技巧(1)
    C# — WinForm 基本控件
    TB 需求分析
    C# 远程连接SQL 2005数据库
    SQL语句的运用
    如何跌倒
    国学堂-梁冬对话张长琳《人体的彩虹》系列
    帝范:中国最伟大帝王的沉思录
    web.xml 配置
  • 原文地址:https://www.cnblogs.com/ylz8401/p/7383225.html
Copyright © 2011-2022 走看看