Java Code Examples for org.junit.Assert#fail()
The following examples show how to use
org.junit.Assert#fail() .
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: InternalPhotosLibraryClientTest.java From java-photoslibrary with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("all") public void shareAlbumExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockPhotosLibrary.addException(exception); try { String albumId = "albumId1532078315"; SharedAlbumOptions sharedAlbumOptions = SharedAlbumOptions.newBuilder().build(); client.shareAlbum(albumId, sharedAlbumOptions); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
Example 2
Source File: CampaignCriterionServiceClientTest.java From google-ads-java with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("all") public void getCampaignCriterionExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCampaignCriterionService.addException(exception); try { String formattedResourceName = CampaignCriterionServiceClient.formatCampaignCriteriaName( "[CUSTOMER]", "[CAMPAIGN_CRITERIA]"); client.getCampaignCriterion(formattedResourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
Example 3
Source File: SpoonTest.java From snowblossom with Apache License 2.0 | 6 votes |
private void waitForMoreBlocks(SnowBlossomNode node, int wait_for) throws Exception { int start = -1; if (node.getBlockIngestor().getHead()!=null) { start = node.getBlockIngestor().getHead().getHeader().getBlockHeight(); } int target = start + wait_for; int height = start; for (int i = 0; i < 15; i++) { Thread.sleep(1000); height = node.getBlockIngestor().getHead().getHeader().getBlockHeight(); if (height >= target) return; } Assert.fail(String.format("Waiting for %d blocks, only got %d", wait_for, height - start)); }
Example 4
Source File: TupleSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private <T extends Tuple> void runTests(int length, T... instances) { try { TupleTypeInfo<T> tupleTypeInfo = (TupleTypeInfo<T>) TypeExtractor.getForObject(instances[0]); TypeSerializer<T> serializer = tupleTypeInfo.createSerializer(new ExecutionConfig()); Class<T> tupleClass = tupleTypeInfo.getTypeClass(); if(tupleClass == Tuple0.class) { length = 1; } SerializerTestInstance<T> test = new SerializerTestInstance<>(serializer, tupleClass, length, instances); test.testAll(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 5
Source File: DomainCategoryServiceClientTest.java From google-ads-java with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("all") public void getDomainCategoryExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDomainCategoryService.addException(exception); try { String formattedResourceName = DomainCategoryServiceClient.formatDomainCategoryName("[CUSTOMER]", "[DOMAIN_CATEGORY]"); client.getDomainCategory(formattedResourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
Example 6
Source File: TestIntegration.java From hadoop with Apache License 2.0 | 6 votes |
@Test(timeout=100000) public void testMultiDirTargetPresent() { try { addEntries(listFile, "multifile", "singledir"); createFiles("multifile/file3", "multifile/file4", "multifile/file5"); mkdirs(target.toString(), root + "/singledir/dir1"); runTest(listFile, target, true, false); checkResult(target, 2, "multifile/file3", "multifile/file4", "multifile/file5", "singledir/dir1"); } catch (IOException e) { LOG.error("Exception encountered while testing distcp", e); Assert.fail("distcp failure"); } finally { TestDistCpUtils.delete(fs, root); } }
Example 7
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSerializationFailureHandling() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance()), mockGateway); Assert.fail(); } catch (RestHandlerException rhe) { Assert.assertEquals(HttpResponseStatus.BAD_REQUEST, rhe.getHttpResponseStatus()); } }
Example 8
Source File: AdGroupSimulationServiceClientTest.java From google-ads-java with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("all") public void getAdGroupSimulationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockAdGroupSimulationService.addException(exception); try { String formattedResourceName = AdGroupSimulationServiceClient.formatAdGroupSimulationName( "[CUSTOMER]", "[AD_GROUP_SIMULATION]"); client.getAdGroupSimulation(formattedResourceName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
Example 9
Source File: BaseDalTableDaoShardByDbTableTest.java From dal with Apache License 2.0 | 5 votes |
private void testDeleteMultipleFail(DalHints hints) throws SQLException { reset(); List<ClientTestModel> entities = create(3); int res[]; try { hints = copy(hints); res = dao.delete(hints, entities); res = assertIntArray(res, hints); Assert.fail(); } catch (Exception e) { } }
Example 10
Source File: XGBoostTrainUDTFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test(expected = UDFArgumentException.class) public void testCheckInvalidTargetValue2() throws HiveException { XGBoostTrainUDTF udtf = new XGBoostTrainUDTF(); udtf.processOptions(new ObjectInspector[] {null, null, ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-objective multi:softmax -num_class 3")}); udtf.processTargetValue(-2f); Assert.fail(); }
Example 11
Source File: CryptoPrimitivesTest.java From fabric-sdk-java with Apache License 2.0 | 5 votes |
@Test public void testValidateNotSignedCertificate() { try { BufferedInputStream bis = new BufferedInputStream(this.getClass().getResourceAsStream("/notsigned.crt")); Certificate cert = cf.generateCertificate(bis); assertFalse(crypto.validateCertificate(cert)); } catch (CertificateException e) { Assert.fail("cannot read cert file"); } }
Example 12
Source File: DataInputDeserializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAvailable() throws Exception { byte[] bytes; DataInputDeserializer dis; bytes = new byte[] {}; dis = new DataInputDeserializer(bytes, 0, bytes.length); Assert.assertEquals(bytes.length, dis.available()); bytes = new byte[] {1, 2, 3}; dis = new DataInputDeserializer(bytes, 0, bytes.length); Assert.assertEquals(bytes.length, dis.available()); dis.readByte(); Assert.assertEquals(2, dis.available()); dis.readByte(); Assert.assertEquals(1, dis.available()); dis.readByte(); Assert.assertEquals(0, dis.available()); try { dis.readByte(); Assert.fail("Did not throw expected IOException"); } catch (IOException e) { // ignore } Assert.assertEquals(0, dis.available()); }
Example 13
Source File: LocalRecoveryDirectoryProviderImplTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testPreconditionsNotNullFiles() { try { new LocalRecoveryDirectoryProviderImpl(new File[]{null}, JOB_ID, JOB_VERTEX_ID, SUBTASK_INDEX); Assert.fail(); } catch (NullPointerException ignore) { } }
Example 14
Source File: SyncPointTest.java From firebase-admin-java with Apache License 2.0 | 5 votes |
private static void assertEventExactMatch(List<TestEvent> expected, List<TestEvent> actual) { if (expected.size() < actual.size()) { Assert.fail("Got extra events: " + actual); } else if (expected.size() > actual.size()) { Assert.fail("Missing events: " + expected); } else { Iterator<TestEvent> expectedIterator = expected.iterator(); Iterator<TestEvent> actualIterator = actual.iterator(); while (expectedIterator.hasNext() && actualIterator.hasNext()) { TestEvent.assertEquals(expectedIterator.next(), actualIterator.next()); } Assert.assertFalse(expectedIterator.hasNext()); Assert.assertFalse(actualIterator.hasNext()); } }
Example 15
Source File: CrossTaskTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStreamEmptyOuterCrossTask() { int keyCnt1 = 10; int valCnt1 = 1; int keyCnt2 = 0; int valCnt2 = 0; final int expCnt = keyCnt1*valCnt1*keyCnt2*valCnt2; setOutput(this.output); addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false)); addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false)); getTaskConfig().setDriverStrategy(DriverStrategy.NESTEDLOOP_STREAMED_OUTER_SECOND); getTaskConfig().setRelativeMemoryDriver(cross_frac); final CrossDriver<Record, Record, Record> testTask = new CrossDriver<>(); try { testDriver(testTask, MockCrossStub.class); } catch (Exception e) { e.printStackTrace(); Assert.fail("Test failed due to an exception."); } Assert.assertEquals("Wrong result size.", expCnt, this.output.getNumberOfRecords()); }
Example 16
Source File: SelfValidatingSortedQueueEntryList.java From qpid-broker-j with Apache License 2.0 | 5 votes |
public void assertTreeIntegrity(final SortedQueueEntry node) { if(node == null) { return; } if(node.getLeft() != null) { if(node.getLeft().getParent() == node) { assertTreeIntegrity(node.getLeft()); } else { Assert.fail("Tree integrity compromised"); } } if(node.getRight() != null) { if(node.getRight().getParent() == node) { assertTreeIntegrity(node.getRight()); } else { Assert.fail("Tree integrity compromised"); } } }
Example 17
Source File: ClientRunningTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
@Test public void testOneServer() { final CountDownLatch countLatch = new CountDownLatch(2); ClientRunningMonitor runningMonitor = buildClientRunning(countLatch, clientId, 2088); runningMonitor.start(); sleep(2000L); runningMonitor.stop(); sleep(2000L); if (countLatch.getCount() != 0) { Assert.fail(); } }
Example 18
Source File: GMTest.java From chain33-sdk-java with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testSM3() { try { byte[] hash = SM3Util.hash(SRC_DATA); System.out.println("SM3 hash result:\n" + ByteUtils.toHexString(hash)); } catch (IOException e) { e.printStackTrace(); Assert.fail(); } }
Example 19
Source File: TestContainerStateMachineIdempotency.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Test public void testContainerStateMachineIdempotency() throws Exception { ContainerWithPipeline container = storageContainerLocationClient .allocateContainer(HddsProtos.ReplicationType.RATIS, HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE); long containerID = container.getContainerInfo().getContainerID(); Pipeline pipeline = container.getPipeline(); XceiverClientSpi client = xceiverClientManager.acquireClient(pipeline); try { //create the container ContainerProtocolCalls.createContainer(client, containerID, null); // call create Container again BlockID blockID = ContainerTestHelper.getTestBlockID(containerID); byte[] data = RandomStringUtils.random(RandomUtils.nextInt(0, 1024)).getBytes(); ContainerProtos.ContainerCommandRequestProto writeChunkRequest = ContainerTestHelper .getWriteChunkRequest(container.getPipeline(), blockID, data.length, null); client.sendCommand(writeChunkRequest); //Make the write chunk request again without requesting for overWrite client.sendCommand(writeChunkRequest); // Now, explicitly make a putKey request for the block. ContainerProtos.ContainerCommandRequestProto putKeyRequest = ContainerTestHelper .getPutBlockRequest(pipeline, writeChunkRequest.getWriteChunk()); client.sendCommand(putKeyRequest).getPutBlock(); // send the putBlock again client.sendCommand(putKeyRequest); // close container call ContainerProtocolCalls.closeContainer(client, containerID, null); ContainerProtocolCalls.closeContainer(client, containerID, null); } catch (IOException ioe) { Assert.fail("Container operation failed" + ioe); } xceiverClientManager.releaseClient(client, false); }
Example 20
Source File: TestSuiteTest.java From octo-rpc with Apache License 2.0 | 5 votes |
@Test public void testVoid() { try { oriThriftClient.testVoid(); octoProtocolClient.testVoid(); } catch (Exception e) { Assert.fail(e.getMessage()); } }