Java Code Examples for org.junit.Assume

The following examples show how to use org.junit.Assume. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void testListImgFiles() throws IOException {
	Assume.assumeTrue(SysUtils.isLinux());
	
	int nrOfFiles1 = 0, nrOfFiles2 = 0;
	final String path = "/mnt/transkribus/user_storage/[email protected]/AAK_scans_scaled";
	SSW sw = new SSW();
	
	sw.start();
	new File(path).list();
	nrOfFiles1 = LocalDocReader.findImgFiles(new File(path)).size();
	sw.stop();

	sw.start();
	new File(path).list();
	nrOfFiles2 = LocalDocReader.findImgFilenames(new File(path)).size();
	sw.stop();
	
	Assert.assertEquals(nrOfFiles1, nrOfFiles2);
}
 
Example 2
Source Project: syndesis   Source File: ConnectorsITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Ignore
public void verifyBadTwitterConnectionSettings() throws IOException {

    // AlwaysOkVerifier never fails.. do don't try this test case, if that's
    // whats being used.
    Assume.assumeFalse(verifier instanceof AlwaysOkVerifier);

    final Properties credentials = new Properties();
    try (InputStream is = getClass().getResourceAsStream("/valid-twitter-keys.properties")) {
        credentials.load(is);
    }
    credentials.put("accessTokenSecret", "badtoken");

    final ResponseEntity<Verifier.Result> response = post("/api/v1/connectors/twitter/verifier/connectivity", credentials,
        Verifier.Result.class);
    assertThat(response.getStatusCode()).as("component list status code").isEqualTo(HttpStatus.OK);
    final Verifier.Result result = response.getBody();
    assertThat(result).isNotNull();
    assertThat(result.getStatus()).isEqualTo(Verifier.Result.Status.ERROR);
    assertThat(result.getErrors()).isNotEmpty();
}
 
Example 3
Source Project: stocator   Source File: ObjectStoreFileSystemTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void existsTest() throws Exception {
  Assume.assumeNotNull(getFs());
  Path testFile = new Path(getBaseURI() + "/testFile");
  getFs().delete(testFile, false);
  Assert.assertFalse(getFs().exists(testFile));

  createFile(testFile, data);
  Assert.assertTrue(getFs().exists(testFile));

  Path input = new Path(getBaseURI() + "/a/b/c/m.data/_temporary/"
          + "0/_temporary/attempt_201603141928_0000_m_000099_102/part-00099");
  Whitebox.setInternalState(mMockObjectStoreFileSystem, "hostNameScheme", getBaseURI());
  String result = Whitebox.invokeMethod(mMockStocatorPath, "parseHadoopFOutputCommitterV1", input,
      true, getBaseURI());
  Path modifiedInput = new Path(getBaseURI() + result);
  getFs().delete(input, false);
  Assert.assertFalse(getFs().exists(input));

  createFile(input, data);
  Assert.assertFalse(getFs().exists(input));
  Assert.assertTrue(getFs().exists(modifiedInput));
}
 
Example 4
Source Project: htmlunit   Source File: HtmlObjectTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception if the test fails
 */
@Test
public void cacheArchive() throws Exception {
    Assume.assumeFalse(SKIP_);

    if (getBrowserVersion().isChrome()) {
        return;
    }

    final URL url = getClass().getResource("/objects/cacheArchiveApplet.html");

    final HtmlPage page = getWebClient().getPage(url);
    final HtmlObject objectNode = page.getHtmlElementById("myApp");

    assertEquals("net.sourceforge.htmlunit.testapplets.EmptyApplet", objectNode.getApplet().getClass().getName());
}
 
Example 5
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(31)
public void testOptionalBaseMetrics() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);

    for (MiniMeta item : names.values()) {
        if (elements.containsKey(item.toJSONName()) && names.get(item.name).optional) {
            String prefix = names.get(item.name).name;
            String type = "'"+item.toJSONName()+"'"+".type";
            String unit= "'"+item.toJSONName()+"'"+".unit";

            given().header(wantJson).options("/metrics/base/"+prefix).then().statusCode(200)
            .body(type, equalTo(names.get(item.name).type))
            .body(unit, equalTo(names.get(item.name).unit));
        }
    }

}
 
