类org.junit.Assume源码实例Demo

下面列出了怎么用org.junit.Assume的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TranskribusCore   文件: LocalDocReaderTest.java
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);
}
 
源代码2 项目: syndesis   文件: ConnectorsITCase.java
@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();
}
 
源代码3 项目: stocator   文件: ObjectStoreFileSystemTest.java
@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));
}
 
源代码4 项目: htmlunit   文件: HtmlObjectTest.java
/**
 * @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());
}
 
源代码5 项目: microprofile-metrics   文件: MpMetricTest.java
@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));
        }
    }

}
 
源代码6 项目: hadoop   文件: TestCryptoCodec.java
@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);
}
 
源代码7 项目: hadoop   文件: TestLinuxContainerExecutor.java
@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);

}
 
源代码8 项目: hadoop   文件: TestOpensslCipher.java
@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);
  }
}
 
源代码9 项目: dremio-oss   文件: TestClassCompilers.java
@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());
}
 
@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);
    }
}
 
源代码11 项目: datawave   文件: StatsJobTest.java
@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);
}
 
源代码12 项目: stocator   文件: ObjectStoreFileSystemTest.java
@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));
}
 
源代码13 项目: ditto   文件: MongoDbResource.java
@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());
}
 
源代码14 项目: hadoop   文件: TestSharedFileDescriptorFactory.java
@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);
}
 
源代码15 项目: orion.server   文件: GitCloneTest.java
@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));
}
 
@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));
}
 
源代码17 项目: netbeans   文件: JavaScriptEnginesTest.java
@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);
}
 
源代码18 项目: flink   文件: PageRankITCase.java
@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);
}
 
源代码19 项目: xtext-xtend   文件: AbstractXtendUITestCase.java
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();
	}
}
 
@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);
}
 
源代码21 项目: htmlunit   文件: CanvasRenderingContext2D2Test.java
/**
 * @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);
}
 
源代码22 项目: iceberg   文件: TestMetricsRowGroupFilter.java
@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);
  }
}
 
源代码23 项目: jcifs-ng   文件: EnumTest.java
@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);
    }
}
 
源代码24 项目: jcifs   文件: FileAttributesTest.java
@Test
public void testFileIndex () throws IOException {
    try ( SmbFile f = createTestFile() ) {
        try {
            long idx = f.fileIndex();
            Assume.assumeTrue("FileIndex unsupported", idx != 0);
        }
        finally {
            f.delete();
        }
    }
}
 
源代码25 项目: localization_nifi   文件: TestEncryptContent.java
@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"));
}
 
@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");
}
 
源代码27 项目: htmlunit   文件: CanvasRenderingContext2D2Test.java
/**
 * @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);
}
 
源代码28 项目: commons-crypto   文件: OpenSslCryptoRandomTest.java
@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;
}
 
源代码29 项目: blueocean-plugin   文件: MultiBranchTest.java
@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);
    }
}
 
@Override
protected ByteBuf newBuffer(int length, int maxCapacity) {
    Assume.assumeTrue(maxCapacity == Integer.MAX_VALUE);

    return new WrappedUnpooledUnsafeDirectByteBuf(UnpooledByteBufAllocator.DEFAULT,
            PlatformDependent.allocateMemory(length), length, true);
}
 
 类所在包
 同包方法