@Test
  public void test_2GB_over() throws IOException {
    Assume.assumeTrue(CC.FULL_TEST);

    byte[] data = new byte[51111];
    int dataHash = Arrays.hashCode(data);

    Set<Long> recids = new TreeSet<Long>();

    for (int i = 0; i < 1e5; i++) {
      long recid = engine.recordPut(data, Serializer.BYTE_ARRAY_SERIALIZER);
      recids.add(recid);

      //            if(i%10000==0){
      //            System.out.println(recid);
      //            for(Long l:recids){
      //                byte[] b = engine.recordGet(l, Serializer.BYTE_ARRAY_SERIALIZER);
      //                int hash = Arrays.hashCode(b);
      //                assertEquals(l,dataHash, hash);
      //            }
      //            }

    }

    engine.commit();

    for (Long l : recids) {
      byte[] b = engine.recordGet(l, Serializer.BYTE_ARRAY_SERIALIZER);
      int hash = Arrays.hashCode(b);
      assertEquals(dataHash, hash);
    }
  }
Example #2
0
  @Test
  public void testCloneOverSshWithPassphraseProtectedKey() throws Exception {
    Assume.assumeTrue(sshRepo2 != null);
    Assume.assumeTrue(privateKey != null);
    Assume.assumeTrue(passphrase != null);

    URI workspaceLocation = createWorkspace(getMethodName());
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null);
    IPath clonePath =
        new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute();
    URIish uri = new URIish(sshRepo2);
    WebRequest request =
        new PostGitCloneRequest()
            .setURIish(uri)
            .setFilePath(clonePath)
            .setKnownHosts(knownHosts2)
            .setPrivateKey(privateKey)
            .setPublicKey(publicKey)
            .setPassphrase(passphrase)
            .getWebRequest();
    String contentLocation = clone(request);

    File file = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile();
    assertTrue(file.exists());
    assertTrue(file.isDirectory());
    assertTrue(
        RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED));
  }
  @Test
  public void test() throws Exception {
    try {
      String queryFileShort =
          queryFile.getPath().substring(PATH_QUERIES.length()).replace(SEPARATOR.charAt(0), '/');
      if (!only.isEmpty()) {
        boolean toRun = TestHelper.isInPrefixList(only, queryFileShort);
        if (!toRun) {
          LOGGER.info(
              "SKIP TEST: \""
                  + queryFile.getPath()
                  + "\" \"only.txt\" not empty and not in \"only.txt\".");
        }
        Assume.assumeTrue(toRun);
      }
      boolean skipped = TestHelper.isInPrefixList(ignore, queryFileShort);
      if (skipped) {
        LOGGER.info("SKIP TEST: \"" + queryFile.getPath() + "\" in \"ignore.txt\".");
      }
      Assume.assumeTrue(!skipped);

      LOGGER.info("RUN TEST: \"" + queryFile.getPath() + "\"");
      parserTestExecutor.testSQLPPParser(queryFile, actualFile, expectedFile);
    } catch (Exception e) {
      if (!(e instanceof AssumptionViolatedException)) {
        LOGGER.severe("Test \"" + queryFile.getPath() + "\" FAILED!");
        throw new Exception("Test \"" + queryFile.getPath() + "\" FAILED!", e);
      } else {
        throw e;
      }
    }
  }
Example #4
0
 @Test
 public void testAssignOp1Div() {
   Assume.assumeTrue(runLongTests);
   Assume.assumeTrue(
       !"cvc4".equals(solver)); // SKIPPING because CVC4 does not handle integer division
   main.addOptions("-escMaxWarnings=1");
   main.addOptions("-logic=AUFNIRA");
   helpTCX(
       "tt.TestJava",
       "package tt; import org.jmlspecs.annotation.*; \n"
           + "public class TestJava { \n"
           + "  public int f;\n"
           + "  //@ requires j != 0;\n"
           + "  public int m2good(int j) {\n"
           + "    int i = j ;\n" // Line 20
           + "    return (i/=j) ;\n"
           + "  }\n"
           + "  //@ requires t != null;\n"
           + "  //@ requires i != 0;\n"
           + "  public void m3(TestJava t, int i) {\n"
           + "    t.f /= i ;\n"
           + "  }\n"
           + "  //@ requires t != null;\n"
           + "  //@ requires i != 0;\n"
           + "  //@ assignable \\everything;\n"
           + "  public void m3good(TestJava t, int i) {\n"
           + "    t.f /= i ;\n"
           + "  }\n"
           + "}");
 }
