org.apache.tools.ant.util.StringUtils Java Examples

The following examples show how to use org.apache.tools.ant.util.StringUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OneLinerFormatter.java    From pxf with Apache License 2.0 6 votes vote down vote up
@Override
public void endTest(Test test) {

	/**
	 * If for some reason the (Failed in setUp before the test get the chance to run) test is
	 * not in the testStarts list, put it in.
	 */
	if (!testStarts.containsKey(test)) {
		startTest(test);
	}

	boolean failed = failedTests.containsKey(test);

	Long l = testStarts.get(test);

	output.write("Ran [");
	output.write(((System.currentTimeMillis() - l.longValue()) / 1000.0) + "] ");
	output.write(getTestName(test) + " ... " + (failed ? "FAILED" : "OK"));
	output.write(StringUtils.LINE_SEP);
	output.flush();
}
 
Example #2
Source File: OneLinerFormatter.java    From pxf with Apache License 2.0 6 votes vote down vote up
@Override
public void startTestSuite(JUnitTest suite) throws BuildException {
	if (output == null) {
		return;
	}
	StringBuffer sb = new StringBuffer(StringUtils.LINE_SEP);
	sb.append("----------------------------------------------------------");
	sb.append(StringUtils.LINE_SEP);
	sb.append("Testsuite: ");
	sb.append(suite.getName());
	sb.append(StringUtils.LINE_SEP);
	sb.append("----------------------------------------------------------");
	sb.append(StringUtils.LINE_SEP);
	output.write(sb.toString());
	output.flush();
}
 
Example #3
Source File: OneLinerFormatter.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Override
public void endTestSuite(JUnitTest suite) throws BuildException {
	StringBuffer sb = new StringBuffer("Tests run: ");
	sb.append(suite.runCount());
	sb.append(", Failures: ");
	sb.append(suite.failureCount());
	sb.append(", Errors: ");
	sb.append(suite.errorCount());
	sb.append(", Time elapsed: ");
	sb.append(numberFormat.format(suite.getRunTime() / 1000.0));
	sb.append(" sec");
	sb.append(" (" + numberFormat.format(suite.getRunTime() / 1000.0 / 60));
	sb.append(" min)");
	sb.append(StringUtils.LINE_SEP);
	sb.append(StringUtils.LINE_SEP);

	if (output != null) {
		try {
			output.write(sb.toString());
			resultWriter.close();
			output.write(results.toString());
			output.flush();
		} finally {
			if (out != System.out && out != System.err) {
				FileUtils.close(out);
			}
		}
	}
}
 
Example #4
Source File: BundleInfoTask.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Set default import set.
 *
 * @param packageList Comma-separated list of package names.
 */
public void setDefaultImports(String packageList) {
  importSet.clear();
  if (null!=packageList) {
    packageList = packageList.trim();
    if (0<packageList.length()) {
      @SuppressWarnings("unchecked")
      final Vector<String> v = StringUtils.split(packageList,',');
      for (final String pkg : v) {
        importSet.add(pkg.trim());
      }
    }
  }
}
 
Example #5
Source File: BundleInfoTask.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Set the extra imports set.
 *
 * @param packageList Comma-separated list of package names.
 */
public void setExtraImports(String packageList) {
  extraImportSet.clear();
  if (null!=packageList) {
    packageList = packageList.trim();
    if (packageList.length()>0) {
      @SuppressWarnings("unchecked")
      final Vector<String> v = StringUtils.split(packageList,',');
      for (final String pkg : v) {
        extraImportSet.add(pkg.trim());
      }
    }
  }
}
 
Example #6
Source File: BundleInfoTask.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Set set of packages always imported.
 *
 * @param packageList Comma-separated list of package names.
 */
public void setStdImports(String packageList) {
  stdImports.clear();
  stdImports.add("java.");
  @SuppressWarnings("unchecked")
  final Vector<String> v = StringUtils.split(packageList,',');
  for (final String imp : v) {
    stdImports.add(imp.trim());
  }
}
 
Example #7
Source File: SentryPolicyProviderForDb.java    From incubator-sentry with Apache License 2.0 4 votes vote down vote up
private void addPrivilege(String roleName, String privileges)
    throws Exception {
  String serverName = null, dbName = null, tableName = null, columnName = null, uriPath = null;
  String action = AccessConstants.ALL;
  for (String privilege : ROLE_SPLITTER.split(privileges)) {
    for (String section : AUTHORIZABLE_SPLITTER.split(privilege)) {
      // action is not an authorizeable
      if (!section.toLowerCase().startsWith(PRIVILEGE_PREFIX)) {
        DBModelAuthorizable dbAuthorizable = DBModelAuthorizables
            .from(section);
        if (dbAuthorizable == null) {
          throw new IOException("Unknow Auth type " + section);
        }

        if (AuthorizableType.Server.equals(dbAuthorizable.getAuthzType())) {
          serverName = dbAuthorizable.getName();
        } else if (AuthorizableType.Db.equals(dbAuthorizable.getAuthzType())) {
          dbName = dbAuthorizable.getName();
        } else if (AuthorizableType.Table.equals(dbAuthorizable
            .getAuthzType())) {
          tableName = dbAuthorizable.getName();
        } else if (AuthorizableType.URI.equals(dbAuthorizable.getAuthzType())) {
          uriPath = dbAuthorizable.getName();
        } else if (AuthorizableType.Column.equals(dbAuthorizable.getAuthzType())) {
          columnName = dbAuthorizable.getName();
        } else {
          throw new IOException("Unsupported auth type "
              + dbAuthorizable.getName() + " : "
              + dbAuthorizable.getTypeName());
        }
      } else {
        action = DBModelAction
            .valueOf(
                StringUtils.removePrefix(section, PRIVILEGE_PREFIX)
                    .toUpperCase()).toString();
      }
    }

    if (columnName != null) {
      sentryClient.grantColumnPrivilege(StaticUserGroup.ADMIN1, roleName, serverName, dbName,
          tableName, columnName, action);
    } else if (tableName != null) {
      sentryClient.grantTablePrivilege(StaticUserGroup.ADMIN1, roleName, serverName, dbName,
          tableName, action);
    } else if (dbName != null) {
      sentryClient.grantDatabasePrivilege(StaticUserGroup.ADMIN1, roleName, serverName,
          dbName, action);
    } else if (uriPath != null) {
      sentryClient.grantURIPrivilege(StaticUserGroup.ADMIN1, roleName, serverName, uriPath);
    } else if (serverName != null) {
      sentryClient.grantServerPrivilege(StaticUserGroup.ADMIN1, roleName, serverName, action);
    }
  }

}