我正在使用AngularJS并尝试测试一个调用工厂来获取一些数据的控制器.
这是控制器代码:
'use strict'
angular.module('AngularApp')
.controller 'IndexCtrl', ($scope, session, navigation) ->
session.find().then (response) ->
$scope.session = response.data
$scope.someOtherVariable = {}
Run Code Online (Sandbox Code Playgroud)
当然,我想用模拟交换工厂,以防止调用真正的API.我正在尝试使用$ provide.factory来注入模拟副本:
'use strict'
describe 'Controller: IndexCtrl', ->
# load the controller's module
beforeEach module 'mosaicAdminWebClientApp'
beforeEach module ($provide) ->
$provide.factory 'session', ->
true
IndexCtrl = {}
scope = {}
# Initialize the controller and a mock scope
beforeEach inject ($controller, $rootScope) ->
scope = $rootScope.$new()
IndexCtrl = $controller 'IndexCtrl', {
$scope: scope
}
it 'should attach a list of …Run Code Online (Sandbox Code Playgroud) 我有以下项目结构:
project
checkstyle
checkstyle.xml
subproject1
...
subproject2
...
build.gradle
Run Code Online (Sandbox Code Playgroud)
我在checkstyle中的配置build.gradle如下:
allprojects {
apply plugin: 'checkstyle'
checkstyle {
configFile = 'checkstyle/checkstyle.xml' as File
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用gradle 2.1时,构建工作正常.升级到2.2或2.2.1后,会发生错误:
:subproject1:checkstyleMain FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':subproject1:checkstyleMain'.
> Unable to create a Checker: unable to find /home/my/project/subproject1/checkstyle/checkstyle.xml
Run Code Online (Sandbox Code Playgroud)
Gradle现在在子项目目录中寻找'checkstyle/checkstyle.xml',这不是我所期望的.
我发现他们在2.2发行说明中提到了这个变化.但他们没有告诉如何保持解决这条道路的旧行为.这该怎么做?
我尝试使用project.file但它也不起作用.
我在grafana创造了一些漂亮的地块.我想直接在我的网站管理面板中显示其中一些,而不是强迫用户转到grafana仪表板并强制他们进行双重身份验证(一次用于我的网站,一次用于grafana).
一种选择是在grafana中启用匿名访问,并使用grafana中每个图形可用的share/embed iframe选项.虽然它有效,但如果知道相应URL的任何人都可以看到grafana数据,那么这似乎是一个巨大的漏洞.
然后我看到grafana有HTTP API,但我看不到在那里显示某个图表的可能性.
我已经尝试了一个带有PHP代理的解决方案,如果用户在我的网站上进行了身份验证,则会添加授权标头并连接到grafana嵌入URL.但是,它不起作用,这是配置的噩梦.
最后一个选项是从服务器端的grafana获取图形的png,并仅为我网站中经过身份验证的管理员提供服务.然而,在这种情况下,我放弃了所有酷的东西grafana提供OOTB,如扩展/折叠时间范围,自动刷新等.
我有一个实体:
@Entity
@EntityListeners(MyEntityListener.class)
class MyEntity{ ... }
Run Code Online (Sandbox Code Playgroud)
而听众:
class MyEntityListener{
@PrePersist
@PreUpdate
public void doSomething(Object entity){ ... }
}
Run Code Online (Sandbox Code Playgroud)
我正在为此实体(1.4.1)和EclipseLink使用Spring Data生成的DAO.代码行为如下:
MyEntity entity = new Entity();
entity = dao.save(entity); // the doSomething() is called here
// change something it the entity and save it again
dao.save(entity); // the doSomething() is NOT called here, checked with breakpoint
Run Code Online (Sandbox Code Playgroud)
这个问题已经在2009年被某人描述过了,然而,他们没有提出任何解决方案.我想知道是否有人有想法如何解决它?
这是我的代码:
<h1 ng-repeat="item in func()">something</h1>
$scope.func = function(){
return [{"property" : "value1"},{"property": "value2"}];
}
Run Code Online (Sandbox Code Playgroud)
在Angular.js v.1.1.1中,没有错.在Angular.JS v 1.2.1中,我得到了一个infDig错误.
你能解释一下这种情况吗?非常感谢.
infinite-loop angularjs angularjs-ng-repeat angularjs-infdig
ObjectNode row = Json.newObject();
row.put("0", a);
row.put("1", x);
row.put("2", y);
Run Code Online (Sandbox Code Playgroud)
现在我有清单
List<String> list = new ArrayList<String>();
Run Code Online (Sandbox Code Playgroud)
如何将其添加到行中?
我想在现有项目上使用Web密码学API。要加密和解密某些内容,我必须使用CryptoKey,但是当我将CryptoKey保存到localStorage时,它只会保存String(CryptoKey)而不是对象。
是否可以序列化/转换简单类型(字符串)的CryptoKey?
我的解密方法是
function decryptDataWithAES(keyName)
{
var decrypt_promise;
var aesKey = localStorage.getItem(keyName + 'key')
var item = localStorage.getItem(keyName)
var invokeVektor = localStorage.getItem(keyName + 'vector')
console.log("aesKey", aesKey )
crypto.subtle.decrypt({ name: "AES-CBC", iv: invokeVektor }, aesKey, item).then(function (result) {
decrypted_data = new Uint8Array(result); decrypted_data = new Uint8Array(result);
decrypt_promise = convertArrayBufferViewtoString(decrypted_data);
console.log('decryptDataWithAES ' + decrypt_promise);
return decrypt_promise;
},
function(e){
console.log(e.message);
}
);
}
Run Code Online (Sandbox Code Playgroud)
错误消息当然是:
无法在'SubtleCrypto'上执行'decrypt':参数2不是'CryptoKey'类型。2localStorageHandler.js:39 CryptoPromise [对象CryptoKey]
如果我不使用localStorage进行解密,则加密数据没有问题。
我正在使用spring-data-jpa @EnableSpringDataWebSupport并且DomainClassConverter不通过存储库手动查找实例.当在控制器上做一个控制器测试(MockMvc独立设置测试)时
@RequestMapping(value = '/user/{userId}', method = RequestMethod.GET)
public UserDetails detail(@PathVariable('userId') User user) {
...
}
Run Code Online (Sandbox Code Playgroud)
我得到了ConversionNotSupportedException.有可能像这样测试控制器吗?我该怎么办?
angularjs ×2
java ×2
php ×2
spring ×2
checkstyle ×1
coffeescript ×1
encryption ×1
gerrit ×1
gradle ×1
grafana ×1
graphite ×1
javascript ×1
jpa ×1
json ×1
phpmd ×1
spring-mvc ×1
unit-testing ×1