Example 6
Source Project: hadoop   Source File: TestCryptoCodec.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout=120000)
public void testJceAesCtrCryptoCodec() throws Exception {
  if (!"true".equalsIgnoreCase(System.getProperty("runningWithNative"))) {
    LOG.warn("Skipping since test was not run with -Pnative flag");
    Assume.assumeTrue(false);
  }
  if (!NativeCodeLoader.buildSupportsOpenssl()) {
    LOG.warn("Skipping test since openSSL library not loaded");
    Assume.assumeTrue(false);
  }
  Assert.assertEquals(null, OpensslCipher.getLoadingFailureReason());
  cryptoCodecTest(conf, seed, 0, jceCodecClass, jceCodecClass, iv);
  cryptoCodecTest(conf, seed, count, jceCodecClass, jceCodecClass, iv);
  cryptoCodecTest(conf, seed, count, jceCodecClass, opensslCodecClass, iv);
  // Overflow test, IV: xx xx xx xx xx xx xx xx ff ff ff ff ff ff ff ff 
  for(int i = 0; i < 8; i++) {
    iv[8 + i] = (byte) 0xff;
  }
  cryptoCodecTest(conf, seed, count, jceCodecClass, jceCodecClass, iv);
  cryptoCodecTest(conf, seed, count, jceCodecClass, opensslCodecClass, iv);
}
 
Example 7
Source Project: hadoop   Source File: TestLinuxContainerExecutor.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testContainerLaunch() throws Exception {
  Assume.assumeTrue(shouldRun());
  String expectedRunAsUser =
      conf.get(YarnConfiguration.NM_NONSECURE_MODE_LOCAL_USER_KEY,
        YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);

  File touchFile = new File(workSpace, "touch-file");
  int ret = runAndBlock("touch", touchFile.getAbsolutePath());

  assertEquals(0, ret);
  FileStatus fileStatus =
      FileContext.getLocalFSFileContext().getFileStatus(
        new Path(touchFile.getAbsolutePath()));
  assertEquals(expectedRunAsUser, fileStatus.getOwner());
  cleanupAppFiles(expectedRunAsUser);

}
 
Example 8
Source Project: hadoop   Source File: TestOpensslCipher.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout=120000)
public void testDoFinalArguments() throws Exception {
  Assume.assumeTrue(OpensslCipher.getLoadingFailureReason() == null);
  OpensslCipher cipher = OpensslCipher.getInstance("AES/CTR/NoPadding");
  Assert.assertTrue(cipher != null);
  
  cipher.init(OpensslCipher.ENCRYPT_MODE, key, iv);
  
  // Require direct buffer
  ByteBuffer output = ByteBuffer.allocate(1024);
  
  try {
    cipher.doFinal(output);
    Assert.fail("Output buffer should be direct buffer.");
  } catch (IllegalArgumentException e) {
    GenericTestUtils.assertExceptionContains(
        "Direct buffer is required", e);
  }
}
 
Example 9
Source Project: dremio-oss   Source File: TestClassCompilers.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void compileDependencyClass() throws IOException, ClassNotFoundException {
  JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
  Assume.assumeNotNull(javaCompiler);

  classes = temporaryFolder.newFolder("classes");;

  StandardJavaFileManager fileManager = javaCompiler.getStandardFileManager(null, Locale.ROOT, UTF_8);
  fileManager.setLocation(StandardLocation.CLASS_OUTPUT, ImmutableList.of(classes));

  SimpleJavaFileObject compilationUnit = new SimpleJavaFileObject(URI.create("FooTest.java"), Kind.SOURCE) {
    String fooTestSource = Resources.toString(Resources.getResource("com/dremio/exec/compile/FooTest.java"), UTF_8);
    @Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
      return fooTestSource;
    }
  };

  CompilationTask task = javaCompiler.getTask(null, fileManager, null, Collections.<String>emptyList(), null, ImmutableList.of(compilationUnit));
  assertTrue(task.call());
}
 
Example 10
@Test
public void testJdbcBasicFunction() throws Exception {
    Assume.assumeTrue(jdbcConnectable);
    Connection conn = null;
    Statement statement = null;
    String createTableSql = "CREATE TABLE test(col1 VARCHAR (10), col2 INTEGER )";
    String dropTableSql = "DROP TABLE IF EXISTS test";
    try {
        conn = connectionManager.getConn();
        statement = conn.createStatement();
        statement.executeUpdate(dropTableSql);
        statement.executeUpdate(createTableSql);
        statement.executeUpdate(dropTableSql);
    } finally {
        JDBCConnectionManager.closeQuietly(statement);
        JDBCConnectionManager.closeQuietly(conn);
    }
}
 
