Example usage for java.util HashMap HashMap

List of usage examples for java.util HashMap HashMap

Introduction

In this page you can find the example usage for java.util HashMap HashMap.

Prototype

public HashMap() 

Source Link

Document

Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).

Usage

From source file:com.sebuilder.interpreter.SeInterpreter.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println(//from   w  w w.  j  av  a2 s . c  om
                "Usage: [--driver=<drivername] [--driver.<configkey>=<configvalue>...] [--implicitlyWait=<ms>] [--pageLoadTimeout=<ms>] [--stepTypePackage=<package name>] <script path>...");
        System.exit(0);
    }

    Log log = LogFactory.getFactory().getInstance(SeInterpreter.class);

    WebDriverFactory wdf = DEFAULT_DRIVER_FACTORY;
    ScriptFactory sf = new ScriptFactory();
    StepTypeFactory stf = new StepTypeFactory();
    sf.setStepTypeFactory(stf);
    TestRunFactory trf = new TestRunFactory();
    sf.setTestRunFactory(trf);

    ArrayList<String> paths = new ArrayList<String>();
    HashMap<String, String> driverConfig = new HashMap<String, String>();
    for (String s : args) {
        if (s.startsWith("--")) {
            String[] kv = s.split("=", 2);
            if (kv.length < 2) {
                log.fatal("Driver configuration option \"" + s
                        + "\" is not of the form \"--driver=<name>\" or \"--driver.<key>=<value\".");
                System.exit(1);
            }
            if (s.startsWith("--implicitlyWait")) {
                trf.setImplicitlyWaitDriverTimeout(Integer.parseInt(kv[1]));
            } else if (s.startsWith("--pageLoadTimeout")) {
                trf.setPageLoadDriverTimeout(Integer.parseInt(kv[1]));
            } else if (s.startsWith("--stepTypePackage")) {
                stf.setPrimaryPackage(kv[1]);
            } else if (s.startsWith("--driver.")) {
                driverConfig.put(kv[0].substring("--driver.".length()), kv[1]);
            } else if (s.startsWith("--driver")) {
                try {
                    wdf = (WebDriverFactory) Class
                            .forName("com.sebuilder.interpreter.webdriverfactory." + kv[1]).newInstance();
                } catch (ClassNotFoundException e) {
                    log.fatal("Unknown WebDriverFactory: " + "com.sebuilder.interpreter.webdriverfactory."
                            + kv[1], e);
                } catch (InstantiationException e) {
                    log.fatal("Could not instantiate WebDriverFactory "
                            + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e);
                } catch (IllegalAccessException e) {
                    log.fatal("Could not instantiate WebDriverFactory "
                            + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e);
                }
            } else {
                paths.add(s);
            }
        } else {
            paths.add(s);
        }
    }

    if (paths.isEmpty()) {
        log.info("Configuration successful but no paths to scripts specified. Exiting.");
        System.exit(0);
    }

    HashMap<String, String> cfg = new HashMap<String, String>(driverConfig);

    for (String path : paths) {
        try {
            TestRun lastRun = null;
            for (Script script : sf.parse(new File(path))) {
                for (Map<String, String> data : script.dataRows) {
                    try {
                        lastRun = script.testRunFactory.createTestRun(script, log, wdf, driverConfig, data,
                                lastRun);
                        if (lastRun.finish()) {
                            log.info(script.name + " succeeded");
                        } else {
                            log.info(script.name + " failed");
                        }
                    } catch (Exception e) {
                        log.info(script.name + " failed", e);
                    }
                }
            }
        } catch (Exception e) {
            log.fatal("Run error.", e);
            System.exit(1);
        }
    }
}

From source file:zz.pseas.ghost.login.taobao.MTaobaoLogin.java

