小编Muh*_*eer的帖子

Angular 模拟多个 HTTP 调用

我有一项服务,它返回多个 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)

rxjs typescript karma-jasmine angular angular-httpclient

8
推荐指数
1
解决办法
3071
查看次数

使用audit-logging插件在grails中插入双记录

我已将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)

grails plugins audit-logging grails-2.1

7
推荐指数
1
解决办法
522
查看次数

Spring + Apache CXF @Autowire在服务中始终为null

我使用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)

java spring soap cxf

1
推荐指数
1
解决办法
1242
查看次数