Skip to content

Instantly share code, notes, and snippets.

@tsurdilo
Created September 14, 2010 16:33
Show Gist options
  • Save tsurdilo/579313 to your computer and use it in GitHub Desktop.
Save tsurdilo/579313 to your computer and use it in GitHub Desktop.
@RunWith(Arquillian.class)
public class KSessionTest
{
@Deployment
public static JavaArchive createTestArchive()
{
String pkgPath = KSessionTest.class.getPackage().getName().replaceAll("\\.", "/");
JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class)
.addPackages(true, new DroolsModuleFilter("ksession"), KnowledgeBaseProducer.class.getPackage())
.addClass(KSessionTestRules.class)
.addClass(KSessionTestProducer.class)
.addResource(pkgPath + "/ksessiontest.drl", ArchivePaths.create("ksessiontest.drl"))
.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
.addManifestResource(pkgPath + "/KSessionTest-beans.xml", ArchivePaths.create("beans.xml"))
.addManifestResource("META-INF/services/javax.enterprise.inject.spi.Extension", ArchivePaths.create("services/javax.enterprise.inject.spi.Extension"));
//System.out.println(archive.toString(Formatters.VERBOSE));
return archive;
}
@Test
public void testKSession(@DefaultConfig @Default StatefulKnowledgeSession ksession)
{
assertNotNull(ksession);
assertTrue(ksession.getId() >= 0);
}
}
*************** KSessionTestProducer
@DroolsConfig(kbuilderConfigFile = "kbuilderconfig.properties",
kbaseConfigFile = "kbaseconfig.properties",
ruleResources = {
@RuleResource( location="classpath", path="kbasetest.drl", type="DRL", templateDataProvider="forkbasetest")
})
@Produces
@DefaultConfig
KnowledgeBaseProducer producer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment