[jboss-cvs] JBossAS SVN: r69277 - in projects/aop/trunk/aop: src/test/org/jboss/test/aop/proxy and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 24 08:55:18 EST 2008
Author: kabir.khan at jboss.com
Date: 2008-01-24 08:55:17 -0500 (Thu, 24 Jan 2008)
New Revision: 69277
Added:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/AbstractSerializeContainerTest.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/InProcessProxyFileCreator.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxyFileCreator.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreator.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsDelegate.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsInVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsOutOfVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsTest.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsDelegate.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsInVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsTest.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsDelegate.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsInVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsOutOfVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsTest.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsDelegate.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsInVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsOutOfVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsTest.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestAspect2.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestInterceptor2.java
Removed:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyInVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyOutOfVmTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTest.java
Modified:
projects/aop/trunk/aop/build-tests-jdk50.xml
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxySerializer.java
Log:
[JBAOP-467] Refactor tests to make it easier to add new scenarios
Modified: projects/aop/trunk/aop/build-tests-jdk50.xml
===================================================================
--- projects/aop/trunk/aop/build-tests-jdk50.xml 2008-01-24 11:32:40 UTC (rev 69276)
+++ projects/aop/trunk/aop/build-tests-jdk50.xml 2008-01-24 13:55:17 UTC (rev 69277)
@@ -865,10 +865,7 @@
haltonfailure="false"
fork="true">
<fileset dir="${build.tests.classes}">
- <include name="org/jboss/test/aop/proxy/ProxyTestCase.class"/>
- <include name="org/jboss/test/aop/proxy/SerializeContainerProxyCacheKeyTestCase.class"/>
- <include name="org/jboss/test/aop/proxy/SerializeContainerProxyInVmTestCase.class"/>
- <include name="org/jboss/test/aop/proxy/SerializeContainerProxyOutOfVmTestCase.class"/>
+ <include name="org/jboss/test/aop/proxy/*TestCase.class"/>
<include name="org/jboss/test/aop/methodhashing/MethodHashingTestCase.class"/>
<include name="org/jboss/test/aop/annotationc/AnnotationTester.class"/>
<include name="org/jboss/test/aop/bridgemethodnotwoven/BridgeMethodTestCase.class"/>
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/AbstractSerializeContainerTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/AbstractSerializeContainerTest.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/AbstractSerializeContainerTest.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractSerializeContainerTest extends TestCase
+{
+
+ ProxyFileCreator creator;
+ public AbstractSerializeContainerTest(String name, ProxyFileCreator creator)
+ {
+ super(name);
+ this.creator = creator;
+ }
+
+ protected SomeInterface getSerializedProxy() throws Exception
+ {
+ File proxyFile = creator.createProxyFile();
+
+ ObjectInputStream in = new ObjectInputStream(new FileInputStream(proxyFile));
+ Object o = in.readObject();
+ assertNotNull(o);
+ SomeInterface si = (SomeInterface)o;
+ return si;
+ }
+
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/InProcessProxyFileCreator.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/InProcessProxyFileCreator.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/InProcessProxyFileCreator.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class InProcessProxyFileCreator implements ProxyFileCreator
+{
+ ProxyFileCreatorDelegate delegate;
+
+ public InProcessProxyFileCreator(ProxyFileCreatorDelegate delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public File createProxyFile() throws Exception
+ {
+ File proxyFile;
+ try
+ {
+ proxyFile = AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
+
+ public File run() throws Exception
+ {
+ return File.createTempFile("proxy", "err");
+ }
+ });
+ }
+ catch (RuntimeException e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+
+ proxyFile.deleteOnExit();
+ delegate.createAndSerializeProxy(proxyFile);
+ return proxyFile;
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxyFileCreator.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxyFileCreator.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxyFileCreator.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,223 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class OutOfProcessProxyFileCreator implements ProxyFileCreator
+{
+ String proxyCreatorClass;
+
+ public OutOfProcessProxyFileCreator(String proxyCreatorClass)
+ {
+ this.proxyCreatorClass = proxyCreatorClass;
+ }
+
+ public File createProxyFile() throws Exception
+ {
+ return runExternalProcess();
+ }
+
+ private File runExternalProcess() throws Exception
+ {
+ Properties props = System.getProperties();
+
+ String classPath = props.getProperty("java.class.path");
+ String libraryPath = props.getProperty("sun.boot.library.path") + File.separator + "java";
+ String java = findJava(libraryPath);
+
+ File proxyFile = File.createTempFile("proxy", "err");
+ proxyFile.deleteOnExit();
+
+ boolean debugFlag = System.getProperty("jboss.aop.debug.classes", "false").equals("true");
+ String debug = debugFlag ? "-Djboss.aop.debug.classes=true " : "";
+
+ if (classPath.contains(" "))
+ {
+ throw new RuntimeException("Classpath should not contain the space character for this test. " + classPath);
+ }
+
+ String run = java +
+ " -classpath " + classPath + " " +
+ debug +
+ proxyCreatorClass + " " +
+ proxyFile.getAbsolutePath().replace('\\', '/');
+
+ Process proc = Runtime.getRuntime().exec(run);
+ InputStream sysout = proc.getInputStream();
+ InputStream syserr = proc.getErrorStream();
+
+ int result = proc.waitFor();
+
+ outputStream("System.out", sysout);
+ outputStream("System.err", syserr);
+
+ switch (result)
+ {
+ case ProxyFileCreatorDelegate.FEW_ARGS:
+ throw new RuntimeException("Too few args passed in");
+ case ProxyFileCreatorDelegate.MANY_ARGS:
+ throw new RuntimeException("Too many args passed in");
+ case ProxyFileCreatorDelegate.NO_SUCH_FILE:
+ throw new RuntimeException("No file found " + proxyFile);
+ case ProxyFileCreatorDelegate.GENERAL_ERROR:
+ String externalException = getExternalException(proxyFile);
+ throw new RuntimeException(externalException);
+ }
+
+ return proxyFile;
+ }
+
+ private void outputStream(String type, InputStream in) throws IOException
+ {
+ System.out.println("= = = = = = = = = = Other process " + type);
+ int i = in.read();
+ while(i != -1)
+ {
+ System.out.print((char)i);
+ i = in.read();
+ }
+ System.out.println("= = = = = = = = = = END Other process " + type);
+ }
+
+ private String getExternalException(File proxyFile)
+ {
+ Reader reader = null;
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ reader = new FileReader(proxyFile);
+ int r = reader.read();
+ while (r != -1)
+ {
+ sb.append((char)r);
+ r = reader.read();
+ }
+ }
+ catch(Exception e)
+ {
+ }
+ finally
+ {
+ try
+ {
+ reader.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ return sb.toString();
+ }
+
+ private String findJava(String classPath)
+ {
+ String java = null;
+ StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
+ while (tok.hasMoreTokens())
+ {
+ String path = tok.nextToken();
+ if (path.endsWith(".jar"))
+ {
+ continue;
+ }
+ java = getJavaPath(path);
+ if (java != null)
+ {
+ return java;
+ }
+ }
+ return null;
+ }
+
+ private String getJavaPath(String dirName)
+ {
+ if (File.separatorChar == '/')
+ {
+ //Probably on Linux
+ if (dirName.contains("jre"))
+ {
+ dirName = dirName.substring(0, dirName.indexOf(File.separatorChar + "jre"));
+ }
+ String file = getFile(dirName + File.separator + "bin" + File.separator + "java");
+ if (file != null)
+ {
+ return file;
+ }
+ file = getFile(dirName);
+ if (file != null)
+ {
+ return file;
+ }
+ }
+ else if (File.separatorChar == '\\')
+ {
+ //We're probably on windows
+ String file = getFile(dirName + File.separator + "java.exe");
+ if (file != null)
+ {
+ return file;
+ }
+ file = getFile(dirName);
+ if (file != null)
+ {
+ return file;
+ }
+ file = getFile(dirName + ".exe");
+ if (file != null)
+ {
+ return file;
+ }
+ }
+ else
+ {
+ throw new RuntimeException("Cannot figure out OS");
+ }
+ return null;
+ }
+
+ private String getFile(String java)
+ {
+ if (java != null)
+ {
+ File file = new File(java);
+
+ if (file.exists() && !file.isDirectory())
+ {
+ System.out.println("Using Java executable: " + java);
+ return file.getAbsolutePath();
+ }
+ }
+ return null;
+ }
+}
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxySerializer.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxySerializer.java 2008-01-24 11:32:40 UTC (rev 69276)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxySerializer.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
@@ -49,13 +48,8 @@
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public class OutOfProcessProxySerializer extends Assert
+public class OutOfProcessProxySerializer extends ProxyFileCreatorDelegate
{
- final static int FEW_ARGS = 1;
- final static int MANY_ARGS = 2;
- final static int NO_SUCH_FILE = 3;
- final static int GENERAL_ERROR = 4;
-
public static void main (String[] args)
{
if (args.length == 0)
@@ -75,7 +69,8 @@
try
{
- createAndSerializeProxy(file);
+ OutOfProcessProxySerializer serializer = new OutOfProcessProxySerializer();
+ serializer.createAndSerializeProxy(file);
}
catch (Throwable t)
{
@@ -102,7 +97,7 @@
}
}
- public static void createAndSerializeProxy(File file) throws Exception
+ public void createAndSerializeProxy(File file) throws Exception
{
AspectManager manager = AspectManager.instance();
addInterceptorBinding(manager,
@@ -158,24 +153,4 @@
}
}
}
-
- private static void addInterceptorBinding(AspectManager manager, int index, Scope scope, String aspectClass, String pointcut) throws ParseException
- {
- addAspectBinding(manager, index, scope, aspectClass, null, pointcut);
- }
-
- private static void addAspectBinding(AspectManager manager, int index, Scope scope, String aspectClass, String adviceName, String pointcut) throws ParseException
- {
- AspectDefinition def = new AspectDefinition("aspect" + index, scope, new GenericAspectFactory(aspectClass, null));
-
- InterceptorFactory advice = (adviceName != null) ? new AdviceFactory(def, "advice") : new ScopedInterceptorFactory(def);
- PointcutExpression pc = new PointcutExpression("pc2" + index, pointcut);
- InterceptorFactory[] interceptors = {advice};
- AdviceBinding binding = new AdviceBinding("binding" + index, pc, null, null, interceptors);
-
- manager.addAspectDefinition(def);
- manager.addInterceptorFactory(advice.getName(), advice);
- manager.addPointcut(pc);
- manager.addBinding(binding);
- }
}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreator.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreator.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreator.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ProxyFileCreator
+{
+ File createProxyFile() throws Exception;
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,122 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.advice.AdviceFactory;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.GenericAspectFactory;
+import org.jboss.aop.advice.InterceptorFactory;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.advice.ScopedInterceptorFactory;
+import org.jboss.aop.pointcut.PointcutExpression;
+import org.jboss.aop.pointcut.ast.ParseException;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ProxyFileCreatorDelegate extends junit.framework.Assert
+{
+ public static final int FEW_ARGS = 1;
+ public static final int MANY_ARGS = 2;
+ public static final int NO_SUCH_FILE = 3;
+ public static final int GENERAL_ERROR = 4;
+
+ protected void createAndSerializeProxy(String[] args)
+ {
+ if (args.length == 0)
+ {
+ System.exit(FEW_ARGS);
+ }
+ else if (args.length > 1)
+ {
+ System.exit(MANY_ARGS);
+ }
+
+ File file = new File(args[0]);
+ if (!file.exists())
+ {
+ System.exit(NO_SUCH_FILE);
+ }
+
+ try
+ {
+ createAndSerializeProxy(file);
+ }
+ catch (Throwable t)
+ {
+ PrintStream out = null;
+ try
+ {
+ out = new PrintStream(new FileOutputStream(file));
+ t.printStackTrace(out);
+ }
+ catch(Exception e)
+ {
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ System.exit(GENERAL_ERROR);
+ }
+ }
+
+
+
+ public abstract void createAndSerializeProxy(File file) throws Exception;
+
+ protected void addInterceptorBinding(AspectManager manager, int index, Scope scope, String aspectClass, String pointcut) throws ParseException
+ {
+ addAspectBinding(manager, index, scope, aspectClass, null, pointcut);
+ }
+
+ protected void addAspectBinding(AspectManager manager, int index, Scope scope, String aspectClass, String adviceName, String pointcut) throws ParseException
+ {
+ AspectDefinition def = new AspectDefinition("aspect" + index, scope, new GenericAspectFactory(aspectClass, null));
+
+ InterceptorFactory advice = (adviceName != null) ? new AdviceFactory(def, "advice") : new ScopedInterceptorFactory(def);
+ PointcutExpression pc = new PointcutExpression("pc2" + index, pointcut);
+ InterceptorFactory[] interceptors = {advice};
+ AdviceBinding binding = new AdviceBinding("binding" + index, pc, null, null, interceptors);
+
+ System.out.println("-----> Adding " + aspectClass + " to " + pointcut + " in " + this.getClass().getName());
+
+ manager.addAspectDefinition(def);
+ manager.addInterceptorFactory(advice.getName(), advice);
+ manager.addPointcut(pc);
+ manager.addBinding(binding);
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsDelegate.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsDelegate.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReSerializeContainerProxyWithAspectsDelegate extends SerializeContainerProxyWithAspectsDelegate
+{
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsInVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsInVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class ReSerializeContainerProxyWithAspectsInVmTestCase extends ReSerializeContainerProxyWithAspectsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReSerializeContainerProxyWithAspectsInVmTestCase");
+ suite.addTestSuite(ReSerializeContainerProxyWithAspectsInVmTestCase.class);
+ return suite;
+ }
+
+ public ReSerializeContainerProxyWithAspectsInVmTestCase(String name)
+ {
+ super(name, new InProcessProxyFileCreator(new ReSerializeContainerProxyWithAspectsDelegate()));
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsOutOfVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsOutOfVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class ReSerializeContainerProxyWithAspectsOutOfVmTestCase extends ReSerializeContainerProxyWithAspectsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReSerializeContainerProxyWithAspectsOutOfVmTestCase");
+ suite.addTestSuite(ReSerializeContainerProxyWithAspectsOutOfVmTestCase.class);
+ return suite;
+ }
+
+ public ReSerializeContainerProxyWithAspectsOutOfVmTestCase(String name)
+ {
+ super(name, new OutOfProcessProxyFileCreator(ReSerializeContainerProxyWithAspectsDelegate.class.getName()));
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsTest.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithAspectsTest.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import java.rmi.MarshalledObject;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public abstract class ReSerializeContainerProxyWithAspectsTest extends AbstractSerializeContainerTest
+{
+ public ReSerializeContainerProxyWithAspectsTest(String name, ProxyFileCreator creator)
+ {
+ super(name, creator);
+ }
+
+ public void testReserializeProxy() throws Exception
+ {
+ try
+ {
+ SomeInterface si = getSerializedProxy();
+
+ MarshalledObject mo = new MarshalledObject(si);
+ Object o = mo.get();
+ assertNotNull(o);
+ SomeInterface rsi = (SomeInterface)o;
+
+ TestAspect.invoked = false;
+ TestAspect2.invoked = false;
+ si.helloWorld();
+ assertTrue(TestAspect.invoked);
+ assertFalse(TestAspect2.invoked);
+
+ OtherMixinInterface omi = (OtherMixinInterface)si;
+ omi.other();
+
+ OtherMixinInterface2 omi2 = (OtherMixinInterface2)si;
+ int i = omi2.other2();
+ assertEquals(20, i);
+
+ TestAspect.invoked = false;
+ TestAspect2.invoked = false;
+ si.otherWorld();
+ assertFalse(TestAspect.invoked);
+ assertTrue(TestAspect2.invoked);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsDelegate.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsDelegate.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReSerializeContainerProxyWithInterceptorsDelegate extends SerializeContainerProxyWithInterceptorsDelegate
+{
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsInVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsInVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class ReSerializeContainerProxyWithInterceptorsInVmTestCase extends ReSerializeContainerProxyWithInterceptorsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReSerializeContainerProxyWithInterceptorsInVmTestCase");
+ suite.addTestSuite(ReSerializeContainerProxyWithInterceptorsInVmTestCase.class);
+ return suite;
+ }
+
+ public ReSerializeContainerProxyWithInterceptorsInVmTestCase(String name)
+ {
+ super(name, new InProcessProxyFileCreator(new ReSerializeContainerProxyWithInterceptorsDelegate()));
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase extends ReSerializeContainerProxyWithInterceptorsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase");
+ suite.addTestSuite(ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase.class);
+ return suite;
+ }
+
+ public ReSerializeContainerProxyWithInterceptorsOutOfVmTestCase(String name)
+ {
+ super(name, new OutOfProcessProxyFileCreator(ReSerializeContainerProxyWithInterceptorsDelegate.class.getName()));
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsTest.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ReSerializeContainerProxyWithInterceptorsTest.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import java.rmi.MarshalledObject;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public abstract class ReSerializeContainerProxyWithInterceptorsTest extends AbstractSerializeContainerTest
+{
+ public ReSerializeContainerProxyWithInterceptorsTest(String name, ProxyFileCreator creator)
+ {
+ super(name, creator);
+ }
+
+ public void testReserializeProxy() throws Exception
+ {
+ try
+ {
+ SomeInterface si = getSerializedProxy();
+
+ MarshalledObject mo = new MarshalledObject(si);
+ Object o = mo.get();
+ assertNotNull(o);
+ SomeInterface rsi = (SomeInterface)o;
+
+ TestInterceptor.invoked = false;
+ TestInterceptor2.invoked = false;
+ rsi.helloWorld();
+ assertTrue(TestInterceptor.invoked);
+ assertFalse(TestInterceptor2.invoked);
+
+ OtherMixinInterface omi = (OtherMixinInterface)si;
+ omi.other();
+
+ OtherMixinInterface2 omi2 = (OtherMixinInterface2)si;
+ int i = omi2.other2();
+ assertEquals(20, i);
+
+ TestInterceptor.invoked = false;
+ TestInterceptor2.invoked = false;
+ rsi.otherWorld();
+ assertFalse(TestInterceptor.invoked);
+ assertTrue(TestInterceptor2.invoked);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+}
Deleted: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyInVmTestCase.java 2008-01-24 11:32:40 UTC (rev 69276)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyInVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.aop.proxy;
-
-import java.io.File;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision: 64431 $
- */
-public class SerializeContainerProxyInVmTestCase extends SerializeContainerProxyTest
-{
-
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("SerializeContainerProxyInVmTestCase");
- suite.addTestSuite(SerializeContainerProxyInVmTestCase.class);
- return suite;
- }
-
- public SerializeContainerProxyInVmTestCase(String name)
- {
- super(name);
- }
-
- @Override
- protected File createProxyFile() throws Exception
- {
- File proxyFile;
- try
- {
- proxyFile = AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
-
- public File run() throws Exception
- {
- return File.createTempFile("proxy", "err");
- }
- });
- }
- catch (RuntimeException e)
- {
- // AutoGenerated
- throw new RuntimeException(e);
- }
-
- proxyFile.deleteOnExit();
- OutOfProcessProxySerializer.createAndSerializeProxy(proxyFile);
- return proxyFile;
- }
-
-}
Deleted: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyOutOfVmTestCase.java 2008-01-24 11:32:40 UTC (rev 69276)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyOutOfVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -1,238 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.aop.proxy;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision: 64431 $
- */
-public class SerializeContainerProxyOutOfVmTestCase extends SerializeContainerProxyTest
-{
-
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("SerializeContainerProxyOutOfVmTestCase");
- suite.addTestSuite(SerializeContainerProxyOutOfVmTestCase.class);
- return suite;
- }
-
- public SerializeContainerProxyOutOfVmTestCase(String name)
- {
- super(name);
- }
-
- @Override
- protected File createProxyFile() throws Exception
- {
- return runExternalProcess();
- }
-
- private File runExternalProcess() throws Exception
- {
- Properties props = System.getProperties();
-
- String classPath = props.getProperty("java.class.path");
- String libraryPath = props.getProperty("sun.boot.library.path") + File.separator + "java";
- String java = findJava(libraryPath);
-
- File proxyFile = File.createTempFile("proxy", "err");
- proxyFile.deleteOnExit();
-
- boolean debugFlag = System.getProperty("jboss.aop.debug.classes", "false").equals("true");
- String debug = debugFlag ? "-Djboss.aop.debug.classes=true " : "";
-
- if (classPath.contains(" "))
- {
- throw new RuntimeException("Classpath should not contain the space character for this test. " + classPath);
- }
-
- String run = java +
- " -classpath " + classPath + " " +
- debug +
- OutOfProcessProxySerializer.class.getName() + " " +
- proxyFile.getAbsolutePath().replace('\\', '/');
-
- Process proc = Runtime.getRuntime().exec(run);
- InputStream sysout = proc.getInputStream();
- InputStream syserr = proc.getErrorStream();
-
- int result = proc.waitFor();
-
- outputStream("System.out", sysout);
- outputStream("System.err", syserr);
-
- switch (result)
- {
- case OutOfProcessProxySerializer.FEW_ARGS:
- throw new RuntimeException("Too few args passed in");
- case OutOfProcessProxySerializer.MANY_ARGS:
- throw new RuntimeException("Too many args passed in");
- case OutOfProcessProxySerializer.NO_SUCH_FILE:
- throw new RuntimeException("No file found " + proxyFile);
- case OutOfProcessProxySerializer.GENERAL_ERROR:
- String externalException = getExternalException(proxyFile);
- throw new RuntimeException(externalException);
- }
-
- return proxyFile;
- }
-
- private void outputStream(String type, InputStream in) throws IOException
- {
- System.out.println("= = = = = = = = = = Other process " + type);
- int i = in.read();
- while(i != -1)
- {
- System.out.print((char)i);
- i = in.read();
- }
- System.out.println("= = = = = = = = = = END Other process " + type);
- }
-
- private String getExternalException(File proxyFile)
- {
- Reader reader = null;
- StringBuffer sb = new StringBuffer();
- try
- {
- reader = new FileReader(proxyFile);
- int r = reader.read();
- while (r != -1)
- {
- sb.append((char)r);
- r = reader.read();
- }
- }
- catch(Exception e)
- {
- }
- finally
- {
- try
- {
- reader.close();
- }
- catch(Exception e)
- {
- }
- }
- return sb.toString();
- }
-
- private String findJava(String classPath)
- {
- String java = null;
- StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
- while (tok.hasMoreTokens())
- {
- String path = tok.nextToken();
- if (path.endsWith(".jar"))
- {
- continue;
- }
- java = getJavaPath(path);
- if (java != null)
- {
- return java;
- }
- }
- return null;
- }
-
- private String getJavaPath(String dirName)
- {
- if (File.separatorChar == '/')
- {
- //Probably on Linux
- if (dirName.contains("jre"))
- {
- dirName = dirName.substring(0, dirName.indexOf(File.separatorChar + "jre"));
- }
- String file = getFile(dirName + File.separator + "bin" + File.separator + "java");
- if (file != null)
- {
- return file;
- }
- file = getFile(dirName);
- if (file != null)
- {
- return file;
- }
- }
- else if (File.separatorChar == '\\')
- {
- //We're probably on windows
- String file = getFile(dirName + File.separator + "java.exe");
- if (file != null)
- {
- return file;
- }
- file = getFile(dirName);
- if (file != null)
- {
- return file;
- }
- file = getFile(dirName + ".exe");
- if (file != null)
- {
- return file;
- }
- }
- else
- {
- throw new RuntimeException("Cannot figure out OS");
- }
- return null;
- }
-
- private String getFile(String java)
- {
- if (java != null)
- {
- File file = new File(java);
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Using Java executable: " + java);
- return file.getAbsolutePath();
- }
- }
- return null;
- }
-}
Deleted: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTest.java 2008-01-24 11:32:40 UTC (rev 69276)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTest.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.aop.proxy;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.ObjectInputStream;
-import java.rmi.MarshalledObject;
-
-import junit.framework.TestCase;
-
-import org.jboss.test.aop.AOPTestWithSetup;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision: 64431 $
- */
-public abstract class SerializeContainerProxyTest extends TestCase
-{
-
- public SerializeContainerProxyTest(String name)
- {
- super(name);
- }
-
- private SomeInterface getProxy() throws Exception
- {
- File proxyFile = createProxyFile();
-
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(proxyFile));
- Object o = in.readObject();
- assertNotNull(o);
- SomeInterface si = (SomeInterface)o;
- return si;
- }
-
- public void testContainerProxy() throws Exception
- {
- try
- {
- SomeInterface si = getProxy();
-
- TestInterceptor.invoked = false;
- TestAspect.invoked = false;
- si.helloWorld();
- assertTrue(TestInterceptor.invoked);
- assertFalse(TestAspect.invoked);
-
- OtherMixinInterface omi = (OtherMixinInterface)si;
- omi.other();
-
- OtherMixinInterface2 omi2 = (OtherMixinInterface2)si;
- int i = omi2.other2();
- assertEquals(20, i);
-
- TestInterceptor.invoked = false;
- TestAspect.invoked = false;
- si.otherWorld();
- assertFalse(TestInterceptor.invoked);
- assertTrue(TestAspect.invoked);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- public void testReserializeProxy() throws Exception
- {
- try
- {
- SomeInterface si = getProxy();
-
- MarshalledObject mo = new MarshalledObject(si);
- Object o = mo.get();
- assertNotNull(o);
- SomeInterface rsi = (SomeInterface)o;
-
- TestInterceptor.invoked = false;
- TestAspect.invoked = false;
- rsi.helloWorld();
- assertTrue(TestInterceptor.invoked);
- assertFalse(TestAspect.invoked);
-
- OtherMixinInterface omi = (OtherMixinInterface)si;
- omi.other();
-
- OtherMixinInterface2 omi2 = (OtherMixinInterface2)si;
- int i = omi2.other2();
- assertEquals(20, i);
-
- TestInterceptor.invoked = false;
- TestAspect.invoked = false;
- rsi.otherWorld();
- assertFalse(TestInterceptor.invoked);
- assertTrue(TestAspect.invoked);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected abstract File createProxyFile() throws Exception;
-}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsDelegate.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsDelegate.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryMixin;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SerializeContainerProxyWithAspectsDelegate extends ProxyFileCreatorDelegate
+{
+ public static void main (String[] args)
+ {
+ SerializeContainerProxyWithAspectsDelegate delegate = new SerializeContainerProxyWithAspectsDelegate();
+ delegate.createAndSerializeProxy(args);
+ }
+
+ public void createAndSerializeProxy(File file) throws Exception
+ {
+ AspectManager manager = AspectManager.instance();
+ addAspectBinding(manager,
+ 1,
+ Scope.PER_VM,
+ TestAspect.class.getName(),
+ "advice",
+ "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+
+ addAspectBinding(manager,
+ 2,
+ Scope.PER_VM,
+ TestAspect2.class.getName(),
+ "advice",
+ "execution(* $instanceof{" + SomeInterface.class.getName() + "}->otherWorld(..))");
+
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setInterfaces(new Class[] {SomeInterface.class});
+ params.setMixins(new AOPProxyFactoryMixin[] {
+ new AOPProxyFactoryMixin(OtherMixin.class, new Class[] {OtherMixinInterface.class, OtherMixinInterface2.class}, "20")
+ });
+
+ params.setTarget(new SerializablePOJO());
+ AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+ SomeInterface si = (SomeInterface)factory.createAdvisedProxy(params);
+
+ TestAspect.invoked = false;
+ TestAspect2.invoked = false;
+ si.helloWorld();
+ assertTrue(TestAspect.invoked);
+ assertFalse(TestAspect2.invoked);
+
+ TestAspect.invoked = false;
+ TestAspect2.invoked = false;
+ si.otherWorld();
+ assertFalse(TestAspect.invoked);
+ assertTrue(TestAspect2.invoked);
+
+ ObjectOutputStream out = null;
+ try
+ {
+ out = new ObjectOutputStream(new FileOutputStream(file));
+ out.writeObject(si);
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsInVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsInVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class SerializeContainerProxyWithAspectsInVmTestCase extends SerializeContainerProxyWithAspectsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("SerializeContainerProxyWithAspectsInVmTestCase");
+ suite.addTestSuite(SerializeContainerProxyWithAspectsInVmTestCase.class);
+ return suite;
+ }
+
+ public SerializeContainerProxyWithAspectsInVmTestCase(String name)
+ {
+ super(name, new InProcessProxyFileCreator(new SerializeContainerProxyWithAspectsDelegate()));
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsOutOfVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsOutOfVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class SerializeContainerProxyWithAspectsOutOfVmTestCase extends SerializeContainerProxyWithAspectsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("SerializeContainerProxyWithAspectsOutOfVmTestCase");
+ suite.addTestSuite(SerializeContainerProxyWithAspectsOutOfVmTestCase.class);
+ return suite;
+ }
+
+ public SerializeContainerProxyWithAspectsOutOfVmTestCase(String name)
+ {
+ super(name, new OutOfProcessProxyFileCreator(SerializeContainerProxyWithAspectsDelegate.class.getName()));
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsTest.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithAspectsTest.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import java.rmi.MarshalledObject;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public abstract class SerializeContainerProxyWithAspectsTest extends AbstractSerializeContainerTest
+{
+ public SerializeContainerProxyWithAspectsTest(String name, ProxyFileCreator creator)
+ {
+ super(name, creator);
+ }
+
+ public void testContainerProxy() throws Exception
+ {
+ try
+ {
+ SomeInterface si = getSerializedProxy();
+
+ TestAspect.invoked = false;
+ TestAspect2.invoked = false;
+ si.helloWorld();
+ assertTrue(TestAspect.invoked);
+ assertFalse(TestAspect2.invoked);
+
+ OtherMixinInterface omi = (OtherMixinInterface)si;
+ omi.other();
+
+ OtherMixinInterface2 omi2 = (OtherMixinInterface2)si;
+ int i = omi2.other2();
+ assertEquals(20, i);
+
+ TestAspect.invoked = false;
+ TestAspect2.invoked = false;
+ si.otherWorld();
+ assertFalse(TestAspect.invoked);
+ assertTrue(TestAspect2.invoked);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsDelegate.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsDelegate.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryMixin;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SerializeContainerProxyWithInterceptorsDelegate extends ProxyFileCreatorDelegate
+{
+ public static void main (String[] args)
+ {
+ SerializeContainerProxyWithInterceptorsDelegate serializer = new SerializeContainerProxyWithInterceptorsDelegate();
+ serializer.createAndSerializeProxy(args);
+ }
+
+ public void createAndSerializeProxy(File file) throws Exception
+ {
+ AspectManager manager = AspectManager.instance();
+ addInterceptorBinding(manager,
+ 1,
+ Scope.PER_VM,
+ TestInterceptor.class.getName(),
+ "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+
+ addInterceptorBinding(manager,
+ 2,
+ Scope.PER_VM,
+ TestInterceptor2.class.getName(),
+ "execution(* $instanceof{" + SomeInterface.class.getName() + "}->otherWorld(..))");
+
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setInterfaces(new Class[] {SomeInterface.class});
+ params.setMixins(new AOPProxyFactoryMixin[] {
+ new AOPProxyFactoryMixin(OtherMixin.class, new Class[] {OtherMixinInterface.class, OtherMixinInterface2.class}, "20")
+ });
+
+ params.setTarget(new SerializablePOJO());
+ AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+ SomeInterface si = (SomeInterface)factory.createAdvisedProxy(params);
+
+ TestInterceptor.invoked = false;
+ TestInterceptor2.invoked = false;
+ si.helloWorld();
+ assertTrue(TestInterceptor.invoked);
+ assertFalse(TestInterceptor2.invoked);
+
+ TestInterceptor.invoked = false;
+ TestInterceptor2.invoked = false;
+ si.otherWorld();
+ assertFalse(TestInterceptor.invoked);
+ assertTrue(TestInterceptor2.invoked);
+
+ ObjectOutputStream out = null;
+ try
+ {
+ out = new ObjectOutputStream(new FileOutputStream(file));
+ out.writeObject(si);
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsInVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsInVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class SerializeContainerProxyWithInterceptorsInVmTestCase extends SerializeContainerProxyWithInterceptorsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("SerializeContainerProxyWithInterceptorsInVmTestCase");
+ suite.addTestSuite(SerializeContainerProxyWithInterceptorsInVmTestCase.class);
+ return suite;
+ }
+
+ public SerializeContainerProxyWithInterceptorsInVmTestCase(String name)
+ {
+ super(name, new InProcessProxyFileCreator(new SerializeContainerProxyWithInterceptorsDelegate()));
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsOutOfVmTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsOutOfVmTestCase.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class SerializeContainerProxyWithInterceptorsOutOfVmTestCase extends SerializeContainerProxyWithInterceptorsTest
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("SerializeContainerProxyWithInterceptorsOutOfVmTestCase");
+ suite.addTestSuite(SerializeContainerProxyWithInterceptorsOutOfVmTestCase.class);
+ return suite;
+ }
+
+ public SerializeContainerProxyWithInterceptorsOutOfVmTestCase(String name)
+ {
+ super(name, new OutOfProcessProxyFileCreator(SerializeContainerProxyWithInterceptorsDelegate.class.getName()));
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsTest.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithInterceptorsTest.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.proxy;
+
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public abstract class SerializeContainerProxyWithInterceptorsTest extends AbstractSerializeContainerTest
+{
+ public SerializeContainerProxyWithInterceptorsTest(String name, ProxyFileCreator creator)
+ {
+ super(name, creator);
+ }
+
+ public void testContainerProxy() throws Exception
+ {
+ try
+ {
+ SomeInterface si = getSerializedProxy();
+
+ TestInterceptor.invoked = false;
+ TestInterceptor2.invoked = false;
+ si.helloWorld();
+ assertTrue(TestInterceptor.invoked);
+ assertFalse(TestInterceptor2.invoked);
+
+ OtherMixinInterface omi = (OtherMixinInterface)si;
+ omi.other();
+
+ OtherMixinInterface2 omi2 = (OtherMixinInterface2)si;
+ int i = omi2.other2();
+ assertEquals(20, i);
+
+ TestInterceptor.invoked = false;
+ TestInterceptor2.invoked = false;
+ si.otherWorld();
+ assertFalse(TestInterceptor.invoked);
+ assertTrue(TestInterceptor2.invoked);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestAspect2.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestAspect2.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestAspect2.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.Serializable;
+
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestAspect2 implements Serializable
+{
+ public static boolean invoked;
+ public Object advice(Invocation inv) throws Throwable
+ {
+ invoked = true;
+ return inv.invokeNext();
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestInterceptor2.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestInterceptor2.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/TestInterceptor2.java 2008-01-24 13:55:17 UTC (rev 69277)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.proxy;
+
+import java.io.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestInterceptor2 implements Interceptor, Serializable
+{
+ private static final long serialVersionUID = 1L;
+ static boolean invoked;
+
+ public String getName()
+ {
+ return null;
+ }
+
+ public Object invoke(Invocation inv) throws Throwable
+ {
+ invoked = true;
+ return inv.invokeNext();
+ }
+}
More information about the jboss-cvs-commits
mailing list