小编Mel*_*vin的帖子

从 Java 使用 LocalStack 时获取 AmazonKinesisException 状态代码:502

我正在使用 LocalStack 编写集成测试来模拟我对 Kinesis 的调用。我创建了一个 Kinesis 客户端,但是当我尝试在 Kinesis 上放置记录时出现错误:

com.amazonaws.services.kinesis.model.AmazonKinesisException: null (Service: AmazonKinesis; Status Code: 502; Error Code: null; Request ID: null)

我尝试使用以下方法禁用 CBOR 和证书检查:

System.setProperty(SDKGlobalConfiguration.DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "false");
Run Code Online (Sandbox Code Playgroud)

System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");

我以这种方式构建客户端:

.withEndpointConfiguration(localstack.getEndpointConfiguration(LocalStackContainer.Service.KINESIS))
.withCredentials(localstack.getDefaultCredentialsProvider())
.build()
Run Code Online (Sandbox Code Playgroud)

我每次都收到502。S3 一切正常,只是 Kinesis 服务给我带来了麻烦。有没有人见过这样的事情?

java amazon-kinesis localstack

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

使用Observable模拟服务时的测试错误(Angular 2)

我有一个使用返回Observable的服务的组件.我没有在我的Jasmine测试中连接这项服务,而是选择监视模拟.

以下是NumProbesService [numprobes.service.ts],它使用Http从Web服务器获取JSON响应:

import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import {Observable} from 'rxjs/Rx';
import 'rxjs/add/operator/map'
import {ProbeCount} from "./probecount.model";

@Injectable()
export class NumProbesService {

  private numProbesUrl = 'http://localhost:9090/getnumberofprobes';
  private probeCount: ProbeCount;

  constructor (private http: Http) {}

  createAuthorizationHeader(headers: Headers) {
    headers.append('X-Auth-Key', 'mjones');
    headers.append('X-Auth-Secret', '111111-2222222-22222-3233-4444444');
  }


  public getProbeCount() : Observable<ProbeCount> {
    let headers = new Headers();
    this.createAuthorizationHeader(headers);

    return this.http.get(this.numProbesUrl, {headers: headers})
      .map((response:Response) =>  this.probeCount = <ProbeCount>response.json())
      .catch((error:any) => Observable.throw(error.json().error || 'Server error'));
  } …
Run Code Online (Sandbox Code Playgroud)

unit-testing observable jasmine angular

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