/
ResourceCreatePlatform_test.java
136 lines (111 loc) · 5.1 KB
/
ResourceCreatePlatform_test.java
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
*
* NOTE: This copyright does *not* cover user programs that use HQ
* program services by normal system calls through the application
* program interfaces provided as part of the Hyperic Plug-in Development
* Kit or the Hyperic Client Development Kit - this is merely considered
* normal use of the program, and does *not* fall under the heading of
* "derived work".
*
* Copyright (C) [2008, 2009], Hyperic, Inc.
* This file is part of HQ.
*
* HQ is free software; you can redistribute it and/or modify
* it under the terms version 2 of the GNU General Public License as
* published by the Free Software Foundation. This program is distributed
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
*/
package org.hyperic.hq.hqapi1.test;
import org.hyperic.hq.hqapi1.ResourceApi;
import org.hyperic.hq.hqapi1.types.Agent;
import org.hyperic.hq.hqapi1.types.Ip;
import org.hyperic.hq.hqapi1.types.ResourcePrototypeResponse;
import org.hyperic.hq.hqapi1.types.ResourceResponse;
import org.hyperic.hq.hqapi1.types.StatusResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class ResourceCreatePlatform_test extends ResourceTestBase {
public ResourceCreatePlatform_test(String name) {
super(name);
}
// Temporarily disable the testCreatePlatform test until HHQ-3435 is fixed
/*
public void testCreatePlatform() throws Exception {
Agent a = getRunningAgent();
ResourceApi api = getApi().getResourceApi();
ResourcePrototypeResponse protoResponse =
api.getResourcePrototype("Network Device");
Random r = new Random();
final String name = "Test Network Device" + r.nextInt();
final String fqdn = "apitest.hyperic.com";
Ip ip = new Ip();
ip.setAddress("10.0.0.1");
List<Ip> ips = new ArrayList<Ip>();
ips.add(ip);
Map<String,String> config = new HashMap<String,String>();
config.put("interface.index", "ifDescr");
config.put("snmpIp", "10.0.0.1");
config.put("snmpPort", "161");
config.put("snmpCommunity", "public");
config.put("snmpVersion", "v2c");
ResourceResponse resp =
api.createPlatform(a, protoResponse.getResourcePrototype(),
name, fqdn, ips, config);
hqAssertSuccess(resp);
pauseTest();
StatusResponse deleteResponse = api.deleteResource(resp.getResource().getId());
hqAssertSuccess(deleteResponse);
}
*/
public void testCreatePlatformLongDescription() throws Exception {
// give hibernate time to flush current session before running
// this test which may cause a transaction failure
pauseTest();
Agent a = getRunningAgent();
ResourceApi api = getApi().getResourceApi();
ResourcePrototypeResponse protoResponse =
api.getResourcePrototype("Network Device");
Random r = new Random();
final String name = "Test Network Device" + r.nextInt();
final String fqdn = "apitest.hyperic.com";
Ip ip = new Ip();
ip.setAddress("10.0.0.1");
List<Ip> ips = new ArrayList<Ip>();
ips.add(ip);
String longDescription = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
Map<String,String> config = new HashMap<String,String>();
config.put("interface.index", "ifDescr");
config.put("snmpIp", "10.0.0.1");
config.put("snmpPort", "161");
config.put("snmpCommunity", "public");
config.put("snmpVersion", "v2c");
config.put("description", longDescription);
ResourceResponse resp =
api.createPlatform(a, protoResponse.getResourcePrototype(),
name, fqdn, ips, config);
hqAssertFailureInvalidParameters(resp);
}
}