use of org.kie.maven.integration.MavenRepository in project drools by kiegroup.
the class KieModuleMavenTest method testKieContainerBeforeAndAfterDeployOfSnapshot.
@Test
public void testKieContainerBeforeAndAfterDeployOfSnapshot() throws Exception {
// BZ-1007977
KieServices ks = KieServices.Factory.get();
String group = "org.kie.test";
String artifact = "test-module";
String version = "1.0.0-SNAPSHOT";
ReleaseId releaseId = ks.newReleaseId(group, artifact, version);
String prefix = new File(".").getAbsolutePath().contains("kie-ci") ? "" : "kie-ci/";
File kjar = new File(prefix + "src/test/resources/kjar/kjar-module-before.jar");
File pom = new File(prefix + "src/test/resources/kjar/pom-kjar.xml");
MavenRepository repository = getMavenRepository();
repository.installArtifact(releaseId, kjar, pom);
KieContainer kContainer = ks.newKieContainer(releaseId);
KieBase kbase = kContainer.getKieBase();
assertNotNull(kbase);
Collection<KiePackage> packages = kbase.getKiePackages();
assertNotNull(packages);
assertEquals(1, packages.size());
Collection<Rule> rules = packages.iterator().next().getRules();
assertEquals(2, rules.size());
ks.getRepository().removeKieModule(releaseId);
// deploy new version
File kjar1 = new File(prefix + "src/test/resources/kjar/kjar-module-after.jar");
File pom1 = new File(prefix + "src/test/resources/kjar/pom-kjar.xml");
repository.installArtifact(releaseId, kjar1, pom1);
KieContainer kContainer2 = ks.newKieContainer(releaseId);
KieBase kbase2 = kContainer2.getKieBase();
assertNotNull(kbase2);
Collection<KiePackage> packages2 = kbase2.getKiePackages();
assertNotNull(packages2);
assertEquals(1, packages2.size());
Collection<Rule> rules2 = packages2.iterator().next().getRules();
assertEquals(4, rules2.size());
ks.getRepository().removeKieModule(releaseId);
}
use of org.kie.maven.integration.MavenRepository in project drools by kiegroup.
the class KieRepositoryScannerTest method testKieScannerScopesNotRequired.
@Test
public void testKieScannerScopesNotRequired() throws Exception {
MavenRepository repository = getMavenRepository();
KieServices ks = KieServices.Factory.get();
ReleaseId releaseIdWithDep = ks.newReleaseId("org.kie", "test-with-dep", "1.0-SNAPSHOT");
Dependency dep1 = dependencyWithScope("org.kie", "test-dep1-in-test-scope", "1.0-SNAPSHOT", "test");
Dependency dep2 = dependencyWithScope("org.kie", "test-dep2-in-provided-scope", "1.0-SNAPSHOT", "provided");
Dependency dep3 = dependencyWithScope("org.kie", "test-dep3-in-system-scope", "1.0-SNAPSHOT", "system");
dep3.setSystemPath(fileManager.getRootDirectory().getAbsolutePath());
// to ensure KieBuilder is able to build correctly:
repository.installArtifact(ks.newReleaseId("org.kie", "test-dep3-in-system-scope", "1.0-SNAPSHOT"), new byte[] {}, new byte[] {});
InternalKieModule kJar2 = createKieJarWithDependencies(ks, releaseIdWithDep, false, "rule1", dep1, dep2, dep3);
KieContainer kieContainer = ks.newKieContainer(releaseIdWithDep);
// DROOLS-1051 following should not throw NPE because dependencies are not in scope of scanner
KieScanner scanner = ks.newKieScanner(kieContainer);
assertNotNull(scanner);
}
use of org.kie.maven.integration.MavenRepository in project drools by kiegroup.
the class KieRepositoryScannerTest method testMissingDependency.
@Test
public void testMissingDependency() throws Exception {
KieServices ks = KieServices.Factory.get();
MavenRepository repository = getMavenRepository();
ReleaseId releaseId = ks.newReleaseId("org.kie", "scanner-test", "1.0");
ReleaseId missingDep = ks.newReleaseId("org.kie", "missing-dep", "1.0");
KieFileSystem kfs = createKieFileSystemWithKProject(ks, false);
kfs.writePomXML(getPom(releaseId, missingDep));
kfs.write("src/main/resources/KBase1/rule1.drl", createDRLWithTypeDeclaration(1, 1));
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
assertEquals(1, messages.size());
assertTrue(messages.get(0).toString().contains("missing-dep"));
ks.getRepository().removeKieModule(releaseId);
}
Aggregations