我有一项服务,它返回多个 http 调用的 forkjoin。我想测试这个场景。
class CommentService{
addComments(){
let ob1 = Observable.of({});
let ob2 = Observable.of({});
if(any condition)
ob1 = {this.http.post('/url/1')};
if(any condition)
ob2 = {this.http.post('/url/2'};
return Observable.forkJoin(ob1,ob2)
}
}
Run Code Online (Sandbox Code Playgroud)
以上是我的服务类。我如何模拟 http 调用。
describe("CommentService", () => {
let httpClient: HttpClient;
let httpTestingController: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, HttpClientTestingModule],
providers: [CommentService]
});
httpClient = TestBed.get(HttpClient);
httpTestingController = TestBed.get(HttpTestingController);
});
it('addComments() call with normal and gate', inject([CommentService], (service: CommentService) => {
let cmts = service.addComments();
const reqGateComment = httpTestingController.expectOne('/url/1');
expect(reqGateComment.request.method).toEqual('POST');
const …
Run Code Online (Sandbox Code Playgroud) 我已将audit-logging
插件安装到我的应用程序中.grails版本是2.1.1
,插件版本是1.0.1
.
在我的Config.groovy
班上,我添加了这个
auditLog {
verbose = true // verbosely log all changed values to db
logIds = true // log db-ids of associated objects.
// Note: if you change next 2 properties, you must update your database schema!
tablename = 'audit_logs' // table name for audit logs.
transactional = false
actorClosure = { request, session ->
org.apache.shiro.SecurityUtils.getSubject()?.getPrincipal()
}
Run Code Online (Sandbox Code Playgroud)
在我的域类中,我添加了这个
class Survey {
static auditable = true
static final int NO_RUNNING_SURVERY = 0 …
Run Code Online (Sandbox Code Playgroud) 我使用Apache CXF创建了soap服务,我创建了一个@WebService.在该服务中,我需要注入@Service.当我@Autowire服务该实例仍然为null.
端点初始化
@Bean
public Endpoint endpointToken() {
EndpointImpl endpoint = new EndpointImpl(bus, new GenerateLoginToken());
endpoint.publish("/Token");
return endpoint;
}
Run Code Online (Sandbox Code Playgroud)
Serivce Class
@WebService(serviceName = "GenerateToken", portName = "TokenPort",
targetNamespace = "http://service.ws.samp",
endpointInterface = "com.web.sigel.ws.soap.webServices.GenerateToken")
@Service("AuthService")
public class GenerateLoginToken implements GenerateToken {
@Autowired
private AuthService authService; //this remains Null whenever i make a call.
@Override
@RequestWrapper(localName = "loginRequest", targetNamespace = "http://service.ws.samp", className = "com.web.sigel.ws.soap.security.LoginRequest")
public LoginResponse generateToken(LoginRequest loginRequest) {
LoginResponse loginResponse = new LoginResponse();
String token = authService.createAuthToken(loginRequest);
loginResponse.setToken(token);
return loginResponse;
} …
Run Code Online (Sandbox Code Playgroud) angular ×1
cxf ×1
grails ×1
grails-2.1 ×1
java ×1
plugins ×1
rxjs ×1
soap ×1
spring ×1
typescript ×1