package org.dataone.service.types.v1; import static org.junit.Assert.*; import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.IOUtils; import org.dataone.exceptions.MarshallingException; import org.apache.commons.lang3.StringUtils; import org.dataone.service.util.TypeMarshaller; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; public class BooleanValueTest { public static String xml; @Before public void setUp() throws Exception { xml = "" + "" + "1" + " 08d2c688-19fd-4cd5-88ff-4ed76bf40332" + " FGDC-STD-001-1998" + " 24018" + " c367489854f10a2edf2168e8394c2bf4" + " uid=EDACGSTORE,o=EDAC,dc=everything,dc=EDAC" + " uid=EDACGSTORE,o=EDAC,dc=everything,dc=EDAC" + " " + " publicread" + " " + " " + " 71fd14aa-8c7e-4e89-a3f3-1df2a011db2a" + " true" + " 2013-10-14T16:52:08.674723Z" + " 2014-02-11T20:37:01.095402Z" + " urn:node:EDACGSTORE" + " urn:node:EDACGSTORE" + ""; } @Test @Ignore ("why is capitalized false bad behavior?") public final void testBooleanInSysmeta_CapitalizedFalse() throws IOException, InstantiationException, IllegalAccessException { InputStream is = IOUtils.toInputStream(xml); try { TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, is); fail("Capitalized 'False' in boolean field should throw exception"); } catch (MarshallingException e) { e.printStackTrace(); } } @Test public final void testBoleanInSysmeta_LowercaseFalse() throws IOException, InstantiationException, IllegalAccessException { String lcXml = StringUtils.replace(xml, "False", "false"); InputStream is = IOUtils.toInputStream(lcXml); try { TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, is); } catch (MarshallingException e) { fail("lowercase 'false' in boolean field should not throw exception: " + e.getMessage()); } } }