Skip to content

Commit

Permalink
gavin is right
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Nov 8, 2009
1 parent 61da83a commit 8b80e29
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
@@ -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();
}

}
@@ -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
{

}

0 comments on commit 8b80e29

Please sign in to comment.