summaryrefslogtreecommitdiffstats
path: root/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java
blob: 27d86bf79e62a96d2979aa88ca9205c5c5bb3648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright 2017 Huawei Technologies Co., Ltd.
 *
 * Licensed under the Apache 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.apache.org/licenses/LICENSE-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.openo.vnfsdk.functests;

import java.util.UUID;

import org.junit.Before;
import org.junit.Test;

import org.openo.vnfsdk.functest.TaskExecution;
import org.openo.vnfsdk.functest.externalservice.entity.Environment;

import org.openo.vnfsdk.functest.externalservice.entity.EnvironmentMap;

import mockit.Mock;
import mockit.MockUp;

public class TaskExecutionTest {
	
	private TaskExecution testExecution = null;
	private Environment functestEnv = null;	
	
	private String dirPath = "src\\test\\resources\\RobotScript";
	private UUID UUIDEnv = UUID.randomUUID();
	private UUID UUIDUpload = UUID.randomUUID();
	private UUID uniqueKey = UUID.randomUUID();
	private String remoteIP = "192.168.4.47";
	private String userName = "root";
	private String password = "root123";
	private String path = "src\\test\\resources";
	private UUID envId = UUID.randomUUID();
	private UUID executeId = UUID.randomUUID();
		
	@Before
	public void setUp() {
		testExecution = new TaskExecution();
		functestEnv = new Environment();
	}
	
	@Test
	public void testExecuteScript() {
		try {
			testExecution.executeScript( dirPath, uniqueKey );
		} catch( Exception e ) {
			e.printStackTrace();
		}		
	}
	
	@Test
	public void testExecuteRobotScript() {
		new MockUp<EnvironmentMap>() {
            @Mock
            public synchronized Environment getEnv( UUID uuid ) {   
            	functestEnv.setRemoteIp( remoteIP );
            	functestEnv.setUserName( userName );
            	functestEnv.setPassword( password );
            	functestEnv.setPath( path );
                return functestEnv;           	
            }
        };
        try {
        	testExecution.executeRobotScript(envId, executeId );
        } catch( Exception e ) {
        	e.printStackTrace();
        }        
	}	
	
	@Test
	public void testUploadScript() {
		 new MockUp<EnvironmentMap>() {
	            @Mock
	            public synchronized Environment getEnv( UUID uuid ) {   
	            	functestEnv.setRemoteIp( remoteIP );
	            	functestEnv.setUserName( userName );
	            	functestEnv.setPassword( password );
	            	functestEnv.setPath( path );
	                return functestEnv;           	
	            }
	        };
	        try {
	        	testExecution.uploadScript( dirPath, UUIDEnv, UUIDUpload );
	        } catch( Exception e ) {
	        	e.printStackTrace();
	        }	
	}
		
	
}