@Override public void evaluate() throws Throwable { final Object[] values = complete.getMethodArguments(); if (!nullsOk()) { Assume.assumeNotNull(values); } method.invokeExplosively(freshInstance, values); } };
@Override public Object createTest() throws Exception { Object[] params = complete.getConstructorArguments(); if (!nullsOk()) { Assume.assumeNotNull(params); } return getTestClass().getOnlyConstructor().newInstance(params); } }.methodBlock(testMethod).evaluate();
@Test public void getBootClassPathShouldReturnSunBootClassPathValue() { String value = System.getProperty("sun.boot.class.path"); assumeNotNull(value); assertThat(getBootClassPath()).isEqualTo(value); } }
private void setUpContext(String tokenName) { String accessToken = System.getProperty(tokenName); Assume.assumeNotNull(accessToken); context.setAccessToken(new DefaultOAuth2AccessToken(accessToken)); }
@Test(expected = IllegalArgumentException.class) public void testReadStaticFieldForceAccessIllegalArgumentException2() throws Exception { final Field nonStaticField = FieldUtils.getField(PublicChild.class, "s", true); assumeNotNull(nonStaticField); FieldUtils.readStaticField(nonStaticField); }
runInSeparateProcess(new TestService.Procedure() { @Override public void run(final Context context) { installCondomProcess(context, new CondomOptions()); // Must be installed before the first call to Context.getPackageManager(). final Intent service_intent = new Intent("android.view.InputMethod").addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES/* For consistency */); final ResolveInfo service = context.getPackageManager().resolveService(service_intent, 0); Assume.assumeNotNull(service); final List<ResolveInfo> services = context.getPackageManager().queryIntentServices(service_intent, 0); assertNotNull(services); assertFalse(services.isEmpty()); final List<ResolveInfo> receivers = context.getPackageManager().queryBroadcastReceivers(new Intent(Intent.ACTION_BOOT_COMPLETED), 0); assertNotNull(receivers); assertFalse(receivers.isEmpty()); installCondomProcess(context, new CondomOptions().setOutboundJudge(sBlockAllJudge)); assertNull(context.getPackageManager().resolveService(service_intent, 0)); List<ResolveInfo> result = context.getPackageManager().queryIntentServices(service_intent, 0); assertTrue(result.isEmpty()); service_intent.setPackage(service.serviceInfo.packageName); assertNull(context.getPackageManager().resolveService(service_intent, 0)); result = context.getPackageManager().queryIntentServices(service_intent, 0); assertTrue(result.isEmpty()); service_intent.setPackage(null); }}); }
public void shouldUpholdConstraintEvenAfterRestart() throws Exception assumeNotNull( PID ); // this test can only run on UNIX
@Test public void testBigMatrix() throws IOException { // only run this test if -DrunSlowTests is used. Also requires 4GB or more of heap. Assume.assumeNotNull(System.getProperty("runSlowTests")); Matrix m0 = new SparseRowMatrix(ROWS, COLUMNS); Random gen = RandomUtils.getRandom(); for (int i = 0; i < 1000; i++) { m0.set(gen.nextInt(ROWS), gen.nextInt(COLUMNS), matrixValue(i)); } File f = File.createTempFile("foo", ".m", getTestTempDir()); f.deleteOnExit(); System.out.printf("Starting to write to %s\n", f.getAbsolutePath()); FileBasedMatrix.writeMatrix(f, m0); System.out.printf("done\n"); System.out.printf("File is %.1f MB\n", f.length() / 1.0e6); FileBasedMatrix m1 = new FileBasedMatrix(ROWS, COLUMNS); System.out.printf("Starting read\n"); m1.setData(f, false); gen = RandomUtils.getRandom(); for (int i = 0; i < 1000; i++) { assertEquals(matrixValue(i), m1.get(gen.nextInt(ROWS), gen.nextInt(COLUMNS)), 0.0); } System.out.printf("done\n"); }
@Test(expected = IllegalArgumentException.class) public void testReadStaticFieldIllegalArgumentException2() throws Exception { assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(Foo.class, "VALUE"))); final Field nonStaticField = FieldUtils.getField(PublicChild.class, "s"); assumeNotNull(nonStaticField); FieldUtils.readStaticField(nonStaticField); }
private ImageReader createReferenceReader() { try { @SuppressWarnings("unchecked") Class<ImageReaderSpi> spiClass = (Class<ImageReaderSpi>) Class.forName("com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi"); ImageReaderSpi provider = spiClass.newInstance(); ImageReader reader = provider.createReaderInstance(); assumeNotNull(reader); return reader; } catch (Throwable t) { assumeNoException(t); } return null; }
@Test public void testWriteRead() throws IOException { ImageWriter writer = createImageWriter(); ImageReader reader = ImageIO.getImageReader(writer); assumeNotNull(reader); for (RenderedImage testData : getTestData()) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try (ImageOutputStream stream = ImageIO.createImageOutputStream(buffer)) { writer.setOutput(stream); writer.write(drawSomething((BufferedImage) testData)); } try (ImageInputStream stream = ImageIO.createImageInputStream(new ByteArrayInputStream(buffer.toByteArray()))) { reader.setInput(stream); BufferedImage image = reader.read(0); assertNotNull(image); assertImageDataEquals("Images differ for " + testData, (BufferedImage) testData, image); } } } }
@Test public void testRewriteExisting() throws IOException { IPTCReader reader = createReader(); Directory iptc = reader.read(getDataAsIIS()); assumeNotNull(iptc); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); MemoryCacheImageOutputStream stream = new MemoryCacheImageOutputStream(bytes); createWriter().write(iptc, stream); stream.close(); Directory written = reader.read(new ByteArrayImageInputStream(bytes.toByteArray())); assertEquals(iptc, written); }
@BeforeClass public static void setUp() throws Exception { TestUtil.ignoreException(() -> { elastic = new ElasticsearchContainer(); elastic.start(); }, Exception.class); assumeNotNull(elastic); assumeTrue("Elastic Search must be running", elastic.isRunning()); defaultParams.put("host", elastic.getHttpHostAddress()); db = new TestGraphDatabaseFactory() .newImpermanentDatabaseBuilder() .newGraphDatabase(); TestUtil.registerProcedure(db, ElasticSearch.class); insertDocuments(); }
@BeforeClass public static void setUp() throws Exception { TestUtil.ignoreException(() -> { mongo = new GenericContainer("mongo:3") .withNetworkAliases("mongo-" + Base58.randomString(6)) .withExposedPorts(MONGO_DEFAULT_PORT) .waitingFor(new HttpWaitStrategy() .forPort(MONGO_DEFAULT_PORT) .forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED) .withStartupTimeout(Duration.ofMinutes(2))); mongo.start(); }, Exception.class); assumeNotNull(mongo); assumeTrue("Mongo DB must be running", mongo.isRunning()); MongoClient mongoClient = new MongoClient(mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); HOST = String.format("mongodb://%s:%s", mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); params = map("host", HOST, "db", "test", "collection", "test"); MongoDatabase database = mongoClient.getDatabase("test"); collection = database.getCollection("test"); collection.deleteMany(new Document()); collection.insertOne(new Document(map("name", "testDocument", "date", currentTime, "longValue", longValue))); db = new TestGraphDatabaseFactory() .newImpermanentDatabaseBuilder() .newGraphDatabase(); TestUtil.registerProcedure(db, MongoDB.class); mongoClient.close(); }
couchbase.start(); }, Exception.class); assumeNotNull(couchbase); assumeTrue("couchbase must be running", couchbase.isRunning()); boolean isFilled = fillDB(couchbase.getCouchbaseCluster());
@BeforeClass public static void setUp() { TestUtil.ignoreException(() -> { couchbase = new CouchbaseContainer() .withClusterAdmin(USERNAME, PASSWORD) .withNewBucket(DefaultBucketSettings.builder() .password(PASSWORD) .name(BUCKET_NAME) .quota(100) .type(BucketType.COUCHBASE) .build()); couchbase.start(); }, Exception.class); assumeNotNull(couchbase); assumeTrue("couchbase must be running", couchbase.isRunning()); boolean isFilled = fillDB(couchbase.getCouchbaseCluster()); assumeTrue("should fill Couchbase with data", isFilled); HOST = getUrl(couchbase); couchbaseBucket = getCouchbaseBucket(couchbase); graphDB = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder() .setConfig("apoc." + CouchbaseManager.COUCHBASE_CONFIG_KEY + CONNECTION_TIMEOUT_CONFIG_KEY, CONNECTION_TIMEOUT_CONFIG_VALUE) .setConfig("apoc." + CouchbaseManager.COUCHBASE_CONFIG_KEY + SOCKET_CONNECT_TIMEOUT_CONFIG_KEY, SOCKET_CONNECT_TIMEOUT_CONFIG_VALUE) .setConfig("apoc." + CouchbaseManager.COUCHBASE_CONFIG_KEY + KV_TIMEOUT_CONFIG_KEY, KV_TIMEOUT_CONFIG_VALUE) .newGraphDatabase(); }
couchbase.start(); }, Exception.class); assumeNotNull(couchbase); assumeTrue("couchbase must be running", couchbase.isRunning()); boolean isFilled = fillDB(couchbase.getCouchbaseCluster());
couchbase.start(); }, Exception.class); assumeNotNull(couchbase); assumeTrue("couchbase must be running", couchbase.isRunning()); boolean isFilled = fillDB(couchbase.getCouchbaseCluster());
couchbase.start(); }, Exception.class); assumeNotNull(couchbase); assumeTrue("couchbase must be running", couchbase.isRunning()); boolean isFilled = fillDB(couchbase.getCouchbaseCluster());
/** * Test that an implementation will accept its own URLs * * @throws SQLException */ @Test public void driver_accepts_01() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); JenaDriver driver = this.getDriver(); Assert.assertTrue(driver.acceptsURL(url)); }