-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Morgan
committed
Jun 24, 2009
1 parent
9e3b0a8
commit c693558
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.hyperic.hq.hqapi1.test; | ||
|
||
import org.hyperic.hq.hqapi1.wadl.*; | ||
|
||
public class WADLUser_test extends WADL_test { | ||
|
||
public void testUserList() throws Exception { | ||
|
||
Endpoint.UserListHqu userList = new Endpoint.UserListHqu(); | ||
|
||
UsersResponse users = userList.getAsUsersResponse(); | ||
hqAssertSuccess(users); | ||
} | ||
|
||
public void testUserGet() throws Exception { | ||
|
||
Endpoint.UserGetHqu userGet = new Endpoint.UserGetHqu(); | ||
|
||
UserResponse user = userGet.getAsUserResponse("guest"); | ||
hqAssertSuccess(user); | ||
} | ||
|
||
public void testUserCreateDeleteSyncChangePassword() throws Exception { | ||
|
||
Endpoint.UserCreateHqu userCreate = new Endpoint.UserCreateHqu(); | ||
Endpoint.UserDeleteHqu userDelete = new Endpoint.UserDeleteHqu(); | ||
Endpoint.UserChangePasswordHqu userChangePassword = | ||
new Endpoint.UserChangePasswordHqu(); | ||
Endpoint.UserSyncHqu userSync = new Endpoint.UserSyncHqu(); | ||
|
||
// Test User Sync - Required Atts | ||
UserResponse responseReq = userCreate.getAsUserResponse("testWadl", | ||
"testWadl", | ||
"Test", | ||
"WADL", | ||
"testwadl@springsource.com"); | ||
hqAssertSuccess(responseReq); | ||
|
||
// Test User Change password | ||
StatusResponse changeResponse = | ||
userChangePassword.getAsStatusResponse(responseReq.getUser().getName(), | ||
"newPassword"); | ||
hqAssertSuccess(changeResponse); | ||
|
||
// Test User Delete | ||
StatusResponse deleteReq = userDelete.getAsStatusResponse(responseReq.getUser().getName()); | ||
hqAssertSuccess(deleteReq); | ||
|
||
// Test User Create Required + Optional attributes | ||
UserResponse responseOpt = userCreate.getAsUserResponse("testWadl", | ||
"testWadl", | ||
"Test", | ||
"WADL", | ||
"testwadl@springsource.com", | ||
true, | ||
true, | ||
"WADL Dept", | ||
"415-555-5555", | ||
"testwadl@springsource.com"); | ||
hqAssertSuccess(responseOpt); | ||
|
||
// Test User Sync | ||
User u = responseOpt.getUser(); | ||
u.setFirstName("New First Name"); | ||
UsersRequest r = new UsersRequest(); | ||
r.getUser().add(u); | ||
StatusResponse syncResponse = userSync.postAsStatusResponse(r); | ||
hqAssertSuccess(syncResponse); | ||
|
||
StatusResponse deleteOpt = userDelete.getAsStatusResponse(responseOpt.getUser().getName()); | ||
hqAssertSuccess(deleteOpt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.hyperic.hq.hqapi1.test; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import org.hyperic.hq.hqapi1.wadl.*; | ||
|
||
import java.net.Authenticator; | ||
import java.net.PasswordAuthentication; | ||
|
||
public class WADL_test extends TestCase { | ||
|
||
public void setUp() throws Exception { | ||
final String username ="hqadmin"; | ||
final String password ="hqadmin"; | ||
|
||
Authenticator.setDefault(new Authenticator() { | ||
protected PasswordAuthentication getPasswordAuthentication() { | ||
return new PasswordAuthentication (username, password.toCharArray()); | ||
} | ||
}); | ||
} | ||
|
||
// Assert SUCCESS | ||
|
||
void hqAssertSuccess(Response response) { | ||
String error = (response.getError() != null) ? | ||
response.getError().getReasonText() : ""; | ||
assertEquals(error, ResponseStatus.SUCCESS, response.getStatus()); | ||
} | ||
} |