public static void main(String[] args) throws UnsupportedEncodingException {

    String tbuserNmae = "TBname";
    String tbpassWord = "TBpasssword";

    GhostClient iPhone = new GhostClient("utf-8");
    String ans = iPhone.get("https://login.m.taobao.com/login.htm");

    Document doc = Jsoup.parse(ans);
    String url = doc.select("form#loginForm").first().attr("action");

    String _tb_token = doc.select("input[name=_tb_token_]").first().attr("value");

    String sid = doc.select("input[name=sid]").first().attr("value");
    System.out.println(_tb_token);
    System.out.println(sid);//from www .  j  a va2s  .  c o m
    System.out.println(url);

    HashMap<String, String> map = new HashMap<String, String>();
    map.put("TPL_password", tbpassWord);
    map.put("TPL_username", tbuserNmae);
    map.put("_tb_token_", _tb_token);
    map.put("action", "LoginAction");
    map.put("event_submit_do_login", "1");
    map.put("loginFrom", "WAP_TAOBAO");
    map.put("sid", sid);

    String location = null;
    while (true) {
        CommonsPage commonsPage = iPhone.postForPage(url, map);
        location = commonsPage.getHeader("Location");
        String postAns = new String(commonsPage.getContents(), "utf-8");
        if (StringUtil.isNotEmpty(location) && StringUtil.isEmpty(postAns)) {
            break;
        }

        String s = Jsoup.parse(postAns).select("img.checkcode-img").first().attr("src");
        String imgUrl = "https:" + s;

        byte[] bytes = iPhone.getBytes(imgUrl);
        FileUtil.writeFile(bytes, "g:/tbCaptcha.jpg");

        String wepCheckId = Jsoup.parse(postAns).select("input[name=wapCheckId]").val();
        String captcha = null;
        map.put("TPL_checkcode", captcha);
        map.put("wapCheckId", wepCheckId);
    }

    iPhone.get(location);

    String tk = iPhone.getCookieValue("_m_h5_tk");
    if (StringUtil.isNotEmpty(tk)) {
        tk = tk.split("_")[0];
    } else {
        tk = "undefined";
    }

    String url2 = genUrl(tk);
    String ans1 = iPhone.get(url2);
    System.out.println(url2);
    System.out.println(ans1);

    tk = iPhone.getCookieValue("_m_h5_tk").split("_")[0];
    if (StringUtil.isEmpty(tk)) {
        tk = "undefined";
    }
    System.out.println(tk);
    url2 = genUrl(tk);
    iPhone.showCookies();
    RequestConfig requestConfig = RequestConfig.custom().setProxy(new HttpHost("127.0.0.1", 8888)).build();

    HttpUriRequest get = RequestBuilder.get().setConfig(requestConfig)
            //.addHeader("User-Agent","Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16")
            .addHeader("Host", "api.m.taobao.com").setUri(url2).build();

    ans1 = iPhone.execute(get);

    System.out.println(ans1);

}

From source file:com.joymove.service.impl.JOYUserServiceImpl.java

