Package net.greghaines.jesque

Examples of net.greghaines.jesque.Job


public class TestReflectiveJobFactory {

    @Test
    public void testMaterializeJob() throws Exception {
        final ReflectiveJobFactory jobFactory = new ReflectiveJobFactory();
        final Object action = jobFactory.materializeJob(new Job(TestRunnableJob.class.getName()));
        Assert.assertNotNull(action);
        Assert.assertEquals(TestRunnableJob.class, action.getClass());
        final Object action2 = jobFactory.materializeJob(new Job(TestCallableJob.class.getName()));
        Assert.assertNotNull(action2);
        Assert.assertEquals(TestCallableJob.class, action2.getClass());
    }
View Full Code Here


        Assert.assertEquals(TestCallableJob.class, action2.getClass());
    }
   
    @Test(expected = ClassCastException.class)
    public void testMaterializeJob_NotRunnable() throws Exception {
        JesqueUtils.materializeJob(new Job(TestBadJob.class.getName()));
    }
View Full Code Here

    public void testMaterializeJob_Types() throws Exception {
        final Map<String, Class<?>> jobTypes = new HashMap<String, Class<?>>();
        jobTypes.put("TestRunnableJob", TestRunnableJob.class);
        jobTypes.put("TestCallableJob", TestCallableJob.class);
        final MapBasedJobFactory jobFactory = new MapBasedJobFactory(jobTypes);
        final Object action = jobFactory.materializeJob(new Job("TestRunnableJob"));
        Assert.assertNotNull(action);
        Assert.assertEquals(TestRunnableJob.class, action.getClass());
        final Object action2 = jobFactory.materializeJob(new Job("TestCallableJob"));
        Assert.assertNotNull(action2);
        Assert.assertEquals(TestCallableJob.class, action2.getClass());
    }
View Full Code Here

   
    @Test(expected = UnpermittedJobException.class)
    public void testMaterializeJob_Types_NotPermitted() throws Exception {
        final Map<String, Class<?>> jobTypes = new HashMap<String, Class<?>>();
        final MapBasedJobFactory jobFactory = new MapBasedJobFactory(jobTypes);
        jobFactory.materializeJob(new Job("TestRunnableJob"));
    }
View Full Code Here

        final String queueKey = "resque:queue:" + name;
        final long jobOffset = 1;
        final long jobCount = 2;
        final long size = 4;
        final Collection<String> payloads = new ArrayList<String>();
        payloads.add(ObjectMapperFactory.get().writeValueAsString(new Job("foo")));
        payloads.add(ObjectMapperFactory.get().writeValueAsString(new Job("bar")));
        this.mockCtx.checking(new Expectations(){{
            oneOf(pool).getResource(); will(returnValue(jedis));
            exactly(2).of(jedis).type(queueKey); will(returnValue(KeyType.LIST.toString()));
            oneOf(jedis).llen(queueKey); will(returnValue(size));
            oneOf(jedis).lrange(queueKey, jobOffset, jobOffset + jobCount - 1); will(returnValue(payloads));
View Full Code Here

        final String queueKey = "resque:queue:" + name;
        final long jobOffset = 1;
        final long jobCount = 2;
        final long size = 4;
        final Collection<String> payloads = new HashSet<String>();
        payloads.add(ObjectMapperFactory.get().writeValueAsString(new Job("foo")));
        payloads.add(ObjectMapperFactory.get().writeValueAsString(new Job("bar")));
        this.mockCtx.checking(new Expectations(){{
            oneOf(pool).getResource(); will(returnValue(jedis));
            exactly(2).of(jedis).type(queueKey); will(returnValue(KeyType.ZSET.toString()));
            oneOf(jedis).zcard(queueKey); will(returnValue(size));
            oneOf(jedis).zrange(queueKey, jobOffset, jobOffset + jobCount - 1); will(returnValue(payloads));
View Full Code Here

        Assert.assertEquals("quz", map.get("baz"));
    }
   
    @Test
    public void testMaterializeJob() throws Exception {
        final Object action = JesqueUtils.materializeJob(new Job(TestRunnableJob.class.getName()));
        Assert.assertNotNull(action);
        Assert.assertEquals(TestRunnableJob.class, action.getClass());
        final Object action2 = JesqueUtils.materializeJob(new Job(TestCallableJob.class.getName()));
        Assert.assertNotNull(action2);
        Assert.assertEquals(TestCallableJob.class, action2.getClass());
    }
View Full Code Here

        Assert.assertEquals(TestCallableJob.class, action2.getClass());
    }
   
    @Test(expected = ClassCastException.class)
    public void testMaterializeJob_NotRunnable() throws Exception {
        JesqueUtils.materializeJob(new Job(TestBadJob.class.getName()));
    }
View Full Code Here

    @Test
    public void testMaterializeJob_Types() throws Exception {
        final Map<String, Class<?>> jobTypes = new HashMap<String, Class<?>>();
        jobTypes.put("TestRunnableJob", TestRunnableJob.class);
        jobTypes.put("TestCallableJob", TestCallableJob.class);
        final Object action = JesqueUtils.materializeJob(new Job("TestRunnableJob"), jobTypes);
        Assert.assertNotNull(action);
        Assert.assertEquals(TestRunnableJob.class, action.getClass());
        final Object action2 = JesqueUtils.materializeJob(new Job("TestCallableJob"), jobTypes);
        Assert.assertNotNull(action2);
        Assert.assertEquals(TestCallableJob.class, action2.getClass());
    }
View Full Code Here

    }
   
    @Test(expected = UnpermittedJobException.class)
    public void testMaterializeJob_Types_NotPermitted() throws Exception {
        final Map<String, Class<?>> jobTypes = new HashMap<String, Class<?>>();
        JesqueUtils.materializeJob(new Job("TestRunnableJob"), jobTypes);
    }
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.Job

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.