我需要将我的angular $ resources连接到自签名的https web api.如果我试着直接这样做,我会收到诸如此类的消息
OPTIONS https://address/api/authentication net::ERR_INSECURE_RESPONSE
Run Code Online (Sandbox Code Playgroud)
有没有办法克服此错误,通过任何方式指定此特定连接是可信的?
我有一个Java中的哈希映射,我需要限制其大小(50000的顺序).但我应该只删除最旧的项目.项的时间戳存储在条目对象的字段中:
Map<String, MyModel> snapshot = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)
和
public class MyModel {
private ZonedDateTime createdAt;
// other fields...
}
Run Code Online (Sandbox Code Playgroud)
我还按时间戳顺序将它们插入到地图中.
完成这种删除最旧条目的最有效方法是什么?请注意,时间"阈值"未知,只有Map的最终大小.
我有一个公开 Websocket/SockJS/Stomp 服务器端点的应用程序,并想运行一个 JUnit 测试,该测试运行客户端(Java STOMP 客户端,也来自 Spring),以测试“发送”功能。
我有一个像
public void measureSpeedWithWebsocket() throws Exception {
final Waiter subscribeWaiter = new Waiter();
new Thread(() -> {
// Prepare connection
WebsocketClient listener = new WebsocketClient("/mytopic/stomp");
try {
listener.connectAndSubscribe();
subscribeWaiter.resume();
} catch (Exception e) {
e.printStackTrace();
}
}).start();
subscribeWaiter.await(); // Wait for connection.
Run Code Online (Sandbox Code Playgroud)
这里我使用了https://github.com/jhalterman/concurrentunit 中的 Waiter ,其效果基本上是将测试的主线程延迟到辅助线程调用 resume()。这很可能是错误的,因为在上下文中运行的 Spring 服务器必须做出反应
我收到以下错误
[INFO ] 2017-02-03 12:36:12.402 [Thread-19] WebsocketClient - Listening
[INFO ] 2017-02-03 12:36:12.403 [Thread-19] WebsocketClient - Connecting to ws://localhost:8083/user...
2017-02-03 …Run Code Online (Sandbox Code Playgroud) 使用 C# Bogus 库,我想生成完全随机的对象,而无需显式枚举所有字段作为 RuleFor。
我如何配置我的 Faker 来实现这一目标?
我正在尝试执行以下操作:
jobs我的 Github Actions 工作流程中有以下内容:
start-process: # THIS JOB IS SUPPOSED TO START A SERVER IN BACKGROUND
name: Start
needs: start-runner # previous job starts the runner
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
- uses: actions/checkout@v2
- name: npm install
working-directory: ./monitor
run: npm install
- name: npm start
run: nohup npm start & # this starts the server in background
working-directory: ./monitor
- run: curl http://localhost:8080/start …Run Code Online (Sandbox Code Playgroud) 我的角度控制器可能会生成消息,我打算使用角度转换进行翻译.
在控制器中,我当前将一个变量分配给翻译键,例如:
$scope.info = "core.projectconfig.created";
Run Code Online (Sandbox Code Playgroud)
其中该键的转换指定为
core.projectconfig.created <=> 'Project {{projectName}} created successfully'
Run Code Online (Sandbox Code Playgroud)
如您所见,我还需要在翻译中替换projectName.
在我看来,我尝试过这样的事情
<P translate="{{info}}", translate-values="{projectName : projectData.ProjectName}"></p>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我如何翻译动态找到的翻译密钥,并在翻译的行中添加范围变量?
我在Jasmine和Karma中有很多依赖于$ httpBackend HTTP模拟检查的测试.当我今天升级Angular时,他们停止了工作.
假设我的Jasmine测试中有这样的东西:
// Arrange
httpBackend.expect('POST', 'https://localhost:44300/api/projects/1/samples').respond(fakedDto);
// Act
scope.updateSamples();
httpBackend.flush();
Run Code Online (Sandbox Code Playgroud)
在最后一行,这是完全正常的,我收到:
TypeError: $browser.$$checkUrlChange is not a function in C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular/angular.js (line 12502)
$RootScopeProvider/this.$get</Scope.prototype.$digest@C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular/angular.js:12502:9
createHttpBackendMock/$httpBackend.flush@C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular-mocks/angular-mocks.js:1481:5
@C:/SVN/samplemgmt/src/ClientApp/tests/integration/sample/samplecreationController_integration.test.js:341:9
Run Code Online (Sandbox Code Playgroud)
此外,我有通常的配置来结束测试:
afterEach(function () {
httpBackend.verifyNoOutstandingExpectation();
httpBackend.verifyNoOutstandingRequest();
});
Run Code Online (Sandbox Code Playgroud)
现在开始生成以下错误:
Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.2.25/$rootScope/inprog?p0=%24digest in C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular/angular.js (line 78)
minErr/<@C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular/angular.js:78:5
beginPhase@C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular/angular.js:13009:9
$RootScopeProvider/this.$get</Scope.prototype.$digest@C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular/angular.js:12500:9
createHttpBackendMock/$httpBackend.verifyNoOutstandingExpectation@C:/SVN/samplemgmt/src/ClientApp/client/bower_components/angular-mocks/angular-mocks.js:1514:5
@C:/SVN/samplemgmt/src/ClientApp/tests/integration/sample/samplecreationController_integration.test.js:137:9
Run Code Online (Sandbox Code Playgroud)
我很欣赏如何让事情再次发挥作用的一些建议.最近是否对httpBackend测试做了任何更改?
我有这样的情况:
我希望我的路线不会在大规模任务进行时重新触发。也就是说,定时器可能会发出事件,但它不应该以某种方式导致触发路由。当大量任务完成后,定时器应该可以重新开始路由。
实现这种行为的最佳方法是什么?
使用SockJS Java客户端,我正在尝试连接到Spring sockjs服务器,并且收到错误消息209(无标题)(错误消息为1009)。Javascript库工作正常。
Transport closed with CloseStatus[code=1009, reason=The decoded text message was too big
for the output buffer and the endpoint does not support partial messages] in WebSocketClientSockJsSession
[id='9fa30eb453e14a8c8612e1064640646a, url=ws://127.0.0.1:8083/user]
Run Code Online (Sandbox Code Playgroud)
我在服务器上有几个配置类(目前我不知道是否配置这些东西的次数超过了必要):
@Configuration
@EnableWebSocket
public class WebSocketTransportConfig implements WebSocketConfigurer {
// Important web socket setup. If big message is coming through, it may overflow the buffer and this will lead in disconnect.
// All messages that are coming through normally (including snapshots) must be order of magnitude smaller, or connection will …Run Code Online (Sandbox Code Playgroud) 我有包含字符串ID的集合idList.函数getCollection为单个ID返回一个项集合(类型为MyType).此外,它可能会返回null.
所以对于来自idList的许多ID,我会得到一些空值和一些集合.
目标是将一组ID的getCollection的所有回复收集到最终List中.
我想象过像
List<MyType> reply = idList.stream().map(id -> getCollection(id))
.filter(p -> p != null).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
但它似乎不是一个有效的表达.如何使其有效?
此外,这个实现的性能如何?