| /* |
| * Copyright (c) 2012, 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: |
| // - rbarkhouse - 28 September 2012 - 2.4 - Initial implementation |
| package org.eclipse.persistence.testing.jaxb.xmlelements; |
| |
| import java.io.InputStream; |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import jakarta.xml.bind.JAXBException; |
| |
| import org.eclipse.persistence.jaxb.JAXBContextProperties; |
| import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases; |
| |
| public class XmlElementsAdapterTestCases extends JAXBWithJSONTestCases { |
| |
| private final static String XML_RESOURCE = "org/eclipse/persistence/testing/jaxb/xmlelements/choiceadapter.xml"; |
| private final static String JSON_RESOURCE = "org/eclipse/persistence/testing/jaxb/xmlelements/choiceadapter.json"; |
| private final static String BINDINGS_RESOURCE = "org/eclipse/persistence/testing/jaxb/xmlelements/bindings.xml"; |
| |
| private final static int CONTROL_ID = 10; |
| |
| public XmlElementsAdapterTestCases(String name) throws Exception { |
| super(name); |
| setControlDocument(XML_RESOURCE); |
| setControlJSON(JSON_RESOURCE); |
| Class[] classes = new Class[2]; |
| classes[0] = Employee.class; |
| classes[1] = Address.class; |
| setClasses(classes); |
| } |
| |
| @Override |
| protected Object getControlObject() { |
| Employee employee = new Employee(); |
| employee.id = CONTROL_ID; |
| Address address = new Address(); |
| address.city = "Ottawa"; |
| address.street = "45 O'Connor St."; |
| employee.choice = address; |
| return employee; |
| } |
| |
| @Override |
| public boolean isUnmarshalTest() { |
| return false; |
| } |
| |
| @Override |
| protected Map getProperties() throws JAXBException { |
| ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); |
| InputStream iStream = classLoader.getResourceAsStream(BINDINGS_RESOURCE); |
| |
| HashMap<String, Object> properties = new HashMap<String, Object>(); |
| properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, iStream); |
| |
| return properties; |
| } |
| |
| } |