- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.exists()
方法的一些代码示例,展示了XpathResultMatchers.exists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XpathResultMatchers.exists()
方法的具体详情如下:
包路径:org.springframework.test.web.servlet.result.XpathResultMatchers
类名称:XpathResultMatchers
方法名:exists
[英]Evaluate the XPath and assert that content exists.
[中]评估XPath并断言内容存在。
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testExists() throws Exception {
String composer = "/ns:people/composers/composer[%s]";
String performer = "/ns:people/performers/performer[%s]";
this.mockMvc.perform(get("/music/people"))
.andExpect(xpath(composer, musicNamespace, 1).exists())
.andExpect(xpath(composer, musicNamespace, 2).exists())
.andExpect(xpath(composer, musicNamespace, 3).exists())
.andExpect(xpath(composer, musicNamespace, 4).exists())
.andExpect(xpath(performer, musicNamespace, 1).exists())
.andExpect(xpath(performer, musicNamespace, 2).exists())
.andExpect(xpath(composer, musicNamespace, 1).node(notNullValue()));
}
代码示例来源:origin: spring-projects/spring-framework
@Test(expected = AssertionError.class)
public void existsNoMatch() throws Exception {
new XpathResultMatchers("/foo/Bar", null).exists().match(getStubMvcResult());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void exists() throws Exception {
new XpathResultMatchers("/foo/bar", null).exists().match(getStubMvcResult());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void testExternalizedBranding(@Autowired MockMvc mockMvc) throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/login"))
.andExpect(xpath("//head/link[@rel='shortcut icon']/@href").string("//cdn.example.com/pivotal/images/square-logo.png"))
.andExpect(xpath("//head/link[@href='//cdn.example.com/pivotal/stylesheets/application.css']").exists())
.andExpect(xpath("//head/style[text()[contains(.,'//cdn.example.com/pivotal/images/product-logo.png')]]").exists());
}
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void testDefaultBranding() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/login"))
.andExpect(xpath("//head/link[@rel='shortcut icon']/@href").string("/resources/oss/images/square-logo.png"))
.andExpect(xpath("//head/link[@href='/resources/oss/stylesheets/application.css']").exists())
.andExpect(xpath("//head/style[text()[contains(.,'/resources/oss/images/product-logo.png')]]").exists());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void testSignupsAndResetPasswordEnabled() throws Exception {
MockMvcUtils.setSelfServiceLinksEnabled(webApplicationContext, getUaa().getId(), true);
mockMvc.perform(MockMvcRequestBuilders.get("/login"))
.andExpect(xpath("//a[text()='Create account']").exists())
.andExpect(xpath("//a[text()='Reset password']").exists());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void testLoginWithAnalytics(@Autowired MockMvc mockMvc) throws Exception {
mockMvc.perform(get("/login").accept(TEXT_HTML))
.andExpect(status().isOk())
.andExpect(xpath("//body/script[contains(text(),'example.com')]").exists());
}
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void tilesFromClientMetadataAndTilesConfigShown() throws Exception {
mockMvc.perform(get("/"))
.andExpect(xpath("//*[@id='tile-1'][text()[contains(.,'client-1')]]").exists())
.andExpect(xpath("//*[@class='tile-1']/@href").string("http://app.launch/url"))
.andExpect(xpath("//head/style[2]").string(".tile-1 .tile-icon {background-image: url(\"data:image/png;base64," + base64EncodedImg + "\")}"))
.andExpect(xpath("//*[@id='tile-2'][text()[contains(.,'Client 2 Name')]]").exists())
.andExpect(xpath("//*[@class='tile-2']/@href").string("http://second.url/"))
.andExpect(xpath("//*[@class='tile-3']").doesNotExist());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void tilesFromClientMetadataAndTilesConfigShown_forOtherZone() throws Exception {
IdentityZone identityZone = MultitenancyFixture.identityZone("test", "test");
IdentityZoneHolder.set(identityZone);
mockMvc.perform(get("/"))
.andExpect(xpath("//*[@id='tile-1'][text()[contains(.,'client-1')]]").exists())
.andExpect(xpath("//*[@class='tile-1']/@href").string("http://app.launch/url"))
.andExpect(xpath("//head/style[1]").string(".tile-1 .tile-icon {background-image: url(\"data:image/png;base64," + base64EncodedImg + "\")}"))
.andExpect(xpath("//*[@id='tile-2'][text()[contains(.,'Client 2 Name')]]").exists())
.andExpect(xpath("//*[@class='tile-2']/@href").string("http://second.url/"))
.andExpect(xpath("//*[@class='tile-3']").doesNotExist());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testNewAccountPage() throws Exception {
mockMvc.perform(get("/create_account").param("client_id", "client-id").param("redirect_uri", "http://example.com/redirect"))
.andExpect(status().isOk())
.andExpect(model().attribute("client_id", "client-id"))
.andExpect(model().attribute("redirect_uri", "http://example.com/redirect"))
.andExpect(view().name("accounts/new_activation_email"))
.andExpect(xpath("//*[@type='hidden' and @value='client-id']").exists())
.andExpect(xpath("//*[@type='hidden' and @value='http://example.com/redirect']").exists());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testChangeEmailPage() throws Exception {
setupSecurityContext();
mockMvc.perform(get("/change_email").param("client_id", "client-id").param("redirect_uri", "http://example.com/redirect"))
.andExpect(status().isOk())
.andExpect(view().name("change_email"))
.andExpect(model().attribute("email", "user@example.com"))
.andExpect(model().attribute("client_id", "client-id"))
.andExpect(model().attribute("redirect_uri", "http://example.com/redirect"))
.andExpect(xpath("//*[@type='hidden' and @value='client-id']").exists())
.andExpect(xpath("//*[@type='hidden' and @value='http://example.com/redirect']").exists());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void idpDiscoveryPageDisplayed_IfFlagIsEnabled(
@Autowired IdentityZoneProvisioning identityZoneProvisioning
) throws Exception {
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
config.setIdpDiscoveryEnabled(true);
IdentityZone zone = setupZone(webApplicationContext, mockMvc, identityZoneProvisioning, generator, config);
mockMvc.perform(get("/login")
.header("Accept", TEXT_HTML)
.with(new SetServerNameRequestPostProcessor(zone.getSubdomain() + ".localhost")))
.andExpect(status().isOk())
.andExpect(view().name("idp_discovery/email"))
.andExpect(content().string(containsString("Sign in")))
.andExpect(xpath("//input[@name='email']").exists())
.andExpect(xpath("//div[@class='action']//a").string("Create account"))
.andExpect(xpath("//input[@name='commit']/@value").string("Next"));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void idpDiscoveryClientNameDisplayed_WithUTF8Characters(
@Autowired IdentityZoneProvisioning identityZoneProvisioning
) throws Exception {
String utf8String = "\u7433\u8D3A";
String clientName = "woohoo-" + utf8String;
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
config.setIdpDiscoveryEnabled(true);
IdentityZone zone = setupZone(webApplicationContext, mockMvc, identityZoneProvisioning, generator, config);
MockHttpSession session = new MockHttpSession();
String clientId = generator.generate();
BaseClientDetails client = new BaseClientDetails(clientId, "", "", "client_credentials", "uaa.none", "http://*.wildcard.testing,http://testing.com");
client.setClientSecret("secret");
client.addAdditionalInformation(ClientConstants.CLIENT_NAME, clientName);
MockMvcUtils.createClient(webApplicationContext, client, zone);
SavedRequest savedRequest = getSavedRequest(client);
session.setAttribute(SAVED_REQUEST_SESSION_ATTRIBUTE, savedRequest);
mockMvc.perform(get("/login")
.session(session)
.header("Accept", TEXT_HTML)
.with(new SetServerNameRequestPostProcessor(zone.getSubdomain() + ".localhost")))
.andExpect(status().isOk())
.andExpect(view().name("idp_discovery/email"))
.andExpect(content().string(containsString("Sign in to continue to " + clientName)))
.andExpect(xpath("//input[@name='email']").exists())
.andExpect(xpath("//div[@class='action']//a").string("Create account"))
.andExpect(xpath("//input[@name='commit']/@value").string("Next"));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
void passwordPageDisplayed_ifUaaIsFallbackIDPForEmailDomain(
@Autowired IdentityZoneProvisioning identityZoneProvisioning
) throws Exception {
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
config.setIdpDiscoveryEnabled(true);
IdentityZone zone = setupZone(webApplicationContext, mockMvc, identityZoneProvisioning, generator, config);
mockMvc.perform(post("/login/idp_discovery")
.header("Accept", TEXT_HTML)
.with(cookieCsrf())
.with(new SetServerNameRequestPostProcessor(zone.getSubdomain() + ".localhost"))
.param("email", "marissa@koala.com"))
.andExpect(status().isFound())
.andExpect(redirectedUrl("/login?discoveryPerformed=true&email=marissa%40koala.com"));
mockMvc.perform(get("/login?discoveryPerformed=true&email=marissa@koala.com")
.with(cookieCsrf())
.with(new SetServerNameRequestPostProcessor(zone.getSubdomain() + ".localhost"))
.header("Accept", TEXT_HTML))
.andExpect(view().name("idp_discovery/password"))
.andExpect(xpath("//input[@name='password']").exists())
.andExpect(xpath("//input[@name='username']/@value").string("marissa@koala.com"))
.andExpect(xpath("//div[@class='action pull-right']//a").string("Reset password"))
.andExpect(xpath("//input[@type='submit']/@value").string("Sign in"));
}
代码示例来源:origin: cloudfoundry/uaa
.andExpect(xpath("//a[text()='" + activeSamlIdentityProviderDefinition.getLinkText() + "']").exists())
.andExpect(xpath("//a[text()='" + inactiveSamlIdentityProviderDefinition.getLinkText() + "']").doesNotExist());
代码示例来源:origin: cloudfoundry/uaa
.andExpect(xpath("//a[text()='" + samlIdentityProviderDefinition.getLinkText() + "']").exists());
代码示例来源:origin: dschulten/hydra-java
@Test
public void testCreatesSimpleLinkForGetAffordanceWithoutRequestParams() throws Exception {
MvcResult result = this.mockMvc.perform(get("/events").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.TEXT_HTML))
.andExpect(xpath("//h:a[@href='http://localhost/events/1']", namespaces).exists())
.andExpect(xpath("//h:a[@href='http://localhost/events/2']", namespaces).exists())
.andReturn();
LOG.debug(result.getResponse()
.getContentAsString());
}
代码示例来源:origin: dschulten/hydra-java
@Test
public void testCreatesHtmlFormForPost() throws Exception {
MvcResult result = this.mockMvc.perform(get("/events").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.TEXT_HTML))
.andExpect(xpath("//h:form[@name='addEvent']/@action", namespaces).string("http://localhost/events"))
.andExpect(xpath("//h:form[@name='addEvent']/@method", namespaces).string("POST"))
.andExpect(xpath("//h:form[@name='addEvent']/h:div/h:select[@name='eventStatus']", namespaces).exists())
.andExpect(xpath("//h:form[@name='addEvent']/h:div/h:select[@name='typicalAgeRange']", namespaces)
.exists())
.andReturn();
LOG.debug(result.getResponse()
.getContentAsString());
}
代码示例来源:origin: dschulten/hydra-java
@Test
public void testCreatesHtmlFormForGet() throws Exception {
MvcResult result = this.mockMvc.perform(get("http://localhost/events").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.TEXT_HTML))
.andExpect(xpath("//h:form[@action='http://localhost/events' and @method='GET' and " +
"@name='findEventByName']", namespaces).exists())
// TODO: form name
.andExpect(xpath("//h:form[@action='http://localhost/events' and @method='GET' and " +
"@name='findEventByName']/h:div/h:input/@name",
namespaces).string("evtName"))
.andReturn();
LOG.debug(result.getResponse()
.getContentAsString());
}
代码示例来源:origin: dschulten/hydra-java
@Test
public void testCreatesInputFieldWithMinMaxNumber() throws Exception {
MvcResult result = this.mockMvc.perform(get("/events").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content()
.contentType(MediaType.TEXT_HTML))
.andExpect(xpath("//h:input[@name='reviewRating.ratingValue']", namespaces).exists())
.andExpect(xpath("//h:input[@name='reviewRating.ratingValue']/@type", namespaces).string("number"))
.andExpect(xpath("//h:input[@name='reviewRating.ratingValue']/@min", namespaces).string("1"))
.andExpect(xpath("//h:input[@name='reviewRating.ratingValue']/@max", namespaces).string("5"))
.andExpect(xpath("//h:input[@name='reviewRating.ratingValue']/@value", namespaces).string("3"))
.andReturn();
LOG.debug(result.getResponse()
.getContentAsString());
}
本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.doesNotExist()方法的一些代码示例,展示
本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.string()方法的一些代码示例,展示了Xpath
本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.()方法的一些代码示例,展示了XpathResult
本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.getDefinedEncoding()方法的一些代
本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.exists()方法的一些代码示例,展示了Xpath
我是一名优秀的程序员,十分优秀!