Package com.alibaba.druid.support.console

Examples of com.alibaba.druid.support.console.Option


public class OptionTest extends TestCase {


    public void test_parseOptions() throws Exception {
        String[] cmdArray = {"-sql","-ds", "200"};
        Option opt = Option.parseOptions(cmdArray);
        Assert.assertNotNull(opt);
        Assert.assertTrue(opt.printSqlData());
        Assert.assertTrue(opt.printDataSourceData());
        Assert.assertFalse(opt.printActiveConn());
        Assert.assertEquals(opt.getPid(), 200);

        cmdArray = new String[] {"-act", "738"};
        opt = Option.parseOptions(cmdArray);
        Assert.assertNotNull(opt);
        Assert.assertFalse(opt.printSqlData());
        Assert.assertFalse(opt.printDataSourceData());
        Assert.assertTrue(opt.printActiveConn());
        Assert.assertEquals(opt.getPid(), 738);

        cmdArray = new String[] {"-ds", "-detail", "1319"};
        opt = Option.parseOptions(cmdArray);
        Assert.assertNotNull(opt);
        Assert.assertFalse(opt.printSqlData());
        Assert.assertTrue(opt.printDataSourceData());
        Assert.assertFalse(opt.printActiveConn());
        Assert.assertTrue(opt.isDetailPrint());
        Assert.assertEquals(opt.getPid(), 1319);
       
        cmdArray = new String[] {"-sql","-id","5","200"};
        opt = Option.parseOptions(cmdArray);
        Assert.assertNotNull(opt);
        Assert.assertEquals(opt.getId(), 5);
        Assert.assertEquals(opt.getPid(), 200);

    cmdArray = new String[] {"-sql","-id","5","200", "3"};
        opt = Option.parseOptions(cmdArray);
        Assert.assertNotNull(opt);
        Assert.assertEquals(opt.getId(), 5);
        Assert.assertEquals(opt.getPid(), 200);
        Assert.assertEquals(opt.getInterval(), 3);


        cmdArray = new String[] {"-ds","-id","5", "-detail", "200", "3"};
        opt = Option.parseOptions(cmdArray);
        Assert.assertNotNull(opt);
        Assert.assertEquals(opt.getId(), 5);
        Assert.assertEquals(opt.getPid(), 200);
        Assert.assertEquals(opt.getInterval(), 3);
        Assert.assertEquals(opt.isDetailPrint(), true);

        //not enough arguments
        cmdArray = new String[] {};
        try {
            opt = Option.parseOptions(cmdArray);
View Full Code Here


  public void test_printDruidStat() throws Exception {
    createDs();
        String pid = getSelfPid();
        String[] cmdArray = {"-sql", pid};
        Option opt = Option.parseOptions(cmdArray);
        DruidStat.printDruidStat(opt);

    cmdArray = new String[] {"-act", pid};
        opt = Option.parseOptions(cmdArray);
        DruidStat.printDruidStat(opt);
View Full Code Here

    }

    public void test_printDruidStat() throws Exception {
        String pid = getSelfPid();
        String[] cmdArray = {"-sql", pid};
        Option opt = Option.parseOptions(cmdArray);
        DruidStat.printDruidStat(opt);

        cmdArray = new String[] {"-sql","-id","1", pid};
        opt = Option.parseOptions(cmdArray);
        DruidStat.printDruidStat(opt);

        cmdArray = new String[] {"-sql","-detail", "-id","1", pid};
        opt = Option.parseOptions(cmdArray);
        DruidStat.printDruidStat(opt);

    cmdArray = new String[] {"-ds",pid};
        opt = Option.parseOptions(cmdArray);
    List<Integer> ids = DruidStat.getDataSourceIds(opt);
    opt.setDetailPrint(true);
    opt.setId( ids.get(0).intValue());
        DruidStat.printDruidStat(opt);

   
    }
View Full Code Here


  public void test_printDruidStat2() throws Exception {
        String pid = getSelfPid();
        String[] cmdArray = {"-act", pid};
        Option opt = Option.parseOptions(cmdArray);

        Connection conn = null;
        Statement stmt = null;
        try {
            conn = dataSource.getConnection();
View Full Code Here

TOP

Related Classes of com.alibaba.druid.support.console.Option

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.