Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tests/src/test/java/org/jboss/weld/tests/unit/reflection/annotation/AnnotationTest.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,36 @@ | ||
package org.jboss.weld.tests.unit.reflection.annotation; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
@Synchronous | ||
public class AnnotationTest | ||
{ | ||
|
||
@Test | ||
public void testSerializability() throws Throwable | ||
{ | ||
Synchronous synchronous = AnnotationTest.class.getAnnotation(Synchronous.class); | ||
deserialize(serialize(synchronous)); | ||
} | ||
|
||
protected byte[] serialize(Object instance) throws IOException | ||
{ | ||
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); | ||
ObjectOutputStream out = new ObjectOutputStream(bytes); | ||
out.writeObject(instance); | ||
return bytes.toByteArray(); | ||
} | ||
|
||
protected <T> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException | ||
{ | ||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); | ||
return (T) in.readObject(); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
tests/src/test/java/org/jboss/weld/tests/unit/reflection/annotation/Synchronous.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,21 @@ | ||
package org.jboss.weld.tests.unit.reflection.annotation; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
@Target( { TYPE, METHOD, PARAMETER }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Qualifier | ||
@interface Synchronous | ||
{ | ||
|
||
} |