Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 75908 Details for
Bug 199476
[DataBinding] Classes should be serializable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
SerializableTest
SerializableTest.java (text/plain), 2.43 KB, created by
Thomas Kratz
on 2007-08-11 11:55:28 EDT
(
hide
)
Description:
SerializableTest
Filename:
MIME Type:
Creator:
Thomas Kratz
Created:
2007-08-11 11:55:28 EDT
Size:
2.43 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * IBM Corporation - initial API and implementation > ******************************************************************************/ > >package org.eclipse.core.tests.databinding; > >import java.io.ByteArrayInputStream; >import java.io.ByteArrayOutputStream; >import java.io.IOException; >import java.io.ObjectInputStream; >import java.io.ObjectOutputStream; >import java.io.Serializable; >import java.util.ArrayList; >import java.util.HashSet; > >import junit.framework.Assert; > >import org.eclipse.core.databinding.observable.list.WritableList; >import org.eclipse.core.databinding.observable.set.WritableSet; >import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase; > >/** > * @since 3.2 > * > */ >public class SerializableTest extends AbstractDefaultRealmTestCase{ > > > > public void testWritableList() throws Exception{ > > try{ > WritableList list = new WritableList(new ArrayList(), Object.class); > Object obj = doSerializationTest(list); > Assert.assertNotNull(obj); > }catch (Exception x){ > x.printStackTrace(); > throw x; > } > } > public void testWritableSet() throws Exception{ > > try{ > WritableSet set = new WritableSet(new HashSet(), Object.class); > Object obj = doSerializationTest(set); > Assert.assertNotNull(obj); > }catch (Exception x){ > x.printStackTrace(); > throw x; > } > } > private Object doSerializationTest(Serializable s) throws Exception{ > byte[] bytes = serialize(s); > Object obj = deserialize(bytes); > return obj; > } > > private byte[] serialize( Serializable s) throws IOException{ > ByteArrayOutputStream bos = new ByteArrayOutputStream() ; > ObjectOutputStream out = new ObjectOutputStream(bos) ; > out.writeObject(s); > out.close(); > return bos.toByteArray(); > } > > private Object deserialize( byte [] bytes) throws IOException,ClassNotFoundException{ > ByteArrayInputStream bis = new ByteArrayInputStream(bytes); > ObjectInputStream in = new ObjectInputStream(bis); > Object result = in.readObject(); > in.close(); > return result; > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 199476
:
75904
|
75905
|
75906
|
75907
| 75908 |
75918