groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [2/2] groovy git commit: Test serializable compatibility between 2.4.x and 2.5.x+
Date Tue, 03 Apr 2018 08:44:47 GMT
Test serializable compatibility between 2.4.x and 2.5.x+

(cherry picked from commit 3b49f45)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f88d0122
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f88d0122
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f88d0122

Branch: refs/heads/master
Commit: f88d0122525cabf6bdf61ab051533f9983f352f1
Parents: 95188e4
Author: sunlan <sunlan@apache.org>
Authored: Tue Apr 3 16:07:04 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Apr 3 16:18:04 2018 +0800

----------------------------------------------------------------------
 .../groovy/SerializableCompatibilityTest.groovy | 48 ++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/f88d0122/src/test/groovy/SerializableCompatibilityTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/SerializableCompatibilityTest.groovy b/src/test/groovy/SerializableCompatibilityTest.groovy
new file mode 100644
index 0000000..c0704c1
--- /dev/null
+++ b/src/test/groovy/SerializableCompatibilityTest.groovy
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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 groovy
+
+import groovy.bugs.TestSupport
+
+class SerializableCompatibilityTest extends TestSupport {
+    void testSerialize() {
+        def obj = new GroovyRuntimeException('boom')
+        assert obj instanceof GroovyRuntimeException
+        assert obj.message == 'boom'
+
+        def out = new ByteArrayOutputStream();
+        out.withObjectOutputStream{
+            it.writeObject(obj)
+        }
+
+        println out.toByteArray().encodeBase64().toString()
+    }
+
+    void testDeserialize() {
+        // generated by testSerialize
+        def serializedObjectStr_2_4_X = 'rO0ABXNyACJncm9vdnkubGFuZy5Hcm9vdnlSdW50aW1lRXhjZXB0aW9uM1jWw9touJUCAAJMAAZtb2R1bGV0ACRMb3JnL2NvZGVoYXVzL2dyb292eS9hc3QvTW9kdWxlTm9kZTtMAARub2RldAAhTG9yZy9jb2RlaGF1cy9ncm9vdnkvYXN0L0FTVE5vZGU7eHIAGmphdmEubGFuZy5SdW50aW1lRXhjZXB0aW9unl8GRwo0g+UCAAB4cgATamF2YS5sYW5nLkV4Y2VwdGlvbtD9Hz4aOxzEAgAAeHIAE2phdmEubGFuZy5UaHJvd2FibGXVxjUnOXe4ywMABEwABWNhdXNldAAVTGphdmEvbGFuZy9UaHJvd2FibGU7TAANZGV0YWlsTWVzc2FnZXQAEkxqYXZhL2xhbmcvU3RyaW5nO1sACnN0YWNrVHJhY2V0AB5bTGphdmEvbGFuZy9TdGFja1RyYWNlRWxlbWVudDtMABRzdXBwcmVzc2VkRXhjZXB0aW9uc3QAEExqYXZhL3V0aWwvTGlzdDt4cHEAfgAKdAAEYm9vbXVyAB5bTGphdmEubGFuZy5TdGFja1RyYWNlRWxlbWVudDsCRio8PP0iOQIAAHhwAAAAHHNyABtqYXZhLmxhbmcuU3RhY2tUcmFjZUVsZW1lbnRhCcWaJjbdhQIABEkACmxpbmVOdW1iZXJMAA5kZWNsYXJpbmdDbGFzc3EAfgAHTAAIZmlsZU5hbWVxAH4AB0wACm1ldGhvZE5hbWVx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ADkpVbml0Q29yZS5qYXZhcQB+AEhzcQB+AA4AAABEdAAoY29tLmludGVsbGlqLmp1bm
 l0NC5KVW5pdDRJZGVhVGVzdFJ1bm5lcnQAGUpVbml0NElkZWFUZXN0UnVubmVyLmphdmF0ABNzdGFydFJ1bm5lcldpdGhBcmdzc3EAfgAOAAAAL3QAN2NvbS5pbnRlbGxpai5ydC5leGVjdXRpb24uanVuaXQuSWRlYVRlc3RSdW5uZXIkUmVwZWF0ZXJ0ABNJZGVhVGVzdFJ1bm5lci5qYXZhcQB+AFdzcQB+AA4AAADydAAsY29tLmludGVsbGlqLnJ0LmV4ZWN1dGlvbi5qdW5pdC5KVW5pdFN0YXJ0ZXJ0ABFKVW5pdFN0YXJ0ZXIuamF2YXQAFnByZXBhcmVTdHJlYW1zQW5kU3RhcnRzcQB+AA4AAABGcQB+AFxxAH4AXXQABG1haW5zcgAmamF2YS51dGlsLkNvbGxlY3Rpb25zJFVubW9kaWZpYWJsZUxpc3T8DyUxteyOEAIAAUwABGxpc3RxAH4ACXhyACxqYXZhLnV0aWwuQ29sbGVjdGlvbnMkVW5tb2RpZmlhYmxlQ29sbGVjdGlvbhlCAIDLXvceAgABTAABY3QAFkxqYXZhL3V0aWwvQ29sbGVjdGlvbjt4cHNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAAAdwQAAAAAeHEAfgBmeHBw'
+        new ByteArrayInputStream(serializedObjectStr_2_4_X.decodeBase64()).withObjectInputStream
{
+            def newObj = it.readObject()
+            assert newObj instanceof GroovyRuntimeException
+            assert newObj.message == 'boom'
+        }
+    }
+}
+


Mime
View raw message