org.junit.jupiter.api.Assertions Java Examples
The following examples show how to use
org.junit.jupiter.api.Assertions.
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: QuaternionTest.java From commons-numbers with Apache License 2.0 | 6 votes |
@Test final void testQuaternionEquals() { final double inc = 1e-5; final Quaternion q1 = Quaternion.of(2, 1, -4, -2); final Quaternion q2 = Quaternion.of(q1.getW() + inc, q1.getX(), q1.getY(), q1.getZ()); final Quaternion q3 = Quaternion.of(q1.getW(), q1.getX() + inc, q1.getY(), q1.getZ()); final Quaternion q4 = Quaternion.of(q1.getW(), q1.getX(), q1.getY() + inc, q1.getZ()); final Quaternion q5 = Quaternion.of(q1.getW(), q1.getX(), q1.getY(), q1.getZ() + inc); Assertions.assertFalse(q1.equals(q2, 0.9 * inc)); Assertions.assertFalse(q1.equals(q3, 0.9 * inc)); Assertions.assertFalse(q1.equals(q4, 0.9 * inc)); Assertions.assertFalse(q1.equals(q5, 0.9 * inc)); Assertions.assertTrue(q1.equals(q2, 1.1 * inc)); Assertions.assertTrue(q1.equals(q3, 1.1 * inc)); Assertions.assertTrue(q1.equals(q4, 1.1 * inc)); Assertions.assertTrue(q1.equals(q5, 1.1 * inc)); }
Example #2
Source File: MatchdirFilterTest.java From drftpd with GNU General Public License v2.0 | 6 votes |
@Test public void testRemove() throws NoAvailableSlaveException, ObjectNotFoundException { Properties p = new Properties(); p.put("1.assign", "slave2-remove"); p.put("1.match", "/path1/*"); ScoreChart sc = new ScoreChart(Arrays.asList(rslaves)); Filter f = new MatchdirFilter(1, p); f.process(sc, null, null, Transfer.TRANSFER_SENDING_DOWNLOAD, new DirectoryHandle("/path1/dir/file.txt"), null); assertEquals(0, sc.getScoreForSlave(rslaves[0]).getScore()); assertEquals(0, sc.getScoreForSlave(rslaves[2]).getScore()); try { sc.getScoreForSlave(rslaves[1]); Assertions.fail("should not be called"); } catch (ObjectNotFoundException success) { //success } }
Example #3
Source File: CameraPropertyEventLogicTest.java From canon-sdk-java with MIT License | 6 votes |
@Test void addCameraPropertyListenerUseWeakReference() { final WeakReference<CameraPropertyListener> weakReference = new WeakReference<>(cameraPropertyListener); cameraPropertyEventLogic().addCameraPropertyListener(cameraPropertyListener); cameraPropertyEventLogic().addCameraPropertyListener(fakeCamera, cameraPropertyListener); cameraPropertyListener = null; int i = 0; while (weakReference.get() != null && i < 100) { System.gc(); sleep(10); i++; } Assertions.assertNull(weakReference.get(), "cameraPropertyEventLogic is holding a strong ref to listener"); sendAndAssertCountEvent(2,0); }
Example #4
Source File: WMCTest.java From ck with Apache License 2.0 | 6 votes |
@Test public void loops() { CKClassResult c = report.get("wmc.CC8"); Assertions.assertEquals(3, c.getMethod("m0/0").get().getWmc()); Assertions.assertEquals(6, c.getMethod("m1/0").get().getWmc()); Assertions.assertEquals(6, c.getMethod("m2/0").get().getWmc()); Assertions.assertEquals(6, c.getMethod("m3/0").get().getWmc()); Assertions.assertEquals(2, c.getMethod("m4/0").get().getWmc()); Assertions.assertEquals(3, c.getMethod("m5/0").get().getWmc()); Assertions.assertEquals(6, c.getMethod("m6/0").get().getWmc()); Assertions.assertEquals(3+6+6+6+2+3+6, c.getWmc()); }
Example #5
Source File: ComponentSpringBootExampleTest.java From dekorate with Apache License 2.0 | 6 votes |
@Test public void shouldContainComponent() { KubernetesList list = Serialization.unmarshalAsList(ComponentSpringBootExampleTest.class.getClassLoader().getResourceAsStream("META-INF/dekorate/halkyon.yml")); assertNotNull(list); List<HasMetadata> items = list.getItems(); Assertions.assertEquals(1, items.size()); Component component = (Component) items.get(0); Assertions.assertEquals("Component", component.getKind()); // This doesn't work during release. //assertEquals("https://github.com/dekorateio/dekorate.git", component.getSpec().getBuildConfig().getUrl()); assertEquals("docker", component.getSpec().getBuildConfig().getType()); assertEquals("feat-229-override-annotationbased-config", component.getSpec().getBuildConfig().getModuleDirName()); // This may be null during the release process where HEAD point to a commit instead of a branch. //assertNotNull("", component.getSpec().getBuildConfig().getRef()); assertEquals(DeploymentMode.build, component.getSpec().getDeploymentMode()); Map<String, String> labels = component.getMetadata().getLabels(); Assertions.assertNotNull(labels.get("key1-from-properties")); Assertions.assertEquals("val1-from-properties", labels.get("key1-from-properties")); Assertions.assertEquals("hello-world", component.getMetadata().getName()); }
Example #6
Source File: ZookeeperTestServerTest.java From kafka-junit with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test calling getConnectString() after calling start on the service. */ @Test void testGetConnectString() throws Exception { // Create instance. try (final ZookeeperTestServer zookeeperTestServer = new ZookeeperTestServer()) { // Start service. zookeeperTestServer.start(); // Ask for the connect String final String connectString = zookeeperTestServer.getConnectString(); Assertions.assertNotNull(connectString); // Validate the zookeeper server appears to be functioning. testZookeeperConnection(connectString); } }
Example #7
Source File: ComplexTest.java From commons-numbers with Apache License 2.0 | 6 votes |
@Test void testAbsNaN() { // The result is NaN if either argument is NaN and the other is not infinite Assertions.assertEquals(nan, NAN.abs()); Assertions.assertEquals(nan, Complex.ofCartesian(3.0, nan).abs()); Assertions.assertEquals(nan, Complex.ofCartesian(nan, 3.0).abs()); // The result is positive infinite if either argument is infinite Assertions.assertEquals(inf, Complex.ofCartesian(inf, nan).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(-inf, nan).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(nan, inf).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(nan, -inf).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(inf, 3.0).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(-inf, 3.0).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(3.0, inf).abs()); Assertions.assertEquals(inf, Complex.ofCartesian(3.0, -inf).abs()); }
Example #8
Source File: MarkdownTest.java From JDA with Apache License 2.0 | 6 votes |
@Test public void testBlock() { Assertions.assertEquals("Hello", markdown.compute("```Hello```")); Assertions.assertEquals("```Hello", markdown.compute("```Hello")); Assertions.assertEquals("\\```Hello```", markdown.compute("\\```Hello```")); Assertions.assertEquals("Hello **World**", markdown.compute("```Hello **World**```")); Assertions.assertEquals("```Hello World", markdown.compute("```Hello **World**")); Assertions.assertEquals("\\```Hello World```", markdown.compute("\\```Hello **World**```")); Assertions.assertEquals("Hello `to` World", markdown.compute("```Hello `to` World```")); Assertions.assertEquals("```Hello to World", markdown.compute("```Hello `to` World")); Assertions.assertEquals("\\```Hello to World```", markdown.compute("\\```Hello `to` World```")); Assertions.assertEquals("Test", markdown.compute("```java\nTest```")); }
Example #9
Source File: CustomResourceTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testCreateOrReplace() throws IOException { String jsonObject = "{\"apiVersion\": \"test.fabric8.io/v1alpha1\",\"kind\": \"Hello\"," + "\"metadata\": {\"resourceVersion\":\"1\", \"name\": \"example-hello\"},\"spec\": {\"size\": 3}}"; server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_INTERNAL_ERROR, new StatusBuilder().build()).once(); server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CREATED, jsonObject).once(); server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CONFLICT, jsonObject).once(); server.expect().put().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); KubernetesClient client = server.getClient(); KubernetesClientException exception = Assertions.assertThrows(KubernetesClientException.class, () -> client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject)); assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, exception.getCode()); Map<String, Object> resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); assertEquals("example-hello", ((Map<String, Object>)resource.get("metadata")).get("name").toString()); resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); assertEquals("example-hello", ((Map<String, Object>)resource.get("metadata")).get("name").toString()); }
Example #10
Source File: NodeRepositoryOkVertxImplTest.java From symbol-sdk-java with Apache License 2.0 | 6 votes |
@Test public void shouldGetStorage() throws Exception { StorageInfoDTO dto = new StorageInfoDTO(); dto.setNumAccounts(1); dto.setNumBlocks(2); dto.setNumTransactions(3); mockRemoteCall(dto); StorageInfo storageInfo = repository.getNodeStorage().toFuture() .get(); Assertions.assertEquals(dto.getNumAccounts(), storageInfo.getNumAccounts()); Assertions.assertEquals(dto.getNumBlocks(), storageInfo.getNumBlocks()); Assertions .assertEquals(dto.getNumTransactions(), storageInfo.getNumTransactions()); }
Example #11
Source File: NBTMojangsonTests.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testSerialize() { Assertions.assertEquals( "{" + "\"testbyte\":5b" + "," + "\"testshort\":78s" + "," + "\"testint\":555" + "," + "\"testlong\":125l" + "," + "\"testfloat\":26.55f" + "," + "\"testdouble\":125.111d" + "," + "\"testqnstring\":\"111\"" + "," + "\"testuqstring\":\"uc\"" + "," + "\"testqwsstring\":\"w s\"" + "," + "\"testqestring\":\"\\\\\\\"\"" + "," + "\"testba\":[B;1b,6b,73b,67b]" + "," + "\"testia\":[I;1,6,6]" + "," + "\"testla\":[L;6l,77l,888l]" + "," + "\"testilist\":[1,10]" + "," + "\"testslist\":[\";111\",\"111\",\"uc\",\"w s\"]" + "," + "\"testcompound\":{\"test\":1s}" + "}", MojangsonSerializer.serialize(tag) ); }
Example #12
Source File: ConsumerStateTest.java From storm-dynamic-spout with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Verifies you can't modify values(). */ @Test public void testImmutabilityViaValues() { ConsumerPartition expectedTopicPartition = new ConsumerPartition("MyTopic", 12); Long expectedOffset = 3444L; final ConsumerState.ConsumerStateBuilder builder = ConsumerState.builder(); final ConsumerState consumerState = builder .withPartition(expectedTopicPartition, expectedOffset) .build(); // Sanity check assertEquals(3444L, (long) consumerState.getOffsetForNamespaceAndPartition(expectedTopicPartition), "Has expected offset"); assertEquals(1, consumerState.size(), "Size should be 1"); // Test using values Assertions.assertThrows(UnsupportedOperationException.class, () -> consumerState.values().remove(3444L) ); }
Example #13
Source File: RepositoryFactoryOkHttpImplTest.java From symbol-sdk-java with Apache License 2.0 | 5 votes |
@Test public void getNetworkTypeFailWhenInvalidServer() { String baseUrl = "https://localhost:1934/path"; RepositoryCallException e = Assertions.assertThrows(RepositoryCallException.class, () -> GeneratorUtils.propagate( () -> new RepositoryFactoryOkHttpImpl(baseUrl).getNetworkType().toFuture().get())); Assertions.assertTrue( e.getMessage().contains("ApiException: java.net.ConnectException: Failed to connect")); }
Example #14
Source File: EnumMapperTest.java From symbol-sdk-java with Apache License 2.0 | 5 votes |
@Test void testAccountTypeModel() { Set<Integer> existingValues = new HashSet<>(); Arrays.stream(AccountTypeEnum.values()).forEach(v -> { Assertions.assertNotNull(AccountType.rawValueOf(v.getValue().byteValue()), v.name()); Assertions.assertTrue(existingValues.add(v.getValue()), v.getValue() + " is duplicated!!"); }); }
Example #15
Source File: MetaTest.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Test public void testMetaSecurity() { Meta meta = new Meta(); Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE); Assertions.assertTrue(meta.hasSecurity()); Assertions.assertNotNull(meta.getSecurity()); Assertions.assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE)); Assertions.assertEquals(1, meta.getSecurity().size()); Assertions.assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE)); Assertions.assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE)); Assertions.assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE)); }
Example #16
Source File: PropertyGetShortcutLogicDefaultMockTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void getGPSSatellites() { final String expectedResult = "value"; mockGetProperty(fakeImage, EdsPropertyID.kEdsPropID_GPSSatellites, expectedResult); final String result = spyPropertyGetShortcutLogic.getGPSSatellites(fakeImage); Assertions.assertEquals(expectedResult, result); }
Example #17
Source File: GreetTestBase.java From quarkus with Apache License 2.0 | 5 votes |
@Test public void testGreetNPE() { try { LambdaClient.invoke(Greeting.class, null); } catch (LambdaException e) { Assertions.assertTrue(e.getMessage().contains(ERR_MSG)); } }
Example #18
Source File: MongodbPanacheMockingTest.java From quarkus with Apache License 2.0 | 5 votes |
@Test @Order(1) public void testPanacheMocking() { PanacheMock.mock(PersonEntity.class); Assertions.assertEquals(0, PersonEntity.count()); Mockito.when(PersonEntity.count()).thenReturn(23l); Assertions.assertEquals(23, PersonEntity.count()); Mockito.when(PersonEntity.count()).thenReturn(42l); Assertions.assertEquals(42, PersonEntity.count()); Mockito.when(PersonEntity.count()).thenCallRealMethod(); Assertions.assertEquals(0, PersonEntity.count()); PanacheMock.verify(PersonEntity.class, Mockito.times(4)).count(); PersonEntity p = new PersonEntity(); Mockito.when(PersonEntity.findById(12l)).thenReturn(p); Assertions.assertSame(p, PersonEntity.findById(12l)); Assertions.assertNull(PersonEntity.findById(42l)); Mockito.when(PersonEntity.findById(12l)).thenThrow(new WebApplicationException()); try { PersonEntity.findById(12l); Assertions.fail(); } catch (WebApplicationException x) { } Mockito.when(PersonEntity.findOrdered()).thenReturn(Collections.emptyList()); Assertions.assertTrue(PersonEntity.findOrdered().isEmpty()); PanacheMock.verify(PersonEntity.class).findOrdered(); PanacheMock.verify(PersonEntity.class, Mockito.atLeastOnce()).findById(Mockito.any()); PanacheMock.verifyNoMoreInteractions(PersonEntity.class); }
Example #19
Source File: AIROptionsParserTests.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
@Test void testSigningOptionsTsa() { String value = "none"; ObjectNode options = JsonNodeFactory.instance.objectNode(); ObjectNode signingOptions = JsonNodeFactory.instance.objectNode(); signingOptions.set(AIRSigningOptions.TSA, JsonNodeFactory.instance.textNode(value)); options.set(AIROptions.SIGNING_OPTIONS, signingOptions); ArrayList<String> result = new ArrayList<>(); parser.parse(AIRPlatform.AIR, false, "application.xml", "content.swf", options, result); int optionIndex = result.indexOf("-" + AIRSigningOptions.TSA); Assertions.assertNotEquals(-1, optionIndex); Assertions.assertEquals(optionIndex + 1, result.indexOf(value)); }
Example #20
Source File: NormalDistributionTest.java From commons-statistics with Apache License 2.0 | 5 votes |
/** * Check to make sure top-coding of extreme values works correctly. * Verifies fixes for JIRA MATH-167, MATH-414 */ @Test void testLowerTail() { final NormalDistribution distribution = new NormalDistribution(0, 1); for (int i = 0; i < 100; i++) { // make sure no convergence exception final double lowerTail = distribution.cumulativeProbability(-i); if (i < 39) { // make sure not top-coded Assertions.assertTrue(lowerTail > 0); } else { // make sure top coding not reversed Assertions.assertEquals(0, lowerTail, 0d); } } }
Example #21
Source File: BinomialDistributionTest.java From commons-statistics with Apache License 2.0 | 5 votes |
@Test void testMoments() { final double tol = 1e-9; BinomialDistribution dist; dist = new BinomialDistribution(10, 0.5); Assertions.assertEquals(10d * 0.5d, dist.getMean(), tol); Assertions.assertEquals(10d * 0.5d * 0.5d, dist.getVariance(), tol); dist = new BinomialDistribution(30, 0.3); Assertions.assertEquals(30d * 0.3d, dist.getMean(), tol); Assertions.assertEquals(30d * 0.3d * (1d - 0.3d), dist.getVariance(), tol); }
Example #22
Source File: CompilerOptionsParserTests.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
@Test void testKeepAS3Metadata() { String value1 = "Inject"; String value2 = "Test"; ObjectNode options = JsonNodeFactory.instance.objectNode(); ArrayNode keepMetadata = JsonNodeFactory.instance.arrayNode(); keepMetadata.add(JsonNodeFactory.instance.textNode(value1)); keepMetadata.add(JsonNodeFactory.instance.textNode(value2)); options.set(CompilerOptions.KEEP_AS3_METADATA, keepMetadata); ArrayList<String> result = new ArrayList<>(); try { parser.parse(options, null, result); } catch(UnknownCompilerOptionException e) {} Assertions.assertEquals(2, result.size(), "CompilerOptionsParser.parse() created incorrect number of options."); Assertions.assertEquals("--" + CompilerOptions.KEEP_AS3_METADATA + "+=" + value1, result.get(0), "CompilerOptionsParser.parse() incorrectly formatted compiler option."); Assertions.assertEquals("--" + CompilerOptions.KEEP_AS3_METADATA + "+=" + value2, result.get(1), "CompilerOptionsParser.parse() incorrectly formatted compiler option."); }
Example #23
Source File: GuiceyExtensionShutdownTest.java From dropwizard-guicey with MIT License | 5 votes |
@Test void checkParallelExecution() { EngineTestKit .engine("junit-jupiter") .selectors(selectClass(Test1.class)) .execute() .testEvents() .debug() .assertStatistics(stats -> stats.succeeded(1)); Assertions.assertTrue(App.shutdown); }
Example #24
Source File: NamespaceRepositoryIntegrationTest.java From symbol-sdk-java with Apache License 2.0 | 5 votes |
@ParameterizedTest @EnumSource(RepositoryType.class) void getNamespacesFromAccount(RepositoryType type) { Account account = config().getDefaultAccount(); List<NamespaceInfo> namespacesInfo = get(getNamespaceRepository(type).getNamespacesFromAccount(account.getAddress())); namespacesInfo.forEach(n -> { Assertions.assertEquals(account.getAddress(), n.getOwnerAddress()); }); }
Example #25
Source File: SingularityUsageTest.java From Singularity with Apache License 2.0 | 5 votes |
protected void assertMemShuffle( Map<String, Map<String, SingularityTaskId>> taskIdMap, String host, String request ) { Optional<SingularityTaskCleanup> cleanup = taskManager.getTaskCleanup( taskIdMap.get(host).get(request).getId() ); Assertions.assertEquals( TaskCleanupType.REBALANCE_MEMORY_USAGE, cleanup.get().getCleanupType() ); }
Example #26
Source File: PropertyDescShortcutLogicDefaultMockTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void getISOSpeedDesc() { final List<EdsISOSpeed> result = spyPropertyDescShortcutLogic.getISOSpeedDesc(fakeCamera); Assertions.assertNotNull(result); verify(propertyDescLogic).getPropertyDesc(fakeCamera, EdsPropertyID.kEdsPropID_ISOSpeed); }
Example #27
Source File: RouteValidationTest.java From nalu with Apache License 2.0 | 5 votes |
@Test void validateStartRoute110() { PropertyFactory.get() .register("startShell/startRoute", true, true, false, false); Assertions.assertFalse(RouteValidation.validateStartRoute(this.shellConfiguration, this.routerConfiguration, "/error/showa")); }
Example #28
Source File: AssetTest.java From evt4j with MIT License | 5 votes |
@Test void testExceptions() { Assertions.assertDoesNotThrow(() -> { Asset asset1 = Asset.parseFromRawBalance("1 S#4"); assertEquals(0, asset1.getSymbol().getPrecision()); }); Assertions.assertThrows(IllegalArgumentException.class, () -> { Asset.parseFromRawBalance("1.0.0 S#4"); }); Assertions.assertThrows(IllegalArgumentException.class, () -> { Asset.parseFromRawBalance("1,0 S#4"); }); }
Example #29
Source File: VirtualContainerTest.java From ofdrw with Apache License 2.0 | 5 votes |
@Test void getObj() throws IOException, DocumentException { String fileName = "Content.xml"; Path path = Paths.get("src/test/resources", fileName); vc.putFile(path); Element obj = vc.getObj(fileName); Assertions.assertEquals("ofd:Page", obj.getQualifiedName()); }
Example #30
Source File: NetworkRepositoryIntegrationTest.java From symbol-sdk-java with Apache License 2.0 | 5 votes |
@ParameterizedTest @EnumSource(RepositoryType.class) void getTransactionFees(RepositoryType type) { TransactionFees transactionFees = get(getNetworkRepository(type).getTransactionFees()); Assertions.assertNotNull(transactionFees.getAverageFeeMultiplier()); Assertions.assertNotNull(transactionFees.getHighestFeeMultiplier()); Assertions.assertNotNull(transactionFees.getLowestFeeMultiplier()); Assertions.assertNotNull(transactionFees.getMedianFeeMultiplier()); System.out.println(jsonHelper().prettyPrint(transactionFees)); }