/*
* Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2011 IBM Corporation
*/
import java.io.StringReader;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
@XmlRootElement(name="root")
public class InvalidBooleanTest {
public static final String DOC = "YesTRUEtrueInvalid!";
public static final String DOC3 = "OneTwo17Invalid!";
@XmlElement
public List bools;
@XmlElement
public List ints;
public static void main (String [] args) {
// Test 1
try {
JAXBContext ctx = JAXBContext.newInstance(InvalidBooleanTest.class);
Unmarshaller u = ctx.createUnmarshaller();
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(DOC));
InvalidBooleanTest o = (InvalidBooleanTest) u.unmarshal(reader);
reader.close();
System.out.println("Test(1) bools: " + o.bools);
}
catch (Exception e) {
e.printStackTrace();
}
// Test 2
try {
JAXBContext ctx = JAXBContext.newInstance(InvalidBooleanTest.class);
Unmarshaller u = ctx.createUnmarshaller();
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(DOC3));
InvalidBooleanTest o = (InvalidBooleanTest) u.unmarshal(reader);
reader.close();
System.out.println("Test(2) ints: " + o.ints);
}
catch (Exception e) {
e.printStackTrace();
}
}
}