diff --git a/src/it/schemagen-encoding-utf8/pom.xml b/src/it/schemagen-encoding-utf8/pom.xml new file mode 100644 index 00000000..759bffee --- /dev/null +++ b/src/it/schemagen-encoding-utf8/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.codehaus.mojo.jaxb2.its + mjaxb-64 + 1.0-SNAPSHOT + + Purpose: Test for bug reported in MJAXB-64 (Combinations of name attributes for + XmlTypes and XmlRootElement). + + + + UTF-8 + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 3.0.0 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.8 + 1.8 + + + + + + + org.codehaus.mojo + jaxb2-maven-plugin + @project.version@ + + + schemagen + + schemagen + + + + + + + + test + transform-test.xsd + + + + + + + diff --git a/src/it/schemagen-encoding-utf8/src/main/java/se/west/shauqra/Foo.java b/src/it/schemagen-encoding-utf8/src/main/java/se/west/shauqra/Foo.java new file mode 100644 index 00000000..a8803e75 --- /dev/null +++ b/src/it/schemagen-encoding-utf8/src/main/java/se/west/shauqra/Foo.java @@ -0,0 +1,21 @@ +package se.west.shauqra; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; + +@XmlType(namespace = "test") +@XmlAccessorType(XmlAccessType.FIELD) +public class Foo { + @XmlElement(name = "utf8-name_äöüÄÖÜáéúàèù") + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/src/it/schemagen-encoding-utf8/verify.groovy b/src/it/schemagen-encoding-utf8/verify.groovy new file mode 100644 index 00000000..41d92d97 --- /dev/null +++ b/src/it/schemagen-encoding-utf8/verify.groovy @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import groovy.xml.XmlSlurper + +// Assemble +final File outputDir = new File(basedir, 'target/generated-resources/schemagen'); +final File vanillaSchema = new File(basedir, 'target/schemagen-work/compile_scope/schema1.xsd'); +final File processedSchema = new File(outputDir, 'transform-test.xsd'); + +assert vanillaSchema.exists(), "Expected file [" + vanillaSchema.getAbsolutePath() + "] not found." +assert processedSchema.exists(), "Expected file [" + processedSchema.getAbsolutePath() + "] not found." + +// Act +def schemaElement = new XmlSlurper().parse(processedSchema) + +// Assert +println "\nValidating schema content" +println "===================================" + +assert schemaElement.complexType.sequence.element.@name == "utf8-name_äöüÄÖÜáéúàèù" +println "1. Got correct name (utf8-name_äöüÄÖÜáéúàèù) for foo element child."