websvc.restkit/test/qa-functional/src/org/netbeans/modules/ws/qaf/rest/JMakiTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun Nov 22 11:35:02 2009 +0100 (10 hours ago)
changeset 154033 fa8b12981306
parent 1161322e479dce2e1d
permissions -rw-r--r--
Merge RP javadoc improvements
     1 /*
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3  *
     4  * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
     5  *
     6  * The contents of this file are subject to the terms of either the GNU
     7  * General Public License Version 2 only ("GPL") or the Common
     8  * Development and Distribution License("CDDL") (collectively, the
     9  * "License"). You may not use this file except in compliance with the
    10  * License. You can obtain a copy of the License at
    11  * http://www.netbeans.org/cddl-gplv2.html
    12  * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    13  * specific language governing permissions and limitations under the
    14  * License.  When distributing the software, include this License Header
    15  * Notice in each file and include the License file at
    16  * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    17  * particular file as subject to the "Classpath" exception as provided
    18  * by Sun in the GPL Version 2 section of the License file that
    19  * accompanied this code. If applicable, add the following below the
    20  * License Header, with the fields enclosed by brackets [] replaced by
    21  * your own identifying information:
    22  * "Portions Copyrighted [year] [name of copyright owner]"
    23  *
    24  * If you wish your version of this file to be governed by only the CDDL
    25  * or only the GPL Version 2, indicate your decision by adding
    26  * "[Contributor] elects to include this software in this distribution
    27  * under the [CDDL or GPL Version 2] license." If you do not indicate a
    28  * single choice of license, a recipient has the option to distribute
    29  * your version of this file under either the CDDL, the GPL Version 2 or
    30  * to extend the choice of license to its licensees as provided above.
    31  * However, if you add GPL Version 2 code and therefore, elected the GPL
    32  * Version 2 license, then the option applies only if the new code is
    33  * made subject to such option by the copyright holder.
    34  *
    35  * Contributor(s):
    36  *
    37  * Portions Copyrighted 2008 Sun Microsystems, Inc.
    38  */
    39 package org.netbeans.modules.ws.qaf.rest;
    40 
    41 import junit.framework.Test;
    42 import org.netbeans.jellytools.Bundle;
    43 import org.netbeans.jellytools.NbDialogOperator;
    44 import org.netbeans.jellytools.nodes.Node;
    45 import org.netbeans.jemmy.operators.JButtonOperator;
    46 import org.netbeans.jemmy.operators.JListOperator;
    47 import org.netbeans.jemmy.operators.JTreeOperator;
    48 import org.netbeans.junit.NbModuleSuite;
    49 
    50 /**
    51  * Test jMaki client stub.
    52  *
    53  * Running of this test suite can be influenced by following system properties:
    54  * "plugins.jmaki.skip=true"
    55  *    - skipping this suite and related preparation steps (un/installing of the jMaki plugin)
    56  * "plugins.jmaki.nbm=/path/to/jmaki.nbm"
    57  *    - where to find jmaki.nbm (default is to download nbm from:
    58  *      https://ajax.dev.java.net/files/documents/3115/90944/org-netbeans-modules-sun-jmaki.nbm)
    59  *
    60  * @author lukas
    61  */
    62 public class JMakiTest extends RestCStubsTest {
    63 
    64     public JMakiTest(String name) {
    65         super(name);
    66     }
    67 
    68     @Override
    69     public void setUp() throws Exception {
    70         if (!Boolean.getBoolean("plugins.jmaki.skip")) {
    71             super.setUp();
    72             try {
    73                 Class.forName("org.netbeans.modules.sun.jmaki.Installer");
    74             } catch (ClassNotFoundException ex) {
    75                 fail("jMaki is not installed.");
    76             }
    77         }
    78     }
    79 
    80     @Override
    81     protected String getProjectName() {
    82         return "JMakiClient"; //NOI18N
    83     }
    84 
    85     @Override
    86     protected boolean useJMaki() {
    87         return true;
    88     }
    89 
    90     /**
    91      * Test stubs creation from a foreign project
    92      */
    93     public void testCreateStubs() {
    94         addJMakiFrameWork();
    95         createStubs("FromEntities"); //NOI18N
    96     }
    97 
    98     /**
    99      * Dummy test for the case when we know that jMaki related tests will not run
   100      */
   101     public void testJMakiTestsSkipped() {
   102         //nothing to do
   103     }
   104 
   105     private void addJMakiFrameWork() {
   106         // open project properties
   107         getProjectRootNode().properties();
   108         // "Project Properties"
   109         String projectPropertiesTitle = Bundle.getStringTrimmed("org.netbeans.modules.web.project.ui.customizer.Bundle", "LBL_Customizer_Title");
   110         NbDialogOperator propertiesDialogOper = new NbDialogOperator(projectPropertiesTitle);
   111         // select "Frameworks" category
   112         String frmLabel = Bundle.getStringTrimmed("org.netbeans.modules.web.project.ui.customizer.Bundle", "LBL_Config_Frameworks");
   113         new Node(new JTreeOperator(propertiesDialogOper), frmLabel).select();
   114         //Add ...
   115         String addBtn = Bundle.getStringTrimmed("org.netbeans.modules.web.project.ui.customizer.Bundle", "LBL_AddFramework");
   116         new JButtonOperator(propertiesDialogOper, addBtn).pushNoBlock();
   117         //Add a Framework
   118         String addFrameworkTitle = Bundle.getStringTrimmed("org.netbeans.modules.web.project.ui.customizer.Bundle", "LBL_SelectWebExtension_DialogTitle");
   119         NbDialogOperator addFrameworkDialogOper = new NbDialogOperator(addFrameworkTitle);
   120         new JListOperator(addFrameworkDialogOper).selectItem("jMaki"); //NOI18N
   121         addFrameworkDialogOper.ok();
   122         // confirm properties dialog
   123         propertiesDialogOper.ok();
   124         // if setting default server, it scans server jars; otherwise it continues immediatelly
   125         waitScanFinished();
   126     }
   127 
   128     /**
   129      * Creates suite from particular test cases. You can define order of testcases here.
   130      */
   131     public static Test suite() {
   132         if (!Boolean.getBoolean("plugins.jmaki.skip")) { //NOI18N
   133             return NbModuleSuite.create(addServerTests(NbModuleSuite.createConfiguration(JMakiTest.class),
   134                     "testCreateStubs",
   135                     "testFromWADL",
   136                     "testCloseProject"
   137                     ).enableModules(".*").clusters(".*"));
   138         } else {
   139             return NbModuleSuite.create(addServerTests(NbModuleSuite.createConfiguration(JMakiTest.class),
   140                     "testJMakiTestsSkipped"
   141                     ).enableModules(".*").clusters(".*"));
   142         }
   143     }
   144 }