Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConversationManager serialization test
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.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,40 @@ | ||
package org.jboss.weld.tests.serialization; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
|
||
import javax.enterprise.inject.spi.Bean; | ||
|
||
import org.jboss.testharness.impl.packaging.Artifact; | ||
import org.jboss.weld.conversation.ConversationManager; | ||
import org.jboss.weld.test.AbstractWeldTest; | ||
import org.testng.annotations.Test; | ||
|
||
@Artifact | ||
public class SerializationTest extends AbstractWeldTest | ||
{ | ||
@SuppressWarnings("unchecked") | ||
@Test(description="WELD-363") | ||
public void testConversationManagerSerializable() | ||
throws IOException, ClassNotFoundException | ||
{ | ||
Bean<ConversationManager> cmBean = (Bean<ConversationManager>) getCurrentManager() | ||
.getBeans(ConversationManager.class).iterator().next(); | ||
|
||
ConversationManager cMgr = cmBean.create(getCurrentManager().createCreationalContext(cmBean)); | ||
|
||
ByteArrayOutputStream serialized = new ByteArrayOutputStream(); | ||
ObjectOutputStream out = new ObjectOutputStream(serialized); | ||
|
||
out.writeObject(cMgr); | ||
out.flush(); | ||
|
||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(serialized.toByteArray())); | ||
Object deserialized = in.readObject(); | ||
|
||
assert deserialized instanceof ConversationManager; | ||
} | ||
} |