问题标签 [spring-junit]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
spring-ws - 用于 Spring WebServiceTemplate 的 JUnit 不起作用
我正在使用 Spring WebServiceTemplate 使用 SOAP Webservice。在执行 JUnit 时,我遇到了一个问题。
我的客户类:
我的测试课:
问题:
当我执行我的测试用例时,我的客户端类中的“webServiceTemplate.marshalSendAndReceive(request)”行出现 NullPointerException。
webServiceTemplate 即将为空。
知道我做错了什么吗?
spring-mvc - Spring StandaloneMockMvcBuilder 无法解析被测控制器中的动态 RequestMapping
我们有具有动态请求映射的控制器:
这些请求映射是通过 spring 环境中的属性文件解析的。
现在,在我们的 SpringJUnit4ClassRunner 测试类的 setup 方法中,我们尝试 mockmvc:
但是 MockMvcBuilder 无法解析value = "${api.emailverification.officialvalidate.POST.uri}"
,尽管 Spring 环境中存在 Properties 文件。下面是实际代码:
控制器方法:
Junit类:
spring-test - 无法使用 MockWebServiceServer 设置多个期望
我正在使用 MockWebServiceServer 来测试 REST API。我使用@Runwith(Parameterized.class) 将值传递给它。
当我只有 1 个输入时,代码工作正常。
但是当我有多个输入时它会抛出异常。
我正在使用 Spring 3.2。我想用多个输入测试我的 api。
spring - 无法在 Spring Junits 中为事务打开 JDBC 连接
Spring junit 在 Maven 构建期间失败。如果我单独运行每个测试用例,它工作正常。如果我批量运行,那么只有我收到以下错误。Spring 版本是 4.3.0,Junit 版本是 4.12
例外:
原因:java.sql.SQLException:侦听器拒绝连接并出现以下错误:ORA-12520,TNS:侦听器找不到请求的服务器类型的可用处理程序
java - ClassFormatError ServletException Maven项目错误
我有一个 Maven 项目,它有一个测试类:
该项目以“mvn clean install”运行抛出错误:
尝试了很多东西,但仍然无法正常工作,有什么想法吗?
这是 pom.xml 的相关依赖项:
以及来自父 pom.xml 的依赖项
插件:
尝试了许多选项,删除了测试范围等提供的所有选项,但仍然出现相同的错误。
java - 带有@RunWith(SpringJUnit4ClassRunner.class) 的配置文件
我的 TestSuite 有两种配置,它们为注入提供了不同的 bean。只要我使用注释设置我的个人资料,这就会起作用。
@ActiveProfiles( profiles={"a"})
和@ActiveProfiles( profiles={"b"})
但我似乎无法从属性源文件中设置它
我的注释看起来像
的内容application.properties
是
结果导致不满意的依赖
正如上面提到的设置@ActiveProfiles
一样,并且使用了正确的被使用。
几乎就好像 PropertySource 和/或 TestPropertySource 不适用@RunWith(SpringJUnit4ClassRunner.class)
spring-boot - 如何在 Spring Boot 应用程序中构建 jar 文件时禁用自动测试运行?
我已经为我的所有存储库和实体创建了 Spring Boot 应用程序。我需要在构建 jar 文件时禁用自动测试运行,因为这些存储库指向不同的数据库。任何人都可以在这里帮助我吗?谢谢。
spring - SpringBoot JPA 测试 bean 不在上下文中
我无法弄清楚..出于某种原因,Spring Junit 没有将我的 bean 添加到上下文中。求救!!
原因:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“com.api.demo.store.FileStorage”类型的合格bean:预计至少有1个有资格作为自动装配候选者的bean。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=com.api.demo.store.FileStorageMemDB)} at org .springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support .DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) 在 org.springframework.beans。
java - 预期的单个匹配 bean,但发现 3:junitTest 中的 objectMapper、halObjectMapper、_halObjectMapper
我的测试有问题。我正在使用 java spring 并尝试运行 junit test 来检查我的服务器是否还活着。
这是我正在尝试的测试:
这是我的 newtest 类正在扩展的 AbstractTestController 类:
我的配置:
这是我得到的完整错误:
希望它有助于解决我的问题。到目前为止,我尝试将 @Primary 放在制作 ObjectMapper 的 Bean 上或添加那些注释 @Order @ConditionalOnMissingBean 但它没有用......谢谢
java - junit没有找到webapplication上下文:没有注册ContextLoad Listener?
我正在尝试为我的结构应用程序编写测试用例,其中基于 springs 的 xml 文件中的一些配置。我将所有 applicationContext 文件移动到 src/test/resources 类路径中,但是当我运行我的测试类(RunAs-> Junit Test)时,它会抛出以下错误