blob: 36211e0a79f947933ae2330a0aa1212963838dc9 [file] [log] [blame]
/*
* Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Blaise Doughan - 2.3 - initial implementation
package org.eclipse.persistence.testing.jaxb.xmlinlinebinary;
import java.io.InputStream;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.sax.SAXSource;
import org.eclipse.persistence.internal.oxm.record.XMLStreamReaderInputSource;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import org.eclipse.persistence.testing.oxm.OXTestCase;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import junit.framework.TestCase;
public class LargeInlineBinaryTestCases extends OXTestCase {
private static final String XML_RESOURCE = "org/eclipse/persistence/testing/jaxb/xmlinlinebinary/largeInlineBinaryData.xml";
public LargeInlineBinaryTestCases(String name) {
super(name);
}
public void testOptimizedUnmarshal() throws Exception {
if(null != XML_INPUT_FACTORY) {
InputStream instream = ClassLoader.getSystemResourceAsStream(XML_RESOURCE);
XMLStreamReader xmlStreamReader = XML_INPUT_FACTORY.createXMLStreamReader(instream);
XMLReader xmlReader = new LargeInlineBinaryDataXMLStreamReaderReader();
InputSource inputSource = new XMLStreamReaderInputSource(xmlStreamReader);
SAXSource saxSource = new SAXSource(xmlReader, inputSource);
JAXBContext jc = JAXBContextFactory.createContext(new Class<?>[] {LargeInlineBinaryRoot.class}, null);
Unmarshaller unmarshaller = jc.createUnmarshaller();
LargeInlineBinaryRoot root = (LargeInlineBinaryRoot) unmarshaller.unmarshal(saxSource);
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.DATA_HANDLER, root.getDataHandler());
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.IMAGE, root.getImage());
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.SOURCE, root.getSource());
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.MIME_MULTIPART, root.getMimeMultipart());
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.DATA_HANDLER, root.getDataHandlerList().get(0));
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.IMAGE, root.getImageList().get(0));
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.SOURCE, root.getSourceList().get(0));
assertSame(LargeInlineBinaryDataXMLStreamReaderReader.MIME_MULTIPART, root.getMimeMultipartList().get(0));
}
}
}