org.junit.Assume Java Examples
The following examples show how to use
org.junit.Assume.
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
Source File: TestSharedFileDescriptorFactory.java From hadoop with Apache License 2.0 | 6 votes |
@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 #2
Source File: TestCryptoCodec.java From hadoop with Apache License 2.0 | 6 votes |
@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 #3
Source File: TestLinuxContainerExecutor.java From hadoop with Apache License 2.0 | 6 votes |
@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 #4
Source File: ObjectStoreFileSystemTest.java From stocator with Apache License 2.0 | 6 votes |
@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 #5
Source File: TestOpensslCipher.java From hadoop with Apache License 2.0 | 6 votes |
@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 #6
Source File: TestClassCompilers.java From dremio-oss with Apache License 2.0 | 6 votes |
@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 #7
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 6 votes |
@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 #8
Source File: JavaScriptEnginesTest.java From netbeans with Apache License 2.0 | 6 votes |
@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 #9
Source File: AbstractStaxHandlerTestCase.java From java-technology-stack with MIT License | 6 votes |
@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 #10
Source File: HtmlObjectTest.java From htmlunit with Apache License 2.0 | 6 votes |
/** * @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 #11
Source File: ITJDBCResourceStoreTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@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 #12
Source File: LocalDocReaderTest.java From TranskribusCore with GNU General Public License v3.0 | 6 votes |
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 #13
Source File: MongoDbResource.java From ditto with Eclipse Public License 2.0 | 6 votes |
@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 File: ConnectorsITCase.java From syndesis with Apache License 2.0 | 6 votes |
@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 #15
Source File: StatsJobTest.java From datawave with Apache License 2.0 | 6 votes |
@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 #16
Source File: ObjectStoreFileSystemTest.java From stocator with Apache License 2.0 | 6 votes |
@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 #17
Source File: GitCloneTest.java From orion.server with Eclipse Public License 1.0 | 6 votes |
@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 #18
Source File: TestListenNowSituation.java From gplaymusic with MIT License | 5 votes |
@Test public void testListenNowSituation() throws IOException { ListenNowSituation listenNowSituation = getApi().getListenNowSituation(); TestUtil.assume(listenNowSituation, listenNowSituation.getSituations()); Assume.assumeTrue(listenNowSituation.getSituations().size() > 0); for (Situation s : listenNowSituation.getSituations()) { testSituation(s); } }
Example #19
Source File: EdgeListITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testPrintWithHypercubeGraph() throws Exception { // skip 'char' since it is not printed as a number Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar")); expectedOutputChecksum(getHypercubeGraphParameters("print"), new Checksum(896, 0x000001f243ee33b2L)); }
Example #20
Source File: PageRankITCase.java From flink with Apache License 2.0 | 5 votes |
@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 #21
Source File: FileOperationsTest.java From jcifs with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testRenameOverwrite () throws CIFSException, MalformedURLException, UnknownHostException { try ( SmbFile defaultShareRoot = getDefaultShareRoot(); SmbResource f = new SmbFile(defaultShareRoot, makeRandomName()); SmbResource tgt = new SmbFile(defaultShareRoot, makeRandomName()) ) { f.createNewFile(); tgt.createNewFile(); boolean renamed = false; try { f.renameTo(tgt, true); try { assertTrue(tgt.exists()); renamed = true; } finally { tgt.delete(); } } catch ( SmbUnsupportedOperationException e ) { try ( SmbTreeHandle th = defaultShareRoot.getTreeHandle() ) { Assume.assumeTrue("Not SMB2", th.isSMB2()); } throw e; } finally { if ( !renamed && f.exists() ) { f.delete(); } } } }
Example #22
Source File: FsNegativeRunningJobsRegistryTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@BeforeClass public static void createHDFS() throws Exception { Assume.assumeTrue("HDFS cluster cannot be start on Windows without extensions.", !OperatingSystem.isWindows()); final File tempDir = TEMP_DIR.newFolder(); Configuration hdConf = new Configuration(); hdConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, tempDir.getAbsolutePath()); MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(hdConf); hdfsCluster = builder.build(); hdfsRootPath = new Path("hdfs://" + hdfsCluster.getURI().getHost() + ":" + hdfsCluster.getNameNodePort() + "/"); }
Example #23
Source File: EdgeListITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testPrintWithGridGraph() throws Exception { // skip 'char' since it is not printed as a number Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar")); expectedOutputChecksum(getGridGraphParameters("print"), new Checksum(130, 0x00000033237d24eeL)); }
Example #24
Source File: DataPatchTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testInlineNarrowObject() { Assume.assumeTrue(config.useCompressedOops); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); Register compressed = asm.emitLoadPointer((HotSpotConstant) c.compress()); Register ret = asm.emitUncompressPointer(compressed, config.narrowOopBase, config.narrowOopShift); asm.emitPointerRet(ret); }); }
Example #25
Source File: SessionTest.java From jcifs-ng with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void logonUserNoDomain () throws IOException { Assume.assumeTrue(getTestDomain().equalsIgnoreCase(getTestUserDomain())); // without a domain name, at this point we do not resolve the domain DFS roots Assume.assumeTrue(getProperties().get("test.share.dfsroot.url") == null); CIFSContext ctx = getContext(); try ( SmbResource f = new SmbFile( getTestShareURL(), ctx.withCredentials(new NtlmPasswordAuthenticator(null, getTestUser(), getTestUserPassword()))); ) { checkConnection(f); f.resolve("test").exists(); } }
Example #26
Source File: ObjectStoreFileSystemTest.java From stocator with Apache License 2.0 | 5 votes |
@Test public void listLocatedStatusTest() throws Exception { Assume.assumeNotNull(getFs()); int count = 0; RemoteIterator<LocatedFileStatus> stats = getFs().listLocatedStatus(new Path(getBaseURI() + "/testFile01")); while (stats.hasNext()) { LocatedFileStatus stat = stats.next(); Assert.assertTrue(stat.getPath().getName().startsWith("testFile01")); count++; } Assert.assertEquals(1, count); }
Example #27
Source File: WindowsInstallScriptProviderTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testGetScriptCommandLine() { Assume.assumeTrue(System.getProperty("os.name").startsWith("Windows")); Path sdkRoot = Paths.get("C:\\path\\to\\sdk"); List<String> commandLine = new WindowsInstallScriptProvider().getScriptCommandLine(sdkRoot); Assert.assertEquals(3, commandLine.size()); Assert.assertEquals("cmd.exe", commandLine.get(0)); Assert.assertEquals("/c", commandLine.get(1)); Path scriptPath = Paths.get(commandLine.get(2)); Assert.assertTrue(scriptPath.isAbsolute()); Assert.assertEquals(Paths.get("C:\\path\\to\\sdk\\install.bat"), scriptPath); }
Example #28
Source File: KerberosTest.java From jcifs with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testKRB () throws Exception { Assume.assumeTrue(getContext().getConfig().getResolveOrder().contains(ResolverType.RESOLVER_DNS)); Subject s = getInitiatorSubject(getTestUser(), getTestUserPassword(), getTestUserDomainRequired(), null); CIFSContext ctx = getContext().withCredentials(new Kerb5Authenticator(s, getTestUserDomainRequired(), getTestUser(), getTestUserPassword())); try ( SmbResource f = new SmbFile(getTestShareURL(), ctx) ) { f.exists(); } catch ( SmbUnsupportedOperationException e ) { Assume.assumeTrue("Using short names", false); } }
Example #29
Source File: BitOpNodesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testBitCountIntEmpty() { Architecture arch = getBackend().getTarget().arch; boolean isAmd64WithPopCount = arch instanceof AMD64 && ((AMD64) arch).getFeatures().contains(AMD64.CPUFeature.POPCNT); boolean isSparc = arch instanceof SPARC; Assume.assumeTrue("Only works on hardware with popcnt at the moment", isAmd64WithPopCount || isSparc); ValueNode result = parseAndInline("bitCountIntEmptySnippet"); Assert.assertEquals(StampFactory.forInteger(JavaKind.Int, 0, 24), result.stamp()); }
Example #30
Source File: IntegrationTestSettingsLoader.java From line-bot-sdk-java with Apache License 2.0 | 5 votes |
public static IntegrationTestSettings load() throws IOException { // Do not run all test cases in this class when src/test/resources/integration_test_settings.yml doesn't // exist. Assume.assumeTrue("exists integration_test_settings.yml in resource directory", TEST_RESOURCE != null); return new ObjectMapper(new YAMLFactory()) .registerModule(new ParameterNamesModule()) .readValue(TEST_RESOURCE, IntegrationTestSettings.class); }