zoukankan      html  css  js  c++  java
  • JAVA Assert

    package common;

    import junit.framework.Assert;
    import org.junit.AfterClass;
    import org.junit.BeforeClass;
    import org.junit.Test;
    import org.junit.runners.JUnit4;

    /**
     * Created by IntelliJ IDEA.
     * User: hantongchao
     * Date: 12-8-3
     * Time: 上午9:40
     * To change this template use File | Settings | File Templates.
     */
    public class EnvTest {


        // 在对象初始化之前,马上执行这个方法
        @BeforeClass
        public static void beforeClass() {

        }

        @Test
        public void test() {
            Assert.assertEquals("韩",Env.getInstance().getProperty("han"));
            System.out.println(Env.getInstance().getProperty("han"));  ;//调用

        }

        // 用完之后
        @AfterClass
        public static void afterClass() {

        }

    }

    package common;

    /**
     * Created by IntelliJ IDEA.
     * User: hantongchao
     * Date: 12-8-3
     * Time: 上午9:22
     * To change this template use File | Settings | File Templates.
     */
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;

        /**
         * 读取properties配置文件
         * @author using
         */
        public class Env extends Properties {
            private static  Env instance;

            public static Env getInstance () {
                if(null != instance) {
                    return instance;
                } else {
                    makeInstance();
                    return instance;
                }
            }

            private static synchronized void makeInstance() {
                if(instance == null) {
                    instance = new Env();
                }
            }

            private Env() {
                InputStream is = getClass().getResourceAsStream("/global.properties");
                try {
                    load(is);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            public static void main(String args[]){
              System.out.println(Env.getInstance().getProperty("han"));  ;//调用

            }
        }

  • 相关阅读:
    Android 在一个程序中启动另一个程序
    Android SDK Manager国内无法更新的解决方案
    Android studio 安装中遇到一些问题的解决办法,分享一下
    apache服务器伪静态配置说明
    POJ3253 Fence Repair【贪心】
    洛谷P1090 合并果子【贪心】
    POJ3069 Saruman's Army【贪心】
    洛谷P1012 拼数【字符串+排序】
    POJ3617 Best Cow Line【贪心】
    洛谷P1583 魔法照片【模拟+排序】
  • 原文地址:https://www.cnblogs.com/cndavy/p/2621060.html
Copyright © 2011-2022 走看看