private File createMasterKPom() throws IOException {
    String pom =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
            + "         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
            + "  <modelVersion>4.0.0</modelVersion>\n"
            + "\n"
            + "  <groupId>org.kie</groupId>\n"
            + "  <artifactId>scanner-master-test</artifactId>\n"
            + "  <version>1.0</version>\n"
            + "  <packaging>pom</packaging>\n"
            + "\n"
            + "    <dependencies>\n"
            + "      <dependency>\n"
            + "        <groupId>org.kie</groupId>\n"
            + "        <artifactId>scanner-test</artifactId>\n"
            + "        <version>LATEST</version>\n"
            + "      </dependency>\n"
            + "    </dependencies>\n"
            + "</project>";

    File pomFile = fileManager.newFile("pom.xml");
    fileManager.write(pomFile, pom);
    return pomFile;
  }
Exemple #2
0
  @Test
  public void testClassNotFoundAfterDeserialization() throws Exception {
    // JBRULES-3670
    String drl =
        "package completely.other.deal;\n"
            + "\n"
            + "declare Person\n"
            + "   firstName : String\n"
            + "   lastName : String\n"
            + "end\n"
            + "\n"
            + "rule \"now use it B\"\n"
            + "   when\n"
            + "       Person( $christianName, $surname; )\n"
            + "   then\n"
            + "       insert( new Person( $christianName, null ) );\n"
            + "end";

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newByteArrayResource(drl.getBytes()), ResourceType.DRL);

    if (kbuilder.hasErrors()) {
      throw new RuntimeException("" + kbuilder.getErrors());
    }

    FileManager fileManager = new FileManager().setUp();

    try {
      File root = fileManager.getRootDirectory();

      ObjectOutputStream out =
          new ObjectOutputStream(new FileOutputStream(new File(root, "test.drl.compiled")));
      out.writeObject(kbuilder.getKnowledgePackages());
      out.close();

      KieBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
      kconf.setOption(LRUnlinkingOption.ENABLED);
      KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kconf);

      ObjectInputStream in =
          new ObjectInputStream(new FileInputStream(new File(root, "test.drl.compiled")));
      kbase.addKnowledgePackages((Collection<KnowledgePackage>) in.readObject());
      in.close();
    } finally {
      fileManager.tearDown();
    }
  }
 private File createKPom(GAV gav) throws IOException {
   File pomFile = fileManager.newFile("pom.xml");
   fileManager.write(pomFile, getPom(gav));
   return pomFile;
 }
 private File createKPom(ReleaseId releaseId) throws IOException {
   File pomFile = fileManager.newFile("pom.xml");
   fileManager.write(pomFile, getPom(releaseId));
   return pomFile;
 }