Example 11
Source Project: datawave   Source File: StatsJobTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testParseArguments() throws Exception {
    Assume.assumeTrue(null != System.getenv("DATAWAVE_INGEST_HOME"));
    log.info("======  testParseArguments  =====");
    Map<String,Object> mapArgs = new HashMap<>();
    
    // mapper options
    mapArgs.put(StatsHyperLogMapper.STATS_MAPPER_INPUT_INTERVAL, 4);
    mapArgs.put(StatsHyperLogMapper.STATS_MAPPER_OUTPUT_INTERVAL, 8);
    mapArgs.put(StatsHyperLogMapper.STATS_MAPPER_LOG_LEVEL, "map-log");
    
    // reducer options
    mapArgs.put(StatsHyperLogReducer.STATS_REDUCER_VALUE_INTERVAL, 6);
    mapArgs.put(StatsHyperLogReducer.STATS_MIN_COUNT, 1);
    mapArgs.put(StatsHyperLogReducer.STATS_REDUCER_COUNTS, Boolean.FALSE);
    mapArgs.put(StatsHyperLogReducer.STATS_REDUCER_LOG_LEVEL, "red-log");
    
    String[] args = new String[mapArgs.size()];
    int n = 0;
    for (Map.Entry<String,Object> entry : mapArgs.entrySet()) {
        args[n++] = "-" + entry.getKey() + "=" + entry.getValue();
    }
    args = addRequiredSettings(args);
    
    wrapper.parseArguments(args, mapArgs);
}
 
Example 12
Source Project: stocator   Source File: ObjectStoreFileSystemTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void deleteTest() throws Exception {
  Assume.assumeNotNull(getFs());

  Path testFile = new Path(getBaseURI() + "/testFile");
  createFile(testFile, data);
  Path input = new Path(getBaseURI() + "/a/b/c/m.data/_temporary/"
          + "0/_temporary/attempt_201603141928_0000_m_000099_102/part-00099");
  Whitebox.setInternalState(mMockObjectStoreFileSystem, "hostNameScheme", getBaseURI());
  String result = Whitebox.invokeMethod(mMockStocatorPath, "parseHadoopFOutputCommitterV1", input,
      true, getBaseURI());
  Path modifiedInput = new Path(getBaseURI() + result);
  createFile(input, data);
  Assert.assertTrue(getFs().exists(modifiedInput));
  Assert.assertTrue(getFs().exists(testFile));

  getFs().delete(testFile, false);
  Assert.assertFalse(getFs().exists(testFile));

  getFs().delete(modifiedInput, false);
  Assert.assertFalse(getFs().exists(modifiedInput));
}
 
Example 13
Source Project: ditto   Source File: MongoDbResource.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void before() {
    final Optional<String> proxyUppercase = Optional.ofNullable(System.getenv(HTTP_PROXY_ENV_KEY));
    final Optional<String> proxyLowercase = Optional.ofNullable(System.getenv(HTTP_PROXY_ENV_KEY.toLowerCase()));
    final Optional<String> httpProxy = proxyUppercase.isPresent() ? proxyUppercase : proxyLowercase;
    final IProxyFactory proxyFactory = httpProxy
            .map(URI::create)
            .map(proxyURI -> (IProxyFactory) new HttpProxyFactory(proxyURI.getHost(), proxyURI.getPort()))
            .orElse(new NoProxyFactory());

    final int mongoDbPort = defaultPort != null
            ? defaultPort
            : System.getenv(MONGO_PORT_ENV_KEY) != null
            ? Integer.parseInt(System.getenv(MONGO_PORT_ENV_KEY))
            : findFreePort();

    mongodExecutable = tryToConfigureMongoDb(bindIp, mongoDbPort, proxyFactory, logger);
    mongodProcess = tryToStartMongoDb(mongodExecutable);
    Assume.assumeTrue("MongoDB resource failed to start.", isHealthy());
}
 
