在XSLT 1.0中,如果我有这样的<xsl:variable>声明:
<xsl:variable name="ListeEcheances">
<bla/><bli/>
</xsl:variable>
Run Code Online (Sandbox Code Playgroud)
我怎么知道它是否空?甚至更好:我怎么知道它包含多少个标签?(我知道这里有2个标签,但我的真实代码有点复杂:))
<xsl:when test="$ListeEcheances=''">返回true(它不计算标签,只计算文本);
<xsl:when test="count($ListeEcheances/*) > 0"> 遗憾的是没有编译.
谢谢您的帮助.
我想使用Spring + JUnit + Mockito测试一个类,但我无法使其正常工作.
假设我的班级引用了一项服务:
@Controller
public class MyController
{
@Autowired
private MyService service;
@PostConstruct
public void init() {
service.whatever();
}
public void doSomething() {
service.create();
}
}
Run Code Online (Sandbox Code Playgroud)
此服务引用了一个存储库:
@Service
public class MyService {
@Autowired
private MyRepository repository;
public void whatever() {}
public void create() {
repository.save();
}
}
Run Code Online (Sandbox Code Playgroud)
在测试MyController类时,我希望模拟该服务.问题是:即使服务被模拟,Spring也会尝试在mock中注入存储库.
这就是我做的.测试类:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { MyControllerTestConfiguration.class })
public class MyControllerTest {
@Autowired
private MyController myController;
@Test
public void testDoSomething() {
myController.doSomething();
}
}
Run Code Online (Sandbox Code Playgroud)
配置类:
@Configuration
public class …Run Code Online (Sandbox Code Playgroud)