Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix polyglot-groovy tests #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions polyglot-groovy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<dependency>
<groupId>io.takari.polyglot</groupId>
<artifactId>polyglot-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
Expand All @@ -50,10 +56,29 @@
</exclusion>
</exclusions>
</dependency>

<!-- Test -->
<dependency>
<groupId>io.takari.polyglot</groupId>
<artifactId>polyglot-maven-plugin</artifactId>
<scope>test</scope>
</dependency>
<!-- polyglot-groovy only one uses PlexusTestCase and that one needs this -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@
*/
package org.sonatype.maven.polyglot.groovy

import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import org.apache.maven.model.Model
import org.apache.maven.model.io.DefaultModelWriter
import org.sonatype.maven.polyglot.groovy.Dom2Groovy
import org.codehaus.plexus.ContainerConfiguration
import org.codehaus.plexus.PlexusConstants
import org.codehaus.plexus.PlexusTestCase
import org.w3c.dom.Document
import org.xml.sax.InputSource
import static org.junit.Assert.*
import org.sonatype.maven.polyglot.groovy.Dom2Groovy
import org.codehaus.plexus.PlexusTestCase

import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory

/**
* Support for model tests.
*
* @author <a href="mailto:[email protected]">Jason Dillon</a>
*/
public class GroovyModelTestSupport
extends PlexusTestCase
{
public class GroovyModelTestSupport extends PlexusTestCase {
@Override
protected void customizeContainerConfiguration(ContainerConfiguration configuration) {
configuration.autoWiring = true;
configuration.classPathScanning = PlexusConstants.SCANNING_CACHE
}

protected String load(final String name) {
assertNotNull(name)
def url = getClass().getResource(name)
Expand All @@ -46,15 +50,15 @@ public class GroovyModelTestSupport
Dom2Groovy converter = new Dom2Groovy(new IndentPrinter(new PrintWriter(buff), " "))
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
Document doc = builder.parse(new InputSource(new StringReader(chew(model))))

def root = doc.documentElement
def attrs = root.attributes
for (int i=0; i<attrs.length; i++) {
for (int i = 0; i < attrs.length; i++) {
root.removeAttribute(attrs.item(i).name)
}
// Not sure where this comes from but the above will not nuke it
root.removeAttribute("xmlns:xsi")

converter.print(doc)
println(buff)
}
Expand Down