Examples of Watch


Examples of org.rioproject.impl.watch.Watch

     */
    @Test
    public void testToString() throws Exception {
        String ids[] = new String[]{"1-2", "watch", "abc"};
        for (String id : ids) {
            Watch watch = construct1(id);
            Assert.assertEquals(id, watch.toString());
            Utils.close(watch.getWatchDataSource());
        }
    }
View Full Code Here

Examples of org.rioproject.impl.watch.Watch

    public void testConstructor1() throws Exception {

        // id
        final String ids[] = new String[]{"1-2", "watch", "aBcde"};
        for (String id : ids) {
            Watch watch = construct1(id);
            Assert.assertEquals(id, watch.getId());
            testInstance(watch);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal id
        try {
            String id = null;
View Full Code Here

Examples of org.rioproject.impl.watch.Watch

    @Test
    public void testConstructor2() throws Exception {
        // id
        final String ids[] = new String[]{"1-2", "watch", "aBcde"};
        for (String id : ids) {
            Watch watch = construct2(id, EmptyConfiguration.INSTANCE);
            Assert.assertEquals(id, watch.getId());
            testInstance(watch);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal id
        try {
            String id = null;
            construct2(id, EmptyConfiguration.INSTANCE);
            Assert.fail("IllegalArgumentException expected but not thrown");
        } catch (IllegalArgumentException e) {
        }
        // Illegal id
        try {
            String id = "";
            construct1(id);
            Assert.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
        }

        // config
        final int collectionSizes[] = new int[]{1, 1000, 5000};
        for (int collectionSize : collectionSizes) {
            DynamicConfiguration config = new DynamicConfiguration();
            config.setEntry("org.rioproject.watch", "collectionSize",
                            collectionSize);
            Watch watch = construct2("watch", config);
            checkInstance(watch, collectionSize, false);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal config
        try {
            Configuration config = null;
View Full Code Here

Examples of org.rioproject.impl.watch.Watch

    @Test
    public void testUsingWatch() throws Exception {
        BasicEventConsumer consumer = new BasicEventConsumer(getEventDescriptor());
        WatchDataSourceRegistry watchRegistry = new WatchDataSourceRegistry();
        Watch watch = consumer.createWatch(watchRegistry);
        Assert.assertNotNull(watch);
        Assert.assertNotNull("Check Watch accessor", consumer.getWatch());
        Assert.assertTrue("Only one watch should be created, calling createWatch twice should return the same watch",
                          watch.equals(consumer.createWatch(watchRegistry)));
        Listener listener = new Listener();
        consumer.register(listener);
        Producer p = new Producer();
        p.createDEH();
        ServiceItem serviceItem = createServiceItem(p);
        EventRegistration eventRegistration = consumer.register(serviceItem);
        Assert.assertNotNull(eventRegistration);
        p.fire();
        p.fire();
        Assert.assertTrue("Should have gotten 2, got "+watch.getCalculables().values().size(),
                          watch.getCalculables().values().size()==2);
        Calculable[] calculables = watch.getWatchDataSource().getCalculable();
        Assert.assertTrue("Should have gotten 2, got "+calculables.length, calculables.length==2);
        for (Calculable calculable : calculables)
            System.out.println("==> " + calculable.getValue());

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.