@Test public void testFallThrough() throws Exception { HandlerList list = new HandlerList(); _server.setHandler(list); ServletContextHandler root = new ServletContextHandler(list, "/", ServletContextHandler.SESSIONS); ServletHandler servlet = root.getServletHandler(); servlet.setEnsureDefaultServlet(false); servlet.addServletWithMapping(HelloServlet.class, "/hello/*"); list.addHandler( new AbstractHandler() { @Override public void handle( String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.sendError(404, "Fell Through"); } }); _server.start(); String response = _connector.getResponses("GET /hello HTTP/1.0\r\n\r\n"); Assert.assertThat(response, Matchers.containsString("200 OK")); response = _connector.getResponses("GET /other HTTP/1.0\r\n\r\n"); Assert.assertThat(response, Matchers.containsString("404 Fell Through")); }
@Test public void resolveHeadersBehindSymlinkTreesInPreprocessedOutput() throws IOException { BuckConfig buckConfig = new FakeBuckConfig(); CxxPlatform cxxPlatform = DefaultCxxPlatforms.build(new CxxBuckConfig(buckConfig)); ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "resolved", tmp); workspace.setUp(); workspace.writeContentsToPath("", "lib2.h"); BuildTarget target = BuildTargetFactory.newInstance("//:bin"); CxxSourceRuleFactory cxxSourceRuleFactory = CxxSourceRuleFactoryHelper.of(target, cxxPlatform); workspace.runBuckCommand("build", target.toString()).assertSuccess(); // Verify that the preprocessed source contains no references to the symlink tree used to // setup the headers. BuildTarget ppTarget = cxxSourceRuleFactory.createPreprocessBuildTarget( "bin.cpp", CxxSource.Type.CXX, CxxSourceRuleFactory.PicType.PDC); Path output = cxxSourceRuleFactory.getPreprocessOutputPath(ppTarget, CxxSource.Type.CXX, "bin.cpp"); String contents = workspace.getFileContents(output.toString()); assertThat(contents, Matchers.not(Matchers.containsString(BuckConstant.SCRATCH_DIR))); assertThat(contents, Matchers.not(Matchers.containsString(BuckConstant.GEN_DIR))); assertThat(contents, Matchers.containsString("# 1 \"bin.h")); assertThat(contents, Matchers.containsString("# 1 \"lib1.h")); assertThat(contents, Matchers.containsString("# 1 \"lib2.h")); }
@Test public void testCachedPut() throws Exception { HttpFields header = new HttpFields(); header.put("Connection", "Keep-Alive"); header.put("tRansfer-EncOding", "CHUNKED"); header.put("CONTENT-ENCODING", "gZIP"); ByteBuffer buffer = BufferUtil.allocate(1024); BufferUtil.flipToFill(buffer); HttpGenerator.putTo(header, buffer); BufferUtil.flipToFlush(buffer, 0); String out = BufferUtil.toString(buffer).toLowerCase(); Assert.assertThat( out, Matchers.containsString( (HttpHeader.CONNECTION + ": " + HttpHeaderValue.KEEP_ALIVE).toLowerCase())); Assert.assertThat( out, Matchers.containsString( (HttpHeader.TRANSFER_ENCODING + ": " + HttpHeaderValue.CHUNKED).toLowerCase())); Assert.assertThat( out, Matchers.containsString( (HttpHeader.CONTENT_ENCODING + ": " + HttpHeaderValue.GZIP).toLowerCase())); }
@Test public void testPOSTRequestNoContent() throws Exception { ByteBuffer header = BufferUtil.allocate(2048); HttpGenerator gen = new HttpGenerator(); HttpGenerator.Result result = gen.generateRequest(null, null, null, null, true); Assert.assertEquals(HttpGenerator.Result.NEED_INFO, result); Assert.assertEquals(HttpGenerator.State.START, gen.getState()); Info info = new Info("POST", "/index.html"); info.getFields().add("Host", "something"); info.getFields().add("User-Agent", "test"); Assert.assertTrue(!gen.isChunking()); result = gen.generateRequest(info, null, null, null, true); Assert.assertEquals(HttpGenerator.Result.NEED_HEADER, result); Assert.assertEquals(HttpGenerator.State.START, gen.getState()); result = gen.generateRequest(info, header, null, null, true); Assert.assertEquals(HttpGenerator.Result.FLUSH, result); Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState()); Assert.assertTrue(!gen.isChunking()); String out = BufferUtil.toString(header); BufferUtil.clear(header); result = gen.generateResponse(null, null, null, null, false); Assert.assertEquals(HttpGenerator.Result.DONE, result); Assert.assertEquals(HttpGenerator.State.END, gen.getState()); Assert.assertTrue(!gen.isChunking()); Assert.assertEquals(0, gen.getContentPrepared()); Assert.assertThat(out, Matchers.containsString("POST /index.html HTTP/1.1")); Assert.assertThat(out, Matchers.containsString("Content-Length: 0")); }
@Test public void testStateFileCanBeWritten() throws Exception { final MetricsLimiterStateManager out = new MetricsLimiterStateManager.Builder().setStateFile(STATE_FILE).build(_marks); out.writeState(); Assert.assertTrue(Files.exists(STATE_FILE)); final List<String> lines = Files.readAllLines(STATE_FILE, StandardCharsets.UTF_8); Assert.assertEquals(2, lines.size()); Assert.assertThat( lines, Matchers.allOf( Matchers.hasItem(Matchers.containsString(METRIC_A)), Matchers.hasItem(Matchers.containsString(METRIC_B)))); if (lines.get(0).contains(METRIC_A)) { Assert.assertThat(lines.get(0), Matchers.containsString(_time1AsString)); Assert.assertThat(lines.get(0), Matchers.containsString(" " + Integer.toString(6) + " ")); Assert.assertThat(lines.get(1), Matchers.containsString(_time2AsString)); Assert.assertThat(lines.get(1), Matchers.containsString(" " + Integer.toString(1) + " ")); } else { Assert.assertThat(lines.get(1), Matchers.containsString(_time1AsString)); Assert.assertThat(lines.get(1), Matchers.containsString(" " + Integer.toString(6) + " ")); Assert.assertThat(lines.get(0), Matchers.containsString(_time2AsString)); Assert.assertThat(lines.get(0), Matchers.containsString(" " + Integer.toString(1) + " ")); } }
@Test public void testRequestWithKnownContent() throws Exception { String out; ByteBuffer header = BufferUtil.allocate(4096); ByteBuffer chunk = BufferUtil.allocate(HttpGenerator.CHUNK_SIZE); ByteBuffer content0 = BufferUtil.toBuffer("Hello World. "); ByteBuffer content1 = BufferUtil.toBuffer("The quick brown fox jumped over the lazy dog."); HttpGenerator gen = new HttpGenerator(); HttpGenerator.Result result = gen.generateRequest(null, null, null, content0, false); Assert.assertEquals(HttpGenerator.Result.NEED_INFO, result); Assert.assertEquals(HttpGenerator.State.START, gen.getState()); Info info = new Info("POST", "/index.html", 58); info.getFields().add("Host", "something"); info.getFields().add("User-Agent", "test"); result = gen.generateRequest(info, null, null, content0, false); Assert.assertEquals(HttpGenerator.Result.NEED_HEADER, result); Assert.assertEquals(HttpGenerator.State.START, gen.getState()); result = gen.generateRequest(info, header, null, content0, false); Assert.assertEquals(HttpGenerator.Result.FLUSH, result); Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState()); Assert.assertTrue(!gen.isChunking()); out = BufferUtil.toString(header); BufferUtil.clear(header); out += BufferUtil.toString(content0); BufferUtil.clear(content0); result = gen.generateRequest(null, null, null, content1, false); Assert.assertEquals(HttpGenerator.Result.FLUSH, result); Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState()); Assert.assertTrue(!gen.isChunking()); out += BufferUtil.toString(content1); BufferUtil.clear(content1); result = gen.generateResponse(null, null, null, null, true); Assert.assertEquals(HttpGenerator.Result.CONTINUE, result); Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState()); Assert.assertTrue(!gen.isChunking()); result = gen.generateResponse(null, null, null, null, true); Assert.assertEquals(HttpGenerator.Result.DONE, result); Assert.assertEquals(HttpGenerator.State.END, gen.getState()); out += BufferUtil.toString(chunk); BufferUtil.clear(chunk); Assert.assertThat(out, Matchers.containsString("POST /index.html HTTP/1.1")); Assert.assertThat(out, Matchers.containsString("Host: something")); Assert.assertThat(out, Matchers.containsString("Content-Length: 58")); Assert.assertThat( out, Matchers.containsString( "\r\n\r\nHello World. The quick brown fox jumped over the lazy dog.")); Assert.assertEquals(58, gen.getContentPrepared()); }
private void assertCompDir(Path compDir, Optional<String> failure) throws Exception { ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot().toPath()); CxxPlatform platform = DefaultCxxPlatforms.build(new CxxBuckConfig(new FakeBuckConfig())); // Build up the paths to various files the archive step will use. ImmutableList<String> compiler = platform.getCc().getCommandPrefix(new SourcePathResolver(new BuildRuleResolver())); Path output = filesystem.resolve(Paths.get("output.o")); Path relativeInput = Paths.get("input.c"); Path input = filesystem.resolve(relativeInput); filesystem.writeContentsToPath("int main() {}", relativeInput); ImmutableList.Builder<String> preprocessorCommand = ImmutableList.builder(); preprocessorCommand.addAll(compiler); ImmutableList.Builder<String> compilerCommand = ImmutableList.builder(); compilerCommand.addAll(compiler); compilerCommand.add("-g"); DebugPathSanitizer sanitizer = new DebugPathSanitizer(200, File.separatorChar, compDir, ImmutableBiMap.<Path, Path>of()); // Build an archive step. CxxPreprocessAndCompileStep step = new CxxPreprocessAndCompileStep( CxxPreprocessAndCompileStep.Operation.COMPILE_MUNGE_DEBUGINFO, output, relativeInput, CxxSource.Type.C, Optional.of(preprocessorCommand.build()), Optional.of(compilerCommand.build()), ImmutableMap.<Path, Path>of(), sanitizer); // Execute the archive step and verify it ran successfully. ExecutionContext executionContext = TestExecutionContext.newBuilder() .setProjectFilesystem(new ProjectFilesystem(tmp.getRoot().toPath())) .build(); TestConsole console = (TestConsole) executionContext.getConsole(); int exitCode = step.execute(executionContext); if (failure.isPresent()) { assertNotEquals("compile step succeeded", 0, exitCode); assertThat( console.getTextWrittenToStdErr(), console.getTextWrittenToStdErr(), Matchers.containsString(failure.get())); } else { assertEquals("compile step failed: " + console.getTextWrittenToStdErr(), 0, exitCode); // Verify that we find the expected compilation dir embedded in the file. String contents = new String(Files.readAllBytes(output)); assertThat(contents, Matchers.containsString(sanitizer.getCompilationDirectory())); } // Cleanup. Files.delete(input); Files.deleteIfExists(output); }
/** * Facebook can generate a HATEOAS link. * * @throws Exception If there is some problem inside */ @Test public void generatesLink() throws Exception { final Resource resource = new ResourceMocker().mock(); final Provider.Visible provider = new Facebook(resource, "KEY", "SECRET"); MatcherAssert.assertThat( provider.link().getHref().toString(), Matchers.allOf( Matchers.containsString("client_id=KEY"), Matchers.containsString("rexsl-facebook"))); }
@Test @RedisAvailable @SuppressWarnings("unchecked") public void testInt3014ExpectMessageTrue() throws Exception { final String queueName = "si.test.redisQueueInboundChannelAdapterTests2"; RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); redisTemplate.setConnectionFactory(this.connectionFactory); redisTemplate.setEnableDefaultSerializer(false); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); redisTemplate.afterPropertiesSet(); Message<?> message = MessageBuilder.withPayload("testing").build(); redisTemplate.boundListOps(queueName).leftPush(message); redisTemplate.boundListOps(queueName).leftPush("test"); PollableChannel channel = new QueueChannel(); PollableChannel errorChannel = new QueueChannel(); RedisQueueMessageDrivenEndpoint endpoint = new RedisQueueMessageDrivenEndpoint(queueName, this.connectionFactory); endpoint.setBeanFactory(Mockito.mock(BeanFactory.class)); endpoint.setExpectMessage(true); endpoint.setOutputChannel(channel); endpoint.setErrorChannel(errorChannel); endpoint.setReceiveTimeout(1000); endpoint.afterPropertiesSet(); endpoint.start(); Message<Object> receive = (Message<Object>) channel.receive(2000); assertNotNull(receive); assertEquals(message, receive); receive = (Message<Object>) errorChannel.receive(2000); assertNotNull(receive); assertThat(receive, Matchers.instanceOf(ErrorMessage.class)); assertThat(receive.getPayload(), Matchers.instanceOf(MessagingException.class)); assertThat( ((Exception) receive.getPayload()).getMessage(), Matchers.containsString("Deserialization of Message failed.")); assertThat( ((Exception) receive.getPayload()).getCause(), Matchers.instanceOf(ClassCastException.class)); assertThat( ((Exception) receive.getPayload()).getCause().getMessage(), Matchers.containsString( "java.lang.String cannot be cast to org.springframework.messaging.Message")); endpoint.stop(); }
/** * Issue https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/307 Invisible input should not * render the surrounding markup */ @Test public void invisibleInput() { InputBehaviorPage page = new InputBehaviorPage(); page.textField.setVisible(false); tester().startPage(page); System.err.println("RES:\n\n" + tester().getLastResponseAsString()); assertThat(tester().getLastResponseAsString(), Matchers.not(Matchers.containsString("<div"))); assertThat(tester().getLastResponseAsString(), Matchers.not(Matchers.containsString("</div"))); }
@Test public void withHeightSizeWithoutColumnSize() { InputBehaviorPage page = new InputBehaviorPage(); page.inputBehavior.size(InputBehavior.Size.Large); tester().startPage(page); tester().assertContainsNot("<div class=\"col-"); TagTester tagTester = tester().getTagById("input"); String cssClass = tagTester.getAttribute("class"); assertThat(cssClass, Matchers.containsString("form-control")); assertThat(cssClass, Matchers.containsString("input-lg")); }
/** * Google can generate a HATEOAS link. * * @throws Exception If there is some problem inside */ @Test public void generatesLink() throws Exception { final Resource resource = new ResourceMocker() .withUriInfo(new UriInfoMocker().withBaseUri(new URI("/A")).mock()) .mock(); final Provider.Visible provider = new Google(resource, "KEY", "SECRET"); MatcherAssert.assertThat( provider.link().getHref().toString(), Matchers.allOf( Matchers.containsString("client_id=KEY"), Matchers.containsString("state=rexsl-google"), Matchers.containsString("redirect_uri=/A"))); }
@Test public void withHeightSizeWithColumnSize() { InputBehaviorPage page = new InputBehaviorPage(); page.inputBehavior.size(ExtraSmallSpanType.SPAN10); tester().startPage(page); TagTester tagTester = tester().getTagById("input"); String cssClass = tagTester.getAttribute("class"); assertThat(cssClass, Matchers.containsString("form-control")); assertThat(cssClass, Matchers.not(Matchers.containsString("input-lg"))); assertThat( tester().getLastResponseAsString(), Matchers.containsString("<div class=\"col-xs-10\"")); assertThat(tester().getLastResponseAsString(), Matchers.containsString("</div")); }
@Test public void platformCompilerFlags() throws IOException { ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "platform_compiler_flags", tmp); workspace.setUp(); workspace.writeContentsToPath("[cxx]\n cxxflags = -Wall -Werror", ".buckconfig"); workspace.runBuckBuild("//:binary_matches_default_exactly").assertSuccess(); workspace.runBuckBuild("//:binary_matches_default").assertSuccess(); ProjectWorkspace.ProcessResult result = workspace.runBuckBuild("//:binary_no_match"); result.assertFailure(); assertThat( result.getStderr(), Matchers.allOf(Matchers.containsString("non-void"), Matchers.containsString("function"))); workspace.runBuckBuild("//:binary_with_library_matches_default").assertSuccess(); }
@Test public void sessionIMChatAccept18() throws JsonGenerationException, JsonMappingException, IOException { Setup.startTest("Checking that User 4 has received composing notification"); RestAssured.authentication = RestAssured.DEFAULT_AUTH; String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.messageNotification[0].isComposing.refresh", Matchers.equalTo(60), "notificationList.messageNotification[0].isComposing.status", Matchers.equalTo("idle"), "notificationList.messageNotification[0].sessionId", Matchers.equalTo(receiveSessionID), "notificationList.messageNotification[0].senderAddress", Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact))) .post(url); System.out.println("Response = " + response.getStatusCode() + " / " + response.asString()); Setup.endTest(); }
@Test public void testImageInsertion() throws Exception { imageProvider.addImage(new ImageData("test", "/de/ks/images/keymap.jpg")); InsertImage command = adocEditor.getCommand(InsertImage.class); command.collectImages(); SelectImageController selectImageController = command.getSelectImageController(); for (Future<?> future : selectImageController.getLoadingFutures()) { future.get(); } activityController.waitForTasks(); FXPlatform.waitForFX(); assertEquals(1, selectImageController.getImagePane().getChildren().size()); FXPlatform.invokeLater( () -> { GridPane grid = (GridPane) command.getSelectImageController().getImagePane().getChildren().get(0); Button node = (Button) grid.getChildren().get(0); node.getOnAction().handle(null); }); assertThat( adocEditor.editor.getText(), Matchers.containsString("image::file:////de/ks/images/keymap.jpg")); }
@Test public void testArgsWithLocationMacroAffectDependenciesAndExpands() throws Exception { BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()); SourcePathResolver pathResolver = new SourcePathResolver(resolver); BuildRule shBinaryRule = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:my_exe")) .setMain(new FakeSourcePath("bin/exe")) .build(resolver); BuildRule exportFileRule = ExportFileBuilder.newExportFileBuilder(BuildTargetFactory.newInstance("//:file")) .setSrc(new FakeSourcePath("file.txt")) .build(resolver); WorkerToolBuilder workerToolBuilder = WorkerToolBuilder.newWorkerToolBuilder(BuildTargetFactory.newInstance("//:worker_rule")) .setExe(shBinaryRule.getBuildTarget()) .setArgs("--input $(location //:file)"); WorkerTool workerTool = (WorkerTool) workerToolBuilder.build(resolver); assertThat( workerToolBuilder.findImplicitDeps(), Matchers.hasItem(exportFileRule.getBuildTarget())); assertThat(workerTool.getDeps(), Matchers.hasItems(shBinaryRule, exportFileRule)); assertThat(workerTool.getRuntimeDeps(), Matchers.hasItems(shBinaryRule, exportFileRule)); assertThat( workerTool.getArgs(), Matchers.containsString( pathResolver .getAbsolutePath(new BuildTargetSourcePath(exportFileRule.getBuildTarget())) .toString())); }
@Test public void sessionIMChatAccept1A() { Setup.startTest("Checking IM notifications for user 4"); String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.chatSessionInvitationNotification", Matchers.notNullValue(), "notificationList.messageNotification.dateTime", Matchers.notNullValue(), "notificationList.messageNotification.messageId", Matchers.notNullValue(), "notificationList.messageNotification.senderAddress[0]", Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact))) .post(url); System.out.println( "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString()); JsonPath jsonData = notifications4.jsonPath(); receiveSessionURL = jsonData.getString("notificationList.chatSessionInvitationNotification[0].link[0].href"); System.out.println("Extracted receiveSessionURL=" + receiveSessionURL); receiveSessionID = jsonData.getString("notificationList.messageNotification.sessionId[0]"); System.out.println("Extracted receiveSessionID=" + receiveSessionID); receiveMessageID = jsonData.getString("notificationList.messageNotification.messageId[0]"); System.out.println("Extracted receiveMessageID=" + receiveMessageID); Setup.endTest(); }
@Test public void testWithAdditionalRequestHeader() { RequestHeader additionalRequestHeader = new RequestHeader(additionalHeaderName, UUID.randomUUID().toString()); MetaDataProviderBuilder builder = new MetaDataProviderBuilder("Ingenico"); if (isAllowed) { MetaDataProvider metaDataProvider = builder.withAdditionalRequestHeader(additionalRequestHeader).build(); Collection<RequestHeader> requestHeaders = metaDataProvider.getServerMetaDataHeaders(); Assert.assertEquals(2, requestHeaders.size()); Iterator<RequestHeader> requestHeaderIterator = requestHeaders.iterator(); RequestHeader requestHeader = requestHeaderIterator.next(); Assert.assertEquals("X-GCS-ServerMetaInfo", requestHeader.getName()); requestHeader = requestHeaderIterator.next(); Assert.assertThat(requestHeader, new RequestHeaderMatcher(additionalRequestHeader)); } else { try { builder.withAdditionalRequestHeader(additionalRequestHeader); Assert.fail("expected IllegalArgumentException"); } catch (IllegalArgumentException e) { Assert.assertThat(e.getMessage(), Matchers.containsString(additionalHeaderName)); } } }
@Test public void withoutHeightSizeWithColumnSize() { InputBehaviorPage page = new InputBehaviorPage(); page.inputBehavior.size(InputBehavior.Size.Small); page.inputBehavior.size(LargeScreenSpanType.SPAN11); tester().startPage(page); TagTester tagTester = tester().getTagById("input"); String cssClass = tagTester.getAttribute("class"); assertThat(cssClass, Matchers.containsString("form-control")); assertThat(cssClass, Matchers.containsString("input-sm")); assertThat( tester().getLastResponseAsString(), Matchers.containsString("<div class=\"col-lg-11\"")); assertThat(tester().getLastResponseAsString(), Matchers.containsString("</div")); }
@Test public void sessionIMChatAccept5() { Setup.startTest("Checking IM notifications for user 4"); String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.messageNotification[0].senderAddress", Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)), "notificationList.messageNotification[0].chatMessage.text", Matchers.equalTo("hello user4")) .post(url); System.out.println( "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString()); /* * {"notificationList":[{"messageNotification": * {"callbackData":"GSMA3","link": * [{"rel":"MessageStatusReport","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000004/oneToOne/tel%3A%2B15554000003/-797939895/messages/1352475373833-1790113032/status"}], * "dateTime":"2012-11-09T15:36:13Z","chatMessage":{"text":"hello user4"},"sessionId":"-797939895","messageId":"1352475373833-1790113032", * "senderAddress":"tel:+15554000003"}}]} */ try { Thread.sleep(1000); } catch (InterruptedException e) { } Setup.endTest(); }
/** * Test that filter style will return a style layer descriptor with correct feature type name and * geom. */ @Test public void testFilterStyle() throws Exception { final String nameFilter = "filterBob"; final String custodianFilter = "filterCustodian"; final String filterDateStart = "1986-10-09"; final String filterDateEnd = "1986-10-10"; final int maxFeatures = 10; final FilterBoundingBox bbox = null; String filter = service.getFilter( nameFilter, custodianFilter, filterDateStart, filterDateEnd, maxFeatures, bbox, null, null, null); String style = service.getStyle( Arrays.asList("style1"), Arrays.asList(filter), Arrays.asList("#2242c7"), null); Assert.assertNotNull(style); Assert.assertThat(style, Matchers.containsString("gsml:Borehole")); Assert.assertTrue(style.contains(service.getGeometryName())); }
@Test public void testTransaction() throws Exception { String retVal = ourCtx.newXmlParser().encodeBundleToString(new Bundle()); ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class); when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse); when(ourHttpResponse.getStatusLine()) .thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK")); when(ourHttpResponse.getEntity().getContentType()) .thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8")); when(ourHttpResponse.getEntity().getContent()) .thenReturn(new ReaderInputStream(new StringReader(retVal), Charset.forName("UTF-8"))); Patient p1 = new Patient(); p1.addIdentifier().setSystem("urn:system").setValue("value"); IGenericClient client = ourCtx.newRestfulGenericClient("http://foo"); client.transaction().withResources(Arrays.asList((IBaseResource) p1)).execute(); HttpUriRequest value = capt.getValue(); assertTrue("Expected request of type POST on long params list", value instanceof HttpPost); HttpPost post = (HttpPost) value; String body = IOUtils.toString(post.getEntity().getContent()); IOUtils.closeQuietly(post.getEntity().getContent()); ourLog.info(body); assertThat( body, Matchers.containsString("<type value=\"" + BundleTypeEnum.TRANSACTION.getCode())); }
/** * MkBase can start a bout and talk in it. * * @throws Exception If there is some problem inside */ @Test public void startsBoutAndTalks() throws Exception { final Messages messages = new MkBase().randomBout().messages(); messages.post("How are you doing?"); MatcherAssert.assertThat( messages.iterate(), Matchers.hasItem(new Message.HasText(Matchers.containsString("are you")))); }
/** * RtRepoCommits can compare two commits and return result in patch mode. * * @throws Exception if there is no github key provided */ @Test public final void compareCommitsPatch() throws Exception { final String patch = RtRepoCommitsITCase.repo().commits().patch("5339b8e35b", "9b2e6efde9"); MatcherAssert.assertThat( patch, Matchers.startsWith("From 9b2e6efde94fabec5876dc481b38811e8b4e992f")); MatcherAssert.assertThat( patch, Matchers.containsString("Issue #430 RepoCommit interface was added")); }
/** * PsCookie can add a cookie. * * @throws IOException If some problem inside */ @Test public void addsCookieToResponse() throws IOException { MatcherAssert.assertThat( new RsPrint( new PsCookie(new CcPlain(), "foo", 1L) .exit(new RsEmpty(), new Identity.Simple("urn:test:99"))) .print(), Matchers.containsString("Set-Cookie: foo=urn%3Atest%3A99;Path=/;HttpOnly;")); }
@Test public void replace_user_which_not_existing_raises_exception() { thrown.expect(NoResultException.class); thrown.expectMessage(Matchers.containsString("not found")); accessToken = OSIAM_CONNECTOR.retrieveAccessToken("marissa", "koala", Scope.ADMIN); UpdateUser patchedUser = new UpdateUser.Builder().build(); OSIAM_CONNECTOR.updateUser(NOT_EXISTING_ID, patchedUser, accessToken); }
@Test public void testPutTo() throws Exception { HttpFields header = new HttpFields(); header.put("name0", "value0"); header.put("name1", "value:A"); header.add("name1", "value:B"); header.add("name2", ""); ByteBuffer buffer = BufferUtil.allocate(1024); BufferUtil.flipToFill(buffer); HttpGenerator.putTo(header, buffer); BufferUtil.flipToFlush(buffer, 0); String result = BufferUtil.toString(buffer); assertThat(result, Matchers.containsString("name0: value0")); assertThat(result, Matchers.containsString("name1: value:A")); assertThat(result, Matchers.containsString("name1: value:B")); }
@Test public void accountDoesNotExist() throws InterruptedException { LoginPage loginPage = new LoginPage(driver); loginPage.getUrl("http://www.flipkart.com/account"); loginPage.setEmail("*****@*****.**"); loginPage.setPassword("Tartaruga011111111"); loginPage.clickLoginButton(); loginPage.waitForElement(ACCOUNT_DOES_NOT_EXIST); assertThat(loginPage.getErrorMessage(), Matchers.containsString(ACCOUNT_DOES_NOT_EXIST)); }
/** * Git can execute simple git command. * * @throws Exception If something is wrong */ @Test @org.junit.Ignore public void clonesSimpleGitRepository() throws Exception { final File key = this.temp.newFile(); FileUtils.writeStringToFile(key, ""); final File folder = this.temp.newFolder(); final Git git = new Git(key, folder); MatcherAssert.assertThat( git.exec(folder.getParentFile(), "init", this.temp.newFolder().getPath()), Matchers.containsString("Initialized empty Git repository")); }