Java Code Examples for org.junit.Test
The following examples show how to use
org.junit.Test. 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: buck Source File: GenruleBuildableTest.java License: Apache License 2.0 | 6 votes |
@Test public void throwsIfGetNonExistentLabel() { expectedThrownException.expect(HumanReadableException.class); expectedThrownException.expectMessage( "Cannot find output label [nonexistent] for target //example:genrule"); GenruleBuildable buildable = ImmutableGenruleBuildableBuilder.builder() .setBuildTarget(BuildTargetFactory.newInstance("//example:genrule")) .setFilesystem(new FakeProjectFilesystem()) .setBash("echo something") .setOuts( Optional.of( ImmutableMap.of( OutputLabel.of("label1"), ImmutableSet.of("output1a", "output1b"), OutputLabel.of("label2"), ImmutableSet.of("output2a")))) .build() .toBuildable(); buildable.getOutputs(OutputLabel.of("nonexistent")); }
Example 2
Source Project: phoenix Source File: WhereClauseOptimizerTest.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testKeyRangeExpression1() throws SQLException { String tenantId = "000000000000001"; String keyPrefix1 = "002"; String keyPrefix2= "004"; String query = "select * from atable where organization_id='" + tenantId + "' and substr(entity_id,1,3) >= '" + keyPrefix1 + "' and substr(entity_id,1,3) < '" + keyPrefix2 + "'"; Scan scan = new Scan(); List<Object> binds = Collections.emptyList(); compileStatement(query, scan, binds); assertNull(scan.getFilter()); byte[] startRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(tenantId),ByteUtil.fillKey(PDataType.VARCHAR.toBytes(keyPrefix1),15)); assertArrayEquals(startRow, scan.getStartRow()); byte[] stopRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(tenantId),ByteUtil.fillKey(PDataType.VARCHAR.toBytes(keyPrefix2),15)); assertArrayEquals(stopRow, scan.getStopRow()); }
Example 3
Source Project: salt-netapi-client Source File: FileTest.java License: MIT License | 6 votes |
@Test public final void testIsLinkTrue() { // true response stubFor(any(urlMatching("/")) .willReturn(aResponse() .withStatus(HttpURLConnection.HTTP_OK) .withHeader("Content-Type", "application/json") .withBody(JSON_TRUE_RESPONSE))); LocalCall<Boolean> call = File.isLink("/test/"); assertEquals("file.is_link", call.getPayload().get("fun")); Map<String, Result<Boolean>> response = call.callSync(client, new MinionList("minion1"), AUTH).toCompletableFuture().join(); assertTrue(response.get("minion1").result().get()); }
Example 4
Source Project: spring-analysis-note Source File: PrintingResultHandlerTests.java License: MIT License | 6 votes |
@Test public void modelAndView() throws Exception { BindException bindException = new BindException(new Object(), "target"); bindException.reject("errorCode"); ModelAndView mav = new ModelAndView("viewName"); mav.addObject("attrName", "attrValue"); mav.addObject(BindingResult.MODEL_KEY_PREFIX + "attrName", bindException); this.mvcResult.setMav(mav); this.handler.handle(this.mvcResult); assertValue("ModelAndView", "View name", "viewName"); assertValue("ModelAndView", "View", null); assertValue("ModelAndView", "Attribute", "attrName"); assertValue("ModelAndView", "value", "attrValue"); assertValue("ModelAndView", "errors", bindException.getAllErrors()); }
Example 5
Source Project: auth0-java Source File: RulesEntityTest.java License: MIT License | 6 votes |
@Test public void shouldCreateRule() throws Exception { Request<Rule> request = api.rules().create(new Rule("my-rule", "function(){}")); assertThat(request, is(notNullValue())); server.jsonResponse(MGMT_RULE, 200); Rule response = request.execute(); RecordedRequest recordedRequest = server.takeRequest(); assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/rules")); assertThat(recordedRequest, hasHeader("Content-Type", "application/json")); assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken")); Map<String, Object> body = bodyFromRequest(recordedRequest); assertThat(body.size(), is(2)); assertThat(body, hasEntry("name", (Object) "my-rule")); assertThat(body, hasEntry("script", (Object) "function(){}")); assertThat(response, is(notNullValue())); }
Example 6
Source Project: cloudbreak Source File: BlueprintToBlueprintV4ResponseConverterTest.java License: Apache License 2.0 | 6 votes |
@Test public void testConvertContainsExpectedMultipleKeyValuePairInTagsProperty() { String nameKey = "name"; String nameValue = "test"; String ageKey = "address"; String ageValue = "something else"; Blueprint source = createSource(); source.setTags(JSON_TO_STRING.convertToEntityAttribute(String.format("{\"%s\":\"%s\", \"%s\":\"%s\"}", nameKey, nameValue, ageKey, ageValue))); BlueprintV4Response result = underTest.convert(source); Assert.assertNotNull(result.getTags()); Assert.assertTrue(result.getTags().containsKey(nameKey)); Assert.assertTrue(result.getTags().containsKey(ageKey)); Assert.assertNotNull(result.getTags().get(nameKey)); Assert.assertNotNull(result.getTags().get(ageKey)); Assert.assertEquals(nameValue, result.getTags().get(nameKey)); Assert.assertEquals(ageValue, result.getTags().get(ageKey)); }
Example 7
Source Project: takes Source File: FbStatusTest.java License: MIT License | 6 votes |
/** * FbStatus can send correct default response with text/plain * body consisting of a status code, status message and message * from an exception. * @throws Exception If some problem inside */ @Test public void sendsCorrectDefaultResponse() throws Exception { final int code = HttpURLConnection.HTTP_NOT_FOUND; final RqFallback req = new RqFallback.Fake( code, new IOException("Exception message") ); final RsPrint response = new RsPrint( new FbStatus(code).route(req).get() ); MatcherAssert.assertThat( response.printBody(), Matchers.equalTo("404 Not Found: Exception message") ); MatcherAssert.assertThat( response.printHead(), Matchers.both( Matchers.containsString("Content-Type: text/plain") ).and(Matchers.containsString("404 Not Found")) ); }
Example 8
Source Project: pravega Source File: ConfigBuilderTests.java License: Apache License 2.0 | 6 votes |
/** * Tests the with() method. */ @Test public void testWith() { final String namespace = "ns"; final int propertyCount = 10; val builder = new ConfigBuilder<TestConfig>(namespace, TestConfig::new); for (int i = 0; i < propertyCount; i++) { val result = builder.with(Property.named(Integer.toString(i)), i); Assert.assertEquals("with() did not return this instance.", builder, result); } TestConfig c = builder.build(); for (int i = 0; i < propertyCount; i++) { val p = Property.<Integer>named(Integer.toString(i)); val actual = c.getProperties().getInt(p); Assert.assertEquals("Unexpected value in result.", i, actual); } }
Example 9
Source Project: herd Source File: BusinessObjectDefinitionServiceTest.java License: Apache License 2.0 | 6 votes |
@Test public void testGetBusinessObjectDefinitionsLowerCaseParameters() { // Create and persist business object definition entities. for (BusinessObjectDefinitionKey key : businessObjectDefinitionDaoTestHelper.getTestBusinessObjectDefinitionKeys()) { businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(key.getNamespace(), key.getBusinessObjectDefinitionName(), DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_ATTRIBUTES); } // Retrieve a list of business object definition keys for the specified namespace using lower case namespace value. BusinessObjectDefinitionKeys resultKeys = businessObjectDefinitionService.getBusinessObjectDefinitions(NAMESPACE.toLowerCase()); // Validate the returned object. assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeysForNamespace(), resultKeys.getBusinessObjectDefinitionKeys()); }
Example 10
Source Project: BioSolr Source File: TestCombinations.java License: Apache License 2.0 | 6 votes |
@Test public void testHetero() { List<Foo> A_36 = Foo.range("A", 3, 6); List<Foo> A_48 = Foo.range("A", 4, 8); List<Foo> B_17 = Foo.range("B", 1, 7); // so, different types shouldn't get mingled List<Foo> A_36_B_17 = Foo.range("A", 3, 6); A_36_B_17.addAll(Foo.range("B", 1, 7)); assertEquals(A_36_B_17, toList(Combinations.or(A_36.iterator(), B_17.iterator()))); assertEquals(0, toList(Combinations.and(A_36.iterator(), B_17.iterator())).size()); // but check that the same type does List<Foo> A_38 = Foo.range("A", 3, 8); assertEquals(A_38, toList(Combinations.or(A_36.iterator(), A_48.iterator()))); Iterator<Foo> A_or_B = Combinations.or(A_48.iterator(), B_17.iterator()); assertEquals(3, toList(Combinations.and(A_36.iterator(), A_or_B)).size()); }
Example 11
Source Project: tutorials Source File: CustomerRestControllerUnitTest.java License: MIT License | 6 votes |
@Test public void givenExistingCustomer_whenPatched_thenReturnPatchedCustomer() throws Exception { Map<String, Boolean> communicationPreferences = new HashMap<>(); communicationPreferences.put("post", true); communicationPreferences.put("email", true); Customer customer = new Customer("1", "001-555-1234", asList("Milk", "Eggs"), communicationPreferences); given(mockCustomerService.findCustomer("1")).willReturn(of(customer)); String patchInstructions = "[{\"op\":\"replace\",\"path\": \"/telephone\",\"value\":\"001-555-5678\"}]"; mvc.perform(patch("/customers/1") .contentType(APPLICATION_JSON_PATCH_JSON) .content(patchInstructions)) .andExpect(status().isOk()) .andExpect(jsonPath("$.id", is("1"))) .andExpect(jsonPath("$.telephone", is("001-555-5678"))) .andExpect(jsonPath("$.favorites", is(asList("Milk", "Eggs")))) .andExpect(jsonPath("$.communicationPreferences", is(communicationPreferences))); }
Example 12
Source Project: activemq-artemis Source File: WildCardRoutingTest.java License: Apache License 2.0 | 6 votes |
@Test public void testWildcardRoutingHashAndStar() throws Exception { SimpleString addressAB = new SimpleString("a.b.c"); SimpleString addressAC = new SimpleString("a.c"); SimpleString address = new SimpleString("#.b.*"); SimpleString queueName1 = new SimpleString("Q1"); SimpleString queueName2 = new SimpleString("Q2"); SimpleString queueName = new SimpleString("Q"); clientSession.createQueue(new QueueConfiguration(queueName1).setAddress(addressAB).setDurable(false)); clientSession.createQueue(new QueueConfiguration(queueName2).setAddress(addressAC).setDurable(false)); clientSession.createQueue(new QueueConfiguration(queueName).setAddress(address).setDurable(false)); ClientProducer producer = clientSession.createProducer(addressAB); ClientProducer producer2 = clientSession.createProducer(addressAC); ClientConsumer clientConsumer = clientSession.createConsumer(queueName); clientSession.start(); producer.send(createTextMessage(clientSession, "m1")); producer2.send(createTextMessage(clientSession, "m2")); ClientMessage m = clientConsumer.receive(500); Assert.assertNotNull(m); Assert.assertEquals("m1", m.getBodyBuffer().readString()); m.acknowledge(); m = clientConsumer.receiveImmediate(); Assert.assertNull(m); }
Example 13
Source Project: camunda-bpm-platform Source File: ProcessDefinitionRestServiceInteractionTest.java License: Apache License 2.0 | 6 votes |
@Test public void testActivateProcessDefinitionThrowsAuthorizationException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); String message = "expected exception"; doThrow(new AuthorizationException(message)).when(repositoryServiceMock).activateProcessDefinitionById(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, false, null); given() .pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID) .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.FORBIDDEN.getStatusCode()) .body("type", is(AuthorizationException.class.getSimpleName())) .body("message", is(message)) .when() .put(SINGLE_PROCESS_DEFINITION_SUSPENDED_URL); }
Example 14
Source Project: j2objc Source File: PluralRulesTest.java License: Apache License 2.0 | 6 votes |
@Test public void testSamples() { String description = "one: n is 3 or f is 5 @integer 3,19, @decimal 3.50 ~ 3.53, …; other: @decimal 99.0~99.2, 999.0, …"; PluralRules test = PluralRules.createRules(description); checkNewSamples(description, test, "one", PluralRules.SampleType.INTEGER, "@integer 3, 19", true, new FixedDecimal(3)); checkNewSamples(description, test, "one", PluralRules.SampleType.DECIMAL, "@decimal 3.50~3.53, …", false, new FixedDecimal(3.5, 2)); checkOldSamples(description, test, "one", SampleType.INTEGER, 3d, 19d); checkOldSamples(description, test, "one", SampleType.DECIMAL, 3.5d, 3.51d, 3.52d, 3.53d); checkNewSamples(description, test, "other", PluralRules.SampleType.INTEGER, "", true, null); checkNewSamples(description, test, "other", PluralRules.SampleType.DECIMAL, "@decimal 99.0~99.2, 999.0, …", false, new FixedDecimal(99d, 1)); checkOldSamples(description, test, "other", SampleType.INTEGER); checkOldSamples(description, test, "other", SampleType.DECIMAL, 99d, 99.1, 99.2d, 999d); }
Example 15
Source Project: ghidra Source File: CreateDataCmdTest.java License: Apache License 2.0 | 6 votes |
@Test public void testCreateString() { Address addr = addr(STRING_AREA); CreateDataCmd cmd = new CreateDataCmd(addr, new StringDataType()); cmd.applyTo(program); Data d = listing.getDataAt(addr); assertNotNull(d); assertTrue(d.isDefined()); assertTrue(d.getDataType() instanceof StringDataType); assertEquals(5, d.getLength());// "notepad.chm",00 d = listing.getDataAt(addr(STRING_AREA + 12)); assertNotNull(d); assertTrue(!d.isDefined()); }
Example 16
Source Project: astor Source File: FastSineTransformerTest.java License: GNU General Public License v2.0 | 6 votes |
/** * Test of transformer for the sine function. */ @Test public void testSinFunction() { UnivariateFunction f = new Sin(); FastSineTransformer transformer; transformer = new FastSineTransformer(DstNormalization.STANDARD_DST_I); double min, max, result[], tolerance = 1E-12; int N = 1 << 8; min = 0.0; max = 2.0 * FastMath.PI; result = transformer.transform(f, min, max, N, TransformType.FORWARD); Assert.assertEquals(N >> 1, result[2], tolerance); for (int i = 0; i < N; i += (i == 1 ? 2 : 1)) { Assert.assertEquals(0.0, result[i], tolerance); } min = -FastMath.PI; max = FastMath.PI; result = transformer.transform(f, min, max, N, TransformType.FORWARD); Assert.assertEquals(-(N >> 1), result[2], tolerance); for (int i = 0; i < N; i += (i == 1 ? 2 : 1)) { Assert.assertEquals(0.0, result[i], tolerance); } }
Example 17
Source Project: firebase-android-sdk Source File: RemoteSerializerTest.java License: Apache License 2.0 | 6 votes |
@Test public void testEncodesLimits() { Query q = Query.atPath(ResourcePath.fromString("docs")).limitToFirst(26); Target actual = serializer.encodeTarget(wrapTargetData(q)); StructuredQuery.Builder structuredQueryBuilder = StructuredQuery.newBuilder() .addFrom(CollectionSelector.newBuilder().setCollectionId("docs")) .addOrderBy(defaultKeyOrder()) .setLimit(Int32Value.newBuilder().setValue(26)); QueryTarget.Builder queryBuilder = QueryTarget.newBuilder() .setParent("projects/p/databases/d/documents") .setStructuredQuery(structuredQueryBuilder); Target expected = Target.newBuilder() .setQuery(queryBuilder) .setTargetId(1) .setResumeToken(ByteString.EMPTY) .build(); assertEquals(expected, actual); assertEquals( serializer.decodeQueryTarget(serializer.encodeQueryTarget(q.toTarget())), q.toTarget()); }
Example 18
Source Project: snowflake-jdbc Source File: PreparedStatement2IT.java License: Apache License 2.0 | 6 votes |
/** * SNOW-31746 */ @Test public void testConstOptLimitBind() throws SQLException { try (Connection connection = init()) { String stmtStr = "select 1 limit ? offset ?"; try (PreparedStatement prepStatement = connection.prepareStatement(stmtStr)) { prepStatement.setInt(1, 10); prepStatement.setInt(2, 0); try (ResultSet resultSet = prepStatement.executeQuery()) { resultSet.next(); assertThat(resultSet.getInt(1), is(1)); assertThat(resultSet.next(), is(false)); } } } }
Example 19
Source Project: ssj Source File: EmpaticaTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public void testBVP() throws Exception { Pipeline frame = Pipeline.getInstance(); Empatica empatica = new Empatica(); empatica.options.apiKey.set(APIKEY); BVPChannel data = new BVPChannel(); frame.addSensor(empatica, data); Logger dummy = new Logger(); frame.addConsumer(dummy, data, 0.1, 0); frame.start(); // Wait duration try { Thread.sleep(TestHelper.DUR_TEST_SHORT); } catch (Exception e) { e.printStackTrace(); } frame.stop(); Log.i("BVP test finished"); }
Example 20
Source Project: conjure Source File: ServiceDefinitionTests.java License: Apache License 2.0 | 5 votes |
@Test public void testParseEnum_withObjectDocs() throws IOException { assertThat(mapper.readValue( multiLineString("docs: Test", "values:", " - A", " - B"), BaseObjectTypeDefinition.class)) .isEqualTo(EnumTypeDefinition.builder() .addValues(EnumValueDefinition.builder().value("A").build()) .addValues(EnumValueDefinition.builder().value("B").build()) .docs("Test") .build()); }
Example 21
Source Project: sso Source File: MailTest.java License: MIT License | 5 votes |
@Test public void connect() { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(mail); message.setTo(mail); //自己给自己发送邮件 message.setSubject("主题:测试邮件"); message.setText("测试邮件内容"); //可以进行测试 // mailSender.send(message); }
Example 22
Source Project: astor Source File: ClassImposterizerTest.java License: GNU General Public License v2.0 | 5 votes |
@Test public void shouldMocksHaveDifferentInterceptors() throws Exception { SomeClass mockOne = ClassImposterizer.INSTANCE.imposterise(new MethodInterceptorStub(), SomeClass.class); SomeClass mockTwo = ClassImposterizer.INSTANCE.imposterise(new MethodInterceptorStub(), SomeClass.class); Factory cglibFactoryOne = (Factory) mockOne; Factory cglibFactoryTwo = (Factory) mockTwo; assertNotSame(cglibFactoryOne.getCallback(0), cglibFactoryTwo.getCallback(0)); }
Example 23
Source Project: unity-ads-android Source File: MetaDataTest.java License: Apache License 2.0 | 5 votes |
@Test public void testMetaDataBaseClassNoCategoryDiskWrite () throws Exception { MetaData metaData = new MetaData(ClientProperties.getApplicationContext()); metaData.set("test.one", 1); metaData.set("test.two", "2"); metaData.set("test.three", 123.123); metaData.set("testNumber", 12345); metaData.commit(); MetaData metaData2 = new MetaData(ClientProperties.getApplicationContext()); metaData2.set("testNumber", 23456); metaData2.set("test.four", 4); metaData2.commit(); Storage storage = StorageManager.getStorage(StorageManager.StorageType.PUBLIC); storage.clearData(); storage.readStorage(); JSONObject keysFromStorage = (JSONObject)storage.get("test"); JSONObject storageFourObject = keysFromStorage.getJSONObject("four"); assertEquals("Incorrect 'four' value", storageFourObject.getInt("value"), 4); assertNotNull("Timestamp for 'three' is null", storageFourObject.getLong("ts")); JSONObject storageOneObject = keysFromStorage.getJSONObject("one"); assertEquals("Incorrect 'one' value", storageOneObject.getInt("value"), 1); assertNotNull("Timestamp for 'one' is null", storageOneObject.getLong("ts")); JSONObject storageTwoObject = keysFromStorage.getJSONObject("two"); assertEquals("Incorrect 'two' value", storageTwoObject.getString("value"), "2"); assertNotNull("Timestamp for 'two' is null", storageTwoObject.getLong("ts")); JSONObject storageThreeObject = keysFromStorage.getJSONObject("three"); assertEquals("Incorrect 'three' value", storageThreeObject.getDouble("value"), 123.123, 0); assertNotNull("Timestamp for 'three' is null", storageThreeObject.getLong("ts")); JSONObject storageTestNumberObject2 = (JSONObject)storage.get("testNumber"); assertEquals("Incorrect 'testNumber' second set value", 23456, storageTestNumberObject2.getInt("value")); assertNotNull("Timestamp for 'testNumber' second set is null", storageTestNumberObject2.getLong("ts")); }
Example 24
Source Project: api-layer Source File: EurekaMetadataParserTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void generateFullMetadata() { String serviceId = "test service"; String gatewayUrl = "api/v1"; String version = "1.0.0"; String swaggerUrl = "https://service/api-doc"; String documentationUrl = "https://www.zowe.org"; String metadataPrefix = API_INFO + ".api-v1."; ApiInfo apiInfo = new ApiInfo("org.zowe", gatewayUrl, version, swaggerUrl, documentationUrl); Map<String, String> metadata = EurekaMetadataParser.generateMetadata(serviceId, apiInfo); String metaVersion = metadata.get(metadataPrefix + API_INFO_VERSION); assertNotNull(metaVersion); assertEquals(version, metaVersion); String metaGatewayUrl = metadata.get(metadataPrefix + API_INFO_GATEWAY_URL); assertNotNull(metaGatewayUrl); assertEquals(gatewayUrl, metaGatewayUrl); String metaSwaggerUrl = metadata.get(metadataPrefix + API_INFO_SWAGGER_URL); assertNotNull(metaSwaggerUrl); assertEquals(swaggerUrl, metaSwaggerUrl); String metaDocumentationUrl = metadata.get(metadataPrefix + API_INFO_DOCUMENTATION_URL); assertNotNull(metaDocumentationUrl); assertEquals(documentationUrl, metaDocumentationUrl); }
Example 25
Source Project: aion Source File: RequestTrieDataTest.java License: MIT License | 5 votes |
@Test public void testEncode_differentType() { byte[] encoding = RLP.encodeList( RLP.encodeElement(nodeKey), RLP.encodeString(STATE.toString()), RLP.encodeInt(Integer.MAX_VALUE)); RequestTrieData message = new RequestTrieData(nodeKey, STORAGE, Integer.MAX_VALUE); assertThat(message.encode()).isNotEqualTo(encoding); }
Example 26
Source Project: bluima Source File: PubmedXmlParserTest.java License: Apache License 2.0 | 5 votes |
@Test public void testParsePubmedXmls() throws Exception { InputStream is = ResourceHelper .getInputStream("pubmed_abstracts/medline13n0787.xml"); List<MedlineCitation> arts = new PubmedXmlParser().parseAsArticles(is); assertEquals(3, arts.size()); assertEquals( "An unusual clinical manifestation in a factor IX deficient patient: orbital haemorrhage without trauma.", arts.get(0).getArticle().getArticleTitle().getvalue()); assertEquals("23419111", arts.get(0).getPMID().getvalue()); }
Example 27
Source Project: astor Source File: RealVectorFormatAbstractTest.java License: GNU General Public License v2.0 | 5 votes |
@Test public void testNonDefaultSetting() { ArrayRealVector c = new ArrayRealVector(new double[] {1, 1, 1}); String expected = "[1 : 1 : 1]"; String actual = realVectorFormatSquare.format(c); Assert.assertEquals(expected, actual); }
Example 28
Source Project: wildfly-core Source File: AutoIgnoredResourcesDomainTestCase.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Test public void test03_AddServerGroupAndServerConfigPullsDownDataFromDc() throws Exception { ModelNode addGroupOp = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP, "testgroup"))); addGroupOp.get(PROFILE).set(PROFILE3); addGroupOp.get(SOCKET_BINDING_GROUP).set(SOCKETS3); validateResponse(masterClient.execute(addGroupOp), false); //New data should not be pushed yet since nothing on the slave uses it checkSlaveProfiles(PROFILE2, ROOT_PROFILE2); checkSlaveExtensions(EXTENSION_LOGGING); checkSlaveServerGroups(GROUP2); checkSlaveSocketBindingGroups(SOCKETSA, SOCKETS2, ROOT_SOCKETS2); checkSystemProperties(0); Assert.assertEquals("running", getSlaveServerStatus(SERVER1)); ModelNode addConfigOp = Util.createAddOperation(PathAddress.pathAddress(getSlaveServerConfigAddress("testserver"))); addConfigOp.get(GROUP).set("testgroup"); validateResponse(slaveClient.execute(addConfigOp), false); //Now that we have a group using the new data it should be pulled down checkSlaveProfiles(PROFILE2, PROFILE3, ROOT_PROFILE2); checkSlaveExtensions(EXTENSION_LOGGING, EXTENSION_JMX); checkSlaveServerGroups(GROUP2, "testgroup"); checkSlaveSocketBindingGroups(SOCKETSA, SOCKETS2, SOCKETS3, ROOT_SOCKETS2); checkSystemProperties(0); Assert.assertEquals("running", getSlaveServerStatus(SERVER1)); }
Example 29
Source Project: totallylazy Source File: JsonTest.java License: Apache License 2.0 | 5 votes |
@Test public void handlesSpecialCharacters() throws Exception { String result = Json.json(map("text", "first line\n second line λ")); assertThat(result, is("{\"text\":\"first line\\n second line λ\"}")); Map<String, Object> parsed = Json.map(result); assertThat((String) parsed.get("text"), is("first line\n second line λ")); Map<String, Object> parsedWithUnicode = Json.map("{\"text\":\"first line\\n second line \\u03BB\"}"); assertThat((String) parsedWithUnicode.get("text"), is("first line\n second line λ")); }
Example 30
Source Project: beam Source File: FileBasedSourceTest.java License: Apache License 2.0 | 5 votes |
@Test public void testReadRangeFromFileWithSplitsFromMiddle() throws IOException { PipelineOptions options = PipelineOptionsFactory.create(); String header = "<h>"; List<String> data = new ArrayList<>(); for (int i = 0; i < 10; i++) { data.add(header); data.addAll(createStringDataset(3, 9)); } String fileName = "file"; File file = createFileWithData(fileName, data); Metadata metadata = FileSystems.matchSingleFileSpec(file.getPath()); TestFileBasedSource source1 = new TestFileBasedSource(metadata, 64, 0, 42, header); TestFileBasedSource source2 = new TestFileBasedSource(metadata, 64, 42, 112, header); TestFileBasedSource source3 = new TestFileBasedSource(metadata, 64, 112, Long.MAX_VALUE, header); List<String> expectedResults = new ArrayList<>(); expectedResults.addAll(data); // Remove all occurrences of header from expected results. expectedResults.removeAll(Collections.singletonList(header)); List<String> results = new ArrayList<>(); results.addAll(readFromSource(source1, options)); results.addAll(readFromSource(source2, options)); results.addAll(readFromSource(source3, options)); assertThat(expectedResults, containsInAnyOrder(results.toArray())); }