Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PMML : explicitly dispose resources in tests to reduce memory consump…

…tion
  • Loading branch information...
commit 419fee9d5b788815bb81aac1e3c8c6e1651e717d 1 parent cef9938
@sotty sotty authored
Showing with 139 additions and 10 deletions.
  1. +1 −0  drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/PMMLUsageDemoTest.java
  2. +8 −2 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/global/ConstrainedDataDictionaryTest.java
  3. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/global/DataDictionaryTest.java
  4. +1 −0  drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/global/HeaderTest.java
  5. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/informer/QuestionnaireTest.java
  6. +5 −1 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/MiningSchemaTest.java
  7. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/TargetsAndOutputsTest.java
  8. +24 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/CleanupTest.java
  9. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/ClusteringTest.java
  10. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/DecisionTreeTest.java
  11. +6 −2 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/MultipleModelTest.java
  12. +7 −1 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/NeuralNetworkTest.java
  13. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/SVMTest.java
  14. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/ScorecardTest.java
  15. +6 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/SimpleRegressionTest.java
  16. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/AggregateFieldsTest.java
  17. +5 −1 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/AliasedFieldsTest.java
  18. +5 −1 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/DiscretizeFieldsTest.java
  19. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/FunctionsTest.java
  20. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/FunctionsWithNestedTest.java
  21. +6 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/LinearNormalizedFieldsTest.java
  22. +5 −1 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/MapValuesTest.java
  23. +5 −1 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/NormDiscreteFieldsTest.java
  24. +5 −0 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/UserDefinedFunctionsTest.java
