Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-26137] Integrate a patched version of JBoss Marshallin…
…g with better diagnostics.
- Loading branch information
Showing
2 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...st/java/org/jenkinsci/plugins/workflow/support/pickles/serialization/RiverWriterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2017 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.workflow.support.pickles.serialization; | ||
|
||
import com.google.common.util.concurrent.ListenableFuture; | ||
import hudson.Functions; | ||
import java.io.File; | ||
import java.io.NotSerializableException; | ||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import static org.hamcrest.Matchers.containsString; | ||
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner; | ||
import org.jenkinsci.plugins.workflow.pickles.PickleFactory; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
import org.junit.Rule; | ||
import org.junit.rules.TemporaryFolder; | ||
import org.jvnet.hudson.test.Issue; | ||
|
||
public class RiverWriterTest { | ||
|
||
@Rule public TemporaryFolder tmp = new TemporaryFolder(); | ||
|
||
@Test public void trivial() throws Exception { | ||
File f = tmp.newFile(); | ||
FlowExecutionOwner owner = FlowExecutionOwner.dummyOwner(); | ||
try (RiverWriter w = new RiverWriter(f, owner, Collections.<PickleFactory>emptySet())) { | ||
w.writeObject(Collections.singletonList("hello world")); | ||
} | ||
Object o; | ||
try (RiverReader r = new RiverReader(f, RiverWriterTest.class.getClassLoader(), owner)) { | ||
o = r.restorePickles(new ArrayList<ListenableFuture<?>>()).get().readObject(); | ||
} | ||
assertEquals(Collections.singletonList("hello world"), o); | ||
} | ||
|
||
@Issue("JENKINS-26137") | ||
@Test public void errors() throws Exception { | ||
File f = tmp.newFile(); | ||
FlowExecutionOwner owner = FlowExecutionOwner.dummyOwner(); | ||
try (RiverWriter w = new RiverWriter(f, owner, Collections.<PickleFactory>emptySet())) { | ||
w.writeObject(Collections.singletonList(new NotActuallySerializable())); | ||
fail(); | ||
} catch (NotSerializableException x) { | ||
/* | ||
original: | ||
Caused by: an exception which occurred: | ||
in field bad | ||
in object java.util.Collections$SingletonList@7791a8b4 | ||
now: | ||
Caused by: an exception which occurred: | ||
in field org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReaderTest$NotActuallySerializable.bad | ||
in object org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReaderTest$NotActuallySerializable@6b09bb57 | ||
in object java.util.Collections$SingletonList@6b09bb76 | ||
*/ | ||
assertThat(Functions.printThrowable(x), containsString(NotActuallySerializable.class.getName() + ".bad")); | ||
} | ||
} | ||
private static class NotActuallySerializable implements Serializable { | ||
String good = "OK"; | ||
Object bad = new Object(); | ||
} | ||
|
||
// TODO pickle resolution | ||
|
||
} |