[overlord-commits] Overlord SVN: r242 - in sam/trunk/modules/sim/src: test/java/org/jboss/test/sam/samples/aggregation and 4 other directories.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Wed Aug 13 10:40:01 EDT 2008


Author: heiko.braun at jboss.com
Date: 2008-08-13 10:40:01 -0400 (Wed, 13 Aug 2008)
New Revision: 242

Added:
   sam/trunk/modules/sim/src/test/resources/simulation/sam-cfg.xml
Modified:
   sam/trunk/modules/sim/src/main/java/org/jboss/sam/simulation/EventSimulation.java
   sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/aggregation/AggregationTestCase.java
   sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/falloff/FalloffTestCase.java
   sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/filtering/FilteringTestCase.java
   sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/simulation/SimulationTestCase.java
Log:
Provide default config to all simulation testcases

Modified: sam/trunk/modules/sim/src/main/java/org/jboss/sam/simulation/EventSimulation.java
===================================================================
--- sam/trunk/modules/sim/src/main/java/org/jboss/sam/simulation/EventSimulation.java	2008-08-13 12:54:02 UTC (rev 241)
+++ sam/trunk/modules/sim/src/main/java/org/jboss/sam/simulation/EventSimulation.java	2008-08-13 14:40:01 UTC (rev 242)
@@ -25,8 +25,11 @@
 import org.javasim.SimulationException;
 import org.javasim.SimulationProcess;
 import org.jboss.sam.EventProcessor;
-import org.jboss.sam.EventProcessorFactory;
+import org.jboss.sam.SAMRuntime;
+import org.jboss.sam.SAMRuntimeFactory;
 import org.jboss.sam.StreamInput;
+import org.jboss.sam.config.ConfigFactory;
+import org.jboss.sam.config.Configurator;
 import org.jboss.sam.internal.stream.InVMDispatcher;
 import org.jboss.sam.internal.stream.InVMStreamInput;
 
@@ -72,6 +75,7 @@
    private InVMDispatcher dispatcher;
 
    // SAM properties
+   private SAMRuntime runtime;
    private EventProcessor eventProcessor;
    private StreamInput streamInput;
 
@@ -81,15 +85,18 @@
 
    private EventSimulation(Properties config, URL bootstrap)
    {
+      assert bootstrap!=null : "Bootstrap config is null!";
+      
       // thread setup
-      setName("EventSimulation {" + getName()+"}");
+      setName("EventSimulation {" + getName()+ "}");
       setPriority(1);
 
       this.context = new SimulationContext(config);
 
-      // setup SAM processor
-      this.eventProcessor = EventProcessorFactory.newInstance().createProcessor();
-      this.eventProcessor.setName("EventSimulation");
+      // setup SAM runtime      
+      Configurator configurator = new Configurator( ConfigFactory.newInstance().unmarshall(bootstrap) );
+      this.runtime = SAMRuntimeFactory.newInstance().createRuntime(configurator);
+      this.eventProcessor = runtime.getEventProcessor();      
 
       // create input for the default in-vm channel
       this.streamInput = new InVMStreamInput(InVMDispatcher.DEFAULT_CHANNEL_NAME);
@@ -254,14 +261,7 @@
          System.exit(-1);
       }
    }
-
-   public static EventSimulation bootstrap(Properties config)
-   {
-      return new EventSimulation(config,
-        Thread.currentThread().getContextClassLoader().getResource("samples/esper-default-cfg.xml")
-      );
-   }
-
+   
    public static EventSimulation bootstrap(Properties config, URL bootstrap)
    {
       return new EventSimulation(config, bootstrap);

Modified: sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/aggregation/AggregationTestCase.java
===================================================================
--- sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/aggregation/AggregationTestCase.java	2008-08-13 12:54:02 UTC (rev 241)
+++ sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/aggregation/AggregationTestCase.java	2008-08-13 14:40:01 UTC (rev 242)
@@ -49,7 +49,9 @@
       config.put(EventSimulation.TOTAL_SIM_TIME, 100.00);
 
       // init
-      simulation = EventSimulation.bootstrap(config);
+      simulation = EventSimulation.bootstrap(config,
+        Thread.currentThread().getContextClassLoader().getResource("simulation/sam-cfg.xml")
+        );
 
       // shared between all entities
       context = simulation.getContext();

Modified: sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/falloff/FalloffTestCase.java
===================================================================
--- sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/falloff/FalloffTestCase.java	2008-08-13 12:54:02 UTC (rev 241)
+++ sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/falloff/FalloffTestCase.java	2008-08-13 14:40:01 UTC (rev 242)
@@ -47,7 +47,9 @@
       config.put(EventSimulation.TOTAL_SIM_TIME, 100.00);
 
       // init
-      simulation = EventSimulation.bootstrap(config);
+      simulation = EventSimulation.bootstrap(config,
+        Thread.currentThread().getContextClassLoader().getResource("simulation/sam-cfg.xml")
+      );
 
       // shared between all entities
       context = simulation.getContext();

Modified: sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/filtering/FilteringTestCase.java
===================================================================
--- sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/filtering/FilteringTestCase.java	2008-08-13 12:54:02 UTC (rev 241)
+++ sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/samples/filtering/FilteringTestCase.java	2008-08-13 14:40:01 UTC (rev 242)
@@ -57,7 +57,9 @@
       config.put(EventSimulation.TOTAL_SIM_TIME, 75.00);
 
       // init
-      simulation = EventSimulation.bootstrap(config);
+      simulation = EventSimulation.bootstrap(config,        
+        Thread.currentThread().getContextClassLoader().getResource("simulation/sam-cfg.xml")
+      );
 
       // shared between all entities
       context = simulation.getContext();

Modified: sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/simulation/SimulationTestCase.java
===================================================================
--- sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/simulation/SimulationTestCase.java	2008-08-13 12:54:02 UTC (rev 241)
+++ sam/trunk/modules/sim/src/test/java/org/jboss/test/sam/simulation/SimulationTestCase.java	2008-08-13 14:40:01 UTC (rev 242)
@@ -41,7 +41,9 @@
       config.put(EventSimulation.TOTAL_SIM_TIME, 60.00);
 
       // init
-      EventSimulation simulation = EventSimulation.bootstrap(config);
+      EventSimulation simulation = EventSimulation.bootstrap(config,
+        Thread.currentThread().getContextClassLoader().getResource("simulation/sam-cfg.xml")
+        );
 
       // shared between all entities
       SimulationContext context = simulation.getContext();

Added: sam/trunk/modules/sim/src/test/resources/simulation/sam-cfg.xml
===================================================================
--- sam/trunk/modules/sim/src/test/resources/simulation/sam-cfg.xml	                        (rev 0)
+++ sam/trunk/modules/sim/src/test/resources/simulation/sam-cfg.xml	2008-08-13 14:40:01 UTC (rev 242)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
+<ns2:processingNode name="DatabaseTestCase"
+                    domain="http://org.jboss.sam/test/database"
+                    xmlns:ns2="http://org.jboss.sam/08/2008/">
+
+   <properties/>
+
+   <database-references/>
+
+   <inputs/>
+
+   <outputs/>
+
+   <statements/>
+
+</ns2:processingNode>
\ No newline at end of file


Property changes on: sam/trunk/modules/sim/src/test/resources/simulation/sam-cfg.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the overlord-commits mailing list