src/java-tests/isac/util/users/TestUser.java
author wneuper
Thu, 15 May 2008 09:20:31 +0200
changeset 3909 4d115ebfa840
parent 3881 72f0be16d83b
child 3928 d38196e9b162
permissions -rw-r--r--
comments on installation problems with sub-nets
     1 /*
     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.
     6  * 
     7  * Use is subject to PGPL license terms.
     8  */
     9 package isac.util.users;
    10 
    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;
    16 
    17 import java.rmi.Naming;
    18 import java.rmi.NotBoundException;
    19 import java.rmi.RemoteException;
    20 
    21 import junit.framework.TestCase;
    22 
    23 /**
    24  * @author neuper
    25  * 
    26  * TODO To change the template for this generated type comment go to Window -
    27  * Preferences - Java - Code Style - Code Templates
    28  */
    29 public class TestUser extends TestCase {
    30 
    31     protected void setUp() throws Exception {
    32         super.setUp();
    33     }
    34 
    35     /**
    36      * set up a minimal testbed for getting UserSettings of a Learner
    37      * 
    38      * @exception RemoteException
    39      *                if XSessionManager=ObjectManager NOT launched
    40      *                (ObjectManager launchedd after KEStore, BridgeMain)
    41      * @see isac.session.TestUserManager#testLogin
    42      */
    43     public void testGetUserSettings() {
    44         System.out
    45                 .println("---BEGIN isac.util.user.TestUser#testGetUserSettings");
    46 
    47 		String name = "//localhost/isac-ObjectManager";
    48 		UserSettings user_settings = null;
    49 		User user = null;
    50 		
    51 		try {
    52 			Object lookup = Naming.lookup(name);
    53 			IUserManager user_manager = ((IObjectManager) lookup)
    54 					.getUserManager();
    55 		
    56 			user_manager.login("x", "x");
    57 
    58             // here TestAll FAILS, if not the WHOLE system has been restarted
    59             // for running the tests.
    60 			user = user_manager.getUser("0");
    61 
    62 			String usern = user.getUsername();
    63 			assertEquals("username", usern, "x");
    64 
    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: "
    73 					+ exc.getMessage());
    74 			exc.printStackTrace();
    75 		}
    76 		
    77         //this stores the whole UserSettings in the local 'user_settings'
    78         user_settings = user.getUserSettings();
    79 
    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);
    86 
    87         val = user_settings.getValue(IUserSettings.KEY3_STATUS);
    88         assertEquals("getValue(IUserSettings.KEY3_STATUS)", val,
    89                 IUserSettings.VAL3_LEARNER);
    90 
    91         System.out
    92                 .println("---END isac.util.user.TestUser#testGetUserSettings");
    93     }
    94 
    95 }