Ejemplo n.º 1
0
 public static int flagsFromString(String flags) {
   int pFlags = 0;
   for (String s : Strings.delimitedListToStringArray(flags, "|")) {
     if (s.isEmpty()) {
       continue;
     }
     if ("CASE_INSENSITIVE".equalsIgnoreCase(s)) {
       pFlags |= Pattern.CASE_INSENSITIVE;
     } else if ("MULTILINE".equalsIgnoreCase(s)) {
       pFlags |= Pattern.MULTILINE;
     } else if ("DOTALL".equalsIgnoreCase(s)) {
       pFlags |= Pattern.DOTALL;
     } else if ("UNICODE_CASE".equalsIgnoreCase(s)) {
       pFlags |= Pattern.UNICODE_CASE;
     } else if ("CANON_EQ".equalsIgnoreCase(s)) {
       pFlags |= Pattern.CANON_EQ;
     } else if ("UNIX_LINES".equalsIgnoreCase(s)) {
       pFlags |= Pattern.UNIX_LINES;
     } else if ("LITERAL".equalsIgnoreCase(s)) {
       pFlags |= Pattern.LITERAL;
     } else if ("COMMENTS".equalsIgnoreCase(s)) {
       pFlags |= Pattern.COMMENTS;
     } else {
       throw new ElasticSearchIllegalArgumentException("Unknown regex flag [" + s + "]");
     }
   }
   return pFlags;
 }
Ejemplo n.º 2
0
 @Test
 public void testIsolatedPluginProperties() throws Exception {
   try {
     String prop = "es.test.isolated.plugin.count";
     int count = Integer.getInteger(prop, 0);
     client();
     // do a >= comparison in case there are multiple tests running in the same JVM (build server)
     assertThat(Integer.getInteger(prop), greaterThanOrEqualTo(count + 2));
     Properties p = System.getProperties();
     prop = p.getProperty("es.test.isolated.plugin.instantiated.hashes");
     String[] hashes = Strings.delimitedListToStringArray(prop, " ");
     // 2 plugins plus trailing space
     assertThat(hashes.length, greaterThanOrEqualTo(count + 2));
     Arrays.sort(hashes);
     assertThat(
         Arrays.binarySearch(hashes, p.getProperty("es.test.isolated.plugin.instantiated")),
         greaterThanOrEqualTo(0));
   } finally {
     System.setProperties(props);
   }
 }