下面列出了怎么用org.junit.jupiter.api.Disabled的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Tests that it is possible to generate a test invite code.
*
* @throws IOException
* @throws InterruptedException
*/
@Test
@Disabled("Requires a running ssb server")
public void testGenerateInvite() throws IOException, InterruptedException {
TestConfig config = TestConfig.fromEnvironment();
AsyncResult<ScuttlebuttClient> client =
ScuttlebuttClientFactory.fromNet(new ObjectMapper(), config.getHost(), config.getPort(), config.getKeyPair());
ScuttlebuttClient scuttlebuttClient = client.get();
AsyncResult<Invite> inviteAsyncResult = scuttlebuttClient.getNetworkService().generateInviteCode(1);
Invite invite = inviteAsyncResult.get();
assertEquals(invite.identity().publicKeyAsBase64String(), config.getKeyPair().publicKey().bytes().toBase64String());
}
@Disabled
@Test
public void testDMNBusinessRuleTaskInvalidExecution()throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper(
"dmn/BPMN2-BusinessRuleTaskDMNByDecisionName.bpmn2", "dmn/0020-vacation-days.dmn");
ksession = createKnowledgeSession(kbase);
Map<String, Object> params = new HashMap<String, Object>();
params.put("age", 16);
try {
ksession.startProcess("BPMN2-BusinessRuleTask", params);
} catch (Exception e) {
assertTrue(e instanceof WorkflowRuntimeException);
assertTrue(e.getCause() instanceof RuntimeException);
assertTrue(e.getCause().getMessage().contains("DMN result errors"));
}
}
@Test
@Disabled("Process does not complete.")
public void testAdHocSubProcess() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-AdHocSubProcess.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
WorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNull();
ksession = restoreSession(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.fireAllRules();
ksession.signalEvent("Hello2", null, processInstance.getId());
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession = restoreSession(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
@Test
@Disabled("Transfomer has been disabled")
public void testIntermediateCatchEventSignalWithTransformation() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventSignalWithTransformation.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
new SystemOutWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
// now signal process instance
ksession.signalEvent("MyMessage", "SomeValue", processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "StartProcess", "UserTask", "EndProcess", "event");
String var = getProcessVarValue(processInstance, "x");
assertThat(var).isNotNull();
assertThat(var).isEqualTo("SOMEVALUE");
}
@Test
@Disabled("Process does not complete.")
public void testAdHocSubProcessAutoComplete() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-AdHocSubProcessAutoComplete.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
WorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNull();
ksession = restoreSession(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.fireAllRules();
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull().withFailMessage("WorkItem should not be null.");
ksession = restoreSession(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
@Test
@Disabled
void test(){
DingTalkProperties properties=new DingTalkProperties();
properties.setAppKey("appkey");
properties.setAppSecret("appSecuret");
DingTalkMessageTemplate messageTemplate=new DingTalkMessageTemplate();
messageTemplate.setAgentId("335474263");
messageTemplate.setMessage("test"+System.currentTimeMillis());
messageTemplate.setUserIdList("0458215455697857");
DingTalkNotifier notifier=new DingTalkNotifier("test",
WebClient.builder().build(),properties,null
);
notifier.send(messageTemplate, Values.of(new HashMap<>()))
.as(StepVerifier::create)
.expectComplete()
.verify();
}
@Test
@Disabled
void test(){
WechatCorpProperties properties=new WechatCorpProperties();
properties.setCorpId("corpId");
properties.setCorpSecret("corpSecret");
WechatMessageTemplate messageTemplate=new WechatMessageTemplate();
messageTemplate.setAgentId("agentId");
messageTemplate.setMessage("test"+System.currentTimeMillis());
messageTemplate.setToUser("userId");
WeixinCorpNotifier notifier=new WeixinCorpNotifier("test",
WebClient.builder().build(),properties,null
);
notifier.send(messageTemplate, Values.of(new HashMap<>()))
.as(StepVerifier::create)
.expectComplete()
.verify();
}
@Test
@Disabled
public void compensationViaCancellation() throws Exception {
KieSession ksession = createKnowledgeSession("compensation/BPMN2-Compensation-IntermediateThrowEvent.bpmn2");
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "0");
ProcessInstance processInstance = ksession.startProcess("CompensateIntermediateThrowEvent", params);
ksession.signalEvent("Cancel", null, processInstance.getId());
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), null);
// compensation activity (assoc. with script task) signaled *after* script task
assertProcessInstanceCompleted(processInstance.getId(), ksession);
assertProcessVarValue(processInstance, "x", "1");
}
@Test
@Disabled("Transfomer has been disabled")
public void testIntermediateCatchEventMessageWithTransformation() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventMessageWithTransformation.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
new SystemOutWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
// now signal process instance
ksession.signalEvent("Message-HelloMessage", "SomeValue", processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
String var = getProcessVarValue(processInstance, "x");
assertThat(var).isNotNull();
assertThat(var).isEqualTo("SOMEVALUE");
}
@Test
@Disabled
public void createCodeLocationLDService() throws IOException {
final String dependencyNodeFile = FunctionalTestFiles.asString("/nuget/LDService_inspection.json");
final ArrayList<String> expectedOutputFiles = new ArrayList<>();
expectedOutputFiles.add("/nuget/LDService_Output_0_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_1_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_2_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_3_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_4_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_5_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_6_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_7_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_8_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_9_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_10_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_11_graph.json");
expectedOutputFiles.add("/nuget/LDService_Output_12_graph.json");
createCodeLocation(dependencyNodeFile, expectedOutputFiles);
}
@Test @Disabled("no solution yet")
void plainGlobalScopeTest() throws URISyntaxException, ScriptException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
Bindings globalBindings = engine.createBindings();
engine.eval("Object.prototype.test = function(arg){print(arg);}", globalBindings);
Bindings local = engine.createBindings();
engine.eval("var local = {}", local);
//works as expected, printing "hello"
engine.getContext().setBindings(globalBindings, ScriptContext.ENGINE_SCOPE);
engine.eval("var x = {}; x.test('hello');");
//throws TypeError: null is not a function in <eval> at line number 1
engine.getContext().setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
engine.getContext().setBindings(globalBindings, ScriptContext.GLOBAL_SCOPE);
engine.eval("var x = {}; x.test('hello');");
}
@Test
@Disabled("too many permuations to go over")
public void testLookup() throws IOException {
IPLookup ipArt = new IPLookup(() -> new AdaptiveRadixTree<>(InetAddressBinaryComparable.INSTANCE));
IPLookup ipRbt = new IPLookup(() -> new TreeMap<>(InetAddressComparator.INSTANCE));
for (int i = 0; i < 256; i++) {
String iaddress = i + ".";
for (int j = 0; j < 256; j++) {
String jaddress = iaddress + j + ".";
for (int k = 0; k < 256; k++) {
String kaddress = jaddress + k + ".";
for (int l = 0; l < 256; l++) {
InetAddress inetAddress = InetAddress.getByName(kaddress + l);
assertEquals(ipArt.lookup(inetAddress), ipRbt.lookup(inetAddress));
}
}
}
}
}
@Test
@Disabled("Transfomer has been disabled")
public void testEventSubprocessSignalWithTransformation() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-EventSubprocessSignalWithTransformation.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
workItemHandler);
ProcessInstance processInstance = ksession
.startProcess("BPMN2-EventSubprocessSignal");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
ksession.signalEvent("MySignal", "john", processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "start", "User Task 1",
"Sub Process 1", "start-sub", "end-sub");
String var = getProcessVarValue(processInstance, "x");
assertThat(var).isNotNull();
assertThat(var).isEqualTo("JOHN");
}
@Test
@Disabled("Transfomer has been disabled")
public void testMessageIntermediateThrowWithTransformation() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateThrowEventMessageWithTransformation.bpmn2");
ksession = createKnowledgeSession(kbase);
final StringBuffer messageContent = new StringBuffer();
ksession.getWorkItemManager().registerWorkItemHandler("Send Task",
new SendTaskHandler(){
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
// collect message content for verification
messageContent.append(workItem.getParameter("Message"));
super.executeWorkItem(workItem, manager);
}
});
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "MyValue");
ProcessInstance processInstance = ksession.startProcess(
"MessageIntermediateEvent", params);
assertProcessInstanceCompleted(processInstance);
assertThat(messageContent.toString()).isEqualTo("MYVALUE");
}
/**
* This test can take a while (> 1 minute).
* @throws Exception
*/
@Test
@Disabled
public void testStatefulSessionsCreation() throws Exception {
KieBase kbase = loadKnowledgeBase("test_OutOfMemoryError.drl");
int i = 0;
SessionConfiguration conf = SessionConfiguration.newInstance();
conf.setKeepReference( true ); // this is just for documentation purposes, since the default value is "true"
try {
for ( i = 0; i < 300000; i++ ) {
KieSession ksession = kbase.newKieSession( conf, null );
ksession.dispose();
}
} catch ( Throwable e ) {
logger.info( "Error at: " + i );
e.printStackTrace();
fail( "Should not raise any error or exception." );
}
}
@Test
@Disabled
public void testIncompleteCode1() throws DroolsParserException,
RecognitionException {
String input = "package a.b.c import a.b.c.* rule MyRule when Class ( property memberOf collexction ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
System.out.println(parser.getErrors());
assertNotNull(descr);
assertEquals("a.b.c", descr.getNamespace());
assertEquals("a.b.c.*", descr.getImports().get(0)
.getTarget());
assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
getLastIntegerValue(parser.getEditorSentences().get(2)
.getContent()));
}
@Test @Disabled
public void testIncompleteCode9() throws DroolsParserException,
RecognitionException {
String input = "package a.b.c import a.b.c.*"
+ " rule MyRule xxxxx Class ( property memberOf collection ) then end "
+ " query MyQuery Class ( property memberOf collection ) end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertEquals("a.b.c", descr.getNamespace());
assertEquals("a.b.c.*", descr.getImports().get(0)
.getTarget());
assertEquals(1, descr.getRules().size());
assertEquals("MyQuery", descr.getRules().get(0).getName());
}
@Test
@Timeout(10)
@Disabled("Transfomer has been disabled")
public void testSignalStartWithTransformation() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 1);
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-SignalStartWithTransformation.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
final List<ProcessInstance> list = new ArrayList<ProcessInstance>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance());
}
});
ksession.signalEvent("MySignal", "NewValue");
countDownListener.waitTillCompleted();
assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(1);
assertThat(list).isNotNull();
assertThat(list.size()).isEqualTo(1);
String var = getProcessVarValue(list.get(0), "x");
assertThat(var).isEqualTo("NEWVALUE");
}
@Test @Disabled
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END3() {
// FIXME for now it will be a limitation of the parser... memberOf is a
// soft-keyword and this sentence cannot be parsed correctly if
// misspelling
String input = "rule MyRule \n" + " when \n"
+ " Class ( property memberOf collection ";
DRLParser parser = getParser(input);
parser.enableEditorInterface();
try {
parser.compilationUnit();
} catch (Exception ex) {
}
assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
getLastIntegerValue(parser.getEditorInterface().get(0)
.getContent()));
}
@Test
@Disabled("process does not complete")
public void testIntermediateCatchEventCondition() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventCondition.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession);
// now activate condition
Person person = new Person();
person.setName("Jack");
ksession.insert(person);
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
@Test @Disabled
public void testLargeData2() {
int range = 6000000;
for ( int i = 0; i < 10; i++ ) {
// produces duplicate entry, isolated in test1
long startTime = System.currentTimeMillis();
generateAndTest2( 90000, range-90000, range, 1 );
long endTime = System.currentTimeMillis();
System.out.println( endTime - startTime );
}
}
@Test
@Disabled
public void testNewSessionWhileModifyingRuleBase() throws InterruptedException {
PackageModifier modifier = new PackageModifier();
SessionCreator creator = new SessionCreator();
creator.start();
modifier.start();
// 10 seconds should be more than enough time to see if the modifer and creator
// get deadlocked
Thread.sleep(10000);
boolean deadlockDetected = creator.isBlocked() && modifier.isBlocked();
if (deadlockDetected) {
// dump both stacks to show it
printThreadStatus(creator);
printThreadStatus(modifier);
}
assertFalse(deadlockDetected, "Threads are deadlocked! See previous stacks for more detail");
// check to see if either had an exception also
if (creator.isInError()) {
creator.getError().printStackTrace();
}
assertFalse(creator.isInError(), "Exception in creator thread");
if (modifier.isInError()) {
modifier.getError().printStackTrace();
}
assertFalse(modifier.isInError(), "Exception in modifier thread");
}
@Disabled("for development")
@Test
public void testRaw() throws Exception {
String json =
"{\n" +
"\n" +
" \"query\": {\n" +
" \"bool\":{\n" +
" \"should\":[\n" +
" {\"multi_match\" : {\n" +
" \"query\": \"brown fox\",\n" +
" \"type\": \"best_fields\",\n" +
" \"fields\": [ \"title\", \"overview\" ],\n" +
" \"tie_breaker\": 0.3\n" +
" }},\n" +
"\t{\"multi_match\" : {\n" +
" \"query\": \"elephant\",\n" +
" \"type\": \"best_fields\",\n" +
" \"fields\": [ \"title\", \"overview\" ],\n" +
" \"tie_breaker\": 0.3\n" +
" }}\n" +
"\t]\n" +
" }\n" +
" }\n" +
"}";
SearchClient searchClient = SearchClientFactory.getClient(TMDB_URL);
String url = TMDB_URL + "/_search";
JsonResponse r = searchClient.postJson(url, json);
System.out.println(r);
}
@Disabled("Requires https://github.com/quarkusio/quarkus/pull/10109")
@Test
void logMessageEdit() throws IOException {
Awaitility.await()
.atMost(1, TimeUnit.MINUTES)
.until(() -> Files.exists(LOG_FILE));
try (BufferedReader logFileReader = Files.newBufferedReader(LOG_FILE, StandardCharsets.UTF_8)) {
assertLogMessage(logFileReader, "Hello foo", 30000);
TEST.modifySourceFile(TimerRoute.class, oldSource -> oldSource.replace("Hello foo", "Hello bar"));
assertLogMessage(logFileReader, "Hello bar", 30000);
}
}
@Test
@Disabled // Hard coded path here
public void test() throws FHIRFormatError, FileNotFoundException, IOException {
File src = new File(Utilities.path("[tmp]", "obs.xml"));
File xml = new File(Utilities.path("[tmp]", "xml.xml"));
File json = new File(Utilities.path("[tmp]", "json.json"));
File json2 = new File(Utilities.path("[tmp]", "json2.json"));
FileUtils.copyFile(new File("C:\\work\\org.hl7.fhir\\build\\publish\\observation-decimal.xml"), src);
Observation obs = (Observation) new XmlParser().parse(new FileInputStream(src));
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(json), obs);
obs = (Observation) new JsonParser().parse(new FileInputStream(json));
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(json2), obs);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(xml), obs);
}
@Test
@Disabled
public void test() throws FileNotFoundException, IOException, FHIRException, EOperationOutcome, UcumException {
Resource res = new XmlParser().parse(new FileInputStream(TestingUtilities.resourceNameToFile("unicode.xml")));
new NarrativeGenerator("", "", TestingUtilities.context()).generate((DomainResource) res, null);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.resourceNameToFile("gen", "unicode.out.xml")), res);
}
@Disabled
@Test
void handleSetCurrentCliContext() {
Context context = mock(Context.class);
this.myCliContextController.handleSetCurrentCliContext(context);
verify(context).status(200);
}
@Test
@Disabled("Transfomer has been disabled")
public void testCallActivityWithTransformation() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-CallActivityWithTransformation.bpmn2", "BPMN2-CallActivitySubProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
final List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
ksession.addEventListener(new DefaultProcessEventListener() {
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
instances.add(event.getProcessInstance());
}
});
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "oldValue");
ProcessInstance processInstance = ksession.startProcess("ParentProcess", params);
assertProcessInstanceCompleted(processInstance);
assertEquals(2, instances.size());
// assert variables of parent process, first in start (input transformation, then on end output transformation)
assertEquals("oldValue",((WorkflowProcessInstance) instances.get(0)).getVariable("x"));
assertEquals("NEW VALUE",((WorkflowProcessInstance) instances.get(0)).getVariable("y"));
// assert variables of subprocess, first in start (input transformation, then on end output transformation)
assertEquals("OLDVALUE", ((WorkflowProcessInstance) instances.get(1)).getVariable("subX"));
assertEquals("new value",((WorkflowProcessInstance) instances.get(1)).getVariable("subY"));
}
@Disabled
@Override
@Test
public void bindFails() {
/*
This test focuses on various corner cases for position-binding, which is unsupported.
*/
}
@Override
@Disabled
@Test
public void returnGeneratedValues() {
/*
This tests auto-generated key columns in Spanner. This isn't supported.
*/
}