@Test
public void testKieModuleUsingPOMMissingKBaseDefinition() throws Exception {
KieServices ks = KieServices.Factory.get();
//Build a KieModule jar, deploy it into local Maven repository
ReleaseId releaseId = ks.newReleaseId( "org.kie",
"metadata-test2",
"1.0-SNAPSHOT" );
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 );
}
KieFileSystem kfs = ks.newKieFileSystem();
kfs.writePomXML( getPom( releaseId ) );
kfs.write( "src/main/java/org/kie/test/Bean.java",
createJavaSourceInPackage() );
KieBuilder kieBuilder1 = ks.newKieBuilder( kfs );
Assert.assertTrue( kieBuilder1.buildAll().getResults().getMessages().isEmpty() );
InternalKieModule kieModule = (InternalKieModule) kieBuilder1.getKieModule();
MavenRepository.getMavenRepository().deployArtifact( releaseId,
kieModule,
pomFile );
//Build a second KieModule, depends on the first KieModule jar which we have deployed into Maven
ReleaseId releaseId2 = ks.newReleaseId( "org.kie",
"metadata-test-using-pom",
"1.0-SNAPSHOT" );
String pomText2 = getPom( releaseId2,
releaseId );
File pomFile2 = new File( System.getProperty( "java.io.tmpdir" ),