@Test public void testSerializationNullDescriptors() throws IOException, ClassNotFoundException { MetacardTypeImpl metacardType = new MetacardTypeImpl("basic", null); String fileLocation = "target/metacardType.ser"; Serializer<MetacardType> serializer = new Serializer<MetacardType>(); serializer.serialize(metacardType, fileLocation); MetacardType readMetacardType = serializer.deserialize(fileLocation); assertEquals(metacardType.getName(), readMetacardType.getName()); Set<AttributeDescriptor> oldAd = metacardType.getAttributeDescriptors(); Set<AttributeDescriptor> newAd = readMetacardType.getAttributeDescriptors(); assertTrue(oldAd.isEmpty()); assertTrue(newAd.isEmpty()); }
@Test public void testSerializationSingle() throws IOException, ClassNotFoundException { HashSet<AttributeDescriptor> descriptors = new HashSet<AttributeDescriptor>(); descriptors.add( new AttributeDescriptorImpl("id", true, true, false, false, BasicTypes.STRING_TYPE)); MetacardTypeImpl metacardType = new MetacardTypeImpl("basic", descriptors); String fileLocation = "target/metacardType.ser"; Serializer<MetacardType> serializer = new Serializer<MetacardType>(); serializer.serialize(metacardType, fileLocation); MetacardType readMetacardType = serializer.deserialize(fileLocation); assertEquals(metacardType.getName(), readMetacardType.getName()); assertEquals( metacardType.getAttributeDescriptor("id").getName(), readMetacardType.getAttributeDescriptor("id").getName()); assertEquals( metacardType.getAttributeDescriptor("id").getType().getBinding(), readMetacardType.getAttributeDescriptor("id").getType().getBinding()); assertEquals( metacardType.getAttributeDescriptor("id").getType().getAttributeFormat(), readMetacardType.getAttributeDescriptor("id").getType().getAttributeFormat()); Set<AttributeDescriptor> oldAd = metacardType.getAttributeDescriptors(); Set<AttributeDescriptor> newAd = readMetacardType.getAttributeDescriptors(); assertTrue(oldAd.iterator().next().equals(newAd.iterator().next())); }