diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/Community.java b/dspace-rest/src/main/java/org/dspace/rest/common/Community.java index f6622b61e0..531bf42623 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/common/Community.java +++ b/dspace-rest/src/main/java/org/dspace/rest/common/Community.java @@ -181,6 +181,10 @@ public class Community extends DSpaceObject{ return logo; } + public void setLogo(Bitstream logo) { + this.logo = logo; + } + // Renamed because of xml annotation exception with this attribute and getSubCommunities. @XmlElement(name = "subcommunities", required = true) public List getSubcommunities() { diff --git a/dspace-rest/src/test/java/org/dspace/rest/common/TestJAXBSchema.java b/dspace-rest/src/test/java/org/dspace/rest/common/TestJAXBSchema.java new file mode 100644 index 0000000000..bd544de90e --- /dev/null +++ b/dspace-rest/src/test/java/org/dspace/rest/common/TestJAXBSchema.java @@ -0,0 +1,70 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.rest.common; + +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.SchemaOutputResolver; +import javax.xml.transform.Result; +import javax.xml.transform.stream.StreamResult; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +public class TestJAXBSchema { + + private static class TestSchemaOutputResolver extends SchemaOutputResolver { + + private final Writer output; + + public TestSchemaOutputResolver(Writer output) { + this.output = output; + } + + public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { + StreamResult result = new StreamResult(output); + result.setSystemId("xsd0.xsd"); + return result; + } + + } + + @Test + public void testFullSchema() throws Exception { + StringWriter writer = new StringWriter(); + TestSchemaOutputResolver resolver = new TestSchemaOutputResolver(writer); + JAXBContext context = JAXBContext.newInstance( + Bitstream.class, + CheckSum.class, + Collection.class, + Community.class, + DSpaceObject.class, + Item.class, + MetadataEntry.class, + ResourcePolicy.class, + Status.class, + User.class + ); + context.generateSchema(resolver); + + String res = "org/dspace/rest/common/expected_xsd0.xsd"; + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(res); + String expected = IOUtils.toString(is, "UTF-8"); + + // System.err.println(writer.toString()); + + assertEquals("JAXB schema", expected, writer.toString()); + } + +} diff --git a/dspace-rest/src/test/resources/org/dspace/rest/common/expected_xsd0.xsd b/dspace-rest/src/test/resources/org/dspace/rest/common/expected_xsd0.xsd new file mode 100644 index 0000000000..7b7e5d592c --- /dev/null +++ b/dspace-rest/src/test/resources/org/dspace/rest/common/expected_xsd0.xsd @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +