当使用带有webdriver的页面对象时,如何检查元素是否存在.
到目前为止,我这样做.
DefaultPage defaultPage = PageFactory.initElements(this.driver,
DefaultPage.class);
assertTrue(defaultPage.isUserCreateMenuLinkPresent());
Run Code Online (Sandbox Code Playgroud)
页面对象:
public class DefaultPage {
@FindBy(id = "link_i_user_create")
private WebElement userCreateMenuLink;
public boolean isUserCreateMenuLinkPresent() {
try {
this.userCreateMenuLink.getTagName();
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我无法相信这种尝试/捕获是人们应该这样做的方式.那么什么是更好的方法来检查元素是否退出(使用页面对象)?
是否有在Eclipse中关闭视图的快捷方式(而不是CTRL+ W关闭编辑器)?
我有一个在Glassfish 3.1.2集群上运行的JEE6应用程序.一个@Singleton Bean包含某种(readolny)缓存.用户可以按下GUI中的按钮,用数据库中的(更新的)内容更新缓存.
这在非集群环境中运行良好,但现在我们需要切换到集群.
所以我面临的问题是,当用户按下该更新按钮时,只更新其服务器节点中的Cache Singleton.我的问题是,让其他Singletons(在其他节点中)更新数据的最简单方法是什么?
我知道群集环境中的Singleton问题,但我的问题是针对Glassfish的(因为我希望有一些内置支持),另一个是用"Websphere"进行分类.我的问题是关于JEE6,另一个比JEE6旧.
在java中,什么是无法访问的对象?对象何时无法访问?在研究垃圾收集时,我无法理解这个概念.
任何人都可以提供任何想法吗?
今天我观察到maven的特性被settings.xml覆盖了pom.xml.
因为这只是观察,我不确定这是否完全正确.所以我找了参考或一些文章,但我没有找到关于覆盖在settings.xml和中使用相同名称定义的属性的行为的具体说明pom.xml.
也许有人可以提供参考部分的链接(我可能会忽略)或可靠的文章/博客?
我有一个带有两个上下文的Spring Web应用程序:一个(applicationContext)构建,ContextLoaderListener另一个(webContext)构建DispatcherServlet.
在applicationContext一个bean(org.springframework.security.authentication.DefaultAuthenticationEventPublisher)中,它触发spring上下文事件.
但是事件的接收器是在webContext.那个接收器没有得到这个事件.(如果将接收器用于测试目的,applicationContext那么它就会得到事件,但我不能这样做,因为我需要webContexts来实现它的功能.)
所以我的问题是,如何将事件与之结合applicationContext起来webContext?
当我编辑conf/context.xmlTomcat 7.0.34 的全局时,服务器似乎自动重启.我想避免AUTOMATIC重启,服务器应该使用"旧"配置运行,直到我手动重启.
所以我的问题是:当我conf/context.xml在Tomcat 7.0.34中更改全局时,如何避免AUTOMATIC重启?
我有一个独立应用程序,这个应用程序计算一个值(属性),然后启动一个Spring Context.我的问题是如何将该计算属性添加到spring上下文中,以便我可以像从属性文件(@Value("${myCalculatedProperty}"))中加载的属性一样使用它?
稍微说明一下
public static void main(final String[] args) {
String myCalculatedProperty = magicFunction();
AbstractApplicationContext appContext =
new ClassPathXmlApplicationContext("applicationContext.xml");
//How to add myCalculatedProperty to appContext (before starting the context)
appContext.getBean(Process.class).start();
}
Run Code Online (Sandbox Code Playgroud)
applicationContext.xml中:
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:*.properties" />
</bean>
<context:component-scan base-package="com.example.app"/>
Run Code Online (Sandbox Code Playgroud)
这是一个Spring 3.0应用程序.
我实现了自己的LowerCaseUsernamePasswordAuthenticationFilter,只是一个子类UsernamePasswordAuthenticationFilter.
但现在我的问题是,如何配置Spring安全性来使用此过滤器.
到目前为止我用过:
<security:http auto-config="true" use-expressions="true">
<security:form-login login-processing-url="/resources/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t" />
<security:logout logout-url="/resources/j_spring_security_logout" />
<security:intercept-url pattern="/**" access="isAuthenticated()" requires-channel="${cfma.security.channel}" />
</security:http>
Run Code Online (Sandbox Code Playgroud)
我是否真的auto-config需要手动配置所有过滤器? - 如果这是真的,有人可以提供一个例子吗?
添加简单的方法security:custom-filter:
<security:http ...>
<security:form-login login-processing-url="/resources/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t" />
<security:custom-filter ref="lowerCaseUsernamePasswordAuthenticationFilter" position="FORM_LOGIN_FILTER"/>
...
</security:http>
Run Code Online (Sandbox Code Playgroud)
确实导致该消息的异常:
配置问题:过滤bean
<lowerCaseUsernamePasswordAuthenticationFilter>和'Root bean:class [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter]; 范围=; 抽象= FALSE; lazyInit = FALSE; autowireMode = 0; dependencyCheck = 0; autowireCandidate = TRUE; 初级= FALSE; factoryBeanName = NULL; factoryMethodName = NULL; initMethodName = NULL; destroyMethodName = null'具有相同的'order'值.使用自定义过滤器时,请确保这些位置与默认过滤器不冲突. …