Refine search
@Test public void withTriggerTask() throws InterruptedException { Assume.group(TestGroup.PERFORMANCE); ctx = new AnnotationConfigApplicationContext(TriggerTaskConfig.class); Thread.sleep(100); assertThat(ctx.getBean(AtomicInteger.class).get(), greaterThan(1)); }
private static void assertRoughlyEqual( long expected, long actual ) { long diff = abs( expected - actual ); assertThat( expected / 10, greaterThan( diff ) ); }
@Test public void matches() { StatusAssertions assertions = statusAssertions(HttpStatus.CONFLICT); // Success assertions.value(equalTo(409)); assertions.value(greaterThan(400)); try { assertions.value(equalTo(200)); fail("Wrong status expected"); } catch (AssertionError error) { // Expected } }
@Test public void nextLongValueBoundedAndShifted() { Set<Value> values = new HashSet<>(); for ( int i = 0; i < ITERATIONS; i++ ) { LongValue value = randomValues.nextLongValue( 1337, 1337 + BOUND ); assertThat( value, notNullValue() ); assertThat( value.compareTo( longValue( 1337 ) ), greaterThanOrEqualTo( 0 ) ); assertThat( value.toString(), value.compareTo( longValue( 1337 + BOUND ) ), lessThanOrEqualTo( 0 ) ); values.add( value ); } assertThat( values.size(), greaterThan( 1 ) ); }
@Test public void succeedsWhenJdkProxyAndScheduledMethodIsPresentOnInterface() throws InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Config.class, JdkProxyTxConfig.class, RepoConfigB.class); ctx.refresh(); Thread.sleep(100); // allow @Scheduled method to be called several times MyRepositoryWithScheduledMethod repository = ctx.getBean(MyRepositoryWithScheduledMethod.class); CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class); assertThat("repository is not a proxy", AopUtils.isJdkDynamicProxy(repository), is(true)); assertThat("@Scheduled method never called", repository.getInvocationCount(), greaterThan(0)); assertThat("no transactions were committed", txManager.commits, greaterThan(0)); }
@Test public void shouldIncrementPublisherLimitOnSubscription() { driverProxy.addSubscription(CommonContext.IPC_CHANNEL, STREAM_ID); driverConductor.doWork(); assertThat(publisherLimit.get(), is(greaterThan(0L))); } }
private void checkDistribution( Supplier<Value> supplier ) { Set<Value> values = new HashSet<>(); for ( int i = 0; i < ITERATIONS; i++ ) { Value value = supplier.get(); assertThat( value, notNullValue() ); values.add( value ); } assertThat( values.size(), greaterThan( 1 ) ); }
@Test public void succeedsWhenSubclassProxyAndScheduledMethodNotPresentOnInterface() throws InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Config.class, SubclassProxyTxConfig.class, RepoConfigA.class); ctx.refresh(); Thread.sleep(100); // allow @Scheduled method to be called several times MyRepository repository = ctx.getBean(MyRepository.class); CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class); assertThat("repository is not a proxy", AopUtils.isCglibProxy(repository), equalTo(true)); assertThat("@Scheduled method never called", repository.getInvocationCount(), greaterThan(0)); assertThat("no transactions were committed", txManager.commits, greaterThan(0)); }
@Test public void test_getCacheEvictions_heapAndOffheap() throws Exception { String ONE_MB = new String(new byte[1024 * 512]); for (int i = 0; i < 20; i++) { offheapCache.put("key" + i, ONE_MB); } assertThat(offheapStatistics.getCacheEvictions(), greaterThan(0L)); }
@AfterClass public static void checkAtLeastOneTestRun() { if (!skipTest) { assertThat( "No S3 filesystem upload test executed. Please activate the " + "'include_hadoop_aws' build profile or set '-Dinclude_hadoop_aws' during build " + "(Hadoop >= 2.6 moved S3 filesystems out of hadoop-common).", numRecursiveUploadTests, greaterThan(0)); } }
@Test public void withAspectConfig() throws InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AspectConfig.class, MyRepositoryWithScheduledMethodImpl.class); ctx.refresh(); Thread.sleep(100); // allow @Scheduled method to be called several times MyRepositoryWithScheduledMethod repository = ctx.getBean(MyRepositoryWithScheduledMethod.class); assertThat("repository is not a proxy", AopUtils.isCglibProxy(repository), is(true)); assertThat("@Scheduled method never called", repository.getInvocationCount(), greaterThan(0)); }
@Test public void shouldWriteToInternalDiagnosticsLog() throws Exception { // Given new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( testDir.databaseDir() ) .setConfig( GraphDatabaseSettings.logs_directory, testDir.directory("logs").getAbsolutePath() ) .newGraphDatabase().shutdown(); File internalLog = new File( testDir.directory( "logs" ), INTERNAL_LOG_FILE ); // Then assertThat( internalLog.isFile(), is( true ) ); assertThat( internalLog.length(), greaterThan( 0L ) ); assertEquals( 1, countOccurrences( internalLog, "Database graph.db is ready." ) ); assertEquals( 2, countOccurrences( internalLog, "Database graph.db is unavailable." ) ); }
@Override public void run() throws IOException { long start = System.currentTimeMillis(); helper.get(root()); int code = helper.getForStatus(root()); long stop = System.currentTimeMillis(); long gap = stop - start + delta; assertThat(gap, greaterThan(TimeUnit.SECONDS.toMillis(1))); assertThat(code, is(200)); } });
@Test public void withInitiallyDelayedFixedRateTask() throws InterruptedException { Assume.group(TestGroup.PERFORMANCE); ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfig_withInitialDelay.class); Thread.sleep(1950); AtomicInteger counter = ctx.getBean(AtomicInteger.class); // The @Scheduled method should have been called at least once but // not more times than the delay allows. assertThat(counter.get(), both(greaterThan(0)).and(lessThanOrEqualTo(10))); }
@Test public void shouldNotWriteDebugToInternalDiagnosticsLogByDefault() throws Exception { // Given GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( testDir.storeDir() ) .setConfig( GraphDatabaseSettings.logs_directory, testDir.directory("logs").getAbsolutePath() ) .newGraphDatabase(); // When LogService logService = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency( LogService.class ); logService.getInternalLog( getClass() ).debug( "A debug entry" ); db.shutdown(); File internalLog = new File( testDir.directory( "logs" ), INTERNAL_LOG_FILE ); // Then assertThat( internalLog.isFile(), is( true ) ); assertThat( internalLog.length(), greaterThan( 0L ) ); assertEquals( 0, countOccurrences( internalLog, "A debug entry" ) ); }
@Override public void run() throws IOException { long start = System.currentTimeMillis(); helper.get(root()); int code = helper.getForStatus(root()); long stop = System.currentTimeMillis(); long gap = stop - start + delta; assertThat(gap, greaterThan(latency)); assertThat(code, is(200)); } });
@Test public void getReadableByteChannel() throws IOException { PathResource resource = new PathResource(TEST_FILE); ReadableByteChannel channel = null; try { channel = resource.readableChannel(); ByteBuffer buffer = ByteBuffer.allocate((int) resource.contentLength()); channel.read(buffer); buffer.rewind(); assertThat(buffer.limit(), greaterThan(0)); } finally { if (channel != null) { channel.close(); } } }
@Test public void shouldCompareByteArrays() { // given final Matcher<Integer> LESS_THAN = lessThan( 0 ); final Matcher<Integer> GREATER_THAN = greaterThan( 0 ); final Matcher<Integer> EQUAL_TO = equalTo( 0 ); // then assertCompare( new byte[0], EQUAL_TO, new byte[0] ); assertCompare( new byte[]{1, 2, 3}, EQUAL_TO, new byte[]{1, 2, 3} ); assertCompare( new byte[]{1, 2, 3}, LESS_THAN, new byte[]{1, 2, 4} ); assertCompare( new byte[]{1, 2, 3}, LESS_THAN, new byte[]{2, 2, 3} ); assertCompare( new byte[]{1, 2, 3}, GREATER_THAN, new byte[]{1, 2, 0} ); assertCompare( new byte[]{1, 2, 3}, GREATER_THAN, new byte[]{0, 2, 3} ); }
private void processByPatterns(JadxDecompiler jadx, Pattern clsPattern, @Nullable Pattern mthPattern) { List<IDexTreeVisitor> passes = Jadx.getPassesList(jadx.getArgs()); RootNode root = JadxInternalAccess.getRoot(jadx); int processed = 0; for (ClassNode classNode : root.getClasses(true)) { String clsFullName = classNode.getClassInfo().getFullName(); if (clsPattern.matcher(clsFullName).matches()) { if (processCls(mthPattern, passes, classNode)) { processed++; } } } assertThat("No classes processed", processed, greaterThan(0)); }
@Test public void getInputStream() throws IOException { PathResource resource = new PathResource(TEST_FILE); byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream()); assertThat(bytes.length, greaterThan(0)); }