@Test public void mixedContent() throws Exception { PMML pmml = ResourceUtil.unmarshal(getClass()); List<?> content = ExtensionUtil.getContent(pmml); assertEquals(5, content.size()); assertEquals("First text value", content.get(0)); assertEquals(Arrays.asList("First extension"), getDeepContent(content.get(1))); assertEquals("Second text value", content.get(2)); assertEquals(Arrays.asList("Second extension"), getDeepContent(content.get(3))); assertEquals("Third text value", content.get(4)); try { SerializationUtil.clone(pmml); fail(); } catch(NotSerializableException nse){ // Ignored } pmml.accept(new LocatorTransformer()); SerializationUtil.clone(pmml); }
@Test public void compressedSequence() throws Exception { PMML pmml = ResourceUtil.unmarshal(Version.PMML_4_3); pmml.accept(new LocatorNullifier()); DirectByteArrayOutputStream buffer = new DirectByteArrayOutputStream(3 * 1024); try(OutputStream os = new GZIPOutputStream(buffer)){ SerializationUtil.serializePMML(pmml, os); SerializationUtil.serializePMML(pmml, os); os.flush(); } try(InputStream is = new GZIPInputStream(buffer.getInputStream())){ PMML firstPmml = SerializationUtil.deserializePMML(is); PMML secondPmml = SerializationUtil.deserializePMML(is); assertNotSame(firstPmml, secondPmml); assertEquals(-1, is.read()); } } }
@Test public void nullifyAndClone() throws Exception { PMML pmml = ResourceUtil.unmarshal(Version.PMML_4_3); assertNotNull(pmml.getLocator()); try { SerializationUtil.clone(pmml); fail(); } catch(NotSerializableException nse){ // Ignored } pmml.accept(new LocatorNullifier()); assertNull(pmml.getLocator()); SerializationUtil.clone(pmml); }
@Test public void transformAndClone() throws Exception { PMML pmml = ResourceUtil.unmarshal(Version.PMML_4_3); assertNotNull(pmml.getLocator()); try { SerializationUtil.clone(pmml); fail(); } catch(NotSerializableException nse){ // Ignored } pmml.accept(new LocatorTransformer()); assertNotNull(pmml.getLocator()); SerializationUtil.clone(pmml); }