View
1  drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/PMMLUsageDemoTest.java
@@ -47,6 +47,7 @@ public void setupSession() {
// Create kSession and initialize it
kSession = kbase.newStatefulKnowledgeSession();
kSession.fireAllRules();
+
}
View
10 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/global/ConstrainedDataDictionaryTest.java
@@ -22,6 +22,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.ClassObjectFilter;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,8 +40,13 @@
@Before
public void setUp() throws Exception {
- setKSession(getModelSession(source,VERBOSE));
- setKbase(getKSession().getKnowledgeBase());
+ setKSession( getModelSession( source, VERBOSE ) );
+ setKbase( getKSession().getKnowledgeBase() );
+ }
+
+ @After
+ public void tearDown() {
+ getKSession().dispose();
}
@Test
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/global/DataDictionaryTest.java
@@ -22,6 +22,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.ClassObjectFilter;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.junit.After;
import org.junit.Test;
@@ -32,6 +33,10 @@
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
1  drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/global/HeaderTest.java
@@ -82,6 +82,7 @@ public void testPMMLHeader() {
KnowledgePackage pack = ksession.getKnowledgeBase().getKnowledgePackage("org.drools.pmml.pmml_4_1.test");
assertNotNull(pack);
+ ksession.dispose();
}
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/informer/QuestionnaireTest.java
@@ -22,6 +22,7 @@
import org.drools.informer.*;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.rule.Variable;
+import org.junit.After;
import org.junit.Test;
import java.util.Collection;
@@ -44,6 +45,10 @@
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testUnquestionable() {
View
6 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/MiningSchemaTest.java
@@ -18,6 +18,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Test;
@@ -29,7 +30,10 @@
-
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/TargetsAndOutputsTest.java
@@ -18,6 +18,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Test;
@@ -29,6 +30,10 @@
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
24 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/CleanupTest.java
@@ -35,6 +35,7 @@
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.QueryResults;
import org.drools.runtime.rule.Variable;
+import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -73,6 +74,7 @@ public void testCleanupANN() {
System.err.println(reportWMObjects(kSession));
assertEquals( 1, kSession.getObjects().size() );
+ kSession.dispose();
}
@@ -113,6 +115,7 @@ public void testReenableANN() {
assertEquals( 61, getKSession().getObjects().size() );
+ getKSession().dispose();
}
@@ -135,6 +138,7 @@ public void testCleanupDT() {
assertEquals( 1, kSession.getObjects().size() );
+ kSession.dispose();
}
@Test
@@ -155,6 +159,7 @@ public void testCleanupRegression() {
assertEquals( 1, kSession.getObjects().size() );
+ kSession.dispose();
}
@Test
@@ -175,6 +180,7 @@ public void testCleanupClustering() {
assertEquals( 1, kSession.getObjects().size() );
+ kSession.dispose();
}
@Test
@@ -195,6 +201,7 @@ public void testCleanupSVM() {
assertEquals( 1, kSession.getObjects().size() );
+ kSession.dispose();
}
@Test
@@ -215,6 +222,7 @@ public void testCleanupScorecard() {
assertEquals( 1, kSession.getObjects().size() );
+ kSession.dispose();
}
@@ -271,6 +279,8 @@ public void testCleanupANNRulesWithIncrementalKA() {
System.err.println( reportWMObjects( kSession ) );
assertEquals( 0, kSession.getObjects().size() );
+ kSession.dispose();
+ kAgent.dispose();
}
@@ -310,6 +320,8 @@ public void testCleanupDTRulesWithIncrementalKA() {
System.err.println( reportWMObjects( kSession ) );
assertEquals( 0, kSession.getObjects().size() );
+ kSession.dispose();
+ kAgent.dispose();
}
@Test
@@ -346,6 +358,9 @@ public void testCleanupClusteringRulesWithIncrementalKA() {
System.err.println( reportWMObjects( kSession ) );
assertEquals( 0, kSession.getObjects().size() );
+
+ kSession.dispose();
+ kAgent.dispose();
}
@Test
@@ -382,6 +397,9 @@ public void testCleanupRegressionRulesWithIncrementalKA() {
System.err.println( reportWMObjects( kSession ) );
assertEquals( 0, kSession.getObjects().size() );
+
+ kSession.dispose();
+ kAgent.dispose();
}
@Test
@@ -418,6 +436,9 @@ public void testCleanupSVMRulesWithIncrementalKA() {
System.err.println( reportWMObjects( kSession ) );
assertEquals( 0, kSession.getObjects().size() );
+
+ kSession.dispose();
+ kAgent.dispose();
}
@Test
@@ -454,6 +475,9 @@ public void testCleanupScorecardRulesWithIncrementalKA() {
System.err.println( reportWMObjects( kSession ) );
assertEquals( 0, kSession.getObjects().size() );
+
+ kSession.dispose();
+ kAgent.dispose();
}
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/ClusteringTest.java
@@ -21,6 +21,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.ClassObjectFilter;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.junit.After;
import org.junit.Test;
import java.util.Collection;
@@ -37,6 +38,10 @@
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testCenterBasedClustering() throws Exception {
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/DecisionTreeTest.java
@@ -32,6 +32,7 @@
import org.dmg.pmml.pmml_4_1.descr.*;
import org.drools.runtime.ClassObjectFilter;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.junit.After;
import org.junit.Test;
import java.util.Collection;
@@ -48,6 +49,10 @@
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testSimpleTree() throws Exception {
View
8 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/MultipleModelTest.java
@@ -206,6 +206,8 @@ public void testIncrementalBuilding() throws Exception {
assertEquals( 2, kSession.getObjects( new ClassObjectFilter( Questionnaire.class ) ).size() );
assertEquals( 11, kSession.getObjects( new ClassObjectFilter( kSession.getKnowledgeBase().getFactType( packageName, "Synapse" ).getFactClass() ) ).size() );
+ kSession.dispose();
+
}
@@ -284,6 +286,8 @@ public void testKnowledgeAgentLoadingMultipleANN() throws Exception {
assertEquals( 23, kSession.getObjects( new ClassObjectFilter( kSession.getKnowledgeBase().getFactType( packageName, "Synapse" ).getFactClass() ) ).size() );
+ kSession.dispose();
+ kagent.dispose();
}
@@ -341,8 +345,8 @@ public void testKnowledgeAgentLoadingMix() throws Exception {
assertEquals( 9, kSession.getObjects( new ClassObjectFilter( kSession.getKnowledgeBase().getFactType( packageName, "Synapse" ).getFactClass() ) ).size() );
assertEquals( 4, kSession.getObjects( new ClassObjectFilter( kSession.getKnowledgeBase().getFactType( packageName, "SupportVector" ).getFactClass() ) ).size() );
-
-
+ kSession.dispose();
+ kagent.dispose();
}
View
8 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/NeuralNetworkTest.java
@@ -32,6 +32,7 @@
import org.drools.pmml.pmml_4_1.ModelMarker;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.Variable;
+import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -62,6 +63,11 @@
private static final String smartVent = "org/drools/pmml/pmml_4_1/smartvent.xml";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
+
@Test
@@ -79,6 +85,7 @@ public void testANNFromSource() throws Exception {
kBase.addKnowledgePackages( knowledgeBuilder.getKnowledgePackages() );
StatefulKnowledgeSession kSession = kBase.newStatefulKnowledgeSession();
+ setKSession( kSession );
// kSession.addEventListener( new DebugAgendaEventListener() );
// kSession.addEventListener( new DebugWorkingMemoryEventListener() );
@@ -124,7 +131,6 @@ public void testANN() throws Exception {
System.err.println(reportWMObjects(getKSession()));
-
Assert.assertEquals( 828.0, Math.floor( queryDoubleField( "OutAmOfClaims", "NeuralInsurance" ) ) );
}
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/SVMTest.java
@@ -20,6 +20,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
@@ -34,6 +35,10 @@
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testSVM() throws Exception {
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/ScorecardTest.java
@@ -21,6 +21,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.ClassObjectFilter;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.junit.After;
import org.junit.Test;
import java.util.Iterator;
@@ -39,6 +40,10 @@
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testScorecard() throws Exception {
View
6 ...s-pmml/src/test/java/org/drools/pmml/pmml_4_1/predictive/models/SimpleRegressionTest.java
@@ -20,6 +20,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
@@ -34,6 +35,11 @@
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
+
@Test
public void testRegression() throws Exception {
setKSession( getModelSession( source1, VERBOSE ) );
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/AggregateFieldsTest.java
@@ -19,6 +19,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -38,6 +39,10 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
6 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/AliasedFieldsTest.java
@@ -19,6 +19,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,7 +40,10 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
-
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testKonst() throws Exception {
View
6 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/DiscretizeFieldsTest.java
@@ -19,6 +19,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,7 +39,10 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
-
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/FunctionsTest.java
@@ -19,6 +19,7 @@
import org.drools.pmml.pmml_4_1.PMML4Helper;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +39,10 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
5 ...-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/FunctionsWithNestedTest.java
@@ -18,6 +18,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -37,6 +38,10 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
6 ...ml/src/test/java/org/drools/pmml/pmml_4_1/transformations/LinearNormalizedFieldsTest.java
@@ -19,6 +19,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,6 +40,11 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
+
@Test
public void testDerivedTypesLinearNormMapMissing() throws Exception {
View
6 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/MapValuesTest.java
@@ -19,6 +19,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -37,7 +38,10 @@ public void setUp() throws Exception {
setKbase(getKSession().getKnowledgeBase());
}
-
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
View
6 ...s-pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/NormDiscreteFieldsTest.java
@@ -19,6 +19,7 @@
import org.drools.definition.type.FactType;
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -40,7 +41,10 @@ public void setUp() throws Exception {
}
-
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
public void testNormDiscrete() throws Exception {
View
5 ...pmml/src/test/java/org/drools/pmml/pmml_4_1/transformations/UserDefinedFunctionsTest.java
@@ -21,6 +21,7 @@
import org.drools.pmml.pmml_4_1.DroolsAbstractPMMLTest;
import org.drools.runtime.ClassObjectFilter;
import org.drools.runtime.rule.FactHandle;
+import org.junit.After;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
@@ -34,6 +35,10 @@
private static final String source3 = "org/drools/pmml/pmml_4_1/test_user_functions_simpleTransformations.xml";
private static final String packageName = "org.drools.pmml.pmml_4_1.test";
+ @After
+ public void tearDown() {
+ getKSession().dispose();
+ }
@Test
Please sign in to comment.
Something went wrong with that request. Please try again.