Java tutorial
/** * Copyright 2010 WicketTraining.com (Jeremy Thomerson at Expert Tech Services, LLC) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.wickettraining.modelproxy.domain; import java.io.Serializable; import java.util.LinkedHashSet; import java.util.Set; import org.apache.commons.lang.SerializationUtils; import junit.framework.TestCase; public class PhoneNumberTest extends TestCase { @SuppressWarnings("unchecked") public void testUseInLinkedHashSet() throws Exception { Set<PhoneNumber> set = new LinkedHashSet<PhoneNumber>(); PhoneNumber p1 = new PhoneNumber("123"); PhoneNumber p2 = new PhoneNumber("234"); set.add(p1); assertTrue(set.contains(p1)); set.add(p2); assertTrue(set.contains(p2)); Set<PhoneNumber> set2 = (Set<PhoneNumber>) SerializationUtils.clone((Serializable) set); assertTrue(set2.containsAll(set)); assertEquals(set, set2); } }