Package org.rioproject.impl.watch

Examples of org.rioproject.impl.watch.Watch


            wds.setConfiguration(EmptyConfiguration.INSTANCE);
            wds.initialize();
            //wds.setID(id);
            //wds.initialize();

            Watch watch = construct4(wds, id);
            Assert.assertEquals(id, watch.getId());
            testInstance(watch);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal id
        try {
            String id = null;
            WatchDataSourceImpl wdsi = new WatchDataSourceImpl();
            wdsi.setID("");
            wdsi.setConfiguration(EmptyConfiguration.INSTANCE);
            WatchDataSource wds = wdsi.export();

            construct4(wds, id);
            Assert.fail("IllegalArgumentException expected but not thrown");
        } catch (IllegalArgumentException e) {
        }
        try {
            String id = "";
            construct1(id);
            Assert.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
        }

        // watchDataSource
        final int collectionSizes[] = new int[]{1, 1000, 5000};
        for (int collectionSize : collectionSizes) {
            DynamicConfiguration config = new DynamicConfiguration();
            config.setEntry("org.rioproject.watch", "collectionSize",
                            collectionSize);
            //WatchDataSource wds = new WatchDataSourceImpl("", null,
            //                                              config).export();
            WatchDataSource wds = new WatchDataSourceImpl();
            wds.setConfiguration(config);

            Watch watch = construct4(wds, "watch");
            Assert.assertSame(wds, watch.getWatchDataSource());
            checkInstance(watch, collectionSize, false);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal watchDataSource
        try {
            WatchDataSource wds = null;
View Full Code Here


     * @throws Exception if the test fails
     */
    @Test
    public void testAddWatchRecord() throws Exception {

        Watch watch1 = construct1("watch1");
        checkInstance(watch1, 1000, false);
        Utils.close(watch1.getWatchDataSource());

        Watch watch2 = construct1("watch2");
        try {
            checkInstance(watch2, 1000, true);
            Assert.fail("IllegalArgumentException expected but not thrown");
        } catch (IllegalArgumentException e) {
        }
        Utils.close(watch2.getWatchDataSource());
    }
View Full Code Here

     *
     * @throws Exception if the test fails
     */
    @Test
    public void testEquals() throws Exception {
        Watch watch1 = construct1("abc");
        Watch watch2 = construct1("abc");
        Watch watch3 = construct1("1-2");
        Watch watch4 = construct1("1.2");
        Assert.assertTrue(watch1.equals(watch2));
        Assert.assertFalse(watch1.equals(watch3));
        Assert.assertFalse(watch1.equals(watch4));
        Assert.assertFalse(watch1.equals(new Object()));
        Assert.assertFalse(watch1.equals("abc"));
        Utils.close(watch1.getWatchDataSource());
        Utils.close(watch2.getWatchDataSource());
        Utils.close(watch3.getWatchDataSource());
        Utils.close(watch4.getWatchDataSource());
    }
View Full Code Here

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

     *
     * @throws Exception if the test fails
     */
    @Test
    public void testGetSetView() throws Exception {
        Watch watch = construct1("watch");
        Assert.assertEquals(expectedView, watch.getView());

        watch.setView("MyView");
        Assert.assertEquals("MyView", watch.getView());

        try {
            watch.setView(null);
            Assert.fail("IllegalArgumentException expected but not thrown");
        } catch (IllegalArgumentException e) {
        }

        Utils.close(watch.getWatchDataSource());
    }
View Full Code Here

    public void testGetSetWatchDataSource() throws Exception {
        WatchDataSourceImpl wdsi = new WatchDataSourceImpl();
        wdsi.setID("wds");
        wdsi.setConfiguration(EmptyConfiguration.INSTANCE);
        WatchDataSource wds = wdsi.export();
        Watch watch = construct4(wds, "watch");
        Assert.assertSame(wds, watch.getWatchDataSource());

        WatchDataSourceImpl wdsi2 = new WatchDataSourceImpl();
        wdsi2.setID("otherWds");
        wdsi2.setConfiguration(EmptyConfiguration.INSTANCE);
        WatchDataSource otherWds = wdsi2.export();
               
        watch.setWatchDataSource(otherWds);
        Assert.assertSame(otherWds, watch.getWatchDataSource());

        watch.setWatchDataSource(null);
        Assert.assertSame(otherWds, watch.getWatchDataSource());

        Utils.close(watch.getWatchDataSource());
    }
View Full Code Here

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

     */
    @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

    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

    @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

TOP

Related Classes of org.rioproject.impl.watch.Watch

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.