1
2
3
4
5 package com.qulice.maven;
6
7 import java.io.File;
8 import java.nio.charset.StandardCharsets;
9 import java.util.Collections;
10 import org.apache.commons.io.FileUtils;
11 import org.cactoos.io.ResourceOf;
12 import org.cactoos.text.TextOf;
13 import org.junit.jupiter.api.Assertions;
14 import org.junit.jupiter.api.Test;
15
16
17
18
19
20
21 final class PomXpathValidatorTest {
22
23
24
25
26
27
28 @Test
29 void canValidatePomWithXpath() throws Exception {
30 final MavenEnvironment env = new MavenEnvironmentMocker().withAsserts(
31 Collections.singletonList(
32 "/pom:project/pom:dependencies/pom:dependency[pom:artifactId='commons-io']/pom:version[.='1.2.5']/text()"
33 )
34 ).mock();
35 FileUtils.write(
36 new File(
37 String.format(
38 "%s%spom.xml", env.basedir(), File.separator
39 )
40 ),
41 new TextOf(
42 new ResourceOf("com/qulice/maven/PomXpathValidator/pom.xml")
43 ).asString(),
44 StandardCharsets.UTF_8
45 );
46 Assertions.assertDoesNotThrow(
47 () -> new PomXpathValidator().validate(env)
48 );
49 }
50 }