boot/src/test/java/org/netbeans/html/boot/impl/JsCallbackTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 02 Aug 2014 12:59:31 +0200
changeset 790 30f20d9c0986
parent 651 ab2e8d07758b
child 838 bdc3d696dd4a
permissions -rw-r--r--
Fixing Javadoc to succeed on JDK8
jtulach@651
     1
/**
jtulach@651
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jtulach@651
     3
 *
jtulach@651
     4
 * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
jtulach@651
     5
 *
jtulach@651
     6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
jtulach@651
     7
 * Other names may be trademarks of their respective owners.
jtulach@651
     8
 *
jtulach@651
     9
 * The contents of this file are subject to the terms of either the GNU
jtulach@651
    10
 * General Public License Version 2 only ("GPL") or the Common
jtulach@651
    11
 * Development and Distribution License("CDDL") (collectively, the
jtulach@651
    12
 * "License"). You may not use this file except in compliance with the
jtulach@651
    13
 * License. You can obtain a copy of the License at
jtulach@651
    14
 * http://www.netbeans.org/cddl-gplv2.html
jtulach@651
    15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jtulach@651
    16
 * specific language governing permissions and limitations under the
jtulach@651
    17
 * License.  When distributing the software, include this License Header
jtulach@651
    18
 * Notice in each file and include the License file at
jtulach@651
    19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
jtulach@651
    20
 * particular file as subject to the "Classpath" exception as provided
jtulach@651
    21
 * by Oracle in the GPL Version 2 section of the License file that
jtulach@651
    22
 * accompanied this code. If applicable, add the following below the
jtulach@651
    23
 * License Header, with the fields enclosed by brackets [] replaced by
jtulach@651
    24
 * your own identifying information:
jtulach@651
    25
 * "Portions Copyrighted [year] [name of copyright owner]"
jtulach@651
    26
 *
jtulach@651
    27
 * Contributor(s):
jtulach@651
    28
 *
jtulach@651
    29
 * The Original Software is NetBeans. The Initial Developer of the Original
jtulach@651
    30
 * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
jtulach@651
    31
 *
jtulach@651
    32
 * If you wish your version of this file to be governed by only the CDDL
jtulach@651
    33
 * or only the GPL Version 2, indicate your decision by adding
jtulach@651
    34
 * "[Contributor] elects to include this software in this distribution
jtulach@651
    35
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
jtulach@651
    36
 * single choice of license, a recipient has the option to distribute
jtulach@651
    37
 * your version of this file under either the CDDL, the GPL Version 2 or
jtulach@651
    38
 * to extend the choice of license to its licensees as provided above.
jtulach@651
    39
 * However, if you add GPL Version 2 code and therefore, elected the GPL
jtulach@651
    40
 * Version 2 license, then the option applies only if the new code is
jtulach@651
    41
 * made subject to such option by the copyright holder.
jtulach@651
    42
 */
jtulach@651
    43
package org.netbeans.html.boot.impl;
jtulach@651
    44
jtulach@651
    45
import static org.testng.Assert.*;
jtulach@651
    46
import org.testng.annotations.Test;
jtulach@651
    47
jtulach@651
    48
/** Verify behavior of the callback parser.
jtulach@651
    49
 *
jtulach@790
    50
 * @author Jaroslav Tulach
jtulach@651
    51
 */
jtulach@651
    52
public class JsCallbackTest {
jtulach@651
    53
    
jtulach@651
    54
    public JsCallbackTest() {
jtulach@651
    55
    }
jtulach@651
    56
    @Test public void missingTypeSpecification() {
jtulach@651
    57
        String body = "console[attr] = function(msg) {\n"
jtulach@651
    58
        + "  @org.apidesign.html.charts.Main::log(msg);\n"
jtulach@651
    59
        + "};\n";
jtulach@651
    60
        JsCallback instance = new JsCallbackImpl();
jtulach@651
    61
        try {
jtulach@651
    62
            String result = instance.parse(body);
jtulach@651
    63
            fail("The parsing should fail!");
jtulach@651
    64
        } catch (IllegalStateException ex) {
jtulach@651
    65
            // OK
jtulach@651
    66
        }
jtulach@651
    67
    }
jtulach@651
    68
jtulach@651
    69
jtulach@651
    70
    public class JsCallbackImpl extends JsCallback {
jtulach@651
    71
        private String ident;
jtulach@651
    72
        private String fqn;
jtulach@651
    73
        private String method;
jtulach@651
    74
        private String params;
jtulach@651
    75
        
jtulach@651
    76
        @Override
jtulach@651
    77
        public CharSequence callMethod(String ident, String fqn, String method, String params) {
jtulach@651
    78
            this.ident = ident;
jtulach@651
    79
            this.fqn = fqn;
jtulach@651
    80
            this.method = method;
jtulach@651
    81
            this.params = params;
jtulach@651
    82
            return "call";
jtulach@651
    83
        }
jtulach@651
    84
    }
jtulach@651
    85
    
jtulach@651
    86
}