Ejemplo n.º 1
0
  @Test
  public void testNoModelUsingWs() throws IOException {
    setupLocalCache();

    final File temp = File.createTempFile("drools-service", ".jar");
    // Delete temp file when program exits.
    temp.deleteOnExit();

    final OutputStream out = new FileOutputStream(temp);

    buildWar(new ServiceConfig(WS_SERVICE_CONFIG), (Map<String, File>) null, out);

    final WebArchive archive = ShrinkWrap.createFromZipFile(WebArchive.class, temp);
    final Collection<String> fileNames = new LinkedList<String>();

    for (final Map.Entry<ArchivePath, Node> entry : archive.getContent().entrySet()) {
      final String extension = getExtension(entry.getKey().get());
      final String fileName = getName(entry.getKey().get());
      if (extension.equalsIgnoreCase("jar")) {
        fileNames.add(fileName);
      } else if (extension.equalsIgnoreCase("xml")) {
        validateGeneratedFiles("ws-", fileName, toString(entry.getValue().getAsset().openStream()));
      }
    }
    assertEquals(2, fileNames.size());
    assertTrue(LIBS.containsAll(fileNames));
  }
 @Deployment(name = "picketlink-wstest-tests", testable = false)
 @TargetsContainer("jboss")
 public static JavaArchive createWSTestDeployment()
     throws ConfigurationException, ProcessingException, ParsingException, InterruptedException {
   return ShrinkWrap.createFromZipFile(
       JavaArchive.class, new File("../../unit-tests/trust/target/picketlink-wstest-tests.jar"));
 }
Ejemplo n.º 3
0
  @Deployment(testable = false)
  public static WebArchive createTestArchive() {

    WebArchive war =
        ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/showcase.war"));
    return war;
  }
  @Deployment
  public static WebArchive createDeployment() {

    File archive = new File("target/sample-war-ejb-app.war");
    if (!archive.exists()) {
      throw new IllegalStateException(
          "There is no archive yet generated, run maven build or mvn assembly:assembly");
    }
    WebArchive war = ShrinkWrap.createFromZipFile(WebArchive.class, archive);
    war.addPackage("org.jbpm.services.ejb.test"); // test cases
    // deploy test kjar
    deployKjar();

    return war;
  }
  @Test
  public void buildUberjarAndRunTests()
      throws IOException, VerificationException, InterruptedException {
    String goal = "package";
    if (testingProject.canRunTests()) {
      goal = "verify";

      // a lot of these fail because of SWARM-873
      if (testingProject.additionalDependency == AdditionalDependency.USING_JAVA_EE) {
        goal = "package";
      }
    }

    try {
      verifier.executeGoal(goal);
    } catch (VerificationException e) {
      if (testingProject.dependencies == Dependencies.JAVA_EE_APIS
          && testingProject.autodetection == Autodetection.NEVER) {
        // the only situation when build failure is expected
        String log = new String(Files.readAllBytes(logPath), StandardCharsets.UTF_8);
        assertThat(log).contains("No WildFly Swarm Bootstrap fraction found");
        return;
      }

      throw e;
    }

    verifier.assertFilePresent(
        "target/testing-project." + testingProject.packaging.fileExtension());
    verifier.assertFilePresent("target/testing-project-swarm.jar");

    String log = new String(Files.readAllBytes(logPath), StandardCharsets.UTF_8);

    assertThat(log).doesNotContain("[ERROR]");
    assertThat(log).doesNotContain("[WARNING]");
    assertThat(log).contains("BUILD SUCCESS");

    checkFractionAutodetection(log);

    File uberjarFile = new File(verifier.getBasedir(), "target/testing-project-swarm.jar");
    Archive uberjar = ShrinkWrap.createFromZipFile(GenericArchive.class, uberjarFile);

    checkFractionsPresent(uberjar);

    checkMainClass(uberjar);
  }
Ejemplo n.º 6
0
  @Test
  public void testRest() throws IOException, URISyntaxException {
    setupLocalCache();

    final File temp = File.createTempFile("drools-service", ".jar");
    // Delete temp file when program exits.
    temp.deleteOnExit();

    final OutputStream out = new FileOutputStream(temp);
    final Map<String, File> models =
        new HashMap<String, File>() {
          {
            put(
                "jarWithSourceFiles.jar",
                new File(
                    ServiceWarGeneratorTest.class
                        .getClassLoader()
                        .getResource(MODEL_NAME)
                        .toURI()));
          }
        };

    buildWar(new ServiceConfig(REST_SERVICE_CONFIG), models, out);

    final WebArchive archive = ShrinkWrap.createFromZipFile(WebArchive.class, temp);
    final Collection<String> fileNames = new LinkedList<String>();

    for (final Map.Entry<ArchivePath, Node> entry : archive.getContent().entrySet()) {
      final String extension = getExtension(entry.getKey().get());
      final String fileName = getName(entry.getKey().get());
      if (extension.equalsIgnoreCase("jar")) {
        fileNames.add(fileName);
      } else if (extension.equalsIgnoreCase("xml")) {
        validateGeneratedFiles(
            "rest-", fileName, toString(entry.getValue().getAsset().openStream()));
      }
    }

    assertEquals(3, fileNames.size());
    assertTrue(fileNames.containsAll(LIBS));
    assertTrue(fileNames.contains("jarWithSourceFiles.jar"));
  }
Ejemplo n.º 7
0
 /**
  * Creates deployment which is sent to the container upon test's start.
  *
  * @return war file which is deployed while testing, the whole application in our case
  */
 public static WebArchive kitchensink() {
   return ShrinkWrap.createFromZipFile(WebArchive.class, new File(KITCHENSINK));
 }