]> source.dussan.org Git - aspectj.git/commitdiff
Bug 150487 "Tracing and Logging Framework" (add JUnit tests)
authormwebster <mwebster>
Thu, 27 Jul 2006 09:30:17 +0000 (09:30 +0000)
committermwebster <mwebster>
Thu, 27 Jul 2006 09:30:17 +0000 (09:30 +0000)
18 files changed:
weaver/src/org/aspectj/weaver/tools/CommonsTrace.java
weaver/src/org/aspectj/weaver/tools/DefaultTrace.java
weaver/src/org/aspectj/weaver/tools/DefaultTraceFactory.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/tools/Trace.java
weaver/src/org/aspectj/weaver/tools/TraceFactory.java
weaver/testsrc/org/aspectj/weaver/AllTracingTests.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/BcweaverTests.java
weaver/testsrc/org/aspectj/weaver/CommonsTraceFactoryTest.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/CommonsTraceTest.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/DefaultTraceFactoryTest.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/DefaultTraceTest.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/TraceFactoryTest.java [new file with mode: 0644]
weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java
weaver5/java5-testsrc/AllWeaver5Tests.java
weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java [new file with mode: 0644]
weaver5/testsrc/Weaver5ModuleTests.java

index c0301416ded5d89499d914d297af7d612652af66..a5fb09751784f1f033ef1fac006452fdc8c12c1d 100644 (file)
@@ -26,32 +26,39 @@ public class CommonsTrace extends AbstractTrace {
        
        public void enter(String methodName, Object thiz, Object[] args) {
                if (log.isDebugEnabled()) {
-                       log.debug("> " + formatMessage(className, methodName, thiz, args));
+                       log.debug(formatMessage(">", className, methodName, thiz, args));
                }
        }
 
        public void enter(String methodName, Object thiz) {
                if (log.isDebugEnabled()) {
-                       log.debug("> " + formatMessage(className, methodName, thiz, null));
+                       log.debug(formatMessage(">", className, methodName, thiz, null));
                }
        }
 
        public void exit(String methodName, Object ret) {
                if (log.isDebugEnabled()) {
-                       log.debug("< " + formatMessage(className, methodName, ret, null));
+                       log.debug(formatMessage("<", className, methodName, ret, null));
                }
        }
 
        public void exit(String methodName, Throwable th) {
                if (log.isDebugEnabled()) {
-                       log.debug("< " + formatMessage(className, methodName, th, null));
+                       log.debug(formatMessage("<", className, methodName, th, null));
                }
        }
 
        public void exit(String methodName) {
                if (log.isDebugEnabled()) {
-                       log.debug("< " + formatMessage(className, methodName, null, null));
+                       log.debug(formatMessage("<", className, methodName, null, null));
                }
        }
 
+       public boolean isTraceEnabled () {
+               return log.isDebugEnabled();
+       }
+
+       public void setTraceEnabled (boolean b) {
+       }
+
 }
