felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1694778 - in /felix/sandbox/pderop/dependencymanager.ds: org.apache.felix.dependencymanager.ds.itest/ org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/ org.apache.felix.dependencymanager.ds.itest/src/org/apa...
Date Sat, 08 Aug 2015 08:49:19 GMT
Author: pderop
Date: Sat Aug  8 08:49:18 2015
New Revision: 1694778

URL: http://svn.apache.org/r1694778
Log:
Compile DS modules in java7 (temporary until the FELIX-4984 issue is fixed).
Added WRITE_LOGS_TO_FILE variable in ComponentTestBase.java in order to allow logging to /tmp/<testname>.log
instead of BndTools console.
Added getLog() method in ComponentTestBase method in order to expose the LogService to other
integration test components.

Modified:
    felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/bnd.bnd
    felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/CircularReferenceTest.java
    felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/ComponentTestBase.java
    felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/components/circular/A.java
    felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds/bnd.bnd

Modified: felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/bnd.bnd?rev=1694778&r1=1694777&r2=1694778&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/bnd.bnd
(original)
+++ felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/bnd.bnd
Sat Aug  8 08:49:18 2015
@@ -4,7 +4,7 @@
 	osgi.enterprise;version=5.0,\
 	${junit},\
 	biz.aQute.bndlib;version=2.4
--runee: JavaSE-1.8
+-runee: JavaSE-1.7
 -runfw: org.apache.felix.framework;version=5.0.1
 -runsystempackages:  \
 	sun.reflect
@@ -29,5 +29,5 @@ Include-Resource: resource=resource
 Export-Package:  \
 	org.apache.felix.scr.integration.*
 	
-javac.source:          1.8
-javac.target:          1.8
\ No newline at end of file
+javac.source:          1.7
+javac.target:          1.7
\ No newline at end of file

Modified: felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/CircularReferenceTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/CircularReferenceTest.java?rev=1694778&r1=1694777&r2=1694778&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/CircularReferenceTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/CircularReferenceTest.java
Sat Aug  8 08:49:18 2015
@@ -56,6 +56,7 @@ public class CircularReferenceTest exten
           "\\[.*\\] Could not get service from ref \\[org.apache.felix.scr.integration.components.circular.B\\]",
         };
         //DS_LOGLEVEL = "debug";
+        //WRITE_LOGS_TO_FILE = true;
     }
 
     /**
@@ -280,7 +281,7 @@ public class CircularReferenceTest exten
     
     private void assertABoundToOneB(A a) {
         if (a.getBs().size() != 1) {
-            System.err.println("detected problem ...");
+            getLog().log(LogService.LOG_WARNING, "detected problem ...");
             a.dumpStackTracesWhenBWasBound();
         }
         assertEquals( 1, a.getBs().size());

Modified: felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1694778&r1=1694777&r2=1694778&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/ComponentTestBase.java
(original)
+++ felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/ComponentTestBase.java
Sat Aug  8 08:49:18 2015
@@ -23,8 +23,10 @@ import static java.lang.System.err;
 import static java.lang.System.out;
 
 import java.io.BufferedOutputStream;
+import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -118,9 +120,9 @@ public abstract class ComponentTestBase
 
 
     protected static boolean NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR = false;
-    protected volatile Log log;
+    protected static volatile Log log;
 
-    private ServiceRegistration<?> logService;
+    protected static ServiceRegistration<?> logService;
 
     private final Set<ServiceReference> existingServices = new HashSet<>();
     private final Set<Configuration> existingConfigurations = new HashSet<>();
@@ -134,7 +136,10 @@ public abstract class ComponentTestBase
 
     protected static final String PROP_NAME_FACTORY = ComponentTestBase.PROP_NAME + ".factory";
 
-
+    // Writes the current log test to /tmp/<testname>.log, instead of write to stdout
+    protected boolean WRITE_LOGS_TO_FILE;
+    
+    //
     public ComponentTestBase()
     {
         // Will use by default this.descriptorFile and this.COMPONENT_PACKAGE
@@ -174,6 +179,10 @@ public abstract class ComponentTestBase
 
         recordExistingConfigurations();
     }
+    
+    public static LogService getLog() {
+        return log;
+    }
 
 
     @After
@@ -192,9 +201,9 @@ public abstract class ComponentTestBase
                 bundle = null;
             }
             
-//            Bundle scrBundle = scrTracker.getServiceReference().getBundle();
-//            scrBundle.stop();
-//            scrBundle.start();
+            Bundle scrBundle = scrTracker.getServiceReference().getBundle();
+            scrBundle.stop();
+            scrBundle.start();
 
             configAdminTracker.close();
             configAdminTracker = null;
@@ -202,6 +211,8 @@ public abstract class ComponentTestBase
             scrTracker = null;
             logService.unregister();
             bundleContext.removeFrameworkListener( log );
+            WRITE_LOGS_TO_FILE = false;
+            log.close();
         }
         finally
         {
@@ -779,7 +790,6 @@ public abstract class ComponentTestBase
         private final long m_time;
         private final Thread m_thread;
 
-
         LogEntry( int level, String msg, Throwable t )
         {
             m_level = level;
@@ -844,10 +854,32 @@ public abstract class ComponentTestBase
         private final String[] log = new String[1000];
         private int i = 0;
 
+        /**
+         * Writer to log file, in tmp dir/<testname>.log instead of writing to stdout
+         */
+        private volatile PrintWriter fileWriter;
+
         public Log( boolean restrictedLogging, String[] ignoredWarnings )
         {
             this.restrictedLogging = restrictedLogging;
             this.ignoredWarnings = ignoredWarnings;
+            if (WRITE_LOGS_TO_FILE == true) {
+                try {
+                    String testName = ComponentTestBase.this.getClass().getName() + "." +
ComponentTestBase.this.getName();
+                    File logFilePath = new File(System.getProperty("java.io.tmpdir")
+                        + File.separator + testName + ".log");
+                    fileWriter = new PrintWriter(new FileWriter(logFilePath, false));
+                } catch (IOException e) {
+                    fileWriter = null;
+                }
+            }
+        }
+
+        public void close()
+        {
+            if (fileWriter != null) {
+                fileWriter.close();
+            }            
         }
 
         public void start()