Example #5
0
 public static Path getRootViaResourceURL(final Class<?> c, String[] paths) {
   URL url = c.getResource(c.getSimpleName() + ".class");
   if (url != null) {
     char sep = File.separatorChar;
     String externalForm = url.toExternalForm();
     String classPart = sep + c.getName().replace('.', sep) + ".class";
     String prefix = null;
     String base;
     if (externalForm.startsWith("jar:file:")) {
       prefix = "jar:file:";
       int bang = externalForm.indexOf('!', prefix.length());
       Assume.assumeTrue(bang != -1);
       File jarfilePath = new File(externalForm.substring(prefix.length(), bang));
       Assume.assumeTrue(jarfilePath.exists());
       base = explodeJarToTempDir(jarfilePath);
     } else if (externalForm.startsWith("file:")) {
       prefix = "file:";
       base = externalForm.substring(prefix.length(), externalForm.length() - classPart.length());
     } else {
       return null;
     }
     for (String path : paths) {
       String candidate = base + sep + path;
       if (new File(candidate).exists()) {
         return FileSystems.getDefault().getPath(candidate);
       }
     }
   }
   return null;
 }
  /**
   * Tests the {@link UnderFileSystem#create(String)} method.
   *
   * @throws Exception when the creation fails
   */
  @Test
  public void createGlusterFS() throws Exception {
    // Using Assume will mark the tests as skipped rather than passed which provides a truer
    // indication of their status
    Assume.assumeTrue(!StringUtils.isEmpty(mMount));
    Assume.assumeTrue(!StringUtils.isEmpty(mVolume));

    mGfs = UnderFileSystem.get("glusterfs:///", mTachyonConf);
    Assert.assertNotNull(mGfs.create("tachyon_test"));
  }
  private void checkModelsAndBinary(String lang) {
    Assume.assumeTrue(
        getClass()
                .getResource(
                    "/de/tudarmstadt/ukp/dkpro/core/treetagger/lib/tagger-" + lang + "-le.bin")
            != null);

    Assume.assumeTrue(
        getClass().getResource("/de/tudarmstadt/ukp/dkpro/core/treetagger/bin/LICENSE.txt")
            != null);
  }
 /** Check if we have a working connection to the xsede server before all unit tests. */
 @Before
 public void checkConnection() {
   TexQueryGenerator gen = new TexQueryGenerator();
   HttpPost httppost = new HttpPost(gen.getLaTeXMLURL());
   CloseableHttpClient httpClient = HttpClients.createDefault();
   HttpResponse response;
   try {
     response = httpClient.execute(httppost);
     Assume.assumeTrue(response.getStatusLine().getStatusCode() != 4);
   } catch (final IOException e) {
     Assume.assumeTrue(false);
   }
 }
  @Test()
  public void JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature()
      throws CertificateException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    Name n = new Name();
    n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature");
    be.getName().add(n);
    be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);

    BusinessService bs = new BusinessService();
    bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
    bs.setServiceKey(null);
    bs.getName().add(new Name("Joe's bs", null));
    DigSigUtil ds = GetDigSig();
    bs = ds.signUddiEntity(bs);

    be.setBusinessServices(new BusinessServices());
    be.getBusinessServices().getBusinessService().add(bs);

    sb.getBusinessEntity().add(be);
    try {
      BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
      Assert.fail("unexpected success");
    } catch (Exception ex) {
      logger.info("Expected failure: " + ex.getMessage());
    }
  }
  @Test
  public void testGetLeaves() throws Exception {
    Assume.assumeTrue(!GraphicsEnvironment.isHeadless());
    final CatalogTree catalogTree = new CatalogTree(null, new DefaultAppContext(""), null);
    List<InvDataset> datasets = new ArrayList<InvDataset>();
    InvCatalog catalog = new InvCatalogImpl("catalogName", "1.0", new URI("http://x.y"));
    final InvDataset rootDataset = createDataset(catalog, "first", "OPENDAP");
    rootDataset.getDatasets().add(createDataset(catalog, "second", "OPENDAP"));
    rootDataset.getDatasets().add(createDataset(catalog, "third", "OPENDAP"));

    datasets.add(rootDataset);
    catalogTree.setNewRootDatasets(datasets);

    OpendapLeaf[] leaves = catalogTree.getLeaves();
    Arrays.sort(
        leaves,
        new Comparator<OpendapLeaf>() {
          @Override
          public int compare(OpendapLeaf o1, OpendapLeaf o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    assertEquals(2, leaves.length);
    assertEquals("second", leaves[0].getName());
    assertEquals("third", leaves[1].getName());
  }
Example #11
0
  @Test
  public void testSignalReadyOutputView() {
    Assume.assumeTrue(!Hadoop.isHadoop1());
    Dataset<Record> inputDataset =
        repo.create("ns", "in", new DatasetDescriptor.Builder().schema(USER_SCHEMA).build());

    Dataset<Record> outputDataset =
        repo.create("ns", "out", new DatasetDescriptor.Builder().schema(USER_SCHEMA).build());

    writeTestUsers(inputDataset, 10);

    View<Record> inputView = inputDataset.with("username", "test-8", "test-9");
    View<Record> outputView = outputDataset.with("username", "test-8", "test-9");
    Assert.assertEquals(2, datasetSize(inputView));

    Pipeline pipeline = new MRPipeline(TestCrunchDatasets.class);
    PCollection<GenericData.Record> data = pipeline.read(CrunchDatasets.asSource(inputView));
    pipeline.write(data, CrunchDatasets.asTarget(outputView), Target.WriteMode.APPEND);
    pipeline.run();

    Assert.assertEquals(2, datasetSize(outputView));

    Assert.assertFalse(
        "Output dataset should not be signaled ready", ((Signalable) outputDataset).isReady());
    Assert.assertTrue("Output view should be signaled ready", ((Signalable) outputView).isReady());
  }
  @Test
  public void testMavenizeRuleProvider()
      throws IOException, InstantiationException, IllegalAccessException {
    try (GraphContext graphContext =
        factory.create(WindupTestUtilMethods.getTempDirectoryForGraph())) {
      final String inputDir = "../../test-files/jee-example-app-1.0.0.ear"; // rules-java/api
      final Class<MavenizeRuleProvider> ruleToRunUpTo = MavenizeRuleProvider.class;

      final Path outputDir =
          executeWindupAgainstAppUntilRule(inputDir, graphContext, ruleToRunUpTo);

      Iterable<IdentifiedArchiveModel> identifiedArchives =
          graphContext.service(IdentifiedArchiveModel.class).findAll();
      Assume.assumeTrue(identifiedArchives.iterator().hasNext());

      // Were the pom.xml's created?
      final Path baseMavenDir = outputDir.resolve("mavenized/jee-example-app");

      Path resultRootPomPath = baseMavenDir.resolve("pom.xml");
      Assert.assertTrue("Exists: " + resultRootPomPath, resultRootPomPath.toFile().exists());

      checkPomExistence(baseMavenDir, "jee-example-app-bom", true);
      checkPomExistence(baseMavenDir, "jee-example-services-jar", true);
      checkPomExistence(baseMavenDir, "jee-example-services", false);
      checkPomExistence(baseMavenDir, "log4j", false);
      checkPomExistence(baseMavenDir, "log4j-jar", false);
      checkPomExistence(baseMavenDir, "unparsable-jar", false);

      // TODO: Load the POM tree with Maven?
      // ProjectBuilder pb = new DefaultProjectBuilder();
      // pb.build(new ArrayList<File>(){{add(outputDir.toFile());}}, true, new
      // DefaultProjectBuildingRequest());
    }
  }
  protected void runTestAGL(GLProfile glprofile) throws InterruptedException {
    GLData gldata = new GLData();
    gldata.doubleBuffer = true;
    // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
    // at the wrong times (we use glClear for this instead)
    final GLCanvas glcanvas = new GLCanvas(composite, SWT.NO_BACKGROUND, gldata);
    Assert.assertNotNull(glcanvas);
    glcanvas.setCurrent();
    final GLContext glcontext = GLDrawableFactory.getFactory(glprofile).createExternalGLContext();
    Assert.assertNotNull(glcontext);

    // fix the viewport when the user resizes the window
    glcanvas.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event event) {
            Rectangle rectangle = glcanvas.getClientArea();
            glcanvas.setCurrent();
            glcontext.makeCurrent();
            GL2ES1 gl = glcontext.getGL().getGL2ES1();
            OneTriangle.setup(gl, rectangle.width, rectangle.height);
            glcontext.release();
            System.err.println("resize");
          }
        });

    // draw the triangle when the OS tells us that any part of the window needs drawing
    glcanvas.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent paintevent) {
            Rectangle rectangle = glcanvas.getClientArea();
            glcanvas.setCurrent();
            glcontext.makeCurrent();
            GL2ES1 gl = glcontext.getGL().getGL2ES1();
            OneTriangle.render(gl, rectangle.width, rectangle.height);
            glcanvas.swapBuffers();
            glcontext.release();
            System.err.println("paint");
          }
        });

    shell.setText(getClass().getName());
    shell.setSize(640, 480);
    shell.open();

    long lStartTime = System.currentTimeMillis();
    long lEndTime = lStartTime + duration;
    try {
      while ((System.currentTimeMillis() < lEndTime) && !glcanvas.isDisposed()) {
        if (!display.readAndDispatch()) {
          // blocks on linux .. display.sleep();
          Thread.sleep(10);
        }
      }
    } catch (Throwable throwable) {
      throwable.printStackTrace();
      Assume.assumeNoException(throwable);
    }
    glcanvas.dispose();
  }
 @Test
 @InSequence(JMS_RANDOM)
 public void testJmsRemoteApiHumanTaskGroupId() throws Exception {
   Assume.assumeTrue(jmsQueuesAvailable());
   printTestName();
   jmsTests.remoteApiHumanTaskGroupIdTest(deploymentUrl);
 }
  /**
   * Runs the console installer against a script with an alternative uninstaller name and path,
   * verifying that the correct uninstall JAR and registry value are created.
   *
   * @throws Exception for any error
   */
  @Test
  @InstallFile("samples/windows/consoleinstall_alt_uninstall.xml")
  public void testNonDefaultUninstaller() throws Exception {
    Assume.assumeTrue(
        "This test must be run as administrator, or with Windows UAC turned off",
        !skipTests && isAdminUser);

    assertFalse(registryKeyExists(handler, DEFAULT_UNINSTALL_KEY));

    TestConsole console = installer.getConsole();
    console.addScript("CheckedHelloPanel", "1");
    console.addScript("InfoPanel", "1");
    console.addScript("TargetPanel", "\n", "O", "1");

    // run installer and check that default uninstaller doesn't exist
    InstallData installData = getInstallData();
    checkInstall(installer, installData, false);

    // check that uninstaller exists as specified in install spec
    String installPath = installData.getInstallPath();
    assertTrue(new File(installPath, "/uninstallme.jar").exists());

    // check that the registry key has the correct value
    assertTrue(registryKeyExists(handler, DEFAULT_UNINSTALL_KEY));
    String command =
        "\""
            + installData.getVariable("JAVA_HOME")
            + "\\bin\\javaw.exe\" -jar \""
            + installPath
            + "\\uninstallme.jar\"";
    registryValueStringEquals(handler, DEFAULT_UNINSTALL_KEY, UNINSTALL_CMD_VALUE, command);
  }
 @Test
 @InSequence(JMS_RANDOM)
 public void testJmsRemoteApiStartProcessInstanceInitiator() throws Exception {
   Assume.assumeTrue(jmsQueuesAvailable());
   printTestName();
   jmsTests.remoteApiInitiatorIdentityTest(MARY_USER, MARY_PASSWORD);
 }
  @Test
  public void correlationKeyTest() throws Exception {
    Assume.assumeFalse(getType().equals(TestType.YAML));

    JaxbCorrelationKey corrKey = new JaxbCorrelationKey();
    corrKey.setName("anton");
    List<JaxbCorrelationProperty> properties = new ArrayList<JaxbCorrelationProperty>(3);
    corrKey.setJaxbProperties(properties);
    properties.add(new JaxbCorrelationProperty("name", "value"));
    properties.add(new JaxbCorrelationProperty("only-a-value"));
    properties.add(new JaxbCorrelationProperty("ngalan", "bili"));

    JaxbCorrelationKey copyCorrKey = testRoundTrip(corrKey);

    assertEquals("name", corrKey.getName(), copyCorrKey.getName());
    assertEquals(
        "prop list size", corrKey.getProperties().size(), copyCorrKey.getProperties().size());
    List<CorrelationProperty<?>> propList = corrKey.getProperties();
    List<CorrelationProperty<?>> copyPropList = copyCorrKey.getProperties();
    for (int i = 0; i < propList.size(); ++i) {
      CorrelationProperty<?> prop = propList.get(i);
      CorrelationProperty<?> copyProp = copyPropList.get(i);
      assertEquals(i + ": name", prop.getName(), copyProp.getName());
      assertEquals(i + ": type", prop.getType(), copyProp.getType());
      assertEquals(i + ": value", prop.getValue(), copyProp.getValue());
    }
  }
  @Test
  public void jaxbClassesTest() throws Exception {
    Assume.assumeTrue(TestType.JAXB.equals(getType()));

    Set<Class<?>> jaxbClasses = reflections.getTypesAnnotatedWith(XmlRootElement.class);

    assertTrue("Not enough classes found! [" + jaxbClasses.size() + "]", jaxbClasses.size() > 20);

    String className = null;
    try {
      for (Class<?> jaxbClass : jaxbClasses) {
        if (jaxbClass.getDeclaringClass() != null
            && jaxbClass.getDeclaringClass().getSimpleName().endsWith("Test")) {
          continue;
        }
        className = jaxbClass.getName();
        Constructor<?> construct = jaxbClass.getConstructor(new Class[] {});
        Object jaxbInst = construct.newInstance(new Object[] {});
        testRoundTrip(jaxbInst);
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(className + ": " + e.getClass().getSimpleName() + " [" + e.getMessage() + "]");
    }
  }
Example #19
0
  /** End-to-end installation test. */
  private void doTestAutoInstallation(String id, String fullversion) throws Exception {
    Assume.assumeTrue(
        "this is a really time consuming test, so only run it when we really want",
        Boolean.getBoolean("jenkins.testJDKInstaller"));

    retrieveUpdateCenterData();

    JDKInstaller installer = new JDKInstaller(id, true);

    JDK jdk =
        new JDK(
            "test",
            tmp.getRoot().getAbsolutePath(),
            Arrays.asList(new InstallSourceProperty(Arrays.<ToolInstaller>asList(installer))));

    j.jenkins.getJDKs().add(jdk);

    FreeStyleProject p = j.createFreeStyleProject();
    p.setJDK(jdk);
    p.getBuildersList().add(new Shell("java -fullversion\necho $JAVA_HOME"));
    FreeStyleBuild b = j.buildAndAssertSuccess(p);
    @SuppressWarnings("deprecation")
    String log = b.getLog();
    System.out.println(log);
    // make sure it runs with the JDK that just got installed
    assertTrue(log.contains(fullversion));
    assertTrue(log.contains(tmp.getRoot().getAbsolutePath()));
  }
Example #20
0
 @Test
 public void deleteFile() throws Exception {
   Assume.assumeTrue(Functions.isWindows());
   Class<?> c;
   try {
     c = Class.forName("java.nio.file.FileSystemException");
   } catch (ClassNotFoundException x) {
     throw new AssumptionViolatedException("prior to JDK 7", x);
   }
   File d = Util.createTempDir();
   try {
     File f = new File(d, "f");
     OutputStream os = new FileOutputStream(f);
     try {
       Util.deleteFile(f);
       fail("should not have been deletable");
     } catch (IOException x) {
       assertEquals(c, x.getClass());
     } finally {
       os.close();
     }
   } finally {
     Util.deleteRecursive(d);
   }
 }
Example #21
0
  @Test
  public void testIsSymlink() throws IOException, InterruptedException {
    Assume.assumeTrue(!Functions.isWindows());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    StreamTaskListener l = new StreamTaskListener(baos);
    File d = Util.createTempDir();
    try {
      new FilePath(new File(d, "original")).touch(0);
      assertFalse(Util.isSymlink(new File(d, "original")));
      Util.createSymlink(d, "original", "link", l);

      assertTrue(Util.isSymlink(new File(d, "link")));

      // test linking to another directory
      File dir = new File(d, "dir");
      assertTrue("Couldn't create " + dir, dir.mkdir());
      assertFalse(Util.isSymlink(new File(d, "dir")));

      File anotherDir = new File(d, "anotherDir");
      assertTrue("Couldn't create " + anotherDir, anotherDir.mkdir());

      Util.createSymlink(d, "dir", "anotherDir/symlinkDir", l);
      // JENKINS-12331: either a bug in createSymlink or this isn't supposed to work:
      // assertTrue(Util.isSymlink(new File(d,"anotherDir/symlinkDir")));
    } finally {
      Util.deleteRecursive(d);
    }
  }
  /**
   * Generate random data, compress it, index and md5 hash the data. Then read it all back and md5
   * that too, to verify that it all went ok.
   *
   * @param testWithIndex Should we index or not?
   * @param charsToOutput How many characters of random data should we output.
   * @throws IOException
   * @throws NoSuchAlgorithmException
   * @throws InterruptedException
   */
  private void runTest(boolean testWithIndex, int charsToOutput)
      throws IOException, NoSuchAlgorithmException, InterruptedException {

    Configuration conf = new Configuration();
    conf.setLong("fs.local.block.size", charsToOutput / 2);
    // reducing block size to force a split of the tiny file
    conf.set("io.compression.codecs", LzopCodec.class.getName());

    Assume.assumeTrue(CoreTestUtil.okToRunLzoTests(conf));

    FileSystem.getLocal(conf).close(); // remove cached filesystem (if any)
    FileSystem localFs = FileSystem.getLocal(conf);
    localFs.delete(outputDir_, true);
    localFs.mkdirs(outputDir_);

    Job job = new Job(conf);
    TextOutputFormat.setCompressOutput(job, true);
    TextOutputFormat.setOutputCompressorClass(job, LzopCodec.class);
    TextOutputFormat.setOutputPath(job, outputDir_);

    TaskAttemptContext attemptContext =
        new TaskAttemptContext(job.getConfiguration(), new TaskAttemptID("123", 0, false, 1, 2));

    // create some input data
    byte[] expectedMd5 = createTestInput(outputDir_, localFs, attemptContext, charsToOutput);

    if (testWithIndex) {
      Path lzoFile = new Path(outputDir_, lzoFileName_);
      LzoIndex.createIndex(localFs, lzoFile);
    }

    LzoTextInputFormat inputFormat = new LzoTextInputFormat();
    TextInputFormat.setInputPaths(job, outputDir_);

    List<InputSplit> is = inputFormat.getSplits(job);
    // verify we have the right number of lzo chunks
    if (testWithIndex && OUTPUT_BIG == charsToOutput) {
      assertEquals(3, is.size());
    } else {
      assertEquals(1, is.size());
    }

    // let's read it all and calculate the md5 hash
    for (InputSplit inputSplit : is) {
      RecordReader<LongWritable, Text> rr =
          inputFormat.createRecordReader(inputSplit, attemptContext);
      rr.initialize(inputSplit, attemptContext);

      while (rr.nextKeyValue()) {
        Text value = rr.getCurrentValue();

        md5_.update(value.getBytes(), 0, value.getLength());
      }

      rr.close();
    }

    localFs.close();
    assertTrue(Arrays.equals(expectedMd5, md5_.digest()));
  }
 @Test
 @InSequence(JMS_SUCCEEDING)
 public void testJmsRemoteApiHistoryVariables() throws Exception {
   Assume.assumeTrue(jmsQueuesAvailable());
   printTestName();
   jmsTests.remoteApiHistoryVariablesTest(deploymentUrl);
 }
  @Test
  public void test_findAbstractionWithoutDecoupling() throws Exception {

    Assume.assumeTrue(cache.ensuresReferentialIntegrity());

    String AWD =
        "motif awd\n"
            + "select client, service, service_impl\n"
            + "where \"client.getProperty('artifacttype')=='type'\" and \"service.getProperty('artifacttype')=='type'\" and \"service_impl.getProperty('artifacttype')=='type'\"\n"
            + "and \"!client.getProperty('abstract')\" and \"service.getProperty('abstract')\" and \"!service_impl.getProperty('abstract')\"\n"
            + "connected by inherits(service_impl>service) and service_invocation(client>service)[1,1] and implementation_dependency(client>service_impl)\n"
            + "where \"inherits.getProperty('type')=='extends' || inherits.getProperty('type')=='implements'\" and \"service_invocation.getProperty('type')=='uses'\" and \"implementation_dependency.getProperty('type')=='uses'\"\n"
            + "group by \"client\" and \"service\"";

    List<MotifInstance<Vertex, Edge>> results = Utilities.query(getBlueprintsAdapter(), AWD);

    System.out.println(" ################ RESULT: ############");
    System.out.println("   SIZE: " + results.size());
    for (MotifInstance<Vertex, Edge> motifInstance : results) {
      System.out.println("  * INSTANCE: " + motifInstance);
      Vertex client = motifInstance.getVertex("client");
      System.out.println("    client : " + client);
      System.out.println("    service: " + motifInstance.getVertex("service"));
      System.out.println("    service_impl: " + motifInstance.getVertex("service_impl"));

      dumpPath(motifInstance, "inherits");
      dumpPath(motifInstance, "service_invocation");
      dumpPath(motifInstance, "implementation_dependency");
    }

    assertEquals(1, results.size());
  }
 @Test
 @InSequence(JMS_ERROR)
 public void testJmsRemoteApiGroupAssignmentEngineering() throws Exception {
   Assume.assumeTrue(jmsQueuesAvailable());
   printTestName();
   jmsTests.remoteApiGroupAssignmentEngineeringTest(deploymentUrl);
 }
  private Path executeWindupAgainstAppUntilRule(
      final String inputDir,
      final GraphContext grCtx,
      final Class<MavenizeRuleProvider> ruleToRunUpTo)
      throws IOException, IllegalAccessException, InstantiationException {
    Assume.assumeTrue("Exists: " + inputDir, new File(inputDir).exists());

    final Path outputPath =
        Paths.get(FileUtils.getTempDirectory().toString(), "Windup-Mavenization-output");
    FileUtils.deleteDirectory(outputPath.toFile());
    Files.createDirectories(outputPath);

    grCtx.getGraph().getBaseGraph().commit();

    // Configure Windup core
    final WindupConfiguration processorConfig = new WindupConfiguration();
    processorConfig.setRuleProviderFilter(new RuleProviderWithDependenciesPredicate(ruleToRunUpTo));
    processorConfig.setGraphContext(grCtx);
    processorConfig.addInputPath(Paths.get(inputDir));
    processorConfig.setOutputDirectory(outputPath);
    processorConfig.setOptionValue(ScanPackagesOption.NAME, Collections.singletonList(""));
    processorConfig.setOptionValue(SourceModeOption.NAME, false);
    processorConfig.setOptionValue(MavenizeOption.NAME, true);

    processor.execute(processorConfig);

    return outputPath;
  }
  @Test
  public void nodeInstanceLogTest() throws Exception {
    Assume.assumeFalse(getType().equals(TestType.YAML));

    int type = 0;
    long processInstanceId = 23;
    String processId = "org.hospital.doctor.review";
    String nodeInstanceId = "1-1";
    String nodeId = "1";
    String nodeName = "notification";

    org.jbpm.process.audit.NodeInstanceLog origLog =
        new org.jbpm.process.audit.NodeInstanceLog(
            type, processInstanceId,
            processId, nodeInstanceId,
            nodeId, nodeName);

    origLog.setWorkItemId(78l);
    origLog.setConnection("link");
    origLog.setExternalId("not-internal-num");
    origLog.setNodeType("the-sort-of-point");

    JaxbNodeInstanceLog xmlLog = new JaxbNodeInstanceLog(origLog);
    xmlLog.setCommandName("test-cmd");
    xmlLog.setIndex(2);
    xmlLog.setId(2l);
    JaxbNodeInstanceLog newXmlLog = testRoundTrip(xmlLog);
    ComparePair.compareOrig(xmlLog, newXmlLog, JaxbNodeInstanceLog.class);

    NodeInstanceLog newLog = newXmlLog.getResult();
    ComparePair.compareOrig(origLog, newLog, NodeInstanceLog.class);
  }
  /**
   * Runs the console installer twice, verifying that a second uninstall key is created.
   *
   * @throws Exception for any error
   */
  @Test
  @InstallFile("samples/windows/install.xml")
  public void testRejectMultipleInstallation() throws Exception {
    Assume.assumeTrue(
        "This test must be run as administrator, or with Windows UAC turned off",
        !skipTests && isAdminUser);

    checkInstall(container, APP_NAME);

    removeLock();

    ConsoleInstallerContainer container2 = new TestConsoleInstallerContainer();
    TestConsoleInstaller installer2 = container2.getComponent(TestConsoleInstaller.class);
    RegistryDefaultHandler handler2 = container2.getComponent(RegistryDefaultHandler.class);
    InstallData installData2 = container2.getComponent(InstallData.class);

    TestConsole console2 = installer2.getConsole();
    console2.addScript("CheckedHelloPanel", "n");

    assertFalse(registryKeyExists(handler2, UNINSTALL_KEY2));
    installer2.run(Installer.CONSOLE_INSTALL, null, new String[0]);

    // verify the installation thinks it was unsuccessful
    assertFalse(installData2.isInstallSuccess());

    // make sure the script has completed
    TestConsole console = installer2.getConsole();
    assertTrue("Script still running panel: " + console.getScriptName(), console.scriptCompleted());

    // verify the second registry key hasn't been created
    assertFalse(registryKeyExists(handler2, UNINSTALL_KEY2));
  }
Example #29
0
  /** Fake installation on Unix. */
  @Test
  public void fakeUnixInstall() throws Exception {
    Assume.assumeFalse("If we're on Windows, don't bother doing this", Functions.isWindows());

    File bundle = File.createTempFile("fake-jdk-by-hudson", "sh");
    try {
      new FilePath(bundle)
          .write(
              "#!/bin/bash -ex\n"
                  + "mkdir -p jdk1.6.0_dummy/bin\n"
                  + "touch jdk1.6.0_dummy/bin/java",
              "ASCII");
      TaskListener l = StreamTaskListener.fromStdout();

      new JDKInstaller("", true)
          .install(
              new LocalLauncher(l),
              Platform.LINUX,
              new JDKInstaller.FilePathFileSystem(j.jenkins),
              l,
              tmp.getRoot().getPath(),
              bundle.getPath());

      assertTrue(new File(tmp.getRoot(), "bin/java").exists());
    } finally {
      bundle.delete();
    }
  }
  @Test
  public void variableInstanceLogTest() throws Exception {
    Assume.assumeFalse(getType().equals(TestType.YAML));

    long processInstanceId = 23;
    String processId = "org.hospital.intern.rounds";
    String variableInstanceId = "patientNum-1";
    String variableId = "patientNum";
    String value = "33";
    String oldValue = "32";

    org.jbpm.process.audit.VariableInstanceLog origLog =
        new org.jbpm.process.audit.VariableInstanceLog(
            processInstanceId, processId, variableInstanceId, variableId, value, oldValue);

    origLog.setExternalId("outside-identity-representation");
    origLog.setOldValue("previous-data-that-this-variable-contains");
    origLog.setValue("the-new-data-that-has-been-put-in-this-variable");
    origLog.setVariableId("shortend-representation-of-this-representation");
    origLog.setVariableInstanceId("id-instance-variable");

    JaxbVariableInstanceLog xmlLog = new JaxbVariableInstanceLog(origLog);
    xmlLog.setCommandName("test-cmd");
    xmlLog.setIndex(2);
    JaxbVariableInstanceLog newXmlLog = testRoundTrip(xmlLog);
    ComparePair.compareObjectsViaFields(xmlLog, newXmlLog, "id");

    VariableInstanceLog newLog = newXmlLog.getResult();
    ComparePair.compareOrig(origLog, newLog, VariableInstanceLog.class);
  }