Skip to content

Commit b89b068

Browse files
committed
Provide test for Camel DSL combination validation camel-tooling#11
also extract utils related tests to a specific utils.js file Signed-off-by: Aurélien Pupier <[email protected]>
1 parent 76e3c21 commit b89b068

File tree

2 files changed

+68
-23
lines changed

2 files changed

+68
-23
lines changed

Diff for: test/app.js

-23
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,6 @@ var defaultCamel = '2.22.2';
2929

3030
describe('generator-camel:app', function () {
3131

32-
describe('Should test the utils class package validation', function () {
33-
it('utilities package validation should work for valid package', function () {
34-
assert.strictEqual(utils.validatePackage('com.valid'), true);
35-
});
36-
it('utilities package validation should fail for package name with invalid characters', function () {
37-
assert.notStrictEqual(utils.validatePackage('[email protected]'), true);
38-
});
39-
it('utilities package validation should fail for package name with java keyword', function () {
40-
assert.notStrictEqual(utils.validatePackage('a.name.with.package'), true);
41-
});
42-
43-
it('utilities findWsdl2RestJar should succeed in finding wsdl2rest jar', function () {
44-
// test runs on its own but fails in the larger test suite - still figuring that out
45-
var targetDir = path.join(__dirname, '../app/wsdl2rest/target');
46-
var jar = utils.findWsdl2RestJar(targetDir);
47-
assert.notStrictEqual(jar, null);
48-
console.log(`jar: ${jar}`);
49-
assert.strictEqual(jar.includes('wsdl2rest-impl-fatjar-'), true);
50-
assert.strictEqual(jar.endsWith('.jar'), true);
51-
assert.notStrictEqual(jar.endsWith('.original'), true);
52-
});
53-
});
54-
5532
describe('Should properly scaffold with default config for Spring', function () {
5633

5734
before(function () {

Diff for: test/utils.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
18+
'use strict';
19+
var path = require('path');
20+
const chalk = require('chalk');
21+
const utils = require('../app/util');
22+
var assert = require('yeoman-assert');
23+
24+
describe('Should test the utils class package validation', function () {
25+
it('utilities package validation should work for valid package', function () {
26+
assert.strictEqual(utils.validatePackage('com.valid'), true);
27+
});
28+
it('utilities package validation should fail for package name with invalid characters', function () {
29+
assert.notStrictEqual(utils.validatePackage('[email protected]'), true);
30+
});
31+
it('utilities package validation should fail for package name with java keyword', function () {
32+
assert.notStrictEqual(utils.validatePackage('a.name.with.package'), true);
33+
});
34+
});
35+
36+
describe('Should test the utils class Wsdl2Rest jar finding', function () {
37+
it('utilities findWsdl2RestJar should succeed in finding wsdl2rest jar', function () {
38+
// test runs on its own but fails in the larger test suite - still figuring that out
39+
var targetDir = path.join(__dirname, '../app/wsdl2rest/target');
40+
var jar = utils.findWsdl2RestJar(targetDir);
41+
assert.notStrictEqual(jar, null);
42+
console.log(`jar: ${jar}`);
43+
assert.strictEqual(jar.includes('wsdl2rest-impl-fatjar-'), true);
44+
assert.strictEqual(jar.endsWith('.jar'), true);
45+
assert.notStrictEqual(jar.endsWith('.original'), true);
46+
});
47+
});
48+
49+
describe('Should test the utils Camel DSL validation', function () {
50+
it('allows Spring for non wsdl2rest', function () {
51+
assert.strictEqual(utils.validateCamelDSL('spring', false), true);
52+
});
53+
it('allows Spring for wsdl2rest', function () {
54+
assert.strictEqual(utils.validateCamelDSL('spring', true), true);
55+
});
56+
it('allows Blueprint for non wsdl2rest', function () {
57+
assert.strictEqual(utils.validateCamelDSL('blueprint', false), true);
58+
});
59+
it('allows Blueprint for wsdl2rest', function () {
60+
assert.strictEqual(utils.validateCamelDSL('blueprint', true), true);
61+
});
62+
it('allows Java for non wsdl2rest', function () {
63+
assert.strictEqual(utils.validateCamelDSL('java', false), true);
64+
});
65+
it('does not allow Java for wsdl2rest', function () {
66+
assert.strictEqual(utils.validateCamelDSL('java', true), chalk.red('When using wsdl2rest, the Camel DSL must be either \'spring\' or \'blueprint\'.'));
67+
});
68+
});

0 commit comments

Comments
 (0)