[jboss-cvs] JBossAS SVN: r69168 - 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
Mon Jan 21 06:57:04 EST 2008
Author: kabir.khan at jboss.com
Date: 2008-01-21 06:57:04 -0500 (Mon, 21 Jan 2008)
New Revision: 69168
Removed:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTestCase.java
Modified:
projects/aop/trunk/aop/build-tests-jdk50.xml
projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxySerializer.java
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
Log:
[JBAOP-467] Add serialize proxy tests to not-woven-tests target, and make SerializeContainerProxyOutOfVmTestCase throw an error if the classpath contains spaces, since this caused problems when running it for me
Modified: projects/aop/trunk/aop/build-tests-jdk50.xml
===================================================================
--- projects/aop/trunk/aop/build-tests-jdk50.xml 2008-01-21 10:39:49 UTC (rev 69167)
+++ projects/aop/trunk/aop/build-tests-jdk50.xml 2008-01-21 11:57:04 UTC (rev 69168)
@@ -866,6 +866,9 @@
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/methodhashing/MethodHashingTestCase.class"/>
<include name="org/jboss/test/aop/annotationc/AnnotationTester.class"/>
<include name="org/jboss/test/aop/bridgemethodnotwoven/BridgeMethodTestCase.class"/>
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-21 10:39:49 UTC (rev 69167)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/OutOfProcessProxySerializer.java 2008-01-21 11:57:04 UTC (rev 69168)
@@ -23,6 +23,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
@@ -30,7 +31,6 @@
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;
@@ -49,16 +49,21 @@
*/
public class OutOfProcessProxySerializer extends Assert
{
- final static int WRONG_ARGS = 1;
- final static int NO_SUCH_FILE = 2;
- final static int GENERAL_ERROR = 3;
-
+ 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 != 1)
+ if (args.length == 0)
{
- System.exit(WRONG_ARGS);
+ System.exit(FEW_ARGS);
}
+ else if (args.length > 1)
+ {
+ System.exit(MANY_ARGS);
+ }
File file = new File(args[0]);
if (!file.exists())
Modified: 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-21 10:39:49 UTC (rev 69167)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyInVmTestCase.java 2008-01-21 11:57:04 UTC (rev 69168)
@@ -22,6 +22,8 @@
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;
@@ -54,7 +56,23 @@
@Override
protected File createProxyFile() throws Exception
{
- File proxyFile = File.createTempFile("proxy", "err");
+ 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;
Modified: 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-21 10:39:49 UTC (rev 69167)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyOutOfVmTestCase.java 2008-01-21 11:57:04 UTC (rev 69168)
@@ -23,6 +23,10 @@
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.Reader;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -72,22 +76,30 @@
File proxyFile = File.createTempFile("proxy", "err");
proxyFile.deleteOnExit();
-// System.out.println(classPath);
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);
+ }
- Process proc = Runtime.getRuntime().exec(
- java +
- " -classpath " + classPath + " " +
- debug +
- OutOfProcessProxySerializer.class.getName() + " " +
- proxyFile.getAbsolutePath());
+ String run = java +
+ " -classpath " + classPath + " " +
+ debug +
+ OutOfProcessProxySerializer.class.getName() + " " +
+ proxyFile.getAbsolutePath().replace('\\', '/');
+
+ Process proc = Runtime.getRuntime().exec(run);
+
int result = proc.waitFor();
-
+
switch (result)
{
- case OutOfProcessProxySerializer.WRONG_ARGS:
- throw new RuntimeException("Wrong number of args passed in");
+ 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:
Modified: 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-21 10:39:49 UTC (rev 69167)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTest.java 2008-01-21 11:57:04 UTC (rev 69168)
@@ -27,6 +27,8 @@
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 $
Deleted: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTestCase.java 2008-01-21 10:39:49 UTC (rev 69167)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyTestCase.java 2008-01-21 11:57:04 UTC (rev 69168)
@@ -1,226 +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.FileReader;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-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 SerializeContainerProxyTestCase extends TestCase
-{
-
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("SerializeContainerProxyTestCase");
- suite.addTestSuite(SerializeContainerProxyTestCase.class);
- return suite;
- }
-
- public SerializeContainerProxyTestCase(String name)
- {
- super(name);
- }
-
- public void testContainerProxy() throws Exception
- {
- try
- {
- File proxyFile = runExternalProcess();
-
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(proxyFile));
- SomeInterface si = (SomeInterface)in.readObject();
-
- si.helloWorld();
- assertTrue(TestInterceptor.invoked);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- 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();
-
-// System.out.println(classPath);
- boolean debugFlag = System.getProperty("jboss.aop.debug.classes", "false").equals("true");
- String debug = debugFlag ? "-Djboss.aop.debug.classes=true " : "";
-
- Process proc = Runtime.getRuntime().exec(
- java +
- " -classpath " + classPath + " " +
- debug +
- OutOfProcessProxySerializer.class.getName() + " " +
- proxyFile.getAbsolutePath());
- int result = proc.waitFor();
-
- switch (result)
- {
- case OutOfProcessProxySerializer.WRONG_ARGS:
- throw new RuntimeException("Wrong number of 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 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 Linuxx
- //AFAIK on linux we have no extension after java in the bin directory?
- String file = getFile(dirName + 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;
- }
-}
More information about the jboss-cvs-commits
mailing list