Search in sources :

Example 31 with Matcher

use of java.util.regex.Matcher in project buck by facebook.

the class CompileStringsStepTest method testContentRegex.

private void testContentRegex(String input, boolean matches, String resourceType, String resourceName, String resourceId) {
    Matcher matcher = CompileStringsStep.R_DOT_TXT_STRING_RESOURCE_PATTERN.matcher(input);
    assertEquals(matches, matcher.matches());
    if (!matches) {
        return;
    }
    assertEquals("Resource type does not match.", resourceType, matcher.group(1));
    assertEquals("Resource name does not match.", resourceName, matcher.group(2));
    assertEquals("Resource id does not match.", resourceId, matcher.group(3));
}
Also used : Matcher(java.util.regex.Matcher)

Example 32 with Matcher

use of java.util.regex.Matcher in project buck by facebook.

the class FilterResourcesStepTest method assertMatchesRegex.

private static void assertMatchesRegex(String path, String language, String country) {
    Matcher matcher = FilterResourcesStep.NON_ENGLISH_STRINGS_FILE_PATH.matcher(path);
    assertTrue(matcher.matches());
    assertEquals(language, matcher.group(1));
    assertEquals(country, matcher.group(2));
}
Also used : Matcher(java.util.regex.Matcher)

Example 33 with Matcher

use of java.util.regex.Matcher in project buck by facebook.

the class InstallCommandIntegrationTest method appleBundleInstallsAndRunsInIphoneSimulatorWithDwarfDebugging.

@Test
public void appleBundleInstallsAndRunsInIphoneSimulatorWithDwarfDebugging() throws IOException, InterruptedException {
    assumeThat(Platform.detect(), is(Platform.MACOS));
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_app_bundle", tmp);
    workspace.setUp();
    workspace.enableDirCache();
    // build locally
    ProcessResult result = workspace.runBuckCommand("install", "--config", "apple.default_debug_info_format_for_binaries=DWARF", "--config", "apple.default_debug_info_format_for_libraries=DWARF", "--config", "apple.default_debug_info_format_for_tests=DWARF", "-r", "//:DemoApp");
    assumeFalse(result.getStderr().contains("no appropriate simulator found"));
    result.assertSuccess();
    // find port to connect lldb to
    // "lldb -p 12345"
    Pattern p = Pattern.compile("lldb -p \\d{1,6}");
    Matcher matcher = p.matcher(result.getStderr());
    assertThat(matcher.find(), equalTo(true));
    String[] lldbCommand = matcher.group().split(" ");
    ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
    // run lldb session
    ProcessExecutor.Result lldbResult = executor.launchAndExecute(ProcessExecutorParams.builder().addCommand(lldbCommand).build(), ImmutableSet.of(), Optional.of("b application:didFinishLaunchingWithOptions:\nb\nexit\nY\n"), Optional.empty(), Optional.empty());
    assertThat(lldbResult.getExitCode(), equalTo(0));
    // check that lldb resolved breakpoint locations
    String lldbOutput = lldbResult.getStdout().orElse("");
    assertThat(lldbOutput, containsString("Current breakpoints:"));
    assertThat(lldbOutput, containsString("name = 'application:didFinishLaunchingWithOptions:', " + "locations = 1, resolved = 1, hit count = 0"));
    // clean buck out
    workspace.runBuckCommand("clean");
    // build again - get everything from cache now
    result = workspace.runBuckCommand("install", "--config", "apple.default_debug_info_format_for_binaries=DWARF", "--config", "apple.default_debug_info_format_for_libraries=DWARF", "--config", "apple.default_debug_info_format_for_tests=DWARF", "-r", "//:DemoApp");
    result.assertSuccess();
    matcher = p.matcher(result.getStderr());
    assertThat(matcher.find(), equalTo(true));
    String[] lldbCommand2 = matcher.group().split(" ");
    // run lldb session again - now on top of files fetched from cache
    lldbResult = executor.launchAndExecute(ProcessExecutorParams.builder().addCommand(lldbCommand2).build(), ImmutableSet.of(), Optional.of("b application:didFinishLaunchingWithOptions:\nb\nexit\nY\n"), Optional.empty(), Optional.empty());
    assertThat(lldbResult.getExitCode(), equalTo(0));
    // check that lldb resolved breakpoint locations with files from cache
    lldbOutput = lldbResult.getStdout().orElse("");
    assertThat(lldbOutput, containsString("Current breakpoints:"));
    assertThat(lldbOutput, containsString("name = 'application:didFinishLaunchingWithOptions:', " + "locations = 1, resolved = 1, hit count = 0"));
}
Also used : Pattern(java.util.regex.Pattern) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Matcher(java.util.regex.Matcher) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 34 with Matcher

use of java.util.regex.Matcher in project jetty.project by eclipse.

the class SpringXmlConfigurationTest method init.

@Before
public void init() throws Exception {
    // Jetty's XML configuration will make use of java.util.ServiceLoader
    // to load the proper ConfigurationProcessorFactory, so these tests
    // will always fail in JDK 5.
    String javaVersion = System.getProperty("java.version");
    Pattern regexp = Pattern.compile("1\\.(\\d{1})\\..*");
    Matcher matcher = regexp.matcher(javaVersion);
    if (matcher.matches()) {
        String minor = matcher.group(1);
        assumeTrue(Integer.parseInt(minor) > 5);
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Before(org.junit.Before)

Example 35 with Matcher

use of java.util.regex.Matcher in project jetty.project by eclipse.

the class SslBytesServerTest method assumeJavaVersionSupportsTLSRenegotiations.

private void assumeJavaVersionSupportsTLSRenegotiations() {
    // Due to a security bug, TLS renegotiations were disabled in JDK 1.6.0_19-21
    // so we check the java version in order to avoid to fail the test.
    String javaVersion = System.getProperty("java.version");
    Pattern regexp = Pattern.compile("1\\.6\\.0_(\\d{2})");
    Matcher matcher = regexp.matcher(javaVersion);
    if (matcher.matches()) {
        String nano = matcher.group(1);
        Assume.assumeThat(Integer.parseInt(nano), Matchers.greaterThan(21));
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Aggregations

Matcher (java.util.regex.Matcher)12640 Pattern (java.util.regex.Pattern)5059 ArrayList (java.util.ArrayList)1525 IOException (java.io.IOException)913 HashMap (java.util.HashMap)575 File (java.io.File)490 Test (org.junit.Test)448 BufferedReader (java.io.BufferedReader)433 Map (java.util.Map)369 List (java.util.List)292 InputStreamReader (java.io.InputStreamReader)268 HashSet (java.util.HashSet)237 MalformedURLException (java.net.MalformedURLException)164 URL (java.net.URL)157 Date (java.util.Date)153 InputStream (java.io.InputStream)148 Field (java.lang.reflect.Field)130 ParseException (java.text.ParseException)130 PatternSyntaxException (java.util.regex.PatternSyntaxException)128 LinkedHashMap (java.util.LinkedHashMap)122