public static void main(String[] args) throws Exception {

    ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test.xml");
    Map<String, Object> likeCondition = new HashMap<String, Object>();
    JOYUser user = new JOYUser();
    DateFormat formatWithTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    user.registerTime = formatWithTime.parse("2013-04-29 15:08:41");

    JOYUserDao dao = (JOYUserDao) context.getBean("JOYUserDao");
    likeCondition.putAll(user.toMap());// w  w w . ja v a2  s  .c o  m
    likeCondition.put("filter", user);
    List<Map<String, Object>> mapList = dao.getPagedRecordList(likeCondition);
    for (int i = 0; i < mapList.size(); i++) {
        JOYUser userObj = new JOYUser();
        user.fromMap(mapList.get(i));
        System.out.println(user);
    }

    /*
            
            
    JOYPayHistoryService service = (JOYPayHistoryService)context.getBean("JOYPayHistoryService");
    JOYPayHistory payHistoryNew = new JOYPayHistory();
    payHistoryNew.balance = 0.2;
    payHistoryNew.type = 2;
    service.deleteByProperties(payHistoryNew);
            
            
    /*
    JOYUserService service = (JOYUserService)context.getBean("JOYUserService");
    JOYUser user = new JOYUser();
    user.mobileNo = "18500217642";
    List<Map<String,Object>> mapList = service.getExtendInfoPagedList(" select u.*, m.driverLicenseNumber  from JOY_Users u left join JOY_DriverLicense m on u.mobileNo = m.mobileNo ",user);
            
            
    //   JOYUser user2 = new JOYUser();
    Map<String,Object> t = mapList.get(0);
    Iterator i =t.entrySet().iterator();
    JSONObject tt = new JSONObject();
    while(i.hasNext()) {
            
       Map.Entry<String,Object> haha = (Map.Entry<String,Object>)i.next();
        if(String.valueOf(haha.getValue()).equals("null")) {
    logger.trace(haha.getKey()+" is null");
       }
    }
            
    /*
    user2.username = "?";
    user.mobileNo="18500217642";
    service.updateRecord(user2,user);
    user = service.getNeededRecord(user);
      logger.trace(user);
            
    /*
    JOYOrderService service = (JOYOrderService) context.getBean("JOYOrderService");
    JOYOrder order = new JOYOrder();
    order = service.getNeededRecord(order);
    JOYOrder order2 = new JOYOrder();
    order2.startTime = order.startTime;
    order = new JOYOrder();
    order.startTime = new Date(System.currentTimeMillis());
    service.updateRecord(order,order2);
       /*
    JOYNReserveOrderService  service  = (JOYNReserveOrderService)context.getBean("JOYNReserveOrderService");
    JOYReserveOrder order = new JOYReserveOrder();
    //service.insertRecord(order);
    JOYReserveOrder order2 = new JOYReserveOrder();
    order2.mobileNo = "18500217642";
    order2.startTime = new Date(System.currentTimeMillis());
      service.insertRecord(order2);
    order2.startTime = null;
    order = service.getNeededRecord(order2);
     order.startTime = new Date(System.currentTimeMillis());
    service.updateRecord(order,order2);
      order2.startTime = order.startTime;
    order2.mobileNo = null;
    order = service.getNeededRecord(order2);
    logger.trace(order);
    /*
    order.delFlag = 1;
    order.startTime = new Date(System.currentTimeMillis()+30);
    service.updateRecord(order,order2);
            
    order2.mobileNo = null;
    order2.startTime = order.startTime;
    order = service.getNeededRecord(order2);
    logger.trace(order);
    //service.deleteByProperties(order);
            
            
    /*
    JOYIdAuthInfoService service  = (JOYIdAuthInfoService)context.getBean("JOYIdAuthInfoService");
    JOYIdAuthInfo dl = new JOYIdAuthInfo();
    dl.idAuthInfo = "nihao".getBytes();
    dl.idAuthInfo_back = "Hello world".getBytes();
    JOYIdAuthInfo dl2 = new JOYIdAuthInfo();
    dl2.mobileNo = "15577586649";
    service.updateRecord(dl,dl2);
            
            
    service.getNeededList(dl2,null,null);
            
            
            
    List<JOYIdAuthInfo> dList = service.getNeededList(dl,null,null);
    logger.trace(dList.get(0));
            
    for(int i=0;i<dList.get(0).idAuthInfo.length;i++)
    System.out.format("%c",dList.get(0).idAuthInfo[i]);
    /*
    JOYUser user = new JOYUser();
    JOYUser user1 = new JOYUser();
    user.mobileNo = ("18500217642");
    List<JOYUser> userList =  service.getNeededList(user,0,10);
      logger.trace("sdfdsdsf :"+userList.size());
    JOYUser u = userList.get(0);
    logger.trace(u);
     */
}

From source file:MapEntrySetDemo.java

public static void main(String[] argv) {

    // Construct and load the hash. This simulates loading a
    // database or reading from a file, or wherever the data is.

    Map map = new HashMap();

    // The hash maps from company name to address.
    // In real life this might map to an Address object...
    map.put("Adobe", "Mountain View, CA");
    map.put("IBM", "White Plains, NY");
    map.put("Learning Tree", "Los Angeles, CA");
    map.put("Microsoft", "Redmond, WA");
    map.put("Netscape", "Mountain View, CA");
    map.put("O'Reilly", "Sebastopol, CA");
    map.put("Sun", "Mountain View, CA");

    // List the entries using entrySet()
    Set entries = map.entrySet();
    Iterator it = entries.iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        System.out.println(entry.getKey() + "-->" + entry.getValue());
    }//from   w w  w.jav a 2s. co  m
}

From source file:net.landora.justintv.JustinTVAPI.java

