• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 1402

Show
Ignore:
Timestamp:
04/13/07 13:09:42 (20 months ago)
Author:
jmoore
Message:

#614 Fixed missing static. Blitz licensing should be functional.

Location:
trunk/components/tools/licenses
Files:
3 modified

  • src/ome/services/licenses/LicenseSessionListener.java (modified) (2 diffs)
  • src/ome/services/licenses/LicenseWiring.java (modified) (2 diffs)
  • test/ome/services/licenses/test/BlitzLicenseTest.java (modified) (5 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/tools/licenses/src/ome/services/licenses/LicenseSessionListener.java

    r1383 r1402  
    2222/** 
    2323 * Listens for {@link AbstractSessionMessages} sent by 
    24  * {@link ome.services.icy.fire.SesssionManagerI} and  
     24 * {@link ome.services.icy.fire.SesssionManagerI} and 
    2525 * {@link ome.services.icy.impl.ServiceFactoryI} and creates licenses 
    26  * when necessary for the user. The listener decouples the session  
     26 * when necessary for the user. The listener decouples the session 
    2727 * creation from the licensing logic. 
    2828 * 
    2929 * This is notably different from the process needed to acquire a 
    30  * license in the application server case, since there is no  
     30 * license in the application server case, since there is no 
    3131 * central session. 
    3232 * 
    … …  
    6060                try { 
    6161                    byte[] token = lic.acquireLicense(); 
     62                    wiring.setToken(create.getSessionId(),token); 
    6263                } finally { 
    6364                    logout(); 
  • trunk/components/tools/licenses/src/ome/services/licenses/LicenseWiring.java

    r1383 r1402  
    5656    LicenseStore store = new LicenseBean(); 
    5757 
    58     private Map<String, byte[]> tokensBySession = Collections 
     58    private static Map<String, byte[]> tokensBySession = Collections 
    5959            .synchronizedMap(new HashMap<String, byte[]>()); 
    6060 
    … …  
    6464    byte[] getToken(String sessionName) { 
    6565        return tokensBySession.get(sessionName); 
     66    } 
     67 
     68    void setToken(String sessionName, byte[] token) { 
     69        tokensBySession.put(sessionName, token); 
    6670    } 
    6771 
  • trunk/components/tools/licenses/test/ome/services/licenses/test/BlitzLicenseTest.java

    r1383 r1402  
    1111import ome.services.icy.client.IceServiceFactory; 
    1212import ome.services.licenses.LicensedServiceFactory; 
     13import ome.system.Login; 
     14import ome.system.OmeroContext; 
     15import omero.ServerError; 
    1316import omero.api.ServiceInterfacePrx; 
    1417import omero.licenses.ILicense; 
    … …  
    1821import org.testng.annotations.AfterClass; 
    1922import org.testng.annotations.BeforeClass; 
     23import org.testng.annotations.BeforeMethod; 
    2024import org.testng.annotations.Test; 
    2125 
    2226@Test( groups = {"client","integration","blitz"} ) 
    23 public class BlitzLicenseTest extends TestCase{ 
     27public class BlitzLicenseTest extends TestCase { 
    2428 
    25     IceServiceFactory ice; 
     29    OmeroContext context; 
     30    Login rootLogin; 
     31    IceServiceFactory ice, root; 
    2632    ILicensePrx licenseService; 
    2733    byte[] token; 
    28      
     34 
    2935    @Override 
    30     @BeforeClass 
     36    @BeforeMethod 
    3137    protected void setUp() throws Exception { 
    3238        super.setUp(); 
    33          
     39 
     40        context = OmeroContext.getInstance("ome.client.test"); 
     41        rootLogin = (Login) context.getBean("rootLogin"); 
    3442        ice = new IceServiceFactory(null,null,null); 
    3543        ice.createSession(); 
    36         ServiceInterfacePrx prx = ice.getProxy().getByName("omero.licenses.ILicense"); 
    37         licenseService = ILicensePrxHelper.uncheckedCast(prx); 
     44        root = new IceServiceFactory(null, null, rootLogin); 
     45        root.createSession(); 
     46 
     47        licenseService = licensePrx(ice); 
     48 
    3849    } 
    39       
     50 
    4051    @Override 
    4152    @AfterClass 
    4253    protected void tearDown() throws Exception { 
    43         licenseService.resetLicenses(); 
     54        licensePrx(root).resetLicenses(); 
    4455        super.tearDown(); 
    4556    } 
    46      
     57 
    4758    @Test 
    4859    public void testAcquireLicenseAutomatically() throws Exception { 
    … …  
    5061        passes(true); 
    5162    } 
    52      
     63 
    5364    @Test 
    5465    public void testAcquireLicenseManually() throws Exception { 
    5566        passes(true); 
    56         licenseService.releaseLicense(token); 
     67        assertTrue( licenseService.releaseLicense(token) ); 
    5768        passes(false); 
    5869        token = licenseService.acquireLicense(); 
    5970        passes(true); 
    6071    } 
    61      
     72 
    6273    @Test 
    6374    public void testReset() throws Exception { 
    64          
     75 
    6576        long totalA = licenseService.getTotalLicenseCount(); 
    6677        long availA  = licenseService.getAvailableLicenseCount(); 
    67          
     78 
    6879        token = licenseService.acquireLicense(); 
    69          
     80 
    7081        long totalB = licenseService.getTotalLicenseCount(); 
    7182        long availB = licenseService.getAvailableLicenseCount(); 
    72          
    73         licenseService.resetLicenses(); 
    74          
     83 
     84        licensePrx(root).resetLicenses(); 
     85 
    7586        long totalC = licenseService.getTotalLicenseCount(); 
    7687        long availC = licenseService.getAvailableLicenseCount(); 
    77          
     88 
    7889        assertTrue(totalA == totalB && totalB == totalC); 
    79         assertTrue(availA == totalA && totalC == availC); 
    80         assertTrue(availB == totalB - 1); 
    81          
     90        assertTrue(availA < totalA && totalC == availC); 
     91        assertTrue(availB == (availA - 1)); 
     92 
    8293    } 
    83      
    84     @Test 
     94 
     95    @Test(groups = {"ignore","NYI"}) 
    8596    public void testTimeouts() { 
    8697        fail("Not implemented."); 
    … …  
    89100    // // ~ Helpers 
    90101    // ========================================================================= 
    91      
     102 
    92103    protected void passes(boolean shouldpass) throws Exception { 
    93104        try { 
    … …  
    103114 
    104115    } 
     116 
     117    private ILicensePrx licensePrx(IceServiceFactory sf) throws ServerError { 
     118        ServiceInterfacePrx prx = sf.getProxy().getByName("omero.licenses.ILicense"); 
     119        ILicensePrx licenses = ILicensePrxHelper.uncheckedCast(prx); 
     120        return licenses; 
     121    } 
    105122} 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/