2 * @author Walther Neuper, member of the ISAC-team,
3 * Copyright (c) 2005 by Walther Neuper
4 * created Apr 15, 2005 8:26:54 AM
5 * Institute for Softwaretechnology, Graz University of Technology, Austria.
7 * Use is subject to PGPL license terms.
9 package isac.util.users;
11 import isac.session.IObjectManager;
12 import isac.users.IUserManager;
13 import isac.users.IUserSettings;
14 import isac.users.User;
15 import isac.users.UserSettings;
17 import java.rmi.Naming;
18 import java.rmi.NotBoundException;
19 import java.rmi.RemoteException;
21 import junit.framework.TestCase;
26 * TODO To change the template for this generated type comment go to Window -
27 * Preferences - Java - Code Style - Code Templates
29 public class TestUser extends TestCase {
31 protected void setUp() throws Exception {
36 * set up a minimal testbed for getting UserSettings of a Learner
38 * @exception RemoteException
39 * if XSessionManager=ObjectManager NOT launched
40 * (ObjectManager launchedd after KEStore, BridgeMain)
41 * @see isac.session.TestUserManager#testLogin
43 public void testGetUserSettings() {
45 .println("---BEGIN isac.util.user.TestUser#testGetUserSettings");
47 String name = "//localhost/isac-ObjectManager";
48 UserSettings user_settings = null;
52 Object lookup = Naming.lookup(name);
53 IUserManager user_manager = ((IObjectManager) lookup)
56 user_manager.login("x", "x");
58 // here TestAll FAILS, if not the WHOLE system has been restarted
59 // for running the tests.
60 user = user_manager.getUser("0");
62 String usern = user.getUsername();
63 assertEquals("username", usern, "x");
65 } catch (RemoteException exc) {
66 System.err.println("no rmiregistry runing on server " + name
67 + " no connection possible --- try later");
68 } catch (NotBoundException exc) {
69 System.err.println("servercom: notboundexc: " + exc.getMessage());
70 System.err.println("server not found - try to connect to Proxy");
71 } catch (java.net.MalformedURLException exc) {
72 System.err.println("servercom: MalformedURLException: "
74 exc.printStackTrace();
77 //this stores the whole UserSettings in the local 'user_settings'
78 user_settings = user.getUserSettings();
80 // in isac/xmldata/users/x_settings.txt we have:
81 // key = IUserSettings.start_worksheet
82 // val = IUserSettings.SKIP_SPECIFY_START_SOLVE
83 int val = user_settings.getValue(IUserSettings.KEY1_START_SPECIFY);
84 assertEquals("getValue(IUserSettings.KEY1_START_SPECIFY)", val,
85 IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE);
87 val = user_settings.getValue(IUserSettings.KEY3_STATUS);
88 assertEquals("getValue(IUserSettings.KEY3_STATUS)", val,
89 IUserSettings.VAL3_LEARNER);
92 .println("---END isac.util.user.TestUser#testGetUserSettings");