+ public static String createRandomIDString() {
+ final char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
+ final int idStringLength = 16;
+
+ Random sr;
+ sr = new Random();
+
+ StringBuilder sb = new StringBuilder(idStringLength);
+ for (int i = 0; i < idStringLength; i++) {
+ sb.append(chars[sr.nextInt(chars.length)]);
+ }
+
+ return sb.toString();
+ }
+
+ public static synchronized String createUniqueName() {
+ return "test" + createRandomIDString() + "a" + (count++) + "u";
+ }
+
+ public static CertificateProfile getClientProfile() {
+ return CertificateProfile.getByName("client");
+ }
+
+ public static int countRegex(String text, String pattern) {
+ Pattern p = Pattern.compile(pattern);
+ Matcher m = p.matcher(text);
+ int i = 0;
+ while (m.find()) {
+ i++;
+ }
+ return i;
+ }
+
+ public static void makeAssurer(int uid) {
+ try (GigiPreparedStatement ps1 = new GigiPreparedStatement("INSERT INTO cats_passed SET user_id=?, variant_id=?, language='en_EN', version='1'")) {
+ ps1.setInt(1, uid);
+ ps1.setInt(2, CATSType.ASSURER_CHALLENGE.getId());
+ ps1.execute();
+ }
+
+ try (GigiPreparedStatement ps2 = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, points='100'")) {
+ ps2.setInt(1, uid);
+ ps2.setInt(2, User.getById(uid).getPreferredName().getId());
+ ps2.execute();
+ }
+ }
+
+ public MailReceiver getMailReceiver() {
+ throw new Error("Feature requires Business or ManagedTest.");