Java Code Examples for org.junit.Assert#assertTrue()
The following examples show how to use
org.junit.Assert#assertTrue() .
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
Source Project: gridgo File: GatewayUnitTest.java License: MIT License | 7 votes |
@Test public void testProducerDeserializeq1Transformer() throws InterruptedException, PromiseException { var context = new DefaultGridgoContextBuilder().setName("test").build(); context.openGateway("test", ProducerJoinMode.SINGLE) // .attachConnector("testtransformer") .transformIncomingWith(this::transformProducerDeserialize); context.start(); var gateway = context.findGatewayMandatory("test"); var result = gateway.callAny(BObject.of("name", "test").toJson()).get(); Assert.assertTrue(result != null && result.body() != null && result.body().isObject()); Assert.assertEquals("test", result.body().asObject().getString("loop")); result = gateway.sendAnyWithAck(BObject.of("name", "test").toJson()).get(); Assert.assertTrue(result != null && result.body() != null && result.body().isObject()); Assert.assertEquals("test", result.body().asObject().getString("loop")); gateway.sendAny(BObject.of("name", "test").toJson()); }
Example 2
Source Project: kylin-on-parquet-v2 File: DefaultSchedulerTest.java License: Apache License 2.0 | 6 votes |
@Test public void testRetryableException() throws Exception { DefaultChainedExecutable job = new DefaultChainedExecutable(); BaseTestExecutable task = new ErrorTestExecutable(); job.addTask(task); System.setProperty("kylin.job.retry", "3"); //don't retry on DefaultChainedExecutable, only retry on subtasks Assert.assertFalse(job.needRetry(1, new Exception(""))); Assert.assertTrue(task.needRetry(1, new Exception(""))); Assert.assertFalse(task.needRetry(1, null)); Assert.assertFalse(task.needRetry(4, new Exception(""))); System.setProperty("kylin.job.retry-exception-classes", "java.io.FileNotFoundException"); Assert.assertTrue(task.needRetry(1, new FileNotFoundException())); Assert.assertFalse(task.needRetry(1, new Exception(""))); }
Example 3
Source Project: sunbird-lms-service File: OTPActorTest.java License: MIT License | 6 votes |
private void verifyOtpFailureTest(boolean isPhone, Response mockedCassandraResponse) { Request request; if (isPhone) { request = createRequestForVerifyOtp(PHONE_KEY, PHONE_TYPE); } else { request = createRequestForVerifyOtp(EMAIL_KEY, EMAIL_TYPE); } when(mockCassandraOperation.getRecordWithTTLById( Mockito.anyString(), Mockito.anyString(), Mockito.anyMap(), Mockito.anyList(), Mockito.anyList())) .thenReturn(mockedCassandraResponse); subject.tell(request, probe.getRef()); ClientErrorResponse errorResponse = probe.expectMsgClass(duration("100 second"), ClientErrorResponse.class); Assert.assertTrue( (errorResponse.getResponseCode().name()).equals(ResponseCode.CLIENT_ERROR.name())); }
Example 4
Source Project: sofa-tracer File: RestTemplateTest.java License: Apache License 2.0 | 6 votes |
public void testGetFromEntity() throws IOException, InterruptedException { RestTemplate restTemplate = SofaTracerRestTemplateBuilder.buildRestTemplate(); ResponseEntity<Map> forEntity = restTemplate.getForEntity(urlHttpPrefix, Map.class); Assert.assertTrue(forEntity.getBody().containsKey("name")); Thread.sleep(1000); //wait for async output List<String> contents = FileUtils.readLines(new File( logDirectoryPath + File.separator + RestTemplateLogEnum.REST_TEMPLATE_DIGEST.getDefaultLogName())); assertTrue(contents.size() == 1); //stat log List<String> statContents = FileUtils.readLines(new File( logDirectoryPath + File.separator + RestTemplateLogEnum.REST_TEMPLATE_STAT.getDefaultLogName())); assertTrue(statContents.size() == 1); }
Example 5
Source Project: mojito File: CSVFileTypeTest.java License: Apache License 2.0 | 5 votes |
@Test public void testTargetPattern() { CSVFileType csvFileType = new CSVFileType(); Matcher matcher = csvFileType.getTargetFilePattern().getPattern().matcher("/source/demo_fr.csv"); Assert.assertTrue(matcher.matches()); Assert.assertEquals("fr", matcher.group(LOCALE)); Assert.assertEquals("/source/", matcher.group(PARENT_PATH)); Assert.assertEquals("demo", matcher.group(BASE_NAME)); Assert.assertEquals("csv", matcher.group(FILE_EXTENSION)); }
Example 6
Source Project: hipparchus File: UnivariateSolverUtilsTest.java License: Apache License 2.0 | 5 votes |
@Test public void testFieldBracketEndpointRoot() { Decimal64[] result = UnivariateSolverUtils.bracket(fieldSin, new Decimal64(1.5), new Decimal64(0), new Decimal64(2.0), 100); Assert.assertEquals(0.0, fieldSin.value(result[0]).getReal(), 1.0e-15); Assert.assertTrue(fieldSin.value(result[1]).getReal() > 0); }
Example 7
Source Project: Flink-CEPplus File: TypeExtractorTest.java License: Apache License 2.0 | 5 votes |
@Test public void testFunctionInputInOutputMultipleTimes() { RichMapFunction<Float, ?> function = new FieldDuplicator<Float>(); TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.FLOAT_TYPE_INFO); Assert.assertTrue(ti.isTupleType()); Assert.assertEquals(2, ti.getArity()); TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti; Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(0)); Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(1)); }
Example 8
Source Project: netty-4.1.22 File: Lz4FrameEncoderTest.java License: Apache License 2.0 | 5 votes |
private void testAllocateBuffer(int blockSize, int bufSize, boolean preferDirect) { // allocate the input buffer to an arbitrary size less than the blockSize ByteBuf in = ByteBufAllocator.DEFAULT.buffer(bufSize, bufSize); in.writerIndex(in.capacity()); ByteBuf out = null; try { Lz4FrameEncoder encoder = newEncoder(blockSize, Lz4FrameEncoder.DEFAULT_MAX_ENCODE_SIZE); out = encoder.allocateBuffer(ctx, in, preferDirect); Assert.assertNotNull(out); if (NONALLOCATABLE_SIZE == bufSize) { Assert.assertFalse(out.isWritable()); } else { Assert.assertTrue(out.writableBytes() > 0); if (!preferDirect) { // Only check if preferDirect is not true as if a direct buffer is returned or not depends on // if sun.misc.Unsafe is present. assertFalse(out.isDirect()); } } } finally { in.release(); if (out != null) { out.release(); } } }
Example 9
Source Project: big-c File: TestParameterParser.java License: Apache License 2.0 | 5 votes |
@Test public void testDeserializeHAToken() throws IOException { Configuration conf = DFSTestUtil.newHAConfiguration(LOGICAL_NAME); final Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(); QueryStringDecoder decoder = new QueryStringDecoder( WebHdfsHandler.WEBHDFS_PREFIX + "/?" + NamenodeAddressParam.NAME + "=" + LOGICAL_NAME + "&" + DelegationParam.NAME + "=" + token.encodeToUrlString()); ParameterParser testParser = new ParameterParser(decoder, conf); final Token<DelegationTokenIdentifier> tok2 = testParser.delegationToken(); Assert.assertTrue(HAUtil.isTokenForLogicalUri(tok2)); }
Example 10
Source Project: dubbo-spring-boot-project File: AwaitingNonWebApplicationListenerTest.java License: Apache License 2.0 | 5 votes |
@Test public void testSingleContextNonWebApplication() { new SpringApplicationBuilder(Object.class) .web(false) .run().close(); AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited(); Assert.assertTrue(awaited.get()); }
Example 11
Source Project: google-ads-java File: AdGroupExtensionSettingServiceClientTest.java License: Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("all") public void getAdGroupExtensionSettingTest() { String resourceName2 = "resourceName2625949903"; AdGroupExtensionSetting expectedResponse = AdGroupExtensionSetting.newBuilder().setResourceName(resourceName2).build(); mockAdGroupExtensionSettingService.addResponse(expectedResponse); String formattedResourceName = AdGroupExtensionSettingServiceClient.formatAdGroupExtensionSettingName( "[CUSTOMER]", "[AD_GROUP_EXTENSION_SETTING]"); AdGroupExtensionSetting actualResponse = client.getAdGroupExtensionSetting(formattedResourceName); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockAdGroupExtensionSettingService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetAdGroupExtensionSettingRequest actualRequest = (GetAdGroupExtensionSettingRequest) actualRequests.get(0); Assert.assertEquals(formattedResourceName, actualRequest.getResourceName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
Example 12
Source Project: fastods File: ContainerTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public final void testCreateAfterDebug() { PowerMock.resetAll(); this.logger.severe("Container put(a, 1)"); PowerMock.replayAll(); this.container.debug(); final boolean ret = this.container.add("a", 1); LogManager.getLogManager().reset(); PowerMock.verifyAll(); Assert.assertTrue(ret); }
Example 13
Source Project: Tomcat8-Source-Read File: TestPojoEndpointBase.java License: MIT License | 5 votes |
@Test public void testOnOpenPojoMethod() throws Exception { // Set up utility classes OnOpenServerEndpoint server = new OnOpenServerEndpoint(); SingletonConfigurator.setInstance(server); ServerConfigListener.setPojoClazz(OnOpenServerEndpoint.class); Tomcat tomcat = getTomcatInstance(); // No file system docBase required Context ctx = tomcat.addContext("", null); ctx.addApplicationListener(ServerConfigListener.class.getName()); Tomcat.addServlet(ctx, "default", new DefaultServlet()); ctx.addServletMappingDecoded("/", "default"); WebSocketContainer wsContainer = ContainerProvider.getWebSocketContainer(); tomcat.start(); Client client = new Client(); URI uri = new URI("ws://localhost:" + getPort() + "/"); Session session = wsContainer.connectToServer(client, uri); client.waitForClose(5); Assert.assertTrue(session.isOpen()); }
Example 14
Source Project: greycat File: AbstractWorldOrderChunkTest.java License: Apache License 2.0 | 5 votes |
@Test public void simpleTest() { ChunkSpace space = factory.newSpace(100, -1, null, false); WorldOrderChunk map = (WorldOrderChunk) space.createAndMark(ChunkType.WORLD_ORDER_CHUNK, 0, 0, 0); //mass insert for (long i = 0; i < 10; i++) { map.put(i, i * 3); } //mass check for (long i = 0; i < 10; i++) { Assert.assertTrue(map.get(i) == i * 3); } space.free(map); space.freeAll(); }
Example 15
Source Project: hadoop File: ClientBaseWithFixes.java License: Apache License 2.0 | 5 votes |
public static boolean recursiveDelete(File d) { if (d.isDirectory()) { File children[] = d.listFiles(); for (File f : children) { Assert.assertTrue("delete " + f.toString(), recursiveDelete(f)); } } return d.delete(); }
Example 16
Source Project: twill File: PlacementPolicyTestRun.java License: Apache License 2.0 | 5 votes |
/** * Test to verify placement policy without dynamically changing number of instances. */ @Test public void testPlacementPolicy() throws Exception { // Ignore test if it is running against older Hadoop versions which does not support blacklists. Assume.assumeTrue(YarnUtils.getHadoopVersion().equals(YarnUtils.HadoopVersions.HADOOP_22)); waitNodeManagerCount(0, 10, TimeUnit.SECONDS); TwillRunner runner = getTwillRunner(); TwillController controller = runner.prepare(new PlacementPolicyApplication()) .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true))) .withApplicationArguments("PlacementPolicyTest") .withArguments("hostRunnable", "host") .withArguments("hostRackRunnable", "hostRack") .withArguments("distributedRunnable", "distributed") .start(); try { // All runnables should get started. ServiceDiscovered serviceDiscovered = controller.discoverService("PlacementPolicyTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 4, 80)); // DISTRIBUTED runnables should be provisioned on different nodes. Assert.assertTrue(getProvisionedNodeManagerCount() >= 2); } finally { controller.terminate().get(120, TimeUnit.SECONDS); } // Sleep a bit before exiting. TimeUnit.SECONDS.sleep(2); }
Example 17
Source Project: dubbox File: GenericServiceTest.java License: Apache License 2.0 | 4 votes |
@Test public void testGenericSerializationJava() throws Exception { ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); DemoServiceImpl ref = new DemoServiceImpl(); service.setRef(ref); service.export(); try { ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { String name = "kimi"; ByteArrayOutputStream bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(name); byte[] arg = bos.toByteArray(); Object obj = genericService.$invoke("sayName", new String[]{String.class.getName()}, new Object[]{arg}); Assert.assertTrue(obj instanceof byte[]); byte[] result = (byte[]) obj; Assert.assertEquals(ref.sayName(name), ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").deserialize(null, new ByteArrayInputStream(result)).readObject().toString()); // getUsers List<User> users = new ArrayList<User>(); User user = new User(); user.setName(name); users.add(user); bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(users); obj = genericService.$invoke("getUsers", new String[]{List.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); result = (byte[]) obj; Assert.assertEquals(users, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream(result)) .readObject()); // echo(int) bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class).getExtension("nativejava") .serialize(null, bos).writeObject(Integer.MAX_VALUE); obj = genericService.$invoke("echo", new String[]{int.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); Assert.assertEquals(Integer.MAX_VALUE, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream((byte[]) obj)) .readObject()); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 18
Source Project: hadoop File: TestOldCombinerGrouping.java License: Apache License 2.0 | 4 votes |
@Test public void testCombiner() throws Exception { if (!new File(TEST_ROOT_DIR).mkdirs()) { throw new RuntimeException("Could not create test dir: " + TEST_ROOT_DIR); } File in = new File(TEST_ROOT_DIR, "input"); if (!in.mkdirs()) { throw new RuntimeException("Could not create test dir: " + in); } File out = new File(TEST_ROOT_DIR, "output"); PrintWriter pw = new PrintWriter(new FileWriter(new File(in, "data.txt"))); pw.println("A|a,1"); pw.println("A|b,2"); pw.println("B|a,3"); pw.println("B|b,4"); pw.println("B|c,5"); pw.close(); JobConf job = new JobConf(); job.set("mapreduce.framework.name", "local"); TextInputFormat.setInputPaths(job, new Path(in.getPath())); TextOutputFormat.setOutputPath(job, new Path(out.getPath())); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setInputFormat(TextInputFormat.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); job.setOutputFormat(TextOutputFormat.class); job.setOutputValueGroupingComparator(GroupComparator.class); job.setCombinerClass(Combiner.class); job.setCombinerKeyGroupingComparator(GroupComparator.class); job.setInt("min.num.spills.for.combine", 0); JobClient client = new JobClient(job); RunningJob runningJob = client.submitJob(job); runningJob.waitForCompletion(); if (runningJob.isSuccessful()) { Counters counters = runningJob.getCounters(); long combinerInputRecords = counters.getGroup( "org.apache.hadoop.mapreduce.TaskCounter"). getCounter("COMBINE_INPUT_RECORDS"); long combinerOutputRecords = counters.getGroup( "org.apache.hadoop.mapreduce.TaskCounter"). getCounter("COMBINE_OUTPUT_RECORDS"); Assert.assertTrue(combinerInputRecords > 0); Assert.assertTrue(combinerInputRecords > combinerOutputRecords); BufferedReader br = new BufferedReader(new FileReader( new File(out, "part-00000"))); Set<String> output = new HashSet<String>(); String line = br.readLine(); Assert.assertNotNull(line); output.add(line.substring(0, 1) + line.substring(4, 5)); line = br.readLine(); Assert.assertNotNull(line); output.add(line.substring(0, 1) + line.substring(4, 5)); line = br.readLine(); Assert.assertNull(line); br.close(); Set<String> expected = new HashSet<String>(); expected.add("A2"); expected.add("B5"); Assert.assertEquals(expected, output); } else { Assert.fail("Job failed"); } }
Example 19
Source Project: gsc-core File: TransferFailed002.java License: GNU Lesser General Public License v3.0 | 4 votes |
@Test(enabled = true, description = "Send Gsc self and balance not enough") public void test6SendGscSelf() { Account info; AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, blockingStubFull); info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); Long beforeBalance = info.getBalance(); Long beforeCpuUsed = resourceInfo.getCpuUsed(); Long beforeNetUsed = resourceInfo.getNetUsed(); Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); logger.info("beforeBalance:" + beforeBalance); logger.info("beforeCpuUsed:" + beforeCpuUsed); logger.info("beforeNetUsed:" + beforeNetUsed); logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); ECKey ecKey2 = new ECKey(Utils.getRandom()); String txid = ""; String num = "1000000000"; txid = PublicMethed.triggerContract(contractAddress, "testSendGscSelf(uint256)", num, false, 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); Optional<TransactionInfo> infoById = null; PublicMethed.waitProduceNextBlock(blockingStubFull); infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); logger.info("infobyid : --- " + infoById); Long fee = infoById.get().getFee(); Long netUsed = infoById.get().getReceipt().getNetUsage(); Long cpuUsed = infoById.get().getReceipt().getCpuUsage(); Long netFee = infoById.get().getReceipt().getNetFee(); long cpuUsageTotal = infoById.get().getReceipt().getCpuUsageTotal(); logger.info("fee:" + fee); logger.info("netUsed:" + netUsed); logger.info("cpuUsed:" + cpuUsed); logger.info("netFee:" + netFee); logger.info("cpuUsageTotal:" + cpuUsageTotal); Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, blockingStubFull1); Long afterBalance = infoafter.getBalance(); Long afterCpuUsed = resourceInfoafter.getCpuUsed(); Long afterNetUsed = resourceInfoafter.getNetUsed(); Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); logger.info("afterBalance:" + afterBalance); logger.info("afterCpuUsed:" + afterCpuUsed); logger.info("afterNetUsed:" + afterNetUsed); logger.info("afterFreeNetUsed:" + afterFreeNetUsed); Assert.assertTrue(infoById.get().getResultValue() == 0); Assert.assertTrue(afterBalance + fee == beforeBalance); Assert.assertTrue(beforeCpuUsed + cpuUsed >= afterCpuUsed); Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); Assert.assertNotEquals(10000000, cpuUsageTotal); }
Example 20
Source Project: datawave File: ExceededOrThresholdMarkerJexlNodeTest.java License: Apache License 2.0 | 4 votes |
@Test public void combinedRangesOneIvaratorTest() throws Exception { // @formatter:off String query = "(" + GEO_FIELD + " >= '" + INDEX_1 + "' && " + GEO_FIELD + " <= '" + INDEX_3 + "') || " + "(" + GEO_FIELD + " >= '" + INDEX_5 + "' && " + GEO_FIELD + " <= '" + INDEX_7 + "') || " + "(" + GEO_FIELD + " >= '" + INDEX_9 + "' && " + GEO_FIELD + " <= '" + INDEX_11 + "')"; // @formatter:on maxOrExpansionThreshold = 100; maxOrFstThreshold = 100; maxOrRangeThreshold = 1; maxOrRangeIvarators = 1; maxRangesPerRangeIvarator = 1; List<String> queryRanges = getQueryRanges(query); Assert.assertEquals(1, queryRanges.size()); String id = queryRanges.get(0).substring(queryRanges.get(0).indexOf("id = '") + 6, queryRanges.get(0).indexOf("') && (field = 'GEO')")); Assert.assertEquals( "((ExceededOrThresholdMarkerJexlNode = true) && (((id = '" + id + "') && (field = 'GEO') && (params = '{\"ranges\":[[\"[1f0aaaaaaaaaaaaaaa\",\"1f1fffb0ebff104155]\"],[\"[1f2000228a00228a00\",\"1f20008a28008a2800]\"],[\"[1f200364bda9c63d03\",\"1f35553ac3ffb0ebff]\"]]}'))))", queryRanges.get(0)); List<DefaultEvent> events = getQueryResults(query); Assert.assertEquals(9, events.size()); List<String> pointList = new ArrayList<>(); pointList.addAll(Arrays.asList(POINT_1, POINT_2, POINT_3, POINT_5, POINT_6, POINT_7, POINT_9, POINT_10, POINT_11)); for (DefaultEvent event : events) { String wkt = null; for (DefaultField field : event.getFields()) { if (field.getName().equals(GEO_FIELD)) wkt = field.getValueString(); } // ensure that this is one of the ingested events Assert.assertTrue(pointList.remove(wkt)); } Assert.assertEquals(0, pointList.size()); }