Merge "Tidy up one test"
authorvarun gudisena <varuneshwar.gudisena@att.com>
Thu, 21 Mar 2019 21:13:38 +0000 (21:13 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 21 Mar 2019 21:13:38 +0000 (21:13 +0000)
.classpath
src/main/java/org/onap/dmaap/dbcapi/client/DrProvConnection.java
src/main/java/org/onap/dmaap/dbcapi/model/DR_Sub.java
src/main/resources/schema_12.sql
src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java [new file with mode: 0644]
src/test/java/org/onap/dmaap/dbcapi/aaf/AafUserRoleTest.java
src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java [new file with mode: 0644]
src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java
src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java

index 17efa84..30fa0bf 100644 (file)
@@ -15,6 +15,7 @@
                <attributes>
                        <attribute name="optional" value="true"/>
                        <attribute name="maven.pomderived" value="true"/>
+                       <attribute name="test" value="true"/>
                </attributes>
        </classpathentry>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
index f928a11..d603679 100644 (file)
@@ -124,7 +124,6 @@ public class DrProvConnection extends BaseLoggingClass {
                        return(true);
                } catch (Exception e) {
                        errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_ERROR,  pURL, e.getMessage() );
-            e.printStackTrace();
             return(false);
         }
 
@@ -222,7 +221,7 @@ public class DrProvConnection extends BaseLoggingClass {
                                logger.info( "artificial 200 response from doPostFeed because unit_test =" + unit_test );
                } else {
                    logger.warn("Unable to read response  " );
-                   e.printStackTrace();
+                   errorLogger.error("Unable to read response  ", e.getMessage());
                    try {
                            err.setCode( uc.getResponseCode());
                            err.setMessage(uc.getResponseMessage());
@@ -235,7 +234,9 @@ public class DrProvConnection extends BaseLoggingClass {
                finally {
                        try {
                                uc.disconnect();
-                       } catch ( Exception e ) {}
+                       } catch ( Exception e ) {
+                               logger.error(e.getMessage(), e);
+                       }
                }
                return responseBody;
 
@@ -284,7 +285,7 @@ public class DrProvConnection extends BaseLoggingClass {
                                logger.info( "artificial 200 response from doXgressPost because unit_test =" + unit_test );
                } else {
                    logger.error("Unable to read response  " );
-                   e.printStackTrace();
+                   logger.error(e.getMessage(), e);
                }
         }              
         finally {
@@ -331,6 +332,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
                  }
             }
                        rc = uc.getResponseCode();
@@ -366,14 +368,15 @@ public class DrProvConnection extends BaseLoggingClass {
                                err.setMessage( "simulated response");
                                logger.info( "artificial 200 response from doPostDr_Sub because unit_test =" + unit_test );
                } else {
-                   System.err.println("Unable to read response  " );
-                   e.printStackTrace();
+                   logger.error("Unable to read response  ", e.getMessage());
                }
         }              
                finally {
                        try {
                                uc.disconnect();
-                       } catch ( Exception e ) {}
+                       } catch ( Exception e ) {
+                               logger.error(e.getMessage(), e);
+                       }
                }
                return responseBody;
 
@@ -410,6 +413,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
                  }
             }
                        rc = uc.getResponseCode();
@@ -461,7 +465,7 @@ public class DrProvConnection extends BaseLoggingClass {
                                logger.info( "artificial 200 response from doPutFeed because unit_test =" + unit_test );
                } else {
                    logger.warn("Unable to read response  " );
-                   e.printStackTrace();
+                   logger.error(e.getMessage(), e);
                }
             try {
                    err.setCode( uc.getResponseCode());
@@ -469,11 +473,14 @@ public class DrProvConnection extends BaseLoggingClass {
             } catch (Exception e2) {
                err.setCode( 500 );
                err.setMessage("Unable to determine response message");
+               logger.error(e2.getMessage(), e2);
             }
         }              finally {
                        try {
                                uc.disconnect();
-                       } catch ( Exception e ) {}
+                       } catch ( Exception e ) {
+                               logger.error(e.getMessage(), e);
+                       }
                }
                return responseBody;
        }
@@ -509,6 +516,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
                  }
             }
                        rc = uc.getResponseCode();
