[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/marshall ...
Brian Stansberry
brian.stansberry at jboss.com
Mon Dec 4 17:17:25 EST 2006
User: bstansberry
Date: 06/12/04 17:17:25
Added: tests/functional/org/jboss/cache/marshall Tag:
Branch_JBossCache_1_4_0 FooClassLoader.java
Foo.notjava Foo.clazz
Log:
[JBCACHE-876] Add tests that custom classes in Fqn's work properly
Revision Changes Path
No revision
No revision
1.1.2.1 +39 -0 JBossCache/tests/functional/org/jboss/cache/marshall/Attic/FooClassLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FooClassLoader.java
===================================================================
RCS file: FooClassLoader.java
diff -N FooClassLoader.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FooClassLoader.java 4 Dec 2006 22:17:25 -0000 1.1.2.1
@@ -0,0 +1,39 @@
+package org.jboss.cache.marshall;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class FooClassLoader extends ClassLoader
+{
+ private Class foo;
+ public FooClassLoader(ClassLoader parent)
+ {
+ super(parent);
+ }
+
+ public Class loadFoo() throws ClassNotFoundException
+ {
+ if (foo == null)
+ {
+ try
+ {
+ InputStream is = getResourceAsStream("org/jboss/cache/marshall/Foo.clazz");
+ byte[] bytes = new byte[1024];
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ int read;
+ while ((read = is.read(bytes)) > -1) {
+ baos.write(bytes, 0, read);
+ }
+ bytes = baos.toByteArray();
+ foo = this.defineClass("org.jboss.cache.marshall.Foo", bytes, 0, bytes.length);
+ }
+ catch (IOException e)
+ {
+ throw new ClassNotFoundException("cannot read org/jboss/cache/marshall/Foo.clazz", e);
+ }
+ }
+ return foo;
+ }
+
+}
1.1.2.1 +37 -0 JBossCache/tests/functional/org/jboss/cache/marshall/Attic/Foo.notjava
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Foo.notjava
===================================================================
RCS file: Foo.notjava
diff -N Foo.notjava
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Foo.notjava 4 Dec 2006 22:17:25 -0000 1.1.2.1
@@ -0,0 +1,37 @@
+package org.jboss.cache.marshall;
+
+import java.io.Serializable;
+import java.security.SecureRandom;
+import java.util.Random;
+
+/**
+ * This is the java code used to create the Foo.clazz file. File deliberately
+ * doesn't end in .java, as we don't want a Foo.class on the classpath,
+ * only the Foo.clazz file that FooClassLoader can load.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1.2.1 $
+ */
+public class Foo implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ public boolean equals(Object obj)
+ {
+ return obj instanceof Foo;
+ }
+
+ public int hashCode()
+ {
+ return 1;
+ }
+
+ public String toString()
+ {
+ Random random = new SecureRandom();
+ StringBuffer sb=new StringBuffer("org.jboss.cache.marshall.Foo[random=");
+ sb.append(random.nextInt()).append("]");
+ return sb.toString();
+ }
+}
1.1.2.1 +10 -0 JBossCache/tests/functional/org/jboss/cache/marshall/Attic/Foo.clazz
<<Binary file>>
More information about the jboss-cvs-commits
mailing list