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

Matteo Bertozzi commented on HBASE-15975:
-----------------------------------------

I had an hard time to read this test with the use of "expected" without having 
it reset every step.
can you change the test to avoid the use of "expected" and do something like a 
bit more readable like:
{code}
// Try double add of same coprocessor
try {
   htd.addCoprocessorWithSpec(spec);
   fatal(); // the coproc already exist so we should fail with IOException
} catch (IOException ioe) {
   // We expect Coprocessor com.foo.FooRegionObserver already exists.
}
{code}

> logic in TestHTableDescriptor#testAddCoprocessorWithSpecStr is wrong
> --------------------------------------------------------------------
>
>                 Key: HBASE-15975
>                 URL: https://issues.apache.org/jira/browse/HBASE-15975
>             Project: HBase
>          Issue Type: Bug
>          Components: test
>    Affects Versions: master
>            Reporter: huaxiang sun
>            Assignee: huaxiang sun
>            Priority: Trivial
>         Attachments: HBASE-15975-v001.patch
>
>
> While working on an unitest case for HBASE-14644, crossed over 
> testAddCoprocessorWithSpecStr().
> {code}
>    HTableDescriptor htd = new HTableDescriptor(TableName.META_TABLE_NAME);
>     String cpName = "a.b.c.d";
>     boolean expected = false;
>     try {
>       htd.addCoprocessorWithSpec(cpName);
>     } catch (IllegalArgumentException iae) {
>       expected = true;
>     }
>     if (!expected) fail();
>     // Try minimal spec.
>     try {
>       htd.addCoprocessorWithSpec("file:///some/path" + "|" + cpName);
>     } catch (IllegalArgumentException iae) {
>       expected = false;
>     }
>     if (expected) fail();
>     // Try more spec.
>     String spec = 
> "hdfs:///foo.jar|com.foo.FooRegionObserver|1001|arg1=1,arg2=2";
>     try {
>       htd.addCoprocessorWithSpec(spec);
>     } catch (IllegalArgumentException iae) {
>       expected = false; <<<< It should be true as it is expected to succeed.
>     }
>     if (expected) fail();
>     // Try double add of same coprocessor
>     try {
>       htd.addCoprocessorWithSpec(spec);
>     } catch (IOException ioe) {
>       expected = true;
>     }
>     if (!expected) fail();
> {code}



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

Reply via email to