Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUVNOR-2140: Recursion in ClassFactBuilder leads to StackOverflow whe…
…n loading in assets into project model cache. More tests.
- Loading branch information
Michael Anstis
committed
Nov 5, 2014
1 parent
c91feca
commit fe0d9e6
Showing
6 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...kie/workbench/common/services/datamodel/backend/server/ProjectDataModelRecursionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.kie.workbench.common.services.datamodel.backend.server; | ||
|
||
import java.net.URL; | ||
import javax.enterprise.context.spi.CreationalContext; | ||
import javax.enterprise.inject.spi.Bean; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
|
||
import org.drools.workbench.models.datamodel.oracle.ProjectDataModelOracle; | ||
import org.jboss.weld.environment.se.StartMain; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService; | ||
import org.uberfire.backend.server.util.Paths; | ||
import org.uberfire.backend.vfs.Path; | ||
import org.uberfire.java.nio.fs.file.SimpleFileSystemProvider; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.kie.workbench.common.services.datamodel.backend.server.ProjectDataModelOracleTestUtils.*; | ||
|
||
/** | ||
* Tests for DataModelService | ||
*/ | ||
public class ProjectDataModelRecursionTest { | ||
|
||
private final SimpleFileSystemProvider fs = new SimpleFileSystemProvider(); | ||
private BeanManager beanManager; | ||
private Paths paths; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
//Bootstrap WELD container | ||
StartMain startMain = new StartMain( new String[ 0 ] ); | ||
beanManager = startMain.go().getBeanManager(); | ||
|
||
//Instantiate Paths used in tests for Path conversion | ||
final Bean pathsBean = (Bean) beanManager.getBeans( Paths.class ).iterator().next(); | ||
final CreationalContext cc = beanManager.createCreationalContext( pathsBean ); | ||
paths = (Paths) beanManager.getReference( pathsBean, | ||
Paths.class, | ||
cc ); | ||
|
||
//Ensure URLs use the default:// scheme | ||
fs.forceAsDefault(); | ||
} | ||
|
||
@Test | ||
public void testProjectDataModelOracle() throws Exception { | ||
final Bean dataModelServiceBean = (Bean) beanManager.getBeans( DataModelService.class ).iterator().next(); | ||
final CreationalContext cc = beanManager.createCreationalContext( dataModelServiceBean ); | ||
final DataModelService dataModelService = (DataModelService) beanManager.getReference( dataModelServiceBean, | ||
DataModelService.class, | ||
cc ); | ||
|
||
final URL packageUrl = this.getClass().getResource( "/DataModelBackendRecursionTest1/src/main/java/t6p1" ); | ||
final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath( packageUrl.toURI() ); | ||
final Path packagePath = paths.convert( nioPackagePath ); | ||
|
||
final ProjectDataModelOracle oracle = dataModelService.getProjectDataModel( packagePath ); | ||
|
||
assertNotNull( oracle ); | ||
|
||
assertEquals( 1, | ||
oracle.getProjectModelFields().size() ); | ||
assertContains( "t6p1.Bean1", | ||
oracle.getProjectModelFields().keySet() ); | ||
|
||
assertFalse( oracle.getProjectEventTypes().get( "t6p1.Bean1" ) ); | ||
|
||
assertEquals( 2, | ||
oracle.getProjectModelFields().get( "t6p1.Bean1" ).length ); | ||
assertContains( "this", | ||
oracle.getProjectModelFields().get( "t6p1.Bean1" ) ); | ||
assertContains( "field1", | ||
oracle.getProjectModelFields().get( "t6p1.Bean1" ) ); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...kie-wb-common-datamodel-backend/src/test/resources/DataModelBackendRecursionTest1/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.kie.example</groupId> | ||
<artifactId>DataModelBackendRecursionTest1</artifactId> | ||
<version>1.0</version> | ||
|
||
</project> |
15 changes: 15 additions & 0 deletions
15
...l-backend/src/test/resources/DataModelBackendRecursionTest1/src/main/java/t6p1/Bean1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package t6p1; | ||
|
||
public class Bean1 { | ||
|
||
private Bean1 field1; | ||
|
||
public Bean1 getField1() { | ||
return field1; | ||
} | ||
|
||
public void setField1( Bean1 field1 ) { | ||
this.field1 = field1; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...src/test/resources/DataModelBackendRecursionTest1/src/main/resources/META-INF/kmodule.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule"> | ||
|
||
</kmodule> |
7 changes: 7 additions & 0 deletions
7
...l-backend/src/test/resources/DataModelBackendRecursionTest1/src/main/resources/empty.rdrl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import java.lang.Number; | ||
|
||
rule "empty" | ||
dialect "mvel" | ||
when | ||
then | ||
end |