gpt4 book ai didi

java.lang.IllegalStateException : Missing the '-javaagent' JVM argument. 确保使用连接到 JVM 的 Quasar java 代理运行测试

转载 作者:行者123 更新时间:2023-12-01 16:29:03 26 4
gpt4 key购买 nike

当尝试运行 CORDA 测试时,给定的测试用例出现以下错误。我在 Windows 10 上使用 JDK 1.8.、Intellij IDEA。尽管我已经在 VM 选项中提到了 Quasar.jar。

RUN >> 编辑配置 >> Junit>> 所需的测试类 >>VM 选项:-ea -javaagent:lib\quasar.jar enter image description here

package com.template;

import com.google.common.collect.ImmutableList;
import com.template.contracts.MetalContract;
import com.template.flows.Responder;
import com.template.states.MetalState;
import net.corda.core.concurrent.CordaFuture;
import net.corda.core.contracts.Command;
import net.corda.core.contracts.TransactionState;
import net.corda.core.transactions.SignedTransaction;
import net.corda.testing.node.MockNetwork;
import net.corda.testing.node.MockNetworkParameters;
import net.corda.testing.node.StartedMockNode;
import net.corda.testing.node.TestCordapp;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.template.flows.IssueMetal;
import com.template.flows.TransferMetal;

import static org.junit.Assert.assertEquals;
import static junit.framework.TestCase.assertTrue;

public class FlowTests {
private final MockNetwork network = new MockNetwork(new MockNetworkParameters(ImmutableList.of(
TestCordapp.findCordapp("com.template.contracts"),
TestCordapp.findCordapp("com.template.flows")
)));

private final StartedMockNode Mint = network.createNode();
private final StartedMockNode A = network.createNode();
private final StartedMockNode B = network.createNode();

@Before
public void setup() {
network.runNetwork();
}

@After
public void tearDown() {
network.stopNodes();
}

// ------------------------------------------ Issue Metal Flow Tests ----------------------------------------

@Test
public void transactionHasNoInputsHasOneMetalStateOutputWithTheCorrectOwner() throws Exception {

IssueMetal flow = new IssueMetal("Gold", 10, A.getInfo().getLegalIdentities().get(0));
CordaFuture<SignedTransaction> future = Mint.startFlow(flow);
setup();
SignedTransaction signedTransaction = future.get();

assertEquals (0, signedTransaction.getTx().getInputs().size());

assertEquals (1, signedTransaction.getTx().getOutputStates().size());
MetalState output = signedTransaction.getTx().outputsOfType(MetalState.class).get(0);

assertEquals(A.getInfo().getLegalIdentities().get(0), output.getOwner());

}
}

错误是:

java.lang.IllegalStateException: Missing the '-javaagent' JVM argument. Make sure you run the tests with the Quasar java agent attached to your JVM.
See https://docs.corda.net/head/testing.html#running-tests-in-intellij - 'Fiber classes not instrumented' for more details.

at net.corda.node.services.statemachine.SingleThreadedStateMachineManager.checkQuasarJavaAgentPresence(SingleThreadedStateMachineManager.kt:317)
at net.corda.node.services.statemachine.SingleThreadedStateMachineManager.start(SingleThreadedStateMachineManager.kt:135)
at net.corda.node.internal.AbstractNode$start$8.invoke(AbstractNode.kt:409)
at net.corda.node.internal.AbstractNode$start$8.invoke(AbstractNode.kt:122)
at net.corda.nodeapi.internal.persistence.CordaPersistence.inTopLevelTransaction(CordaPersistence.kt:268)
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:237)
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:254)
at net.corda.node.internal.AbstractNode.start(AbstractNode.kt:388)
at net.corda.testing.node.internal.InternalMockNetwork$MockNode.start(InternalMockNetwork.kt:346)
at net.corda.testing.node.internal.InternalMockNetwork.createNodeImpl(InternalMockNetwork.kt:471)
at net.corda.testing.node.internal.InternalMockNetwork.createNode(InternalMockNetwork.kt:449)
at net.corda.testing.node.internal.InternalMockNetwork.createNode(InternalMockNetwork.kt:444)
at net.corda.testing.node.internal.InternalMockNetwork.createNotaries$node_driver(InternalMockNetwork.kt:253)
at net.corda.testing.node.internal.InternalMockNetwork.<init>(InternalMockNetwork.kt:236)
at net.corda.testing.node.internal.InternalMockNetwork.<init>(InternalMockNetwork.kt:149)
at net.corda.testing.node.MockNetwork.<init>(MockNetwork.kt:305)
at net.corda.testing.node.MockNetwork.<init>(MockNetwork.kt:294)
at net.corda.testing.node.MockNetwork.<init>(MockNetwork.kt:303)
at com.template.FlowTests.<init>(FlowTests.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64)

最佳答案

我建议使用 Gradle Test Runner,这样您就不必手动设置 javaagent 标志。

要使用 Gradle Test Runner,请单击“运行/调试配置”下拉列表 > 编辑配置... > + > Gradle 在表单中出现后,填写详细信息:

Gradle-Project :[项目路径]

任务: :cleanTest :test

参数:--tests ""

引用如下: enter image description here

关于java.lang.IllegalStateException : Missing the '-javaagent' JVM argument. 确保使用连接到 JVM 的 Quasar java 代理运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62085434/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com