1+ /*-
2+ * #%L
3+ * ChipField Addon
4+ * %%
5+ * Copyright (C) 2018 Flowing Code
6+ * %%
7+ * Licensed under the Apache License, Version 2.0 (the "License");
8+ * you may not use this file except in compliance with the License.
9+ * You may obtain a copy of the License at
10+ *
11+ * http://www.apache.org/licenses/LICENSE-2.0
12+ *
13+ * Unless required by applicable law or agreed to in writing, software
14+ * distributed under the License is distributed on an "AS IS" BASIS,
15+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+ * See the License for the specific language governing permissions and
17+ * limitations under the License.
18+ * #L%
19+ */
20+ package com .flowingcode .addons .chipfield .test ;
21+
22+ import com .flowingcode .vaadin .addons .chipfield .ChipField ;
23+ import java .io .ByteArrayInputStream ;
24+ import java .io .ByteArrayOutputStream ;
25+ import java .io .IOException ;
26+ import java .io .ObjectInputStream ;
27+ import java .io .ObjectOutputStream ;
28+ import org .junit .Test ;
29+
30+ public class SerializationTest {
31+
32+ private void testSerializationOf (Object obj ) throws IOException , ClassNotFoundException {
33+ ByteArrayOutputStream baos = new ByteArrayOutputStream ();
34+ try (ObjectOutputStream oos = new ObjectOutputStream (baos )) {
35+ oos .writeObject (obj );
36+ }
37+ try (ObjectInputStream in = new ObjectInputStream (new ByteArrayInputStream (baos .toByteArray ()))) {
38+ obj .getClass ().cast (in .readObject ());
39+ }
40+ }
41+
42+ @ Test
43+ public void testSerialization () throws ClassNotFoundException , IOException {
44+ testSerializationOf (new ChipField <>("Label" , "Item1" , "Item2" , "Item3" ));
45+ }
46+
47+ }
0 commit comments