public static void main(String[] args) throws Exception {
    List<JustinArchive> archives = readArchives("tsmtournaments", 64);
    Map<String, List<JustinArchive>> groups = new HashMap<String, List<JustinArchive>>();
    for (int i = 0; i < archives.size(); i++) {
        JustinArchive archive = archives.get(i);
        List<JustinArchive> group = groups.get(archive.getBroadcastId());
        if (group == null) {
            group = new ArrayList<JustinArchive>(archive.getBroadcastPart());
            groups.put(archive.getBroadcastId(), group);
        }/*from ww w . j a va2s .  c o  m*/
        group.add(archive);
    }

    BroadcastSorter sorter = new BroadcastSorter();

    for (List<JustinArchive> group : groups.values()) {
        Collections.sort(group, sorter);

        JustinArchive base = group.get(group.size() - 1);

        StringBuffer cmd = new StringBuffer();
        cmd.append("mkvmerge -o \"");
        cmd.append(base.getBroadcastId());
        cmd.append(" - ");
        cmd.append(base.getTitle());
        cmd.append("\" ");

        for (int i = 0; i < group.size(); i++) {
            JustinArchive archive = group.get(i);
            if (i > 0)
                cmd.append("+ ");

            cmd.append(archive.getId());
            cmd.append(".mkv ");
        }
        System.out.println(cmd);
    }
}

From source file:com.glaf.core.xml.XmlBuilder.java

public static void main(String[] args) throws Exception {
    long start = System.currentTimeMillis();
    String systemName = "default";

    XmlBuilder builder = new XmlBuilder();
    InputStream in = new FileInputStream("./template/user.template.xml");
    String filename = "user.xml";
    byte[] bytes = FileUtils.getBytes(in);
    Map<String, Object> dataMap = new HashMap<String, Object>();
    dataMap.put("now", new Date());
    Document doc = builder.process(systemName, new ByteArrayInputStream(bytes), dataMap);
    FileUtils.save(filename, com.glaf.core.util.Dom4jUtils.getBytesFromPrettyDocument(doc, "GBK"));
    // net.sf.json.xml.XMLSerializer xmlSerializer = new
    // net.sf.json.xml.XMLSerializer();
    // net.sf.json.JSON json = xmlSerializer.read(doc.asXML());
    // System.out.println(json.toString(1));

    long time = (System.currentTimeMillis() - start) / 1000;
    System.out.println("times:" + time + " seconds");
}

From source file:com.jkoolcloud.tnt4j.streams.sample.builder.SampleStreamingApp.java

/**
 * Main entry point for running as a standalone application.
 *
 * @param args/* w w  w.ja  va  2s  . co  m*/
 *            program command-line arguments. Supported arguments:
 *            <table summary="TNT4J-Streams agent command line arguments">
 *            <tr>
 *            <td>&nbsp;&nbsp;</td>
 *            <td>&nbsp;&lt;orders_log_file_path&gt;</td>
 *            <td>(optional) path of "orders.log" file. Default value is working dir.</td>
 *            </tr>
 *            </table>
 * @throws Exception
 *             if any exception occurs while running application
 */
public static void main(String... args) throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put(ParserProperties.PROP_FLD_DELIM, "|"); // NON-NLS

    ActivityTokenParser atp = new ActivityTokenParser();
    atp.setName("TokenParser"); // NON-NLS
    atp.setProperties(props.entrySet());

    ActivityField f = new ActivityField(StreamFieldType.StartTime.name());
    ActivityFieldLocator afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "1");
    afl.setFormat("dd MMM yyyy HH:mm:ss", "en-US"); // NON-NLS
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.ServerIp.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "2");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.ApplName.name());
    afl = new ActivityFieldLocator("orders"); // NON-NLS
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.Correlator.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "3");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.UserName.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "4");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.EventName.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "5");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.EventType.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "5");
    afl.addValueMap("Order Placed", "START").addValueMap("Order Received", "RECEIVE") // NON-NLS
            .addValueMap("Order Processing", "OPEN").addValueMap("Order Processed", "SEND") // NON-NLS
            .addValueMap("Order Shipped", "END"); // NON-NLS
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField("MsgValue"); // NON-NLS
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "8");
    f.addLocator(afl);
    atp.addField(f);

    props = new HashMap<>();
    props.put(StreamProperties.PROP_FILENAME, ArrayUtils.isEmpty(args) ? "orders.log" : args[0]); // NON-NLS

    FileLineStream fls = new FileLineStream();
    fls.setName("FileStream"); // NON-NLS
    fls.setProperties(props.entrySet());
    fls.addParser(atp);
    // if (fls.getOutput() == null) {
    // fls.setDefaultStreamOutput();
    // }

    StreamsAgent.runFromAPI(fls);
}

