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