Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.kuali.student.common.test.spring;
 
This class will start a Jetty server and deploy an exploded war file defined in @IntegrationServer annotation.

@IntegrationServer annotation takes the following parameters:

  • port - Server port to deploy web application on e.g. 9090
  • webAppPath - Webapp path of exploded war file e.g. brms-ws-1.0.0.war
  • contextPath - Servlet context path e.g. brms-ws-1.0.0

The @SystemProperties and @Property annotation is used to set System properties before starting the Jetty server. For instance, if you want to set the catalina.base path or the URL or port of a service that is different from what is specified in the file CXF configuration in the war file.

@SystemProperties takes the following parameter:

  • properties - List of Property to set

@Property takes the following parameter:

  • key - Property key
  • value - Property value

Example 1: Setup an integration test on port 8080 which is the same port as specified in the application.properties file in the war file.

 @IntegrationServer(
     port=8080, 
     webAppPath="../../../brms-ws/target/brms-ws-0.1.0-SNAPSHOT", 
     contextPath="/brms-ws-0.1.0-SNAPSHOT")
 
Example 2: Setup an integration test on port 9090 which is different from what is specified in the application.properties file in the war file.
 @IntegrationServer(
     port=9090, 
     webAppPath="../../../brms-ws/target/brms-ws-0.1.0-SNAPSHOT", 
     contextPath="/brms-ws-0.1.0-SNAPSHOT")
     
 @SystemProperties(properties={
     @Property(
         key="ks.servicelocation.RuleManagementService", 
         value="http://localhost:9090/brms-ws-0.1.0-SNAPSHOT/services/RuleManagementService")
  })
 
Example 3: Integration test.
 package org.kuali.student.rules.integration;
 // The following system properties are only needed if you want to specify a
 // server port (port 9000) other than 8080 as defined in
 // brms-ws/src/main/resources/application.properties, 
 // application-ruleexecution.properties and application-rulerepository.properties
 @IntegrationServer(port=9000, webappPath="../../../brms-ws/target/brms-ws-0.1.0-SNAPSHOT", contextPath="/brms-ws-0.1.0-SNAPSHOT")
 @SystemProperties(properties={
     @Property(key="ks.servicelocation.RuleManagementService", value="http://localhost:9000/brms-ws-0.1.0-SNAPSHOT/services/RuleManagementService"),
 })
 public class IntegrationTest extends AbstractIntegrationServiceTest {
     private final static String HOST = "http://localhost:9000/brms-ws-0.1.0-SNAPSHOT";
 
     private static String ruleManagementServiceURL = HOST+"/services/RuleManagementService";
     private static String ruleManagementNamespace = "http://student.kuali.org/wsdl/brms/RuleManagement";
     private static String ruleManagementServiceName = "RuleManagementService";
     private static String ruleManagementServiceInterface = RuleManagementService.class.getName();
 
     private static RuleManagementService ruleManagementService;
 
     @BeforeClass
     public static void setUpOnce() throws Exception {
         ruleManagementService = (RuleManagementService) ServiceFactory.getPort(
             ruleManagementServiceURL + "?wsdl", 
             ruleManagementNamespace, 
             ruleManagementServiceName, 
             ruleManagementServiceInterface, 
             ruleManagementServiceURL);

     }
  
     @AfterClass
     public static void tearDownOnce() throws Exception { }

     @Before
     public void setUp() throws Exception { }
  
     @After
     public void tearDown() throws Exception { }
     
     @Test
     public void testFindBusinessRuleTypesFromTestBeans() throws Exception {
         List<String> businessRuleIdList1 = ruleManagementService.findBusinessRuleIdsByBusinessRuleType("KUALI_PRE_REQ");
         Assert.assertNotNull(businessRuleIdList1);
         List<String> businessRuleIdList2 = ruleManagementService.findBusinessRuleIdsByBusinessRuleType("KUALI_CO_REQ");
         Assert.assertNotNull(businessRuleIdList2);
     }
 }
 
public abstract class AbstractIntegrationServiceTest {
New to GrepCode? Check out our FAQ X