Package javax.util.concurrent

Examples of javax.util.concurrent.ContextService


       
        assertEquals(Arrays.asList(expected, null, null, null, expected), task1.getList());
    }
      
    public void testBadProxyInterfaces() throws Exception {
        ContextService service = getContextService();
       
        MyTask task1 = new MyTask();
       
        try {
            service.createContextObject(task1, null);
            fail("Did not throw exception");
        } catch (IllegalArgumentException e) {
            // ok
        }
       
        try {
            service.createContextObject(task1, new Class[] {} );
            fail("Did not throw exception");
        } catch (IllegalArgumentException e) {
            // ok
        }
       
        try {
            service.createContextObject(task1, new Class[] {null} );
            fail("Did not throw exception");
        } catch (IllegalArgumentException e) {
            // ok
        }
       
        try {
            service.createContextObject(task1, new Class[] {Serializable.class, null} );
            fail("Did not throw exception");
        } catch (IllegalArgumentException e) {
            // ok
        }
       
        try {
            service.createContextObject(task1, new Class[] {Runnable.class, null} );
            fail("Did not throw exception");
        } catch (IllegalArgumentException e) {
            // ok
        }
    }
View Full Code Here


                                   new ArrayBlockingQueue<Runnable>(10));
       
        ExecutorCompletionService threadPool =
            new ExecutorCompletionService(threadPoolExecutor);
       
        ContextService service = getContextService();
               
        MyTask task1 = new MyTask();  
       
        String expected = "hello123World";
        TestContextHandler.setCurrentObject(expected);
       
        Callable task2 = (Callable)service.createContextObject(task1, new Class[] {Callable.class});
       
        assertEquals(expected, TestContextHandler.getCurrentObject());
        TestContextHandler.setCurrentObject(null);
        assertNull(TestContextHandler.getCurrentObject());
       
View Full Code Here

       
        threadPoolExecutor.shutdown();
    }
     
    public void testProxyingProperties1() throws Exception {
        ContextService service = getContextService();
               
        MyTask task1 = new MyTask();  
       
        Object expected = "foo123bar";
        TestContextHandler.setCurrentObject(expected);
       
        Runnable task2 = (Runnable)service.createContextObject(task1, new Class[] {Runnable.class});
       
        assertEquals(expected, TestContextHandler.getCurrentObject());
        TestContextHandler.setCurrentObject(null);
        assertNull(TestContextHandler.getCurrentObject());
               
        task2.run();
       
        assertEquals(Arrays.asList(expected), task1.getList());
        
        Map<String, String> props = null;
       
        props = new HashMap<String, String>();
        props.put(TestContextHandler.SKIP, "true");
       
        service.setProperties(task2, props);
       
        task1.getList().clear();
        task2.run();
       
        assertEquals(Arrays.asList("skipped"), task1.getList());
       
        props = new HashMap<String, String>();
        props.put(TestContextHandler.SKIP, "false");
       
        service.setProperties(task2, props);
       
        task1.getList().clear();
        task2.run();
       
        assertEquals(Arrays.asList(expected), task1.getList());
View Full Code Here

       
        assertEquals(Arrays.asList(expected), task1.getList());
    }
   
    public void testProxyingProperties2() throws Exception {
        ContextService service = getContextService();
               
        Map<String, String> props = null;
                       
        MyTask task1 = new MyTask();  
       
        Object expected = "foo123bar";
        TestContextHandler.setCurrentObject(expected);
       
        props = new HashMap<String, String>();
        props.put(TestContextHandler.SKIP, "true");
       
        Runnable task2 = (Runnable)service.createContextObject(task1, new Class[] {Runnable.class}, props);
       
        props = new HashMap<String, String>();
        props.put(TestContextHandler.SKIP, "false");
       
        Runnable task3 = (Runnable)service.createContextObject(task1, new Class[] {Runnable.class}, props);
       
        assertEquals(expected, TestContextHandler.getCurrentObject());
        TestContextHandler.setCurrentObject(null);
        assertNull(TestContextHandler.getCurrentObject());
          
View Full Code Here

        task3.run();
        assertEquals(Arrays.asList(expected), task1.getList());       
    }
   
    public void testGetSetProperties() throws Exception {
        ContextService service = getContextService();
       
        Map<String, String> props1 = new HashMap<String, String>();
        props1.put("foo", "bar");
       
        MyTask task1 = new MyTask();                 
        Runnable task2 = (Runnable)service.createContextObject(task1, new Class[] {Runnable.class}, props1);
       
        assertEquals(props1, service.getProperties(task2));
       
        Map<String, String> props2 = new HashMap<String, String>();      
        props2.put("hello", "world");
       
        service.setProperties(task2, props2);
       
        assertEquals(props2, service.getProperties(task2));  
    }
View Full Code Here

       
        assertEquals(props2, service.getProperties(task2));  
    }
   
    public void testBadGetSetProperties() throws Exception {
        ContextService service = getContextService();
       
        MyTask task1 = new MyTask();  
       
        // get Properties on non-proxied object
        try {
            service.getProperties(task1);
            fail("did not throw exception");
        } catch (IllegalArgumentException e) {
            // ignore
        }
       
        // set Properties on non-proxied object
        try {
            service.setProperties(task1, new HashMap<String, String>());
            fail("did not throw exception");
        } catch (IllegalArgumentException e) {
            // ignore
        }       
    }
View Full Code Here

TOP

Related Classes of javax.util.concurrent.ContextService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.