HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2011-05-06 fde981d8ab4a12ec284d80195a94300a1270b26f
work on tests
8 files modified
164 ■■■■ changed files
hsarback/test/de/hsadmin/remote/DomainTest.java 4 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/EMailAddressTest.java 14 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/EMailAliasTest.java 4 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/MysqlDbTest.java 44 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/MysqlUserTest.java 10 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/PgsqlDbTest.java 40 ●●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/PgsqlUserTest.java 44 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/RemoteTest.java 4 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/DomainTest.java
@@ -36,7 +36,7 @@
    @Test
    public void testSearchAllAsPacAdmin() {
        String user = "peh00";
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        Object[] params = new Object[] { user, 
@@ -49,7 +49,7 @@
            for (Object o : result) {
                if (o instanceof Map<?, ?>) {
                    Map<?, ?> row = (Map<?, ?>) o;
                    assertEquals("peh00", row.get("user"));
                    assertEquals("aaa00", row.get("user"));
                } else {
                    fail("map expected");
                }
hsarback/test/de/hsadmin/remote/EMailAddressTest.java
@@ -35,7 +35,7 @@
    @Test
    public void testSearchAllAsPacAdmin() {
        String user = "peh00";
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        Object[] params = new Object[] { user, 
@@ -48,7 +48,7 @@
            for (Object o : result) {
                if (o instanceof Map<?, ?>) {
                    Map<?, ?> row = (Map<?, ?>) o;
                    assertEquals("peh00", row.get("pac"));
                    assertEquals("aaa00", row.get("pac"));
                } else {
                    fail("map expected");
                }
@@ -60,7 +60,7 @@
    @Test
    public void testSearchAsPacAdmin() {
        String user = "peh00";
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        whereParams.put("domain", "herzensklaenge.de");
@@ -74,7 +74,7 @@
            for (Object o : result) {
                if (o instanceof Map<?, ?>) {
                    Map<?, ?> row = (Map<?, ?>) o;
                    assertEquals("peh00", row.get("pac"));
                    assertEquals("aaa00", row.get("pac"));
                } else {
                    fail("map expected");
                }
@@ -87,11 +87,11 @@
    @Test
    public void testUpdate() {
        int count = getTargetCount();
        String user = "peh00";
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> setParams = new HashMap<String, String>();
        Map<String, String> whereParams = new HashMap<String, String>();
        setParams.put("target", "peh00-phor");
        setParams.put("target", "aaa00-test2");
        whereParams.put("domain", "jalin.de");
        whereParams.put("localpart", "fax");
        Object[] params = new Object[] { user, 
@@ -107,7 +107,7 @@
        assertEquals(count + 1, getTargetCount());
        setParams = new HashMap<String, String>();
        whereParams = new HashMap<String, String>();
        setParams.put("target", "peh00-hotline");
        setParams.put("target", "aaa00-test2");
        whereParams.put("domain", "jalin.de");
        whereParams.put("localpart", "fax");
        params = new Object[] { user, 
hsarback/test/de/hsadmin/remote/EMailAliasTest.java
@@ -33,7 +33,7 @@
    @Test
    public void testSearchAllAsPacAdmin() {
        String user = "peh00";
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        Object[] params = new Object[] { user, 
@@ -46,7 +46,7 @@
            for (Object o : result) {
                if (o instanceof Map<?, ?>) {
                    Map<?, ?> row = (Map<?, ?>) o;
                    assertEquals("peh00", row.get("pac"));
                    assertEquals("aaa00", row.get("pac"));
                } else {
                    fail("map expected");
                }
hsarback/test/de/hsadmin/remote/MysqlDbTest.java
@@ -48,10 +48,33 @@
        try {
            Object execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
            params[1] = cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL());
            setParams.put("name", "aaa00_db2");
            execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count + 1, getDBsCount());
        assertEquals(count + 2, getDBsCount());
    }
    @Test
    public void testDelete() {
        int count = getDBsCount();
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        whereParams.put("name", "aaa00_db2");
        Object[] params = new Object[] { user,
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
                whereParams };
        try {
            Object execute = client.execute(MODULE + ".delete", params);
            assertNull(execute);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count - 1, getDBsCount());
    }
    @Test
@@ -69,25 +92,6 @@
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
    }
    @Test
    public void testDelete() {
        int count = getDBsCount();
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        whereParams.put("name", "aaa00_db1");
        Object[] params = new Object[] { user,
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
                whereParams };
        try {
            Object execute = client.execute(MODULE + ".delete", params);
            assertNull(execute);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count - 1, getDBsCount());
    }
    private int getDBsCount() {
hsarback/test/de/hsadmin/remote/MysqlUserTest.java
@@ -48,10 +48,14 @@
        try {
            Object execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
            setParams.put("name", "aaa00_dba2");
            params[1] = cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL());
            execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count + 1, getDBUsersCount());
        assertEquals(count + 2, getDBUsersCount());
    }
    @Test
@@ -71,13 +75,13 @@
        }
    }
    @Test @Ignore
    @Test
    public void testDelete() {
        int count = getDBUsersCount();
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        whereParams.put("name", "aaa00_dba");
        whereParams.put("name", "aaa00_dba2");
        Object[] params = new Object[] { user, 
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
                whereParams };
hsarback/test/de/hsadmin/remote/PgsqlDbTest.java
@@ -48,27 +48,14 @@
        try {
            Object execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
            setParams.put("name", "aaa00_db2");
            params[1] = cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL());
            execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count + 1, getDBsCount());
    }
    @Test
    public void testSearch() {
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        Object[] params = new Object[] { user,
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
                whereParams };
        try {
            Object execute = client.execute(MODULE + ".search", params);
            Object[] result = (Object[]) execute;
            assertEquals(1, result.length);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count + 2, getDBsCount());
    }
    @Test
@@ -90,6 +77,23 @@
        assertEquals(count - 1, getDBsCount());
    }
    @Test
    public void testSearch() {
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        Object[] params = new Object[] { user,
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
                whereParams };
        try {
            Object execute = client.execute(MODULE + ".search", params);
            Object[] result = (Object[]) execute;
            assertEquals(1, result.length);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
    }
    private int getDBsCount() {
        int count = 0;
        String user = "aaa00";
hsarback/test/de/hsadmin/remote/PgsqlUserTest.java
@@ -48,10 +48,33 @@
        try {
            Object execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
            setParams.put("name", "aaa00_dba2");
            params[1] = cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL());
            execute = client.execute(MODULE + ".add", params);
            assertTrue(execute instanceof Map<?, ?>);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count + 1, getDBsCount());
        assertEquals(count + 2, getDBsCount());
    }
    @Test
    public void testDelete() {
        int count = getDBsCount();
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        whereParams.put("name", "aaa00_dba2");
        Object[] params = new Object[] { user,
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
                whereParams };
        try {
            Object execute = client.execute(MODULE + ".delete", params);
            assertNull(execute);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count - 1, getDBsCount());
    }
    @Test
@@ -69,25 +92,6 @@
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
    }
    @Test @Ignore
    public void testDelete() {
        int count = getDBsCount();
        String user = "aaa00";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> whereParams = new HashMap<String, String>();
        whereParams.put("name", "aaa00_dba");
        Object[] params = new Object[] { user,
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
                whereParams };
        try {
            Object execute = client.execute(MODULE + ".delete", params);
            assertNull(execute);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
        assertEquals(count - 1, getDBsCount());
    }
    private int getDBsCount() {
hsarback/test/de/hsadmin/remote/RemoteTest.java
@@ -12,10 +12,10 @@
    MysqlDbTest.class,
    PgsqlUserTest.class,
    PgsqlDbTest.class,
    CustomerTest.class
//    EMailAliasTest.class,
//    EMailAddressTest.class,
//    DomainTest.class,
//    EMailAddressTest.class,
    CustomerTest.class
//    HostmasterTest.class,
//    QueueTaskTest.class
})