@Test(groups = {"HomeRoutingManagement"}) public void testSerialition() throws Exception { CcMccmncCollection original = new CcMccmncCollection(); original.addCcMccmnc(new CcMccmncImpl("", "555", "")); original.addCcMccmnc(new CcMccmncImpl("11111", "222", "00001")); original.addCcMccmnc(new CcMccmncImpl("3333", "444", null)); // Writes the area to a file. ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLObjectWriter writer = XMLObjectWriter.newInstance(baos); writer.setIndentation("\t"); writer.write(original, "CcMccmnsCollection", CcMccmncCollection.class); writer.close(); byte[] rawData = baos.toByteArray(); String serializedEvent = new String(rawData); System.out.println(serializedEvent); ByteArrayInputStream bais = new ByteArrayInputStream(rawData); XMLObjectReader reader = XMLObjectReader.newInstance(bais); CcMccmncCollection copy = reader.read("CcMccmnsCollection", CcMccmncCollection.class); Map<String, CcMccmncImpl> arr = copy.getCcMccmncMap(); assertEquals(arr.size(), 3); int i1 = 0; for (CcMccmncImpl el : arr.values()) { switch (i1) { case 0: assertEquals(el.getCountryCode(), "11111"); assertEquals(el.getMccMnc(), "222"); assertEquals(el.getSmsc(), "00001"); break; case 1: assertNull(el.getSmsc()); break; case 2: assertEquals(el.getSmsc(), ""); break; } i1++; } }
@Test(groups = {"HomeRoutingManagement"}) public void testFunc() throws Exception { CcMccmncCollection original = new CcMccmncCollection(); original.addCcMccmnc(new CcMccmncImpl("1111", "222", "00001")); original.addCcMccmnc(new CcMccmncImpl("", "555", "")); original.addCcMccmnc(new CcMccmncImpl("3333", "444", null)); CcMccmnc s1 = original.findMccmnc("111"); CcMccmnc s2 = original.findMccmnc("1111"); CcMccmnc s3 = original.findMccmnc("11111"); CcMccmnc s4 = original.findMccmnc("33333"); CcMccmnc s5 = original.findMccmnc("4444"); assertEquals(s1.getMccMnc(), "555"); assertEquals(s2.getMccMnc(), "222"); assertEquals(s3.getMccMnc(), "222"); assertEquals(s4.getMccMnc(), "444"); assertEquals(s5.getMccMnc(), "555"); }