blob: 85a210edb656b75d9a34e025a2bc9f9e8aa96a09 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010-2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
******************************************************************************/
package example.mysports.tests.admin.services.glassfish;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import org.junit.Test;
import example.mysports.admin.services.glassfish.Message;
public class ParseListJDBCConnectionPoolsTests {
@Test
public void parse() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>(2);
properties.put("eclipselink.media-type", "application/json");
properties.put("eclipselink.json.include-root", false);
JAXBContext jc = JAXBContext.newInstance(new Class[] { Message.class }, properties);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
Message message = unmarshaller.unmarshal(new StreamSource(new FileInputStream(packageFile("list-jdbc-connection-pools.json"))), Message.class).getValue();
marshaller.marshal(message, System.out);
}
private String packageFile(String fileName) {
return "src/" + getClass().getPackage().getName().replace(".", "/") + "/" + fileName;
}
}