junitparams.naming.TestCaseName Java Examples
The following examples show how to use
junitparams.naming.TestCaseName.
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: ConfigIOTest.java From raistlic-lib-commons-core with Apache License 2.0 | 6 votes |
@Test(expected = ConfigIOException.class) @Parameters(method = "failedCallCases") @TestCaseName("writeConfigWhenOutputStreamThrowsException with : {1}") public void writeConfigWhenOutputStreamThrowsException(ConfigIO configIO, String description) throws Exception { Config config = ConfigFactory.newMutableConfig() .setString("test.key", "test value") .get(); OutputStream outputStream = spy(new ByteArrayOutputStream()); doThrow(new RuntimeException("Test Exception")).when(outputStream).write(anyInt()); doThrow(new RuntimeException("Test Exception")).when(outputStream).write(any(byte[].class)); doThrow(new RuntimeException("Test Exception")).when(outputStream).write(any(byte[].class), anyInt(), anyInt()); configIO.writeConfig(config, outputStream); }
Example #2
Source File: PaxosTests.java From rapid with Apache License 2.0 | 6 votes |
/** * Test multiple nodes issuing different proposals in parallel */ @Test @Parameters(method = "nValues") @TestCaseName("{method}[N={0}]") public void testRecoveryFromFastRoundWithDifferentProposals(final int numNodes) throws InterruptedException { final ExecutorService executorService = Executors.newFixedThreadPool(numNodes); final LinkedBlockingDeque<List<Endpoint>> decisions = new LinkedBlockingDeque<>(); final Consumer<List<Endpoint>> onDecide = decisions::add; final Map<Endpoint, FastPaxos> instances = createNFastPaxosInstances(numNodes, onDecide); final long recoveryDelayInMs = 100; instances.forEach((host, fp) -> executorService.execute(() -> fp.propose(Collections.singletonList(host), recoveryDelayInMs))); waitAndVerifyAgreement(numNodes, 20, 50, decisions); for (final List<Endpoint> decision : decisions) { assertTrue(decision.size() == 1); assertTrue(instances.containsKey(decision.get(0))); // proposed values are host names } }
Example #3
Source File: PodTemplateBuilderTest.java From kubernetes-plugin with Apache License 2.0 | 6 votes |
@Test @TestCaseName("{method}(directConnection={0})") @Parameters({ "true", "false" }) public void testOverridesContainerSpec(boolean directConnection) throws Exception { cloud.setDirectConnection(directConnection); PodTemplate template = new PodTemplate(); ContainerTemplate cT = new ContainerTemplate("jnlp", "jenkinsci/jnlp-slave:latest"); template.setContainers(Lists.newArrayList(cT)); template.setYaml(loadYamlFile("pod-overrides.yaml")); setupStubs(); Pod pod = new PodTemplateBuilder(template).withSlave(slave).build(); Map<String, Container> containers = toContainerMap(pod); assertEquals(1, containers.size()); Container jnlp = containers.get("jnlp"); assertEquals("Wrong number of volume mounts: " + jnlp.getVolumeMounts(), 1, jnlp.getVolumeMounts().size()); validateContainers(pod, slave, directConnection); }
Example #4
Source File: ConfigIOTest.java From raistlic-lib-commons-core with Apache License 2.0 | 6 votes |
@Test @Parameters(method = "expectedCases") @TestCaseName("readConfigExpected with {2}") public void readConfigExpected(ConfigIO configIO, String fixturePath, String description) throws Exception { InputStream inputStream = getClass().getResourceAsStream(fixturePath); Config actual = configIO.readConfig(inputStream); inputStream.close(); Config expected = ConfigFixture.getConfigFixture(); assertThat(actual.getKeys()).hasSize(expected.getKeys().size()); assertThat(actual.getKeys()).containsAll(expected.getKeys()); for (String key : expected.getKeys()) { assertThat(actual.getString(key)).isEqualTo(expected.getString(key)); } }
Example #5
Source File: PodTemplateBuilderTest.java From kubernetes-plugin with Apache License 2.0 | 6 votes |
@Test @TestCaseName("{method}(directConnection={0})") @Parameters({ "true", "false" }) public void testOverridesFromYaml(boolean directConnection) throws Exception { cloud.setDirectConnection(directConnection); PodTemplate template = new PodTemplate(); template.setYaml(loadYamlFile("pod-overrides.yaml")); setupStubs(); Pod pod = new PodTemplateBuilder(template).withSlave(slave).build(); Map<String, Container> containers = toContainerMap(pod); assertEquals(1, containers.size()); Container jnlp = containers.get("jnlp"); assertThat("Wrong number of volume mounts: " + jnlp.getVolumeMounts(), jnlp.getVolumeMounts(), hasSize(1)); PodTemplateUtilsTest.assertQuantity("2", jnlp.getResources().getLimits().get("cpu")); PodTemplateUtilsTest.assertQuantity("2Gi", jnlp.getResources().getLimits().get("memory")); PodTemplateUtilsTest.assertQuantity("200m", jnlp.getResources().getRequests().get("cpu")); PodTemplateUtilsTest.assertQuantity("256Mi", jnlp.getResources().getRequests().get("memory")); validateContainers(pod, slave, directConnection); }
Example #6
Source File: PodTemplateBuilderTest.java From kubernetes-plugin with Apache License 2.0 | 6 votes |
@Test @TestCaseName("{method}(directConnection={0})") @Parameters({ "true", "false" }) public void testBuildFromYaml(boolean directConnection) throws Exception { cloud.setDirectConnection(directConnection); PodTemplate template = new PodTemplate(); template.setYaml(loadYamlFile("pod-busybox.yaml")); setupStubs(); Pod pod = new PodTemplateBuilder(template).withSlave(slave).build(); validatePod(pod, directConnection); assertThat(pod.getMetadata().getLabels(), hasEntry("jenkins", "slave")); Map<String, Container> containers = toContainerMap(pod); assertEquals(2, containers.size()); Container container0 = containers.get("busybox"); assertNotNull(container0.getResources()); assertNotNull(container0.getResources().getRequests()); assertNotNull(container0.getResources().getLimits()); assertThat(container0.getResources().getRequests(), hasEntry("example.com/dongle", new Quantity("42"))); assertThat(container0.getResources().getLimits(), hasEntry("example.com/dongle", new Quantity("42"))); }
Example #7
Source File: PropertySortUtilsTest.java From jsonschema-generator with Apache License 2.0 | 6 votes |
@Test @Parameters @TestCaseName(value = "{method}({0}) [{index}]") public void testSortProperties(String _testCaseName, String expectedResult, Comparator<MemberScope<?, ?>> sortingLogic) { Stream<MemberScope<?, ?>> properties = Stream.of( this.createMemberMock(FieldScope.class, false, "c"), this.createMemberMock(MethodScope.class, true, "f()"), this.createMemberMock(FieldScope.class, true, "e"), this.createMemberMock(FieldScope.class, false, "a"), this.createMemberMock(MethodScope.class, false, "b()"), this.createMemberMock(MethodScope.class, true, "d()")); String sortingResult = properties.sorted(sortingLogic) .map(MemberScope::getSchemaPropertyName) .collect(Collectors.joining(" ")); Assert.assertEquals(expectedResult, sortingResult); }
Example #8
Source File: ConfigSourceTest.java From raistlic-lib-commons-core with Apache License 2.0 | 6 votes |
@Test @Parameters(method = "getTestCases") @TestCaseName("'getKeysReadOnly' for implementation type: {1}, {2}") public void getKeysReadOnly(ConfigSource configSource, Class<? extends ConfigSource> configSourceType, String instanceDescription) { Set<String> keys = configSource.getKeys(); try { keys.add("abc"); fail("Expected exception not thrown: " + UnsupportedOperationException.class); } catch (UnsupportedOperationException ex) { // do nothing } }
Example #9
Source File: FastPaxosWithoutFallbackTests.java From rapid with Apache License 2.0 | 6 votes |
/** * Verifies that a node makes a decision only after |quorum| identical proposals are received. * This test does not generate conflicting proposals. */ @Test @Parameters(method = "fastQuorumTestNoConflictsData") @TestCaseName("{method}[N={0},Q={1}]") public void fastQuorumTestNoConflicts(final int N, final int quorum) throws InterruptedException, ExecutionException { final int serverPort = 1234; final Endpoint node = Utils.hostFromParts("127.0.0.1", serverPort); final Endpoint proposalNode = Utils.hostFromParts("127.0.0.1", serverPort + 1); final MembershipView view = createView(serverPort, N); final MembershipService service = createAndStartMembershipService(node, view); assertEquals(N, service.getMembershipSize()); final long currentId = view.getCurrentConfigurationId(); final FastRoundPhase2bMessage.Builder proposal = getProposal(currentId, Collections.singletonList(proposalNode)); for (int i = 0; i < quorum - 1; i++) { service.handleMessage(asRapidMessage(proposal.setSender(addrForBase(i)).build())).get(); assertEquals(N, service.getMembershipSize()); } service.handleMessage(asRapidMessage(proposal.setSender(addrForBase(quorum - 1)).build())) .get(); assertEquals(N - 1, service.getMembershipSize()); }
Example #10
Source File: SchemaGeneratorComplexTypesTest.java From jsonschema-generator with Apache License 2.0 | 6 votes |
@Test @Parameters @TestCaseName(value = "{method}({0}) [{index}]") public void testGenerateSchema(String caseTitle, OptionPreset preset, Class<?> targetType, Module testModule) throws Exception { final SchemaVersion schemaVersion = SchemaVersion.DRAFT_7; SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(schemaVersion, preset); configBuilder.with(testModule); SchemaGenerator generator = new SchemaGenerator(configBuilder.build()); JsonNode result = generator.generateSchema(targetType); // ensure that the generated definition keys are valid URIs without any characters requiring encoding JsonNode definitions = result.get(SchemaKeyword.TAG_DEFINITIONS.forVersion(schemaVersion)); if (definitions instanceof ObjectNode) { Iterator<String> definitionKeys = ((ObjectNode) definitions).fieldNames(); while (definitionKeys.hasNext()) { String key = definitionKeys.next(); Assert.assertEquals(key, new URI(key).toASCIIString()); } } JSONAssert.assertEquals('\n' + result.toString() + '\n', TestUtils.loadResource(this.getClass(), caseTitle + ".json"), result.toString(), JSONCompareMode.STRICT); }
Example #11
Source File: BuildTargetPatternParserTest.java From buck with Apache License 2.0 | 6 votes |
@Test @Parameters({ "", "path/to:target", "//", "///", "...", ":", "/", "/:", "/...", "///some/path:target", "//path/to...", "//path/:...", "//a/b//c/d:f", "//a/b/" }) @TestCaseName("parsingFails({0})") public void parsingFails(String pattern) throws BuildTargetParseException { exception.expect(BuildTargetParseException.class); BuildTargetPatternParser.parse(pattern, cellNameResolver); }
Example #12
Source File: DefaultByteConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "validDecodeCases") @TestCaseName("decodeExpected with '{0}', expected decode result: {1}") public void decodeExpected(String dest, Byte expected) { Byte actual = converter.decode(dest); assertThat(actual).isEqualTo(expected); }
Example #13
Source File: DefaultDoubleConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "expectedDecodeCases") @TestCaseName("decodeExpected with '{0}'") public void decodeExpected(String dest, Double expected) { Double actual = converter.decode(dest); assertThat(actual).isEqualTo(expected); }
Example #14
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test(expected = InvalidParameterException.class) @Parameters(method = "getTestCases") @TestCaseName("hasKeyWithNullKey {1}") public void hasKeyWithNullKey(Config config, String description) { config.hasKey(null); }
Example #15
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "getTestCases") @TestCaseName("hasKeyExpected {1}") public void hasKeyExpected(Config config, String description) { assertThat(config.hasKey(KEY_STRING)).isTrue(); assertThat(config.hasKey(KEY_BOOLEAN)).isTrue(); assertThat(config.hasKey(KEY_BYTE)).isTrue(); assertThat(config.hasKey(KEY_CHAR)).isTrue(); assertThat(config.hasKey(KEY_SHORT)).isTrue(); assertThat(config.hasKey(KEY_INT)).isTrue(); assertThat(config.hasKey(KEY_LONG)).isTrue(); assertThat(config.hasKey(KEY_FLOAT)).isTrue(); assertThat(config.hasKey(KEY_DOUBLE)).isTrue(); }
Example #16
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test(expected = InvalidParameterException.class) @Parameters(method = "getTestCases") @TestCaseName("getValueWithNullDecoder {1}") public void getValueWithNullDecoder(Config config, String description) { String key = "8dd11f23-3e41-4823-9634-dfe1b966d0ab"; config.getValue(key, null); }
Example #17
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "getTestCases") @TestCaseName("getLongNotFound {1}") public void getLongNotFound(Config config, String description) { long actual = config.getLong("6130abf3-9e33-4353-8b6f-504300fe4ca0", 1L); assertThat(actual).isEqualTo(1L); }
Example #18
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "getTestCases") @TestCaseName("getDoubleNotFound {1}") public void getDoubleNotFound(Config config, String description) { double actual = config.getDouble("58a04a0a-088c-4a0f-a014-46c90c53437b", 1.0); assertThat(actual).isEqualTo(1.0); }
Example #19
Source File: ConfigSourceTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test(expected = InvalidParameterException.class) @Parameters(method = "getTestCases") @TestCaseName("'getStringWithNullKey' for implementation type: {1}, {2}") public void getStringWithNullKey(ConfigSource configSource, Class<? extends ConfigSource> configSourceType, String instanceDescription) { configSource.getString(null); }
Example #20
Source File: DefaultByteConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "validEncodeCases") @TestCaseName("encodeExpected with {0}, expected encode result: '{1}'") public void encodeExpected(Byte src, String expected) { String actual = converter.encode(src); assertThat(actual).isEqualTo(expected); }
Example #21
Source File: DefaultLongConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "expectedDecodeCases") @TestCaseName("decodeExpected with '{0}', expected decode result: {1}") public void decodeExpected(String dest, Long expected) { Long actual = converter.decode(dest); assertThat(actual).isEqualTo(expected); }
Example #22
Source File: DefaultByteConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test(expected = ConfigValueConvertException.class) @Parameters(method = "invalidDecodeCases") @TestCaseName("decodeWithInvalidDests with '{0}") public void decodeWithInvalidDests(String dest) { converter.decode(dest); }
Example #23
Source File: DefaultShortConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "expectedEncodeCases") @TestCaseName("encodeExpected with {0}, expected encode result: '{1}'") public void encodeExpected(Short src, String expected) { String actual = converter.encode(src); assertThat(actual).isEqualTo(expected); }
Example #24
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "getTestCases") @TestCaseName("getIntExpected {1}") public void getIntExpected(Config config, String description) { int actual = config.getInt(KEY_INT, 1); assertThat(actual).isNotEqualTo(1); assertThat(actual).isEqualTo(FIXTURE_INT); }
Example #25
Source File: DefaultBooleanConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "validCases") @TestCaseName("decodeExpected with '{0}' and expected result {1}") public void decodeExpected(String dest, Boolean expected) { assertThat(converter.decode(dest)).isEqualTo(expected); }
Example #26
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "getTestCases") @TestCaseName("getFloatNotFound {1}") public void getFloatNotFound(Config config, String description) { float actual = config.getFloat("6c598679-51a8-4b6a-a814-24e82d91eb8d", 1F); assertThat(actual).isEqualTo(1F); }
Example #27
Source File: DefaultFloatConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "expectedEncodeCases") @TestCaseName("encodeExpected with {0}, expected encode result: '{1}'") public void encodeExpected(Float src, String expected) { String actual = converter.encode(src); assertThat(actual).isEqualTo(expected); }
Example #28
Source File: DefaultFloatConverterTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "expectedDecodeCases") @TestCaseName("decodeExpected with '{0}', expected decode result: {1}") public void decodeExpected(String dest, Float expected) { Float actual = converter.decode(dest); assertThat(actual).isEqualTo(expected); }
Example #29
Source File: ConfigTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test(expected = ConfigValueConvertException.class) @Parameters(method = "getTestCases") @TestCaseName("getCharFoundButNotChar {1}") public void getCharFoundButNotChar(Config config, String description) { config.getChar(KEY_STRING, '$'); }
Example #30
Source File: DeserializersTest.java From raistlic-lib-commons-core with Apache License 2.0 | 5 votes |
@Test @Parameters(method = "validByteTargetCases") @TestCaseName("getByteDeserializerDecodeExpected with {0}, expect: {1}") public void getByteDeserializerDecodeExpected(String target, Byte expected) { Deserializer<Byte> deserializer = Deserializers.getByteDeserializer(); assertThat(deserializer.decode(target)).isEqualTo(expected); }