2 * Copyright 2016 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openo.msb.wrapper;
18 import org.junit.After;
19 import org.junit.Assert;
20 import org.junit.Before;
21 import org.junit.BeforeClass;
22 import org.junit.Test;
23 import org.openo.msb.api.IuiRouteInfo;
24 import org.openo.msb.api.RouteServer;
25 import org.openo.msb.api.exception.ExtendedInternalServerErrorException;
26 import org.openo.msb.api.exception.ExtendedNotFoundException;
28 public class IuiRouteServiceWrapperTest {
29 private static IuiRouteServiceWrapper iuiRouteServiceWrapper;
32 public static void setUpBeforeClass() throws Exception {
33 iuiRouteServiceWrapper=IuiRouteServiceWrapper.getInstance();
38 IuiRouteInfo iuiRouteInfo=new IuiRouteInfo();
39 iuiRouteInfo.setServiceName("testForJunit");
40 iuiRouteInfo.setUrl("/iui/test");
41 RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
42 iuiRouteInfo.setServers(servers);
44 iuiRouteServiceWrapper.saveIuiRouteInstance(iuiRouteInfo);
45 }catch(ExtendedInternalServerErrorException e){
48 Assert.fail("Exception" + e.getMessage());
54 public void tearDown() {
56 iuiRouteServiceWrapper.deleteIuiRoute("testForJunit", "*");
57 }catch(ExtendedInternalServerErrorException e){
58 } catch (Exception e) {
59 Assert.fail("Exception" + e.getMessage());
64 public void testGetAllIuiRouteInstances(){
66 IuiRouteInfo[] iuiRouteInfoList=iuiRouteServiceWrapper.getAllIuiRouteInstances();
67 Assert.assertTrue(iuiRouteInfoList.length >= 0);
68 }catch(ExtendedInternalServerErrorException e){
71 Assert.fail("Exception" + e.getMessage());
77 public void testGetIuiRouteInstance_not_exist(){
78 IuiRouteInfo iuiRouteInfo = null;
80 iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("testForJunit2");
81 Assert.assertNotNull(iuiRouteInfo);
82 }catch(ExtendedInternalServerErrorException e){
84 catch(ExtendedNotFoundException e){
85 Assert.assertNull(iuiRouteInfo);
91 public void testGetIuiRouteInstance_exist(){
93 IuiRouteInfo iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("testForJunit");
94 Assert.assertNotNull(iuiRouteInfo);
95 }catch(ExtendedInternalServerErrorException e){
98 Assert.fail("Exception" + e.getMessage());
104 public void testUpdateIuiRouteInstance(){
107 IuiRouteInfo iuiRouteInfo=new IuiRouteInfo();
108 iuiRouteInfo.setServiceName("testForJunit");
109 iuiRouteInfo.setUrl("/iui/test_update");
110 RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
111 iuiRouteInfo.setServers(servers);
113 IuiRouteInfo new_iuiRouteInfo= iuiRouteServiceWrapper.updateIuiRouteInstance("testForJunit", iuiRouteInfo);
114 Assert.assertEquals("/iui/test_update", new_iuiRouteInfo.getUrl());
115 }catch(ExtendedInternalServerErrorException e){
118 Assert.fail("Exception" + e.getMessage());
124 public void testUpdateIuiRouteStatus(){
126 IuiRouteInfo new_iuiRouteInfo= iuiRouteServiceWrapper.updateIuiRouteStatus("testForJunit", "0");
127 Assert.assertEquals("0",new_iuiRouteInfo.getStatus());
128 }catch(ExtendedInternalServerErrorException e){
130 Assert.fail("Exception" + e.getMessage());