karavan-core 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.bebelrc +3 -0
- package/.mocharc.json +11 -0
- package/.prettierignore +9 -0
- package/.prettierrc +14 -0
- package/package.json +62 -0
- package/src/core/api/CamelDefinitionApi.ts +3271 -0
- package/src/core/api/CamelDefinitionApiExt.ts +757 -0
- package/src/core/api/CamelDefinitionYaml.ts +412 -0
- package/src/core/api/CamelDefinitionYamlStep.ts +4733 -0
- package/src/core/api/CamelDisplayUtil.ts +143 -0
- package/src/core/api/CamelUtil.ts +360 -0
- package/src/core/api/ComponentApi.ts +368 -0
- package/src/core/api/KameletApi.ts +147 -0
- package/src/core/api/MainConfigurationApi.ts +47 -0
- package/src/core/api/ProjectModelApi.ts +75 -0
- package/src/core/api/SpiBeanApi.ts +104 -0
- package/src/core/api/TemplateApi.ts +58 -0
- package/src/core/api/TopologyUtils.ts +392 -0
- package/src/core/api/VariableUtil.ts +104 -0
- package/src/core/model/CamelDefinition.ts +3783 -0
- package/src/core/model/CamelMetadata.ts +2714 -0
- package/src/core/model/ComponentModels.ts +106 -0
- package/src/core/model/IntegrationDefinition.ts +188 -0
- package/src/core/model/KameletModels.ts +223 -0
- package/src/core/model/MainConfigurationModel.ts +37 -0
- package/src/core/model/ProjectModel.ts +43 -0
- package/src/core/model/SpiBeanModels.ts +53 -0
- package/src/core/model/TopologyDefinition.ts +117 -0
- package/test/addStep.spec.ts +124 -0
- package/test/addStep1.yaml +27 -0
- package/test/allowableValues.camel.yaml +19 -0
- package/test/allowableValues.spec.ts +30 -0
- package/test/avro-serialize-action.kamelet.yaml +70 -0
- package/test/beans.spec.ts +92 -0
- package/test/beans1.yaml +36 -0
- package/test/beans2.yaml +42 -0
- package/test/beans3.yaml +7 -0
- package/test/checkRequired.spec.ts +53 -0
- package/test/circuitBreaker.spec.ts +57 -0
- package/test/circuitBreaker.yaml +19 -0
- package/test/cloneDefinition.spec.ts +106 -0
- package/test/createKamelet.spec.ts +38 -0
- package/test/cxf.json +615 -0
- package/test/cxf.spec.ts +44 -0
- package/test/cxf.yaml +15 -0
- package/test/deleteStep.spec.ts +74 -0
- package/test/demo.spec.ts +49 -0
- package/test/demo.yaml +32 -0
- package/test/doCatchOnWhen.camel.yaml +20 -0
- package/test/doCatchOnWhen.spec.ts +36 -0
- package/test/errorHandler.spec.ts +38 -0
- package/test/errorHandler1.yaml +27 -0
- package/test/expression.spec.ts +55 -0
- package/test/findStep.spec.ts +112 -0
- package/test/findStep.yaml +65 -0
- package/test/getElementProperties.spec.ts +32 -0
- package/test/getElementPropertiesByName.spec.ts +31 -0
- package/test/getExpressionLanguage.spec.ts +40 -0
- package/test/hasElementWithId.camel.yaml +98 -0
- package/test/hasElementWithId.spec.ts +57 -0
- package/test/hasElementWithId1.camel.yaml +16 -0
- package/test/hasElementWithIdError.camel.yaml +98 -0
- package/test/integration.spec.ts +60 -0
- package/test/integration1.yaml +24 -0
- package/test/integration2.yaml +23 -0
- package/test/integrationToYaml.spec.ts +51 -0
- package/test/intercept.spec.ts +62 -0
- package/test/intercept.yaml +19 -0
- package/test/is-not-integration.yaml +5114 -0
- package/test/isIntegration.spec.ts +45 -0
- package/test/kamelet.spec.ts +61 -0
- package/test/metadata/components.json +697 -0
- package/test/metadata/kamelets.yaml +23414 -0
- package/test/metadata/spiBeans.json +3094 -0
- package/test/multiObjectProperties.spec.ts +46 -0
- package/test/multiObjectProperties1.yaml +19 -0
- package/test/multiple.spec.ts +38 -0
- package/test/multiple.yaml +29 -0
- package/test/openapi.spec.ts +48 -0
- package/test/openapi.yaml +7 -0
- package/test/placeholder.spec.ts +32 -0
- package/test/placeholder.yaml +133 -0
- package/test/plain-try-catch.yaml +31 -0
- package/test/plain.spec.ts +72 -0
- package/test/plain1.yaml +22 -0
- package/test/plain2.yaml +13 -0
- package/test/plain3.yaml +5 -0
- package/test/plain4.yaml +5 -0
- package/test/postgresql-source.kamelet.yaml +113 -0
- package/test/restConfigDsl.yaml +15 -0
- package/test/restDsl.spec.ts +83 -0
- package/test/restDsl.yaml +29 -0
- package/test/routes.spec.ts +37 -0
- package/test/routes1.yaml +31 -0
- package/test/supported-components.json +1221 -0
- package/test/supportedComponents.spec.ts +34 -0
- package/test/template1.AggregationStrategy.java +21 -0
- package/test/template1.Processor.java +13 -0
- package/test/template2.AggregationStrategy.java +21 -0
- package/test/template2.Processor.java +13 -0
- package/test/templateApi.spec.ts +45 -0
- package/test/timer-source.kamelet.yaml +75 -0
- package/test/tod.spec.ts +31 -0
- package/test/tod.yaml +9 -0
- package/test/topology.spec.ts +51 -0
- package/test/topology1.camel.yaml +56 -0
- package/test/topology2.camel.yaml +44 -0
- package/test/topology3.camel.yaml +27 -0
- package/test/tsconfig.testing.json +14 -0
- package/test/updateStep.spec.ts +72 -0
- package/test/variable1.camel.yaml +42 -0
- package/test/variable2.camel.yaml +42 -0
- package/test/variables.spec.ts +34 -0
- package/tsconfig.json +34 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
4
|
+
* this work for additional information regarding copyright ownership.
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
7
|
+
* the License. You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
import {expect} from 'chai';
|
18
|
+
import 'mocha';
|
19
|
+
import {FromDefinition, ExpressionDefinition, PropertyExpressionDefinition} from "../src/core/model/CamelDefinition";
|
20
|
+
import {Integration} from "../src/core/model/IntegrationDefinition";
|
21
|
+
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
22
|
+
import {RouteDefinition, SagaDefinition, ToDefinition} from "../src/core/model/CamelDefinition";
|
23
|
+
import * as fs from 'fs';
|
24
|
+
|
25
|
+
describe('Multi object property', () => {
|
26
|
+
// TODO: Make new test for multiobject property because wireTab has no setHeader anymore
|
27
|
+
|
28
|
+
it('Saga options', () => {
|
29
|
+
const i = Integration.createNew("test")
|
30
|
+
const option1 = new PropertyExpressionDefinition({key:"key1", expression: new ExpressionDefinition({simple:"${body}"})})
|
31
|
+
const option2 = new PropertyExpressionDefinition({key:"key2", expression: new ExpressionDefinition({simple:"${headers}"})})
|
32
|
+
const saga = new SagaDefinition({steps: [new ToDefinition({uri: "direct"})], option: [option1, option2]})
|
33
|
+
const flow1 = new FromDefinition({uri: "direct1"});
|
34
|
+
flow1.steps?.push(saga);
|
35
|
+
i.spec.flows?.push(new RouteDefinition({from: flow1}));
|
36
|
+
|
37
|
+
const yaml = fs.readFileSync('test/multiObjectProperties1.yaml', {encoding: 'utf8', flag: 'r'});
|
38
|
+
|
39
|
+
const i2 = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml);
|
40
|
+
|
41
|
+
const s: SagaDefinition = i2.spec.flows?.[0].from.steps[0] as SagaDefinition;
|
42
|
+
const t: ToDefinition | undefined = s.steps?.[0] as ToDefinition;
|
43
|
+
expect(t?.uri).to.equal('direct');
|
44
|
+
});
|
45
|
+
|
46
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- route:
|
2
|
+
id: route-e653
|
3
|
+
from:
|
4
|
+
uri: direct1
|
5
|
+
id: from-6ecf
|
6
|
+
steps:
|
7
|
+
- saga:
|
8
|
+
option:
|
9
|
+
- key: key1
|
10
|
+
expression:
|
11
|
+
simple: ${body}
|
12
|
+
- key: key2
|
13
|
+
expression:
|
14
|
+
simple: ${headers}
|
15
|
+
id: saga-726c
|
16
|
+
steps:
|
17
|
+
- to:
|
18
|
+
uri: direct:direct2
|
19
|
+
id: to-efd8
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
4
|
+
* this work for additional information regarding copyright ownership.
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
7
|
+
* the License. You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
import {expect} from 'chai';
|
18
|
+
import * as fs from 'fs';
|
19
|
+
import 'mocha';
|
20
|
+
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
21
|
+
|
22
|
+
|
23
|
+
describe('Plain YAML to integration', () => {
|
24
|
+
|
25
|
+
it('YAML <-> Object', () => {
|
26
|
+
const yaml = fs.readFileSync('test/multiple.yaml',{encoding:'utf8', flag:'r'});
|
27
|
+
const i = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml);
|
28
|
+
expect(i.metadata.name).to.equal('test1.yaml');
|
29
|
+
expect(i.kind).to.equal('Integration');
|
30
|
+
expect(i.spec.flows?.length).to.equal(2);
|
31
|
+
expect(i.type).to.equal('plain');
|
32
|
+
if (i.spec.flows) {
|
33
|
+
expect(i.spec.flows[0].from.uri).to.equal('netty-http');
|
34
|
+
expect(i.spec.flows[1].from.uri).to.equal('kamelet:aws-kinesis-source');
|
35
|
+
}
|
36
|
+
});
|
37
|
+
|
38
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
- from:
|
2
|
+
uri: netty-http
|
3
|
+
parameters:
|
4
|
+
protocol: http
|
5
|
+
host: localhost
|
6
|
+
port: 8080
|
7
|
+
path: demo
|
8
|
+
steps:
|
9
|
+
- convertBodyTo:
|
10
|
+
type: String
|
11
|
+
- unmarshal:
|
12
|
+
json: {}
|
13
|
+
- choice:
|
14
|
+
when:
|
15
|
+
- expression:
|
16
|
+
simple: ${body[amount]} < 1000
|
17
|
+
steps:
|
18
|
+
- log:
|
19
|
+
message: 'WHEN: ${body}'
|
20
|
+
logging-level: INFO
|
21
|
+
log-name: when
|
22
|
+
otherwise:
|
23
|
+
steps:
|
24
|
+
- log:
|
25
|
+
log-name: otherwise
|
26
|
+
logging-level: INFO
|
27
|
+
message: 'OTHERWISE: ${body}'
|
28
|
+
- from:
|
29
|
+
uri: kamelet:aws-kinesis-source
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
4
|
+
* this work for additional information regarding copyright ownership.
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
7
|
+
* the License. You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
import {expect} from 'chai';
|
18
|
+
import 'mocha';
|
19
|
+
import {
|
20
|
+
FromDefinition,
|
21
|
+
LogDefinition,
|
22
|
+
WhenDefinition,
|
23
|
+
ChoiceDefinition,
|
24
|
+
MulticastDefinition,
|
25
|
+
ExpressionDefinition,
|
26
|
+
RouteDefinition, TryDefinition, CatchDefinition, RestDefinition, GetDefinition, OpenApiDefinition,
|
27
|
+
} from '../src/core/model/CamelDefinition';
|
28
|
+
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
29
|
+
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
30
|
+
import {SimpleExpression} from "../src/core/model/CamelDefinition";
|
31
|
+
import {Integration} from "../src/core/model/IntegrationDefinition";
|
32
|
+
import * as fs from 'fs';
|
33
|
+
|
34
|
+
describe('OpenAPI', () => {
|
35
|
+
|
36
|
+
it('Simple config', () => {
|
37
|
+
let i = Integration.createNew("test")
|
38
|
+
|
39
|
+
const openApi = new OpenApiDefinition({specification: "openapi.json", id: 'openapi-1'});
|
40
|
+
const rest = new RestDefinition({id: 'rest-1', path: "/demo", description: "Hello World", openApi: openApi});
|
41
|
+
i = CamelDefinitionApiExt.addRestToIntegration(i, rest);
|
42
|
+
|
43
|
+
const yaml1 = CamelDefinitionYaml.integrationToYaml(i);
|
44
|
+
const yaml2 = fs.readFileSync('test/openapi.yaml', {encoding: 'utf8', flag: 'r'});
|
45
|
+
|
46
|
+
expect(yaml1).to.equal(yaml2);
|
47
|
+
});
|
48
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
4
|
+
* this work for additional information regarding copyright ownership.
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
7
|
+
* the License. You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
import {expect} from 'chai';
|
18
|
+
import * as fs from 'fs';
|
19
|
+
import 'mocha';
|
20
|
+
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
21
|
+
import {CamelUtil} from "../src/core/api/CamelUtil";
|
22
|
+
|
23
|
+
describe('Get Placeholders', () => {
|
24
|
+
|
25
|
+
it('Get Placeholders', () => {
|
26
|
+
const yaml = fs.readFileSync('test/placeholder.yaml',{encoding:'utf8', flag:'r'});
|
27
|
+
const i = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml);
|
28
|
+
const placeholders = CamelUtil.findPlaceholdersInObject(i);
|
29
|
+
expect(placeholders.size).to.equal(4);
|
30
|
+
});
|
31
|
+
|
32
|
+
});
|
@@ -0,0 +1,133 @@
|
|
1
|
+
apiVersion: camel.apache.org/v1
|
2
|
+
kind: Integration
|
3
|
+
metadata:
|
4
|
+
name: parceldemo
|
5
|
+
spec:
|
6
|
+
flows:
|
7
|
+
- rest:
|
8
|
+
post:
|
9
|
+
- to: direct:post
|
10
|
+
path: /parcels
|
11
|
+
consumes: application/json
|
12
|
+
produces: application/json
|
13
|
+
- route:
|
14
|
+
from:
|
15
|
+
uri: direct:post
|
16
|
+
steps:
|
17
|
+
- log:
|
18
|
+
message: 'Received: ${body}'
|
19
|
+
- multicast:
|
20
|
+
steps:
|
21
|
+
- to:
|
22
|
+
uri: kamelet:kafka-not-secured-sink
|
23
|
+
parameters:
|
24
|
+
topic: parcels
|
25
|
+
bootstrapServers: '{{kafka-brokers}}'
|
26
|
+
- to:
|
27
|
+
uri: kamelet:postgresql-sink
|
28
|
+
parameters:
|
29
|
+
serverName: '{{postgres-server}}'
|
30
|
+
serverPort: '5432'
|
31
|
+
username: postgres
|
32
|
+
password: postgres
|
33
|
+
databaseName: demo
|
34
|
+
query: >-
|
35
|
+
INSERT INTO parcels (id,address) VALUES
|
36
|
+
(:#id,:#address) ON CONFLICT (id) DO NOTHING
|
37
|
+
aggregationStrategy: >-
|
38
|
+
#class:org.apache.camel.processor.aggregate.UseOriginalAggregationStrategy
|
39
|
+
parallelProcessing: true
|
40
|
+
streaming: true
|
41
|
+
id: post
|
42
|
+
- route:
|
43
|
+
from:
|
44
|
+
uri: kamelet:jms-apache-artemis-source
|
45
|
+
steps:
|
46
|
+
- to:
|
47
|
+
uri: xj:identity
|
48
|
+
parameters:
|
49
|
+
transformDirection: XML2JSON
|
50
|
+
- to:
|
51
|
+
uri: kamelet:kafka-not-secured-sink
|
52
|
+
parameters:
|
53
|
+
topic: payments
|
54
|
+
bootstrapServers: '{{kafka-brokers}}'
|
55
|
+
parameters:
|
56
|
+
destinationType: queue
|
57
|
+
destinationName: payments
|
58
|
+
brokerURL: '{{jms-broker}}'
|
59
|
+
id: payment
|
60
|
+
- route:
|
61
|
+
from:
|
62
|
+
uri: kamelet:kafka-not-secured-source
|
63
|
+
steps:
|
64
|
+
- log:
|
65
|
+
message: 'Aggegating: ${body}'
|
66
|
+
- unmarshal:
|
67
|
+
json:
|
68
|
+
library: jackson
|
69
|
+
- aggregate:
|
70
|
+
steps:
|
71
|
+
- choice:
|
72
|
+
when:
|
73
|
+
- expression:
|
74
|
+
groovy:
|
75
|
+
expression: >-
|
76
|
+
body.find { it.containsKey('status') }.status ==
|
77
|
+
'confirmed'
|
78
|
+
steps:
|
79
|
+
- marshal:
|
80
|
+
json:
|
81
|
+
library: jackson
|
82
|
+
- log:
|
83
|
+
message: 'Send to MQTT : ${body}'
|
84
|
+
- to:
|
85
|
+
uri: kamelet:mqtt-sink
|
86
|
+
parameters:
|
87
|
+
topic: deliveries
|
88
|
+
brokerUrl: '{{mqtt-broker}}'
|
89
|
+
otherwise:
|
90
|
+
steps:
|
91
|
+
- setBody:
|
92
|
+
expression:
|
93
|
+
groovy:
|
94
|
+
expression: 'body.find { it.containsKey(''status'') } '
|
95
|
+
- marshal:
|
96
|
+
json:
|
97
|
+
library: jackson
|
98
|
+
- log:
|
99
|
+
message: 'Send to database: ${body}'
|
100
|
+
- to:
|
101
|
+
uri: kamelet:postgresql-sink
|
102
|
+
parameters:
|
103
|
+
serverName: '{{postgres-server}}'
|
104
|
+
serverPort: '5432'
|
105
|
+
username: postgres
|
106
|
+
password: postgres
|
107
|
+
databaseName: demo
|
108
|
+
query: >-
|
109
|
+
UPDATE parcels set status = 'CANCELED' WHERE
|
110
|
+
id = :#id
|
111
|
+
aggregationStrategy: aggregator
|
112
|
+
completionSize: 2
|
113
|
+
correlationExpression:
|
114
|
+
groovy:
|
115
|
+
expression: body.get('id')
|
116
|
+
parameters:
|
117
|
+
topic: parcels,payments
|
118
|
+
bootstrapServers: '{{kafka-brokers}}'
|
119
|
+
autoCommitEnable: true
|
120
|
+
consumerGroup: parceldemo
|
121
|
+
id: aggregator
|
122
|
+
- route:
|
123
|
+
from:
|
124
|
+
uri: kamelet:mqtt-source
|
125
|
+
steps:
|
126
|
+
- log:
|
127
|
+
message: 'Delivery: ${body}'
|
128
|
+
parameters:
|
129
|
+
topic: deliveries
|
130
|
+
brokerUrl: '{{mqtt-broker}}'
|
131
|
+
- beans:
|
132
|
+
- name: aggregator
|
133
|
+
type: org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy
|
@@ -0,0 +1,31 @@
|
|
1
|
+
- route:
|
2
|
+
id: route-1
|
3
|
+
from:
|
4
|
+
id: from-1
|
5
|
+
uri: timer
|
6
|
+
parameters:
|
7
|
+
name: info
|
8
|
+
steps:
|
9
|
+
- doTry:
|
10
|
+
id: doTry-1
|
11
|
+
doCatch:
|
12
|
+
- id: doCatch-1
|
13
|
+
exception:
|
14
|
+
- java.lang.ArithmeticException
|
15
|
+
steps:
|
16
|
+
- log:
|
17
|
+
id: log-1
|
18
|
+
message: Exception
|
19
|
+
doFinally:
|
20
|
+
id: doFinally-1
|
21
|
+
steps:
|
22
|
+
- log:
|
23
|
+
id: log-2
|
24
|
+
message: ${body}
|
25
|
+
steps:
|
26
|
+
- setBody:
|
27
|
+
id: setBody-1
|
28
|
+
expression:
|
29
|
+
groovy:
|
30
|
+
id: groovy-1
|
31
|
+
expression: 1000 / 0
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
4
|
+
* this work for additional information regarding copyright ownership.
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
7
|
+
* the License. You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
import {expect} from 'chai';
|
18
|
+
import * as fs from 'fs';
|
19
|
+
import 'mocha';
|
20
|
+
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
21
|
+
|
22
|
+
|
23
|
+
describe('Plain YAML to integration', () => {
|
24
|
+
|
25
|
+
it('YAML <-> Object', () => {
|
26
|
+
const yaml = fs.readFileSync('test/plain1.yaml',{encoding:'utf8', flag:'r'});
|
27
|
+
const i = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml);
|
28
|
+
expect(i.metadata.name).to.equal('test1.yaml');
|
29
|
+
expect(i.kind).to.equal('Integration');
|
30
|
+
expect(i.spec.flows?.length).to.equal(1);
|
31
|
+
expect(i.type).to.equal('plain');
|
32
|
+
if (i.spec.flows) {
|
33
|
+
expect(i.spec.flows[0].from.uri).to.equal('timer');
|
34
|
+
expect(i.spec.flows[0].from.steps[0].when.length).to.equal(2);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
|
38
|
+
it('YAML <-> Object 2', () => {
|
39
|
+
const yaml = fs.readFileSync('test/plain2.yaml',{encoding:'utf8', flag:'r'});
|
40
|
+
const i = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml);
|
41
|
+
expect(i.metadata.name).to.equal('test1.yaml');
|
42
|
+
expect(i.kind).to.equal('Integration');
|
43
|
+
expect(i.spec.flows?.length).to.equal(1);
|
44
|
+
expect(i.type).to.equal('plain');
|
45
|
+
if (i.spec.flows) {
|
46
|
+
expect(i.spec.flows[0].from.uri).to.equal('timer');
|
47
|
+
expect(i.spec.flows[0].from.parameters.name).to.equal('info');
|
48
|
+
expect(i.spec.flows[0].from.steps[0].expression.constant.expression).to.equal("Hello Yaml !!!");
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
it('Boolean Properties', () => {
|
53
|
+
const yaml1 = fs.readFileSync('test/plain3.yaml',{encoding:'utf8', flag:'r'});
|
54
|
+
const yaml2 = fs.readFileSync('test/plain4.yaml',{encoding:'utf8', flag:'r'});
|
55
|
+
const i = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml1);
|
56
|
+
(i.spec.flows?.at(0)).autoStartup = false;
|
57
|
+
const y = CamelDefinitionYaml.integrationToYaml(i);
|
58
|
+
expect(y).to.equal(yaml2.replaceAll("\r\n", "\n")); // replace for Windows compatibility
|
59
|
+
});
|
60
|
+
|
61
|
+
it('YAML <-> Integration', () => {
|
62
|
+
const yaml = fs.readFileSync('test/plain-try-catch.yaml',{encoding:'utf8', flag:'r'});
|
63
|
+
const i = CamelDefinitionYaml.yamlToIntegration("try-catch.yaml", yaml);
|
64
|
+
expect(i.metadata.name).to.equal('try-catch.yaml');
|
65
|
+
expect(i.kind).to.equal('Integration');
|
66
|
+
expect(i.spec.flows?.length).to.equal(1);
|
67
|
+
expect(i.type).to.equal('plain');
|
68
|
+
const yaml2 = CamelDefinitionYaml.integrationToYaml(i);
|
69
|
+
expect(yaml.replaceAll("\r\n", "\n")).to.equal(yaml2); // replace for Windows compatibility
|
70
|
+
});
|
71
|
+
|
72
|
+
});
|
package/test/plain1.yaml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
- from:
|
2
|
+
uri: timer
|
3
|
+
id: from-1
|
4
|
+
parameters:
|
5
|
+
name: info
|
6
|
+
steps:
|
7
|
+
- choice:
|
8
|
+
when:
|
9
|
+
- expression:
|
10
|
+
simple:
|
11
|
+
expression: ${headers} != null
|
12
|
+
steps:
|
13
|
+
- log:
|
14
|
+
message: hello11
|
15
|
+
logName: log11
|
16
|
+
- expression:
|
17
|
+
simple:
|
18
|
+
expression: ${headers} == null
|
19
|
+
steps:
|
20
|
+
- log:
|
21
|
+
message: hello22
|
22
|
+
logName: log22
|
package/test/plain2.yaml
ADDED
package/test/plain3.yaml
ADDED
package/test/plain4.yaml
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# ---------------------------------------------------------------------------
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright ownership.
|
5
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
# (the "License"); you may not use this file except in compliance with
|
7
|
+
# the License. You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
# ---------------------------------------------------------------------------
|
17
|
+
apiVersion: camel.apache.org/v1
|
18
|
+
kind: Kamelet
|
19
|
+
metadata:
|
20
|
+
name: postgresql-source
|
21
|
+
annotations:
|
22
|
+
camel.apache.org/kamelet.support.level: "Stable"
|
23
|
+
camel.apache.org/catalog.version: "4.6.0-SNAPSHOT"
|
24
|
+
camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG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wIDAgMCAuMTQ4LjA3Yy4xNzEuMDUyLjQ1OC4wODYuNzc4LjA4MS42MzgtLjAwNyAxLjQyMy0uMTU2IDEuODQtLjM1YTMuOTUgMy45NSAwIDAgMCAuOTQzLS42MTVoLS4wMDFjLTEuMzkzLjI4OC0yLjE4LjIxMS0yLjY2My4wMTJhMS4zMTUgMS4zMTUgMCAwIDEtLjMzMi0uMnptLTguMDMxLjA5NGgtLjAyMWMtLjA1My4wMDUtLjEzLjAyMy0uMjc5LjE4OC0uMzQ4LjM5LS40Ny42MzUtLjc1Ny44NjQtLjI4Ny4yMjgtLjY2LjM1LTEuNDA1LjUwMy0uMjM2LjA0OC0uMzcxLjEwMS0uNDYxLjE0NC4wMjkuMDI0LjAyNi4wMy4wNy4wNTMuMTA5LjA2LjI0OS4xMTMuMzYyLjE0Mi4zMi4wOC44NDYuMTczIDEuMzk1LjA4LjU0OS0uMDk0IDEuMTItLjM1NyAxLjYwNy0xLjA0LjA4NC0uMTE4LjA5My0uMjkyLjAyNC0uNDc5LS4wNy0uMTg3LS4yMjMtLjM0OC0uMzMxLS4zOTNhLjY1My42NTMgMCAwIDAtLjIwNC0uMDZ6Ii8+PC9zdmc+"
|
25
|
+
camel.apache.org/provider: "Apache Software Foundation"
|
26
|
+
camel.apache.org/kamelet.group: "SQL"
|
27
|
+
camel.apache.org/kamelet.namespace: "Database"
|
28
|
+
labels:
|
29
|
+
camel.apache.org/kamelet.type: "source"
|
30
|
+
spec:
|
31
|
+
definition:
|
32
|
+
title: "PostgreSQL Source"
|
33
|
+
description: |-
|
34
|
+
Query data from a PostgreSQL Database.
|
35
|
+
required:
|
36
|
+
- serverName
|
37
|
+
- username
|
38
|
+
- password
|
39
|
+
- query
|
40
|
+
- databaseName
|
41
|
+
type: object
|
42
|
+
properties:
|
43
|
+
serverName:
|
44
|
+
title: Server Name
|
45
|
+
description: The server name for the data source.
|
46
|
+
type: string
|
47
|
+
example: localhost
|
48
|
+
serverPort:
|
49
|
+
title: Server Port
|
50
|
+
description: The server port for the data source.
|
51
|
+
type: string
|
52
|
+
default: 5432
|
53
|
+
username:
|
54
|
+
title: Username
|
55
|
+
description: The username to access a secured PostgreSQL Database.
|
56
|
+
type: string
|
57
|
+
x-descriptors:
|
58
|
+
- urn:camel:group:credentials
|
59
|
+
password:
|
60
|
+
title: Password
|
61
|
+
description: The password to access a secured PostgreSQL Database.
|
62
|
+
type: string
|
63
|
+
format: password
|
64
|
+
x-descriptors:
|
65
|
+
- urn:camel:group:credentials
|
66
|
+
query:
|
67
|
+
title: Query
|
68
|
+
description: The query to execute against the PostgreSQL Database.
|
69
|
+
type: string
|
70
|
+
example: 'INSERT INTO accounts (username,city) VALUES (:#username,:#city)'
|
71
|
+
databaseName:
|
72
|
+
title: Database Name
|
73
|
+
description: The name of the PostgreSQL Database.
|
74
|
+
type: string
|
75
|
+
consumedQuery:
|
76
|
+
title: Consumed Query
|
77
|
+
description: A query to run on a tuple consumed.
|
78
|
+
type: string
|
79
|
+
example: 'DELETE FROM accounts where user_id = :#user_id'
|
80
|
+
delay:
|
81
|
+
title: Delay
|
82
|
+
description: The number of milliseconds before the next poll
|
83
|
+
type: integer
|
84
|
+
default: 500
|
85
|
+
types:
|
86
|
+
out:
|
87
|
+
mediaType: application/json
|
88
|
+
dependencies:
|
89
|
+
- "camel:jackson"
|
90
|
+
- "camel:kamelet"
|
91
|
+
- "camel:sql"
|
92
|
+
- "mvn:org.postgresql:postgresql:42.7.3"
|
93
|
+
- "mvn:org.apache.commons:commons-dbcp2:2.12.0"
|
94
|
+
template:
|
95
|
+
beans:
|
96
|
+
- name: dsBean
|
97
|
+
type: "#class:org.apache.commons.dbcp2.BasicDataSource"
|
98
|
+
properties:
|
99
|
+
username: '{{username}}'
|
100
|
+
password: '{{password}}'
|
101
|
+
url: 'jdbc:postgresql://{{serverName}}:{{serverPort}}/{{databaseName}}'
|
102
|
+
driverClassName: 'org.postgresql.Driver'
|
103
|
+
from:
|
104
|
+
uri: "sql:{{query}}"
|
105
|
+
parameters:
|
106
|
+
dataSource: "#bean:{{dsBean}}"
|
107
|
+
onConsume: "{{?consumedQuery}}"
|
108
|
+
delay: "{{delay}}"
|
109
|
+
steps:
|
110
|
+
- marshal:
|
111
|
+
json:
|
112
|
+
library: Jackson
|
113
|
+
- to: "kamelet:sink"
|