我通过java配置配置了我的测试环境.在我的测试中,我需要一些数据来预先运行它,但是当我使用@DatabaseSetup注释运行测试时,我总是得到错误
Unable to load dataset from "personTestData.xml" using class com.github.springtestdbunit.dataset.FlatXmlDataSetLoader
Run Code Online (Sandbox Code Playgroud)
该文件位于src/test/resources/personTestData.xml.出于好奇,我将文件移动到测试本身所在的同一个包中,仍然是同样的错误.
我花了无数个小时在网上搜索错误,直到现在都没有解决方案.
UPDATE
我使用的组件和版本:
junit: 4.12
hamcrest: 1.3
springtestdbunit: 1.2.1
dbunit: 2.5.0
bonecp: 0.8.0
hsqldb: 1.8.0.10
Run Code Online (Sandbox Code Playgroud)
我的xml
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<person id="uuid'da578845-356c-4c99-9bda-c288c88e7b55"
dateCreated="2015-03-24 10:54:00"
isEnabled="1"
city="Graz"
displayName="42"
email="dent@example.com"
firstname="Arthur"
lastname="Dent"
phone="01123456"
street="Waßkannergasse 16"
web="www.vdsoft.at"
zip="1010"/>
<person id="uuid'5aaae7dd-b84f-463e-a534-e7b2bc54752a"
dateCreated="2015-03-24 10:54:10"
isEnabled="1"
city="Graz"
displayName="Towel"
email="prefect@example.com"
firstname="Ford"
lastname="Prefect"
phone="01123856"
street="Waßkannergasse 45"
web="www.vdsoft.at"
zip="1010"/>
<person id="uuid'b770b982-3a59-4292-9fd8-715afa2c1bef"
dateCreated="2015-03-24 10:54:20"
isEnabled="1"
city="Graz"
displayName="Lemon"
email="beeblebrox@example.com"
firstname="Zaphod"
lastname="Beeblebrox"
phone="01125456"
street="Waßkannergasse 20"
web="www.vdsoft.at"
zip="1010"/> …Run Code Online (Sandbox Code Playgroud) 我想模拟我的存储库上提供的查询,如下所示:
@Test
public void GetByEmailSuccessful() {
// setup mocks
Mockito.when(this.personRepo.findAll()
.stream()
.filter(p -> (p.getEmail().equals(Mockito.any(String.class))))
.findFirst()
.get())
.thenReturn(this.personOut);
Mockito.when(this.communityUserRepo.findOne(this.communityUserId))
.thenReturn(this.communityUserOut);
...
Run Code Online (Sandbox Code Playgroud)
我的@Before方法看起来像这样:
@Before
public void initializeMocks() throws Exception {
// prepare test data.
this.PrepareTestData();
// init mocked repos.
this.personRepo = Mockito.mock(IPersonRepository.class);
this.communityUserRepo = Mockito.mock(ICommunityUserRepository.class);
this.userProfileRepo = Mockito.mock(IUserProfileRepository.class);
}
Run Code Online (Sandbox Code Playgroud)
可悲的是,当我运行测试时,我收到错误:
java.util.NoSuchElementException:没有值存在
当我双击错误时,它指向.get()第一个lambda 的方法.
有没有人成功嘲笑过一个lambda表达式并知道如何解决我的问题?
我正在努力使用 Xamarin 和 BouncyCastle 创建 pfx 文件。我有以下设置/规范
我想为我的移动客户端生成一个自签名证书,以便根据我的服务器对其进行身份验证。使用 BouncyCastle 进行创作效果非常好。我的问题是,当我想将证书及其私钥存储为 PKCS#12 (pfx) 容器并从该容器恢复它以发送由它签名的 Web 请求时,会抛出异常告诉我Input data cannot be coded as a valide certificate。
以下是我创建证书、密钥和存储 pfx 容器的步骤。
创建密钥对:
private AsymmetricCipherKeyPair GenerateKeyPair()
{
var random = new SecureRandom();
var keyGenerationParameter = new KeyGenerationParameters(random, 4096);
var keyPairGenerator = new RsaKeyPairGenerator();
keyPairGenerator.Init(keyGenerationParameter);
var keyPair = keyPairGenerator.GenerateKeyPair();
return keyPair;
}
Run Code Online (Sandbox Code Playgroud)
创建证书,它将调用创建密钥并创建容器:
public void CreateCertificate()
{
var random = new SecureRandom();
var keyPair …Run Code Online (Sandbox Code Playgroud) 我认为这个问题更适合所有UI设计师;-)
我想制作一个看起来像高保真放大器上的音量控制旋钮的WPFelement.为了更好地表达我正在谈论的内容,请看一下这张照片

我把它从swDVDD中删除了.
该元素应该可左右转动.当它向右移动时,该值应增加0.5f,向左转动该值应减少0.5f.
为什么我需要这样的东西?目前我正在研究我的Deneon AVR-4306放大器的控制sw,我认为使用这样的控制来设置放大器的音量看起来很酷.
目前我正在写论文,我遇到了一个我以前从未见过的.Net C#的行为.我在谈论计算中的错误.我实现了这个公式:
1/2*(Theta i-1 + Theta i)+ Sum(Alph k,k = 1,i-1)
此公式适用于4个对象.Theta在声明为float的所有对象中,值为1,5708.Alpha初始化为0,并且每次迭代都会增加.
第一个实施
float alpha = 0;
float value = 0;
for (int sphereCount = 1; sphereCount < this.spheres.Count; sphereCount++)
{
value = (1/2) * (this.spheres[sphereCount - 1].Theta + this.spheres[sphereCount].Theta);
alpha += value;
}
Run Code Online (Sandbox Code Playgroud)
使用此版本值始终为0.0!所以我改成了:
工作实施
float alpha = 0;
float value = 0;
for (int sphereCount = 1; sphereCount < this.spheres.Count; sphereCount++)
{
value =(this.spheres[sphereCount - 1].Theta + this.spheres[sphereCount].Theta) * 1/2;
alpha += value;
}
Run Code Online (Sandbox Code Playgroud)
通过移除1/2周围的括号并将其放置在计算结束时它起作用.
为什么会这样???
当你将1/2放在括号中而不依赖于1/2的位置时,结果似乎为0.0.但是当我在最后放置(1/2)时它会产生0.0.这里有人知道为什么吗?
c# ×3
java ×2
bouncycastle ×1
dbunit ×1
junit ×1
lambda ×1
math ×1
mockito ×1
mono ×1
spring ×1
ui-design ×1
unit-testing ×1
wpf ×1
wpf-controls ×1
xamarin ×1