Search in sources :

Example 6 with KieRepositoryImpl

use of org.drools.compiler.kie.builder.impl.KieRepositoryImpl in project drools by kiegroup.

the class KieModuleMavenTest method testResourceTypeInKieModuleReleaseId.

@Test
public void testResourceTypeInKieModuleReleaseId() throws Exception {
    final KieServices ks = new KieServicesImpl() {

        @Override
        public KieRepository getRepository() {
            // override repository to not store the artifact on deploy to trigger load from maven repo
            return new KieRepositoryImpl();
        }
    };
    ReleaseId releaseId = ks.newReleaseId("org.kie", "maven-test.drl", "1.0-SNAPSHOT");
    InternalKieModule kJar1 = createKieJar(ks, releaseId, true, "rule1", "rule2");
    String pomText = getPom(releaseId);
    File pomFile = new File(System.getProperty("java.io.tmpdir"), MavenRepository.toFileName(releaseId, null) + ".pom");
    try {
        FileOutputStream fos = new FileOutputStream(pomFile);
        fos.write(pomText.getBytes());
        fos.flush();
        fos.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    KieMavenRepository.getKieMavenRepository().installArtifact(releaseId, kJar1, pomFile);
    KieContainer kieContainer = ks.newKieContainer(releaseId);
    KieBase kieBase = kieContainer.getKieBase("KBase1");
    assertNotNull(kieBase);
    assertEquals("There must be one package built", 1, kieBase.getKiePackages().size());
    ClassLoader classLoader = kieContainer.getClassLoader();
    assertEnumerationSize(1, classLoader.getResources("KBase1/org/test"));
    assertEnumerationSize(1, classLoader.getResources("META-INF/maven/org.kie/maven-test.drl"));
}
Also used : KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) IOException(java.io.IOException) KieBase(org.kie.api.KieBase) KieRepositoryImpl(org.drools.compiler.kie.builder.impl.KieRepositoryImpl) FileOutputStream(java.io.FileOutputStream) KieServicesImpl(org.drools.compiler.kie.builder.impl.KieServicesImpl) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Aggregations

FileOutputStream (java.io.FileOutputStream)6 IOException (java.io.IOException)6 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)6 KieRepositoryImpl (org.drools.compiler.kie.builder.impl.KieRepositoryImpl)6 KieServices (org.kie.api.KieServices)6 ReleaseId (org.kie.api.builder.ReleaseId)6 KieContainer (org.kie.api.runtime.KieContainer)6 File (java.io.File)5 KieServicesImpl (org.drools.compiler.kie.builder.impl.KieServicesImpl)5 Test (org.junit.Test)5 KieBaseModel (org.kie.api.builder.model.KieBaseModel)3 FileNotFoundException (java.io.FileNotFoundException)1 HashSet (java.util.HashSet)1 ReleaseIdImpl (org.drools.compiler.kproject.ReleaseIdImpl)1 InternalRuleUnitExecutor (org.drools.core.impl.InternalRuleUnitExecutor)1 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)1 KieBase (org.kie.api.KieBase)1 KieRepository (org.kie.api.builder.KieRepository)1 Resource (org.kie.api.io.Resource)1 RuleUnitExecutor (org.kie.api.runtime.rule.RuleUnitExecutor)1