Java 类org.springframework.beans.factory.config.YamlProcessor.DocumentMatcher 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcher.java   
@Override
public MatchStatus matches(Properties properties) {
    DocumentMatcher activeProfilesMatcher = getActiveProfilesDocumentMatcher();
    String profiles = properties.getProperty(SPRING_PROFILES);
    String negative = extractProfiles(profiles, ProfileType.NEGATIVE);
    String positive = extractProfiles(profiles, ProfileType.POSITIVE);
    if (StringUtils.hasLength(negative)) {
        properties = new Properties(properties);
        properties.setProperty(SPRING_PROFILES, negative);
        if (activeProfilesMatcher.matches(properties) == MatchStatus.FOUND) {
            return MatchStatus.NOT_FOUND;
        }
        if (StringUtils.isEmpty(positive)) {
            return MatchStatus.FOUND;
        }
        properties.setProperty(SPRING_PROFILES, positive);
    }
    return activeProfilesMatcher.matches(properties);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcher.java   
@Override
public MatchStatus matches(Properties properties) {
    DocumentMatcher activeProfilesMatcher = getActiveProfilesDocumentMatcher();
    String profiles = properties.getProperty(SPRING_PROFILES);
    String negative = extractProfiles(profiles, ProfileType.NEGATIVE);
    String positive = extractProfiles(profiles, ProfileType.POSITIVE);
    if (StringUtils.hasLength(negative)) {
        properties = new Properties(properties);
        properties.setProperty(SPRING_PROFILES, negative);
        if (activeProfilesMatcher.matches(properties) == MatchStatus.FOUND) {
            return MatchStatus.NOT_FOUND;
        }
        if (StringUtils.isEmpty(positive)) {
            return MatchStatus.FOUND;
        }
        properties.setProperty(SPRING_PROFILES, positive);
    }
    return activeProfilesMatcher.matches(properties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcher.java   
private DocumentMatcher getActiveProfilesDocumentMatcher() {
    String[] profiles = this.activeProfiles;
    if (profiles.length == 0) {
        profiles = DEFAULT_PROFILES;
    }
    return new ArrayDocumentMatcher(SPRING_PROFILES, profiles);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcher.java   
private DocumentMatcher getActiveProfilesDocumentMatcher() {
    String[] profiles = this.activeProfiles;
    if (profiles.length == 0) {
        profiles = DEFAULT_PROFILES;
    }
    return new ArrayDocumentMatcher(SPRING_PROFILES, profiles);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void matchesSingleProfile() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: foo");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void abstainNoConfiguredProfiles() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("some.property: spam");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.ABSTAIN);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void noActiveProfiles() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher();
    Properties properties = getProperties("spring.profiles: bar,spam");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void matchesCommaSeparatedArray() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: bar,spam");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void noMatchingProfiles() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: baz,blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void inverseMatchSingle() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: !baz");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void testInverseMatchMulti() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: !baz,!blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void negatedWithMatch() throws Exception {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar", "blah");
    Properties properties = getProperties("spring.profiles: !baz,blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void negatedWithNoMatch() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar", "blah");
    Properties properties = getProperties("spring.profiles: !baz,another");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void negatedTrumpsMatching() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "baz", "blah");
    Properties properties = getProperties("spring.profiles: !baz,blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void matchesSingleProfile() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: foo");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void abstainNoConfiguredProfiles() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("some.property: spam");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.ABSTAIN);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void noActiveProfiles() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher();
    Properties properties = getProperties("spring.profiles: bar,spam");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void matchesCommaSeparatedArray() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: bar,spam");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void noMatchingProfiles() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: baz,blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void inverseMatchSingle() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: !baz");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void testInverseMatchMulti() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar");
    Properties properties = getProperties("spring.profiles: !baz,!blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void negatedWithMatch() throws Exception {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar", "blah");
    Properties properties = getProperties("spring.profiles: !baz,blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void negatedWithNoMatch() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar", "blah");
    Properties properties = getProperties("spring.profiles: !baz,another");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}
项目:spring-boot-concourse    文件:SpringProfileDocumentMatcherTests.java   
@Test
public void negatedTrumpsMatching() throws IOException {
    DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "baz", "blah");
    Properties properties = getProperties("spring.profiles: !baz,blah");
    assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.NOT_FOUND);
}