@@ -542,6 +550,7 @@ public class DrProvConnection extends BaseLoggingClass {
             errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
             err.setCode( 500 );
                err.setMessage("Backend connection refused");
+               logger.error(ce.getMessage(), ce);
                } catch (Exception e) {
                if ( unit_test.equals( "Yes" ) ) {
                                err.setCode(200);
@@ -552,7 +561,9 @@ public class DrProvConnection extends BaseLoggingClass {
                    logger.error(e.getMessage(), e);
                }
         } finally {
-               uc.disconnect();
+               if(null != uc){
+                   uc.disconnect();
+               }
         }
                return responseBody;
 
@@ -583,6 +594,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
                  }
             } 
        
@@ -621,14 +633,14 @@ public class DrProvConnection extends BaseLoggingClass {
             errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
             err.setCode( 500 );
                err.setMessage("Backend connection refused");
+               logger.error(ce.getMessage(), ce);
                } catch (Exception e) {
                if ( unit_test.equals( "Yes" ) ) {
                                err.setCode(200);
                                err.setMessage( "simulated response");
                                logger.info( "artificial 200 response from doGetNodes because unit_test =" + unit_test );
                } else {
-                   System.err.println("Unable to read response  " );
-                   e.printStackTrace();
+                   logger.error("Unable to read response  ", e.getMessage());
                }
         } finally {
 
@@ -706,8 +718,7 @@ public class DrProvConnection extends BaseLoggingClass {
                                err.setMessage( "simulated response");
                                logger.info( "artificial 200 response from doPutNodes because unit_test =" + unit_test );
                } else {
-                   System.err.println("Unable to read response  " + e.getMessage() );
-                   e.printStackTrace();
+                   logger.error("Unable to read response  ", e.getMessage());
                }
         } finally {
                        if ( uc != null ) {
@@ -748,6 +759,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
                  }
             }
                        rc = uc.getResponseCode();
@@ -788,10 +800,12 @@ public class DrProvConnection extends BaseLoggingClass {
                        errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
             err.setCode( 500 );
                err.setMessage("Backend connection refused");
+               logger.error(ce.getMessage(), ce);
                } catch (SocketException se) {
                        errorLogger.error( DmaapbcLogMessageEnum.SOCKET_EXCEPTION, se.getMessage(), "response from Prov server" );
                        err.setCode( 500 );
                        err.setMessage( "Unable to read response from DR");
+                       logger.error(se.getMessage(), se);
         } catch (Exception e) {
                if ( unit_test.equals( "Yes" ) ) {
                                err.setCode(200);
@@ -799,19 +813,24 @@ public class DrProvConnection extends BaseLoggingClass {
                                logger.info( "artificial 200 response from doDeleteFeed because unit_test =" + unit_test );
                } else {
                    logger.warn("Unable to read response  " );
-                   e.printStackTrace();
+                   logger.error(e.getMessage(), e);
                    try {
                            err.setCode( uc.getResponseCode());
                            err.setMessage(uc.getResponseMessage());
                    } catch (Exception e2) {
                        err.setCode( 500 );
                        err.setMessage("Unable to determine response message");
+                       logger.error(e2.getMessage(), e2);
                    }
                }
         }              finally {
                        try {
-                               uc.disconnect();
-                       } catch ( Exception e ) {}
+                               if(uc != null) {
+                                   uc.disconnect();
+                               }
+                       } catch ( Exception e ) {
+                               logger.error(e.getMessage(), e);
+                       }
                }
                return responseBody;
        }
@@ -848,6 +867,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
                  }
             }
                        rc = uc.getResponseCode();
@@ -892,11 +912,12 @@ public class DrProvConnection extends BaseLoggingClass {
                                err.setMessage( "simulated response");
                                logger.info( "artificial 200 response from doDeleteDr_Sub because unit_test =" + unit_test );
                } else {
-                   System.err.println("Unable to read response  " );
-                   e.printStackTrace();
+                   logger.error("Unable to read response  ", e.getMessage());
                }
         } finally {
-               uc.disconnect();
+               if(uc != null){
+                   uc.disconnect();
+               }
         }
                return responseBody;
 