Example 14
Source Project: hadoop   Source File: TestSharedFileDescriptorFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout=10000)
public void testCleanupRemainders() throws Exception {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  File path = new File(TEST_BASE, "testCleanupRemainders");
  path.mkdirs();
  String remainder1 = path.getAbsolutePath() + 
      Path.SEPARATOR + "woot2_remainder1";
  String remainder2 = path.getAbsolutePath() +
      Path.SEPARATOR + "woot2_remainder2";
  createTempFile(remainder1);
  createTempFile(remainder2);
  SharedFileDescriptorFactory.create("woot2_", 
      new String[] { path.getAbsolutePath() });
  // creating the SharedFileDescriptorFactory should have removed 
  // the remainders
  Assert.assertFalse(new File(remainder1).exists());
  Assert.assertFalse(new File(remainder2).exists());
  FileUtil.fullyDelete(path);
}
 
Example 15
Source Project: orion.server   Source File: GitCloneTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testCloneOverSshWithPassphraseProtectedKey() throws Exception {
	Assume.assumeTrue(sshRepo2 != null);
	Assume.assumeTrue(privateKey != null);
	Assume.assumeTrue(passphrase != null);

	createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
	String workspaceId = workspaceIdFromLocation(workspaceLocation);
	JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null);
	IPath clonePath = getClonePath(workspaceId, project);
	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));
}
 
Example 16
@Test
public void noNamespacePrefixes() throws Exception {
	Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible());

	StringWriter stringWriter = new StringWriter();
	AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter));
	xmlReader.setContentHandler(handler);
	xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);

	xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
	xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);

	xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML)));

	assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML).withNodeFilter(nodeFilter));
}
 
Example 17
Source Project: netbeans   Source File: JavaScriptEnginesTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void preventLoadAClassInJS() throws Exception {
    Assume.assumeFalse("All access has to be disabled", allowAllAccess);
    Object fn = engine.eval("(function(obj) {\n"
            + "  var Long = Java.type('java.lang.Long');\n"
            + "  return new Long(33);\n"
            + "})\n");
    assertNotNull(fn);

    Object value;
    try {
        value = ((Invocable) engine).invokeMethod(fn, "call", null, null);
    } catch (ScriptException | RuntimeException ex) {
        return;
    }
    fail("Access to Java.type classes shall be prevented: " + value);
}
 
Example 18
Source Project: flink   Source File: PageRankITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintWithRMatGraph() throws Exception {
	// skip 'char' since it is not printed as a number
	Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar"));

	expectedCount(parameters(8, "print"), 233);
}
 
Example 19
protected void setJavaVersion(JavaVersion javaVersion) throws Exception {
	IJavaProject javaProject = JavaProjectSetupUtil.findJavaProject(WorkbenchTestHelper.TESTPROJECT_NAME);
	Pair<String,Boolean> result = WorkbenchTestHelper.changeBree(javaProject, javaVersion);
	IExecutionEnvironment execEnv = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(result.getKey());
	Assume.assumeNotNull("Execution environment not found for: " + javaVersion.getLabel(), execEnv);
	Assume.assumeTrue("No compatible VM was found for: " + javaVersion.getLabel(),
			execEnv.getCompatibleVMs().length > 0);
	if(result.getValue()) {
		WorkbenchTestHelper.makeCompliantFor(javaProject, javaVersion);
		IResourcesSetupUtil.reallyWaitForAutoBuild();
	}
}
 
Example 20
@Test
public void testAndroidNoTransformation() throws Exception {
   Assume.assumeTrue(testName == TestName.AndroidNoTransformation);
   Map<String, Object> attributes = getAttributesForRequest(MobileDeviceCapability.ATTR_APPVERSION, MobileDeviceCapability.ATTR_NAME);
   assertEquals(attributes.get(MobileDeviceCapability.ATTR_NAME), TestMobileDeviceGetAttributesHandler.MY_ANDROID);
   assertEquals(attributes.get(MobileDeviceCapability.ATTR_APPVERSION), TestMobileDeviceGetAttributesHandler.SOME_VERSION);
}
 
Example 21
Source Project: htmlunit   Source File: CanvasRenderingContext2D2Test.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("data:image/png;base64,"
        + "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR42mNgGAVDEvBQ07ASIH4"
        + "NxBzUMCwBiB8DsQa1XAcyzINahikA8XMgZqGWgSZQF+IDv0mN2c9ALIJDXgWIT5PqynYgng7EAl"
        + "A+KKZ1oOIg17uQaiALVPNrqAHfgfg2EC+GGkw24IBGEs9oHh+iAAAZGRFncAWu2AAAAABJRU5ErkJggg==")