@@ -963,8 +995,13 @@ public abstract class ComponentTestBase
                     }
                     else
                     {
-                        m_out.println( sw.toString() );
-                        m_out.flush();
+                        if (fileWriter != null) {
+                            fileWriter.println(sw.toString());
+                            fileWriter.flush();
+                        } else {
+                            m_out.println( sw.toString() );
+                            m_out.flush();
+                        }
                     }
                 }
             }

Modified: felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/components/circular/A.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/components/circular/A.java?rev=1694778&r1=1694777&r2=1694778&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/components/circular/A.java
(original)
+++ felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest/src/org/apache/felix/scr/integration/components/circular/A.java
Sat Aug  8 08:49:18 2015
@@ -23,7 +23,9 @@ package org.apache.felix.scr.integration
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.felix.scr.integration.ComponentTestBase;
 import org.osgi.service.component.ComponentContext;
+import org.osgi.service.log.LogService;
 
 /**
  * @version $Rev: 1350816 $ $Date: 2012-06-15 23:37:30 +0200 (Fri, 15 Jun 2012) $
@@ -38,20 +40,20 @@ public class A
 
     private void activate(ComponentContext cc)
     {
-        System.out.println(Thread.currentThread().getName() + ":" + "A.activate");
+        ComponentTestBase.getLog().log(LogService.LOG_DEBUG, "A.activate");
         activated = true;
     }
     
     private void setB(B b)
     {
-        System.out.println(Thread.currentThread().getName() + ":" + "A.setB(" + b + ")");
+        ComponentTestBase.getLog().log(LogService.LOG_DEBUG, "A.setB(" + b + ")");
         bs.add( b );
         bsStackTraces.add(new Exception());
     }
 
     private void unsetB(B b)
     {
-        System.out.println(Thread.currentThread().getName() + ":" + "A.unsetB(" + b + ")");
+        ComponentTestBase.getLog().log(LogService.LOG_DEBUG, "A.unsetB(" + b + ")");
         bs.remove( b );
         bsStackTraces.remove(bsStackTraces.size()-1);
     }
@@ -62,9 +64,9 @@ public class A
     }
     
     public void dumpStackTracesWhenBWasBound() {
-        System.out.println("stack traces when B was bound:");
+        ComponentTestBase.getLog().log(LogService.LOG_WARNING, "Stack traces when B was bound:");
         for (Exception e : bsStackTraces) {
-            e.printStackTrace();
+            ComponentTestBase.getLog().log(LogService.LOG_WARNING, "stack trace:", e);
         }
     }
 

Modified: felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds/bnd.bnd?rev=1694778&r1=1694777&r2=1694778&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds/bnd.bnd
(original)
+++ felix/sandbox/pderop/dependencymanager.ds/org.apache.felix.dependencymanager.ds/bnd.bnd
Sat Aug  8 08:49:18 2015
@@ -59,7 +59,7 @@ DynamicImport-Package: \
 Include-Resource: \
     @kxml2-2.2.2.jar!/org/kxml2/io/KXmlParser.class|org/xmlpull/v1/XmlPull**
 
-javac.source:          1.8
-javac.target:          1.8
+javac.source:          1.7
+javac.target:          1.7
 
 



Mime
View raw message