hs.hsadmin/hsarback/test/de/hsadmin/remote/EMailAliasTest.java

73 lines
1.9 KiB
Java
Raw Permalink Normal View History

2010-10-05 21:42:07 +02:00
package de.hsadmin.remote;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class EMailAliasTest {
private static final String MODULE = "emailalias";
private XmlRpcClient client;
private RemoteCASHelper cas;
@Before
public void setUp() throws Exception {
client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper();
}
@After
public void tearDown() throws Exception {
client = null;
cas = null;
}
@Test
public void testSearchAllAsPacAdmin() {
2011-05-06 18:28:11 +02:00
String user = "aaa00";
2010-10-05 21:42:07 +02:00
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, Object> setParams = new HashMap<String, Object>();
2012-01-02 15:27:42 +01:00
setParams.put("name", "aaa00-alias");
setParams.put("target", new String[] { "aaa00-admin" });
2010-10-05 21:42:07 +02:00
Object[] params = new Object[] { user,
2012-01-02 15:27:42 +01:00
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
client.execute(MODULE + ".add", params);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
user = "aaa00";
grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
params = new Object[] { user,
2010-10-05 21:42:07 +02:00
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
2012-01-02 15:27:42 +01:00
assertEquals(1, result.length);
2010-10-05 21:42:07 +02:00
for (Object o : result) {
if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o;
2011-05-06 18:28:11 +02:00
assertEquals("aaa00", row.get("pac"));
2010-10-05 21:42:07 +02:00
} else {
fail("map expected");
}
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
}