public void arcStroke() throws Exception {
    Assume.assumeFalse(SKIP_);

    final String html = "<html><head>\n"
        + "<script>\n"
        + "  function test() {\n"
        + "    var canvas = document.getElementById('myCanvas');\n"
        + "    if (canvas.getContext) {\n"
        + "      var context = canvas.getContext('2d');\n"
        + "      context.arc(10, 10, 4, 0, 4.3);\n"
        + "      context.stroke();\n"
        + "      alert(canvas.toDataURL());\n"
        + "    }\n"
        + "  }\n"
        + "</script>\n"
        + "</head><body onload='test()'>\n"
        + "  <canvas id='myCanvas' width='20', height='20' style='border: 1px solid red;'></canvas>"
        + "</body></html>";

    loadPageWithAlerts(html);
}
 
Example 22
Source Project: iceberg   Source File: TestMetricsRowGroupFilter.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMissingStatsParquet() {
  Assume.assumeTrue(format == FileFormat.PARQUET);
  Expression[] exprs = new Expression[] {
      lessThan("no_stats_parquet", "a"), lessThanOrEqual("no_stats_parquet", "b"), equal("no_stats_parquet", "c"),
      greaterThan("no_stats_parquet", "d"), greaterThanOrEqual("no_stats_parquet", "e"),
      notEqual("no_stats_parquet", "f"), isNull("no_stats_parquet"), notNull("no_stats_parquet"),
      startsWith("no_stats_parquet", "a")
  };

  for (Expression expr : exprs) {
    boolean shouldRead = shouldRead(expr);
    Assert.assertTrue("Should read when missing stats for expr: " + expr, shouldRead);
  }
}
 
Example 23
Source Project: jcifs-ng   Source File: EnumTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testDomainSeverEnum () throws MalformedURLException, CIFSException {
    try ( SmbFile smbFile = new SmbFile("smb://" + getTestDomain(), withTestNTLMCredentials(getContext())) ) {
        String[] list = smbFile.list();
        assertNotNull(list);
        log.debug(Arrays.toString(list));
    }
    catch ( SmbUnsupportedOperationException e ) {
        Assume.assumeTrue(false);
    }
}
 
Example 24
@Test
public void testFileIndex () throws IOException {
    try ( SmbFile f = createTestFile() ) {
        try {
            long idx = f.fileIndex();
            Assume.assumeTrue("FileIndex unsupported", idx != 0);
        }
        finally {
            f.delete();
        }
    }
}
 
Example 25
Source Project: localization_nifi   Source File: TestEncryptContent.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldDecryptOpenSSLRawUnsalted() throws IOException {
    // Arrange
    Assume.assumeTrue("Test is being skipped due to this JVM lacking JCE Unlimited Strength Jurisdiction Policy file.",
            PasswordBasedEncryptor.supportsUnlimitedStrength());

    final TestRunner testRunner = TestRunners.newTestRunner(new EncryptContent());

    final String password = "thisIsABadPassword";
    final EncryptionMethod method = EncryptionMethod.MD5_256AES;
    final KeyDerivationFunction kdf = KeyDerivationFunction.OPENSSL_EVP_BYTES_TO_KEY;

    testRunner.setProperty(EncryptContent.PASSWORD, password);
    testRunner.setProperty(EncryptContent.KEY_DERIVATION_FUNCTION, kdf.name());
    testRunner.setProperty(EncryptContent.ENCRYPTION_ALGORITHM, method.name());
    testRunner.setProperty(EncryptContent.MODE, EncryptContent.DECRYPT_MODE);

    // Act
    testRunner.enqueue(Paths.get("src/test/resources/TestEncryptContent/unsalted_raw.enc"));
    testRunner.clearTransferState();
    testRunner.run();

    // Assert
    testRunner.assertAllFlowFilesTransferred(EncryptContent.REL_SUCCESS, 1);
    testRunner.assertQueueEmpty();

    MockFlowFile flowFile = testRunner.getFlowFilesForRelationship(EncryptContent.REL_SUCCESS).get(0);
    logger.info("Decrypted contents (hex): {}", Hex.encodeHexString(flowFile.toByteArray()));
    logger.info("Decrypted contents: {}", new String(flowFile.toByteArray(), "UTF-8"));

    // Assert
    flowFile.assertContentEquals(new File("src/test/resources/TestEncryptContent/plain.txt"));
}
 