index 9b6e2d7..9d30021 100644 (file)
@@ -45,15 +45,16 @@ public class DR_Sub extends DmaapObject {
        private boolean guaranteedDelivery;
        private boolean guaranteedSequence;
        private boolean privilegedSubscriber;
-       
+       private boolean decompressData;
+
        // NOTE: the following fields are optional in the API but not stored in the DB
+
        private String  feedName;
        private String  feedVersion;
-
        public DR_Sub() {
 
        }
-       
+
        public DR_Sub( String dLN,
                                        String uN,
                                        String uP,
@@ -71,12 +72,12 @@ public class DR_Sub extends DmaapObject {
                this.setStatus( DmaapObject_Status.NEW );
                this.subId = "0";
        }
-       
+
        public DR_Sub ( String json ) {
                logger.info( "DR_Sub:" + json );
                JSONParser parser = new JSONParser();
                JSONObject jsonObj;
-               
+
                try {
                        jsonObj = (JSONObject) parser.parse( json );
                } catch ( ParseException pe ) {
@@ -87,7 +88,7 @@ public class DR_Sub extends DmaapObject {
 
                this.setOwner( (String) jsonObj.get("subscriber"));
                this.setSuspended( (boolean) jsonObj.get("suspend"));
-               
+
                try {
                        JSONObject links = (JSONObject) jsonObj.get("links");
                        String url = (String) links.get("feed");
@@ -97,7 +98,7 @@ public class DR_Sub extends DmaapObject {
                        logger.info( "feedid="+ this.getFeedId() );
                        this.setLogURL( (String) links.get("log") );
                } catch (NullPointerException npe ) {
-                       
+
                }
                try {
                        this.setGuaranteedDelivery( (boolean) jsonObj.get("guaranteed_delivery"));
@@ -114,20 +115,23 @@ public class DR_Sub extends DmaapObject {
                } catch( NullPointerException npe ) {
                        this.setPrivilegedSubscriber(false);
                }
-               
+               try {
+                       this.setDecompressData((boolean) jsonObj.get("decompressData"));
+               } catch( NullPointerException npe ) {
+                       this.setDecompressData(false);
+               }
+
                JSONObject del = (JSONObject) jsonObj.get("delivery");
-               this.setDeliveryURL( (String) del.get("url") ); 
+               this.setDeliveryURL( (String) del.get("url") );
                this.setUsername( (String) del.get("user"));
                this.setUserpwd( (String) del.get( "password"));
                this.setUse100((boolean) del.get( "use100"));
 
-               
-
                this.setStatus( DmaapObject_Status.VALID );
 
                logger.info( "new DR_Sub returning");
        }
-       
+
        public String getOwner() {
                return owner;
        }
@@ -234,8 +238,14 @@ public class DR_Sub extends DmaapObject {
        public void setPrivilegedSubscriber(boolean privilegedSubscriber) {
                this.privilegedSubscriber = privilegedSubscriber;
        }
-       
-       
+
+       public boolean isDecompressData() {
+               return decompressData;
+       }
+
+       public void setDecompressData(boolean decompressData) {
+               this.decompressData = decompressData;
+       }
 
        public String getFeedName() {
                return feedName;
@@ -260,31 +270,32 @@ public class DR_Sub extends DmaapObject {
                return toProvJSON().getBytes(StandardCharsets.UTF_8);
        }
        // returns the DR_Sub object in JSON that conforms to ONAP DR Prov Server expectations
-       public String toProvJSON() {    
+       public String toProvJSON() {
                // this is the original DR API that was contributed to ONAP
                String postJSON = String.format("{\"suspend\": %s, \"delivery\":"
                                + "{\"url\": \"%s\", \"user\": \"%s\", \"password\": \"%s\", \"use100\":  %s }"
                                + ", \"metadataOnly\": %s, \"groupid\": \"%s\", \"follow_redirect\": %s "
-                               + ", \"privilegedSubscriber\": %s "
+                               + ", \"privilegedSubscriber\": %s, \"decompress\": %s "
                                + "}"
                                ,this.suspended
                                ,this.getDeliveryURL()
                                ,this.getUsername()
                                ,this.getUserpwd()
-                               ,this.isUse100()                
+                               ,this.isUse100()
                                ,"false"
                                ,"0"
                                ,"true"
                                ,this.isPrivilegedSubscriber()
-                       );      
-               
+                               ,this.isDecompressData()
+                       );
+
                logger.info( postJSON );
                return postJSON;
        }
        // returns the DR_Sub object in JSON that conforms to AT&T DR Prov Server expectations
        // In Jan, 2019, the DR API used internally at AT&T diverged, so this function can be used in
        // that runtime environment
-       public String toProvJSONforATT() {      
+       public String toProvJSONforATT() {
                // in DR 3.0, API v2.1 a new groupid field is added.  We are not using this required field so just set it to 0.
                // we send this regardless of DR Release because older versions of DR seem to safely ignore it
                // and soon those versions won't be around anyway...
@@ -312,12 +323,12 @@ public class DR_Sub extends DmaapObject {
                                ,"true"
                                ,this.isGuaranteedDelivery()
                                ,this.isGuaranteedSequence()
-                               );      
-               
+                               );
+
                logger.info( postJSON );
                return postJSON;
        }
-       
+
        @Override
        public String toString() {
                String rc = String.format ( "DR_Sub: {dcaeLocationName=%s username=%s userpwd=%s feedId=%s deliveryURL=%s logURL=%s subid=%s use100=%s suspended=%s owner=%s}",
index 7aaab11..22f0559 100644 (file)
@@ -7,9 +7,9 @@
 -- Licensed under the Apache License, Version 2.0 (the "License");
 -- you may not use this file except in compliance with the License.
 -- You may obtain a copy of the License at
--- 
+--
 --      http://www.apache.org/licenses/LICENSE-2.0
--- 
+--
 -- Unless required by applicable law or agreed to in writing, software
 -- distributed under the License is distributed on an "AS IS" BASIS,
 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
 @alter table dr_sub
 
-       add column      guaranteed_delivery     boolean,
-       add column      guaranteed_sequence     boolean,
-       add column      privileged_subscriber   boolean
+    add column  guaranteed_delivery     boolean,
+    add column  guaranteed_sequence     boolean,
+    add column  privileged_subscriber    boolean,
+    add column  decompress_data          boolean
 ;
 
 
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java
new file mode 100644 (file)
index 0000000..c53d8c6
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright 2019 IBM
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.dbcapi.aaf;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class AafRoleTest {
+
+    AafRole aafRole;
+
+    @Before
+    public void setUp() {
+        aafRole = new AafRole("testNs", "testRole");
+    }
+
+    @Test
+    public void testAafRole() {
+        aafRole.setNamespace("namespace");
+        aafRole.setRole("role");
+        assertEquals("namespace", aafRole.getNamespace());
+        assertEquals("role", aafRole.getRole());
+        assertEquals("namespace.role", aafRole.getFullyQualifiedRole());
+        assertNotNull(aafRole.toJSON());
+    }
+}
index 6328c21..88fff87 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 IBM
+ * ===================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package org.onap.dmaap.dbcapi.aaf;
 
-import org.junit.Test;
-
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
 
 public class AafUserRoleTest {
 
+    AafUserRole aafUserRole;
+
+    @Before
+    public void setUp() {
+        aafUserRole = new AafUserRole("xyz", "admin");
+    }
+
+    @Test
+    public void testGetIdentity() {
+        aafUserRole.setIdentity("xyz");
+        assertEquals("xyz", aafUserRole.getIdentity());
+    }
+
+    @Test
+    public void testGetRole() {
+        aafUserRole.setRole("admin");
+        assertEquals("admin", aafUserRole.getRole());
+    }
+
     @Test
     public void toJSON() {
-        AafUserRole role = new AafUserRole("test","admin");
+        AafUserRole role = new AafUserRole("test", "admin");
         assertThat(role.toJSON(), is(" { \"user\": \"test\", \"role\": \"admin\" }"));
     }
 }
\ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java
new file mode 100644 (file)
index 0000000..11e7c85
--- /dev/null
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright 2019 IBM
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dmaap.dbcapi.model;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class BrTopicTest {
+
+    BrTopic brTopic;
+
+    @Before
+    public void setUp() {
+        brTopic = new BrTopic();
+    }
+
+    @Test
+    public void testGetBrSource() {
+        brTopic.setBrSource("brSource");
+        assertEquals("brSource", brTopic.getBrSource());
+    }
+
+    @Test
+    public void testGetBrTarget() {
+        brTopic.setBrTarget("brTarget");
+        assertEquals("brTarget", brTopic.getBrTarget());
+    }
+
+    @Test
+    public void testGetTopicCount() {
+        brTopic.setTopicCount(1);
+        assertEquals(1, brTopic.getTopicCount());
+    }
+
+    @Test
+    public void testGetMmAgentName() {
+        brTopic.setMmAgentName("Test");
+        assertEquals("Test", brTopic.getMmAgentName());
+    }
+}
index 480ff07..59a4023 100644 (file)
@@ -69,7 +69,7 @@ public class DRSubTest {
                assertTrue( t.isGuaranteedDelivery() == false );
                assertTrue( t.isGuaranteedSequence() == false );
                assertTrue( t.isPrivilegedSubscriber() == false );
-       
+               assertTrue( t.isDecompressData() == false );
        }
 
        @Test
@@ -113,6 +113,8 @@ public class DRSubTest {
                assertTrue( t.isGuaranteedSequence() == v );
                t.setPrivilegedSubscriber(v);
                assertTrue( t.isPrivilegedSubscriber() == v );
+               t.setDecompressData(v);
+               assertTrue( t.isDecompressData() == v );
        }
 
        @Test
index 15753cd..ba95a85 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -17,6 +19,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.dmaap.dbcapi.model;
 
 import static org.junit.Assert.*;
@@ -26,67 +29,83 @@ import org.junit.Before;
 import org.junit.Test;
 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
 
-
 public class MRClientTest {
 
-       private static final String  fmt = "%24s: %s%n";
-
-       ReflectionHarness rh = new ReflectionHarness();
-
-       String d, t, f, c, m;
-
-       @Before
-       public void setUp() throws Exception {
-               d = "central-onap";
-               t = "org.onap.dmaap.interestingTopic";
-               f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
-               c = "publisher";
-               m = "m12345";
-       }
-
-       @After
-       public void tearDown() throws Exception {
-       }
-
-
-       @Test
-       public void test1() {
-
-               // can't use simple reflection to test for null since null constructor initializes some fields.
-               //rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );   
-               // so brute force instead...
-               String[] a = { "put", "view" };
-               MR_Client m = new MR_Client();
-
-
-               assertTrue( null ==  m.getDcaeLocationName() );
-               assertTrue( null ==  m.getFqtn() );
-               assertTrue( null ==  m.getClientRole() );
-               assertTrue( null ==  m.getAction() );
-       
-       }
-
-       @Test
-       public void test2() {
-               String[] a = { "put", "view" };
-               MR_Client m = new MR_Client( d, f, c, a );
-
-
-               assertTrue( d.equals( m.getDcaeLocationName() ));
-               assertTrue( f.equals( m.getFqtn() ));
-               assertTrue( c.equals( m.getClientRole() ));
-               String[] ma = m.getAction();
-               assertTrue( a.length == ma.length );
-               for( int i = 0; i < a.length; i++ ) {
-                       assertTrue( a[i].equals( ma[i] ) );
-               }
-       }
-
-       @Test
-       public void test3() {
-
-               String v = "Validate";
-               rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "set", v );
-       }
+    private static final String fmt = "%24s: %s%n";
+
+    ReflectionHarness rh = new ReflectionHarness();
+
+    String d, t, f, c, m;
+
+    @Before
+    public void setUp() throws Exception {
+        d = "central-onap";
+        t = "org.onap.dmaap.interestingTopic";
+        f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
+        c = "publisher";
+        m = "m12345";
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void test1() {
+
+        // can't use simple reflection to test for null since null constructor
+        // initializes some fields.
+        // rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
+        // so brute force instead...
+        String[] a = { "put", "view" };
+        MR_Client m = new MR_Client();
+
+        assertTrue(null == m.getDcaeLocationName());
+        assertTrue(null == m.getFqtn());
+        assertTrue(null == m.getClientRole());
+        assertTrue(null == m.getAction());
+
+    }
+
+    @Test
+    public void test2() {
+        String[] a = { "put", "view" };
+        MR_Client m = new MR_Client(d, f, c, a);
+
+        assertTrue(d.equals(m.getDcaeLocationName()));
+        assertTrue(f.equals(m.getFqtn()));
+        assertTrue(c.equals(m.getClientRole()));
+        String[] ma = m.getAction();
+        assertTrue(a.length == ma.length);
+        for (int i = 0; i < a.length; i++) {
+            assertTrue(a[i].equals(ma[i]));
+        }
+    }
+
+    @Test
+    public void test3() {
+
+        String v = "Validate";
+        rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
+    }
+
+    @Test
+    public void test4() {
+        MR_Client mrClient = new MR_Client();
+        String stringArray[] = { "test" };
+        mrClient.setAction(stringArray);
+        mrClient.hasAction("");
+        mrClient.setMrClientId("mrClientId");
+        mrClient.setTopicURL("testTopicURL");
+        mrClient.setClientIdentity("clientIdentity");
+
+        assertEquals("clientIdentity", mrClient.getClientIdentity());
+        assertEquals("testTopicURL", mrClient.getTopicURL());
+        assertEquals("mrClientId", mrClient.getMrClientId());
+        assertEquals(false, mrClient.isPublisher());
+        assertEquals(false, mrClient.isSubscriber());
+        assertEquals("test", mrClient.getAction()[0]);
+
+    }
 
 }