]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.history/test/org/simantics/history/test/TestXYZ.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.history / test / org / simantics / history / test / TestXYZ.java
diff --git a/bundles/org.simantics.history/test/org/simantics/history/test/TestXYZ.java b/bundles/org.simantics.history/test/org/simantics/history/test/TestXYZ.java
new file mode 100644 (file)
index 0000000..69c57df
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.history.test;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.mutable.Variant;\r
+import org.simantics.databoard.serialization.Serializer;\r
+import org.simantics.history.impl.CollectorState;\r
+import org.simantics.history.impl.CollectorState.Item;\r
+\r
+public class TestXYZ {\r
+\r
+       public static void main(String[] args) throws Exception {\r
+               \r
+               CollectorState.Item cs = new CollectorState.Item();\r
+               Binding b = Bindings.getBinding(CollectorState.Item.class);\r
+               cs = (CollectorState.Item) b.createDefault();\r
+               Serializer s = Bindings.getSerializer(b);\r
+               byte[] dat = s.serialize(cs);\r
+               cs = (Item) s.deserialize(dat);\r
+               System.out.println(b.toString(cs));\r
+               \r
+               Variant v = new Variant(b, cs);\r
+               Serializer vs = Bindings.getSerializer( Bindings.VARIANT );\r
+               byte[] data = vs.serialize(v);          \r
+               v = (Variant) vs.deserialize(data);\r
+               System.out.println(v);\r
+               \r
+               Binding b2 = Bindings.getBinding( b.type() );\r
+               Object cs2 = Bindings.adapt(cs, b, b2);\r
+               System.out.println(b2.toString(cs2));\r
+       }\r
+       \r
+}\r