index fdfc5e0e9902def80d9cd1269d51636c244b8fd8..3e0bb5609b920755a8abd80b0d7648becadb0417 100644 (file)
@@ -12,40 +12,48 @@ package org.aspectj.weaver.tools;
 
 public class DefaultTrace extends AbstractTrace {
        
+       private boolean traceEnabled = false; 
+       
        public DefaultTrace (Class clazz) {
                super(clazz);
        }
        
+       public boolean isTraceEnabled () {
+               return traceEnabled;
+       }
+       
+       public void setTraceEnabled (boolean b) {
+               traceEnabled = b;
+       }
+       
        public void enter (String methodName, Object thiz, Object[] args) {
-               if (tracingEnabled) {
-//                     println("> " + tracedClass.getName() + "." + methodName + " " + formatObj(thiz) + " " + formatArgs(args));
-                       println("> " + formatMessage(tracedClass.getName(),methodName,thiz,args));
+               if (traceEnabled) {
+                       println(formatMessage(">",tracedClass.getName(),methodName,thiz, args));
                }
        }
        
        public void enter (String methodName, Object thiz) {
-               if (tracingEnabled) {
-//                     println("> " + tracedClass.getName() + "." + methodName + " " + formatObj(thiz));
-                       println("> " + formatMessage(tracedClass.getName(),methodName,thiz,null));
+               if (traceEnabled) {
+                       println(formatMessage(">",tracedClass.getName(),methodName,thiz, null));
                }
        }
 
        public void exit (String methodName, Object ret) {
-               if (tracingEnabled) {
-//                     println("< " + tracedClass.getName() + "." + methodName + " " + formatObj(ret));
-                       println("< " + formatMessage(tracedClass.getName(),methodName,ret,null));
+               if (traceEnabled) {
+                       println(formatMessage("<",tracedClass.getName(),methodName,ret, null));
                }
        }
 
        public void exit (String methodName) {
-               if (tracingEnabled) {
-//                     println("< " + tracedClass.getName() + "." + methodName);
-                       println("< " + formatMessage(tracedClass.getName(),methodName,null,null));
+               if (traceEnabled) {
+                       println(formatMessage("<",tracedClass.getName(),methodName,null, null));
                }
        }
 
        public void exit(String methodName, Throwable th) {
-               exit(methodName,th);
+               if (traceEnabled) {
+                       println(formatMessage("<",tracedClass.getName(),methodName,th, null));
+               }
        }
 
        /**
@@ -57,12 +65,12 @@ public class DefaultTrace extends AbstractTrace {
                System.err.println(s);
        }
 
-       private static boolean tracingEnabled = getBoolean("org.aspectj.weaver.tools.tracing",false);
-
-       private static boolean getBoolean (String name, boolean def) {
-               String defaultValue = String.valueOf(def);
-               String value = System.getProperty(name,defaultValue);
-               return Boolean.valueOf(value).booleanValue();
-       }
+//     private static boolean isTracingEnabled = getBoolean("org.aspectj.weaver.tools.tracing",false);
+//
+//     private static boolean getBoolean (String name, boolean def) {
+//             String defaultValue = String.valueOf(def);
+//             String value = System.getProperty(name,defaultValue);
+//             return Boolean.valueOf(value).booleanValue();
+//     }
 
 }
diff --git a/weaver/src/org/aspectj/weaver/tools/DefaultTraceFactory.java b/weaver/src/org/aspectj/weaver/tools/DefaultTraceFactory.java
new file mode 100644 (file)
index 0000000..66a6348
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.tools;
+
+public class DefaultTraceFactory extends TraceFactory {
+
+       public final static String ENABLED_PROPERTY = "org.aspectj.tracing.enabled";
+
+    private boolean tracingEnabled = getBoolean(ENABLED_PROPERTY,false);
+
+    public boolean isEnabled() {
+               return tracingEnabled;
+       }
+    
+    public Trace getTrace (Class clazz) {
+       DefaultTrace trace = new DefaultTrace(clazz);
+       trace.setTraceEnabled(tracingEnabled);
+       return trace;
+    }
+
+}
index 6337c608363a9546461a5a9569a72342b95f3ff5..9c8fdb6ab2d88f7918c7f8a60690329ffa996b1e 100644 (file)
@@ -46,4 +46,6 @@ public interface Trace {
        public void exit (String methodName, boolean b);
        
        public boolean isTraceEnabled ();
+
+       public void setTraceEnabled (boolean b);
 }
index 553d4f0eb652a910526cf74a37578c193aa80800..5e194ea6c88b99dafed803753da2d2ad1e93b209 100644 (file)
@@ -12,19 +12,33 @@ package org.aspectj.weaver.tools;
 
 import org.aspectj.util.LangUtil;
 
-public class TraceFactory {
+public abstract class TraceFactory {
     
-    public static TraceFactory instance = new TraceFactory(); 
+       public final static String DEBUG_PROPERTY = "org.aspectj.tracing.debug";
+       public final static String FACTORY_PROPERTY = "org.aspectj.tracing.factory";
+       
+    private static boolean debug = getBoolean(DEBUG_PROPERTY,false); 
+    private static TraceFactory instance = new DefaultTraceFactory();
     
     public Trace getTrace (Class clazz) {
-       return new DefaultTrace(clazz);
+       return instance.getTrace(clazz);
     }
+
+       public boolean isEnabled() {
+               return true;
+       }
     
     public static TraceFactory getTraceFactory () {
        return instance;
     }
     
-    static {
+    protected static boolean getBoolean(String name, boolean def) {
+               String defaultValue = String.valueOf(def);
+               String value = System.getProperty(name,defaultValue);
+               return Boolean.valueOf(value).booleanValue();
+       }
+
+       static {
        try {
                        if (LangUtil.is15VMOrGreater()) {
                        Class factoryClass = Class.forName("org.aspectj.weaver.tools.Jdk14TraceFactory");
@@ -35,9 +49,10 @@ public class TraceFactory {
                        }
        }
        catch (Throwable th) {
-//             th.printStackTrace();
+               if (debug) th.printStackTrace();
        }
-//     System.out.println("TraceFactory.<clinit>() instance=" + instance);
+       
+       if (debug) System.out.println("TraceFactory.instance=" + instance);
     }
 
 }
diff --git a/weaver/testsrc/org/aspectj/weaver/AllTracingTests.java b/weaver/testsrc/org/aspectj/weaver/AllTracingTests.java
new file mode 100644 (file)
index 0000000..81a9529
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTracingTests {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite(AllTracingTests.class.getName());
+               //$JUnit-BEGIN$
+               suite.addTestSuite(TraceFactoryTest.class);
+               suite.addTestSuite(DefaultTraceFactoryTest.class);
+               suite.addTestSuite(DefaultTraceTest.class);
+               suite.addTestSuite(CommonsTraceFactoryTest.class);
+               suite.addTestSuite(CommonsTraceTest.class);
+               //$JUnit-END$
+               return suite;
+       }
+
+}
index 1d3f65ea76a3ac2a022b6031620f6e716293f0c9..88a97ce03305e851f779aa951dd96156a79c37bb 100644 (file)
@@ -54,6 +54,7 @@ public class BcweaverTests extends TestCase {
                suite.addTestSuite(TypeXTestCase.class); 
                suite.addTestSuite(WeaverMessagesTestCase.class);
                suite.addTestSuite(DumpTestCase.class);
+        suite.addTest(AllTracingTests.suite());
         //$JUnit-END$
         return suite;
     }
diff --git a/weaver/testsrc/org/aspectj/weaver/CommonsTraceFactoryTest.java b/weaver/testsrc/org/aspectj/weaver/CommonsTraceFactoryTest.java
new file mode 100644 (file)
index 0000000..ecdaf63
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import junit.framework.TestCase;
+
+import org.aspectj.weaver.tools.CommonsTraceFactory;
+import org.aspectj.weaver.tools.Trace;
+
+public class CommonsTraceFactoryTest extends TestCase {
+
+       public void testGetTraceFactory() {
+               CommonsTraceFactory factory = new CommonsTraceFactory();
+               Trace trace = factory.getTrace(getClass());
+               assertFalse("Tracing should be disbled by default",trace.isTraceEnabled());
+       }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/CommonsTraceTest.java b/weaver/testsrc/org/aspectj/weaver/CommonsTraceTest.java
new file mode 100644 (file)
index 0000000..ccc074b
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.tools.CommonsTrace;
+
+import junit.framework.TestCase;
+
+public class CommonsTraceTest extends TestCase {
+
+       private CommonsTrace trace; 
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               trace = new CommonsTrace(getClass());
+               trace.setTraceEnabled(true);
+       }
+
+       public void testCommonsTrace() {
+               CommonsTrace trace = new CommonsTrace(getClass());
+       }
+
+       public void testEnterWithThisAndArgs() {
+               trace.enter("testEnterWithThisAndArgs",this,new Object[] { "arg1", "arg2" });
+       }
+
+       public void testEnterWithThis() {
+               trace.enter("testEnterWithThis",this);
+       }
+
+       public void testEnter() {
+               trace.enter("testEnter");
+       }
+
+       public void testExitWithReturn() {
+               trace.exit("testExitWithReturn","ret");
+       }
+
+       public void testExitWithThrowable() {
+               trace.exit("testExitWithThrowable",new RuntimeException());
+       }
+
+       public void testExit() {
+               trace.exit("testExit");
+       }
+
+       public void testIsTraceEnabled() {
+               CommonsTrace trace = new CommonsTrace(getClass());
+               assertFalse(trace.isTraceEnabled());
+       }
+
+       public void testSetTraceEnabled() {
+               CommonsTrace trace = new CommonsTrace(getClass());
+               trace.setTraceEnabled(true);
+               /* XXX Need to find out how to turn tracing on */
+//             assertTrue(trace.isTraceEnabled());
+       }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/DefaultTraceFactoryTest.java b/weaver/testsrc/org/aspectj/weaver/DefaultTraceFactoryTest.java
new file mode 100644 (file)
index 0000000..16d14bf
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.tools.DefaultTraceFactory;
+import org.aspectj.weaver.tools.Trace;
+
+import junit.framework.TestCase;
+
+public class DefaultTraceFactoryTest extends TestCase {
+
+       public void testGetTrace() {
+               DefaultTraceFactory factory = new DefaultTraceFactory();
+               Trace trace = factory.getTrace(getClass());
+               assertFalse("Tracing should be disbled by default",trace.isTraceEnabled());
+       }
+
+//     public void testIsEnabled() {
+//             fail("Not yet implemented");
+//     }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/DefaultTraceTest.java b/weaver/testsrc/org/aspectj/weaver/DefaultTraceTest.java
new file mode 100644 (file)
index 0000000..784c209
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import junit.framework.TestCase;
+
+import org.aspectj.weaver.tools.DefaultTrace;
+
+public class DefaultTraceTest extends TestCase {
+
+       private DefaultTrace trace; 
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               trace = new DefaultTrace(getClass());
+               trace.setTraceEnabled(true);
+       }
+
+       public void testDefaultTrace() {
+               DefaultTrace trace = new DefaultTrace(getClass());
+       }
+
+       public void testEnterWithThisAndArgs() {
+               trace.enter("testEnterWithThisAndArgs",this,new Object[] { "arg1", "arg2" });
+       }
+
+       public void testEnterWithThis() {
+               trace.enter("testEnterWithThis",this);
+       }
+
+       public void testEnter() {
+               trace.enter("testEnter");
+       }
+
+       public void testExitWithReturn() {
+               trace.exit("testExitWithReturn","ret");
+       }
+
+       public void testExitWithThrowable() {
+               trace.exit("testExitWithThrowable",new RuntimeException());
+       }
+
+       public void testExit() {
+               trace.exit("testExit");
+       }
+
+       public void testIsTraceEnabled() {
+               DefaultTrace trace = new DefaultTrace(getClass());
+               assertFalse(trace.isTraceEnabled());
+       }
+
+       public void testSetTraceEnabled() {
+               DefaultTrace trace = new DefaultTrace(getClass());
+               trace.setTraceEnabled(true);
+               assertTrue(trace.isTraceEnabled());
+       }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/TraceFactoryTest.java b/weaver/testsrc/org/aspectj/weaver/TraceFactoryTest.java
new file mode 100644 (file)
index 0000000..e755fa2
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
+
+import junit.framework.TestCase;
+
+public class TraceFactoryTest extends TestCase {
+
+       public void testGetTraceFactory() {
+               TraceFactory traceFactory = TraceFactory.getTraceFactory();
+               assertNotNull(traceFactory);
+       }
+
+       public void testGetTrace() {
+               TraceFactory traceFactory = TraceFactory.getTraceFactory();
+               Trace trace = traceFactory.getTrace(getClass());
+               assertNotNull(trace);
+       }
+
+       public void testIsEnabled() {
+               TraceFactory traceFactory = TraceFactory.getTraceFactory();
+               assertTrue(traceFactory.isEnabled());
+       }
+
+}
index 93d816d90566fe42ba225c421ec4d619cb9d24d8..7847e612765cc568fe9d488f6a49c5146f35cfc8 100644 (file)
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.aspectj.weaver.tools;
 
+import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -55,9 +56,26 @@ public class Jdk14Trace extends AbstractTrace {
                }
        }
 
-       @Override
        public boolean isTraceEnabled() {
-               return logger.isLoggable(Level.FINE);
+               return logger.isLoggable(Level.FINER);
+       }
+
+       public void setTraceEnabled (boolean b) {
+               if (b) {
+                       logger.setLevel(Level.FINER);
+                       Handler[] handlers = logger.getHandlers();
+                       if (handlers.length == 0) {
+                               Logger parent = logger.getParent();
+                               if (parent != null) handlers = parent.getHandlers();
+                       }
+                       for (int i = 0; i < handlers.length; i++) {
+                               Handler handler = handlers[i];
+                               handler.setLevel(Level.FINER);
+                       }
+               }
+               else {
+                       logger.setLevel(Level.INFO);
+               }
        }
        
 }
index f0ef453c608d7d31ef9939c8cd0514e5e6c41e07..f54997a4e4bf4c551cf3073a861f1d9486b3ab02 100644 (file)
@@ -1,3 +1,7 @@
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.aspectj.weaver.AllTracing5Tests;
 import org.aspectj.weaver.TestJava5ReflectionBasedReferenceTypeDelegate;
 import org.aspectj.weaver.patterns.ArgsTestCase;
 import org.aspectj.weaver.patterns.ThisOrTargetTestCase;
@@ -6,9 +10,6 @@ import org.aspectj.weaver.tools.PointcutExpressionTest;
 import org.aspectj.weaver.tools.PointcutParserTest;
 import org.aspectj.weaver.tools.TypePatternMatcherTest;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 public class AllWeaver5Tests {
 
        public static Test suite() {
@@ -21,6 +22,7 @@ public class AllWeaver5Tests {
                suite.addTestSuite(PointcutExpressionTest.class);
                suite.addTestSuite(PointcutParserTest.class);
                suite.addTestSuite(TypePatternMatcherTest.class);
+        suite.addTest(AllTracing5Tests.suite());
                //$JUnit-END$
                return suite;
        }
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java b/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java
new file mode 100644 (file)
index 0000000..bc6e594
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTracing5Tests {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite("Test for org.aspectj.weaver");
+               //$JUnit-BEGIN$
+               suite.addTestSuite(Jdk14TraceFactoryTest.class);
+               suite.addTestSuite(Jdk14TraceTest.class);
+               //$JUnit-END$
+               return suite;
+       }
+
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java
new file mode 100644 (file)
index 0000000..39bdef2
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import junit.framework.TestCase;
+
+import org.aspectj.weaver.tools.Jdk14TraceFactory;
+import org.aspectj.weaver.tools.Trace;
+
+public class Jdk14TraceFactoryTest extends TestCase {
+
+       public void testJdk14TraceFactory() {
+               Jdk14TraceFactory factory = new Jdk14TraceFactory();
+       }
+
+       public void testGetTrace() {
+               Jdk14TraceFactory factory = new Jdk14TraceFactory();
+               Trace trace = factory.getTrace(getClass());
+               assertFalse("Tracing should be disbled by default",trace.isTraceEnabled());
+       }
+
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java
new file mode 100644 (file)
index 0000000..283aadb
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.tools.DefaultTrace;
+import org.aspectj.weaver.tools.Jdk14Trace;
+
+import junit.framework.TestCase;
+
+public class Jdk14TraceTest extends TestCase {
+
+       private Jdk14Trace trace; 
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               trace = new Jdk14Trace(getClass());
+               trace.setTraceEnabled(true);
+       }
+
+       public void testJdk14Trace() {
+               Jdk14Trace trace = new Jdk14Trace(getClass());
+       }
+
+       public void testEnterWithThisAndArgs() {
+               trace.enter("testEnterWithThisAndArgs",this,new Object[] { "arg1", "arg2" });
+       }
+
+       public void testEnterWithThis() {
+               trace.enter("testEnterWithThis",this);
+       }
+
+       public void testEnter() {
+               trace.enter("testEnter");
+       }
+
+       public void testExitWithReturn() {
+               trace.exit("testExitWithReturn","ret");
+       }
+
+       public void testExitWithThrowable() {
+               trace.exit("testExitWithThrowable",new RuntimeException());
+       }
+
+       public void testExit() {
+               trace.exit("testExit");
+       }
+
+       public void testIsTraceEnabled() {
+               DefaultTrace trace = new DefaultTrace(getClass());
+               assertFalse(trace.isTraceEnabled());
+       }
+
+       public void testSetTraceEnabled() {
+               DefaultTrace trace = new DefaultTrace(getClass());
+               trace.setTraceEnabled(true);
+               assertTrue(trace.isTraceEnabled());
+       }
+
+}
index b8bb1170b25b30f097dad6d6a04beb5d2cf47d6d..8aa725b93eba5071eb430e2f06b0eb7e2ddb6e1c 100644 (file)
@@ -25,6 +25,7 @@ public class Weaver5ModuleTests extends TestCase {
         TestSuite suite = new TestSuite(Weaver5ModuleTests.class.getName());
         if (TestUtil.is15VMOrGreater()) {
                    TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.tools.Java15PointcutExpressionTest", false);
+                   TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.AllTracing5Tests", false);
                    suite.addTestSuite(PointcutExpressionTest.class);
         } else {
             suite.addTest(TestUtil.testNamed("all tests require 1.5"));