From source file:akori.AKORI.java

public static void main(String[] args) throws IOException, InterruptedException {
    System.out.println("esto es AKORI");

    URL = "http://www.mbauchile.cl";
    PATH = "E:\\NetBeansProjects\\AKORI\\";
    NAME = "mbauchile.png";
    // Extrar DOM tree

    Document doc = Jsoup.connect(URL).timeout(0).get();

    // The Firefox driver supports javascript 
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    System.out.println(driver.manage().window().getSize().toString());
    System.out.println(driver.manage().window().getPosition().toString());
    int xmax = driver.manage().window().getSize().width;
    int ymax = driver.manage().window().getSize().height;

    // Go to the URL page
    driver.get(URL);//from  ww w.  j a v a2  s.c  om

    File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(screen, new File(PATH + NAME));

    BufferedImage img = ImageIO.read(new File(PATH + NAME));
    //Graphics2D graph = img.createGraphics();

    BufferedImage img1 = new BufferedImage(xmax, ymax, BufferedImage.TYPE_INT_ARGB);
    Graphics2D graph1 = img.createGraphics();
    double[][] matrix = new double[ymax][xmax];
    BufferedReader in = new BufferedReader(new FileReader("et.txt"));
    String linea;
    double max = 0;
    graph1.drawImage(img, 0, 0, null);
    HashMap<String, Integer> lista = new HashMap<String, Integer>();
    int count = 0;
    for (int i = 0; (linea = in.readLine()) != null && i < 10000; ++i) {
        String[] datos = linea.split(",");
        int x = (int) Double.parseDouble(datos[0]);
        int y = (int) Double.parseDouble(datos[2]);
        long time = Double.valueOf(datos[4]).longValue();
        if (x >= xmax || y >= ymax)
            continue;
        if (time < 691215)
            continue;
        if (time > 705648)
            break;
        if (lista.containsKey(x + "," + y))
            lista.put(x + "," + y, lista.get(x + "," + y) + 1);
        else
            lista.put(x + "," + y, 1);
        ++count;
    }
    System.out.println(count);
    in.close();
    Iterator iter = lista.entrySet().iterator();
    Map.Entry e;
    for (String key : lista.keySet()) {
        Integer i = lista.get(key);
        if (max < i)
            max = i;
    }
    System.out.println(max);
    max = 0;
    while (iter.hasNext()) {
        e = (Map.Entry) iter.next();
        String xy = (String) e.getKey();
        String[] datos = xy.split(",");
        int x = Integer.parseInt(datos[0]);
        int y = Integer.parseInt(datos[1]);
        matrix[y][x] += (int) e.getValue();
        double aux;
        if ((aux = normalMatrix(matrix, y, x, ((int) e.getValue()) * 4)) > max) {
            max = aux;
        }
        //normalMatrix(matrix,x,y,20);
        if (matrix[y][x] > max)
            max = matrix[y][x];
    }
    int A, R, G, B, n;
    for (int i = 0; i < xmax; ++i) {
        for (int j = 0; j < ymax; ++j) {
            if (matrix[j][i] != 0) {
                n = (int) Math.round(matrix[j][i] * 100 / max);
                R = Math.round((255 * n) / 100);
                G = Math.round((255 * (100 - n)) / 100);
                B = 0;
                A = Math.round((255 * n) / 100);
                ;
                if (R > 255)
                    R = 255;
                if (R < 0)
                    R = 0;
                if (G > 255)
                    G = 255;
                if (G < 0)
                    G = 0;
                if (R < 50)
                    A = 0;
                graph1.setColor(new Color(R, G, B, A));
                graph1.fillOval(i, j, 1, 1);
            }
        }
    }
    //graph1.dispose();

    ImageIO.write(img, "png", new File("example.png"));
    System.out.println(max);

    graph1.setColor(Color.RED);
    // Extraer elementos
    Elements e1 = doc.body().getAllElements();
    int i = 1;
    ArrayList<String> tags = new ArrayList<String>();
    for (Element temp : e1) {

        if (tags.indexOf(temp.tagName()) == -1) {
            tags.add(temp.tagName());

            List<WebElement> query = driver.findElements(By.tagName(temp.tagName()));
            for (WebElement temp1 : query) {
                Point po = temp1.getLocation();
                Dimension d = temp1.getSize();
                if (d.width <= 0 || d.height <= 0 || po.x < 0 || po.y < 0)
                    continue;
                System.out.println(i + " " + temp.nodeName());
                System.out.println("  x: " + po.x + " y: " + po.y);
                System.out.println("  width: " + d.width + " height: " + d.height);
                graph1.draw(new Rectangle(po.x, po.y, d.width, d.height));
                ++i;
            }
        }
    }

    graph1.dispose();
    ImageIO.write(img, "png", new File(PATH + NAME));

    driver.quit();

}