Example 26
Source Project: Tomcat8-Source-Read   Source File: TestSSLHostConfigCompat.java    License: MIT License 5 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();

    AprLifecycleListener listener = new AprLifecycleListener();
    Assume.assumeTrue(AprLifecycleListener.isAprAvailable());
    Assume.assumeTrue(JreCompat.isJre8Available());

    Tomcat tomcat = getTomcatInstance();
    Connector connector = tomcat.getConnector();

    connector.setPort(0);
    connector.setScheme("https");
    connector.setSecure(true);
    connector.setProperty("SSLEnabled", "true");
    connector.setProperty("sslImplementationName", sslImplementationName);
    sslHostConfig.setProtocols("TLSv1.2");
    connector.addSslHostConfig(sslHostConfig);

    StandardServer server = (StandardServer) tomcat.getServer();
    server.addLifecycleListener(listener);

    // Simple webapp
    Context ctxt = tomcat.addContext("", null);
    Tomcat.addServlet(ctxt, "TesterServlet", new TesterServlet());
    ctxt.addServletMappingDecoded("/*", "TesterServlet");
}
 
Example 27
Source Project: htmlunit   Source File: CanvasRenderingContext2D2Test.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("data:image/png;base64,"
        + "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAaUlEQVR42mNgGPGABYhdgFiAmobeBu"
        + "L/UHo1EFdQaslkqIHYMMySElIMdMBjIDJWIcXQx0QYmEOKgdOJMHA/KQYGEOltGWIN5AHizUD8nICB"
        + "GeTEugzUxc1YLFlPrbQKs6RitCwYBVQAABQ1QYDFZuLyAAAAAElFTkSuQmCC")
public void transformFillRect() throws Exception {
    Assume.assumeFalse(SKIP_);

    final String html = "<html><head>\n"
        + "<script>\n"
        + "  function test() {\n"
        + "    var canvas = document.getElementById('myCanvas');\n"
        + "    if (canvas.getContext) {\n"
        + "      var context = canvas.getContext('2d');\n"
        + "      context.transform(1, .2, .3, 1, 0, 0);\n"
        + "      context.fillRect(3, 3, 10, 7);\n"
        + "      alert(canvas.toDataURL());\n"
        + "    }\n"
        + "  }\n"
        + "</script>\n"
        + "</head><body onload='test()'>\n"
        + "  <canvas id='myCanvas' width='20', height='20' style='border: 1px solid red;'></canvas>"
        + "</body></html>";

    loadPageWithAlerts(html);
}
 
Example 28
Source Project: commons-crypto   Source File: OpenSslCryptoRandomTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CryptoRandom getCryptoRandom() throws GeneralSecurityException {
    Assume.assumeTrue(Crypto.isNativeCodeLoaded());
    final Properties props = new Properties();
    props.setProperty(
            CryptoRandomFactory.CLASSES_KEY,
            OpenSslCryptoRandom.class.getName());
    final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
    assertTrue(
            "The CryptoRandom should be: " + OpenSslCryptoRandom.class.getName(),
            random instanceof OpenSslCryptoRandom);
    return random;
}
 
Example 29
Source Project: blueocean-plugin   Source File: MultiBranchTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getMultiBranchPipeline() throws IOException, ExecutionException, InterruptedException {
    Assume.assumeTrue(runAllTests());
    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }

    mp.scheduleBuild2(0).getFuture().get();


    Map resp = get("/organizations/jenkins/pipelines/p/");
    validateMultiBranchPipeline(mp, resp, 3);

    List<String> names = (List<String>) resp.get("branchNames");

    IsArrayContainingInAnyOrder.arrayContainingInAnyOrder(names, branches);

    List<Map> br = get("/organizations/jenkins/pipelines/p/branches", List.class);

    List<String> branchNames = new ArrayList<>();
    List<Integer> weather = new ArrayList<>();
    for (Map b : br) {
        branchNames.add((String) b.get("name"));
        weather.add((int) b.get("weatherScore"));
    }

    for (String n : branches) {
        assertTrue(branchNames.contains(n));
    }

    for (int s : weather) {
        assertEquals(100, s);
    }
}
 
Example 30
@Override
protected ByteBuf newBuffer(int length, int maxCapacity) {
    Assume.assumeTrue(maxCapacity == Integer.MAX_VALUE);

    return new WrappedUnpooledUnsafeDirectByteBuf(UnpooledByteBufAllocator.DEFAULT,
            PlatformDependent.allocateMemory(length), length, true);
}