[ 
https://issues.apache.org/jira/browse/BOOKKEEPER-866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14909756#comment-14909756
 ] 

Jia Zhai commented on BOOKKEEPER-866:
-------------------------------------

For the first error, seem code in Junit is not working very well with 
ZooKeeperUtil.sleepServer
{code}
    FailOnTimeout.java
   @Override
    public void evaluate() throws Throwable {
        CallableStatement callable = new CallableStatement();
        FutureTask<Throwable> task = new FutureTask<Throwable>(callable);
        threadGroup = new ThreadGroup("FailOnTimeoutGroup");
        Thread thread = new Thread(threadGroup, task, "Time-limited test");     
      < ==
        thread.setDaemon(true);
        thread.start();
        callable.awaitStarted();
        Throwable throwable = getResult(task, thread);
        if (throwable != null) {
            throw throwable;
        }
    }
{code}

code of sleepServer()
{code}
    public void sleepServer(final int seconds, final CountDownLatch l)
            throws InterruptedException, IOException {
        Thread[] allthreads = new Thread[Thread.activeCount()];
        Thread.enumerate(allthreads);        
               < == Here could only get thread "Time-limited test", which 
created by above code of junit.
        for (final Thread t : allthreads) {
            if (t.getName().contains("SyncThread:0")) {
                Thread sleeper = new Thread() {
                    @SuppressWarnings("deprecation")
                    public void run() {
                        try {
                            t.suspend();
                            l.countDown();
                            Thread.sleep(seconds*1000);
                            t.resume();
                        } catch (Exception e) {
                            LOG.error("Error suspending thread", e);
                        }
                    }
                };
                sleeper.start();
                return;
            }
        }
        throw new IOException("ZooKeeper thread not found");            < === 
so will not find wanted thread, and got this exception.
    }
{code}

> Fix compile issue when Updating junit to latest release version( 4.12) in the 
> test of  Bookkeeper-server.
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: BOOKKEEPER-866
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-866
>             Project: Bookkeeper
>          Issue Type: Improvement
>          Components: bookkeeper-server
>            Reporter: Jia Zhai
>            Assignee: Jia Zhai
>         Attachments: BOOKKEEPER-866.patch
>
>
> When write test cases for BOOKKEEPER-865,  It appears that current version of 
> junit could not support some new features well, such as Parameterized test. 
> Then we try to update junit to latest release version, but found " 
> junit.framework.Assert in junit.framework has been deprecated" .  
> So using this new ticket to trace this to make the objective more clear.
> The fix is simple, 
> replace 
> import junit.framework.Assert;
> to
> import org.junit.Assert; 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to