From source file:uk.ac.kcl.Main.java

public static void main(String[] args) {
    File folder = new File(args[0]);
    File[] listOfFiles = folder.listFiles();
    assert listOfFiles != null;
    for (File listOfFile : listOfFiles) {
        if (listOfFile.isFile()) {
            if (listOfFile.getName().endsWith(".properties")) {
                System.out.println("Properties sile found:" + listOfFile.getName()
                        + ". Attempting to launch application context");
                Properties properties = new Properties();
                InputStream input;
                try {
                    input = new FileInputStream(listOfFile);
                    properties.load(input);
                    if (properties.getProperty("globalSocketTimeout") != null) {
                        TcpHelper.setSocketTimeout(
                                Integer.valueOf(properties.getProperty("globalSocketTimeout")));
                    }//  w w  w  .  j av a2s.co  m
                    Map<String, Object> map = new HashMap<>();
                    properties.forEach((k, v) -> {
                        map.put(k.toString(), v);
                    });
                    ConfigurableEnvironment environment = new StandardEnvironment();
                    MutablePropertySources propertySources = environment.getPropertySources();
                    propertySources.addFirst(new MapPropertySource(listOfFile.getName(), map));
                    @SuppressWarnings("resource")
                    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
                    ctx.registerShutdownHook();
                    ctx.setEnvironment(environment);
                    String scheduling;
                    try {
                        scheduling = properties.getProperty("scheduler.useScheduling");
                        if (scheduling.equalsIgnoreCase("true")) {
                            ctx.register(ScheduledJobLauncher.class);
                            ctx.refresh();
                        } else if (scheduling.equalsIgnoreCase("false")) {
                            ctx.register(SingleJobLauncher.class);
                            ctx.refresh();
                            SingleJobLauncher launcher = ctx.getBean(SingleJobLauncher.class);
                            launcher.launchJob();
                        } else if (scheduling.equalsIgnoreCase("slave")) {
                            ctx.register(JobConfiguration.class);
                            ctx.refresh();
                        } else {
                            throw new RuntimeException(
                                    "useScheduling not configured. Must be true, false or slave");
                        }
                    } catch (NullPointerException ex) {
                        throw new RuntimeException(
                                "useScheduling not configured. Must be true, false or slave");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.wordnik.swagger.testframework.JavaTestCaseExecutor.java

/**
 * Follow the following argument pattern
 * Arguments in calling this method:/*from   w  w w  .ja v a  2s  .c o  m*/
 * ApiServerURL
 *
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {

    JavaTestCaseExecutor runner = new JavaTestCaseExecutor();
    String apiServer = args[1];
    String servicePackageName = args[2];
    String apiKey = args[3];
    String authToken = args[4];
    String resource = args[5];
    String httpMethod = args[6];
    String suggestedMethodName = args[7];
    Map<String, String> queryAndPathParameters = new HashMap<String, String>();
    String postData = null;
    if (args.length > 8 && args[8].length() > 0) {
        String[] qpTuple = args[8].split("~");
        for (String tuple : qpTuple) {
            String[] nameValue = tuple.split("=");
            queryAndPathParameters.put(nameValue[0], nameValue[1]);
        }
    }
    if (args.length > 9) {
        postData = args[9];
    }
    queryAndPathParameters.put("authToken", authToken);

    ApiKeyAuthTokenBasedSecurityHandler securityHandler = new ApiKeyAuthTokenBasedSecurityHandler(apiKey,
            authToken);
    APIInvoker aAPIInvoker = APIInvoker.initialize(securityHandler, apiServer, true);

    runner.executeTestCase(resource, servicePackageName, suggestedMethodName, queryAndPathParameters, postData);

}