Пример #1
0
 public String getSqlBySqlFile(Class daoClass, Method method, String suffix) {
   String base = daoClass.getName().replace('.', '/') + "_" + method.getName();
   String dbmsPath =
       base + (StringUtil.isEmpty(suffix) ? "" : "_" + suffix) + DaoConstants.SQL_EXTENSION;
   String standardPath = base + DaoConstants.SQL_EXTENSION;
   if (ResourceUtil.isExist(dbmsPath)) {
     return TextUtil.readUTF8(dbmsPath);
   } else if (ResourceUtil.isExist(standardPath)) {
     return TextUtil.readUTF8(standardPath);
   }
   return null;
 }
 protected void setupBaseDir() {
   String path = ResourceUtil.getResourcePath(referenceClass);
   URL url = ResourceUtil.getResource(path);
   String fileName = null;
   if ("zip".equals(url.getProtocol())) {
     fileName = ZipFileUtil.toZipFilePath(url);
   } else {
     fileName = JarFileUtil.toJarFilePath(url);
   }
   File jarFile = new File(fileName);
   File dir = jarFile.getParentFile();
   setBaseDir(FileUtil.getCanonicalPath(dir));
 }
Пример #3
0
 public DataSet read(TestContext testContext) {
   final String dirPath = testContext.getTestClassPackagePath();
   final boolean trimString = testContext.isTrimString();
   for (final String path : expectedDataXlsPaths) {
     if (ResourceUtil.isExist(path)) {
       return readXls(path, trimString);
     }
     final String newPath = dirPath + "/" + path;
     if (ResourceUtil.isExist(newPath)) {
       return readXls(newPath, trimString);
     }
   }
   return null;
 }
 @Test(expected = RoutingException.class)
 public void testPut() throws RoutingException {
   Routes.load(ResourceUtil.getResourceAsFile("routes/via.xml"));
   System.out.println(Routes.getRouteSet().toString());
   MockHttpServletRequest request = ((MockHttpServletRequest) RequestUtil.getRequest());
   request.setMethod("PUT");
   Routes.recognizePath("/methods/");
 }
  @Test
  public void testPost() {
    Routes.load(ResourceUtil.getResourceAsFile("routes/via.xml"));
    System.out.println(Routes.getRouteSet().toString());
    MockHttpServletRequest request = ((MockHttpServletRequest) RequestUtil.getRequest());
    request.setMethod("POST");
    Options options = Routes.recognizePath("/methods/");
    System.out.println(options);

    assertThat(options.getString("action"), is("getAndPost"));
  }
 public S2Container build(String path) {
   try {
     S2Container container = new S2ContainerImpl();
     Properties props = new Properties();
     props.load(ResourceUtil.getResourceAsStream(path));
     for (Iterator it = props.keySet().iterator(); it.hasNext(); ) {
       String name = (String) it.next();
       container.register(ClassUtil.forName(props.getProperty(name)), name);
     }
     return container;
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }