code-intelligence.com/cifuzz@v0.40.0/internal/build/maven/xml_test.go (about) 1 package maven 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestParseXML_BuildDirs(t *testing.T) { 12 13 in := strings.NewReader(` 14 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 15 <build> 16 <directory>/target</directory> 17 <outputDirectory>/target/classes</outputDirectory> 18 <testOutputDirectory>/target/test-classes</testOutputDirectory> 19 <resources> 20 <resource> 21 <directory>/main/resources1</directory> 22 </resource> 23 <resource> 24 <directory>/main/resources2</directory> 25 </resource> 26 </resources> 27 <testResources> 28 <testResource> 29 <directory>/test/resources</directory> 30 </testResource> 31 </testResources> 32 </build> 33 </project> 34 `) 35 project, err := parseXML(in) 36 require.NoError(t, err) 37 require.NotEmpty(t, project) 38 39 assert.Equal(t, "/target", project.Build.Directory) 40 assert.Equal(t, "/target/classes", project.Build.OutputDirectory) 41 assert.Equal(t, "/target/test-classes", project.Build.TestOutputDirectory) 42 43 assert.Len(t, project.Build.Resources.Resource, 2) 44 assert.Equal(t, "/main/resources1", project.Build.Resources.Resource[0].Directory) 45 assert.Equal(t, "/main/resources2", project.Build.Resources.Resource[1].Directory) 46 47 assert.Len(t, project.Build.TestResources.TestResource, 1) 48 assert.Equal(t, "/test/resources", project.Build.TestResources.TestResource[0].Directory) 49 }