@Test
  public void testHdfsApiDependsOnInstance() throws Exception {
    UserLocal.dropAllConnections(HdfsApi.class); //cleanup API connection

    ViewContext context1 = createNiceMock(ViewContext.class);
    ViewContext context2 = createNiceMock(ViewContext.class);
    ViewContext context3 = createNiceMock(ViewContext.class);
    expect(context1.getProperties()).andReturn(properties).anyTimes();
    expect(context1.getUsername()).andReturn("ambari-qa").anyTimes();
    expect(context1.getInstanceName()).andReturn("Pig1").anyTimes();

    expect(context2.getProperties()).andReturn(properties).anyTimes();
    expect(context2.getUsername()).andReturn("ambari-qa").anyTimes();
    expect(context2.getInstanceName()).andReturn("Pig2").anyTimes();

    expect(context3.getProperties()).andReturn(properties).anyTimes();
    expect(context3.getUsername()).andReturn("ambari-qa").anyTimes();
    expect(context3.getInstanceName()).andReturn("Pig1").anyTimes();

    replay(context1, context2, context3);

    HdfsApi hdfsApi1 = UserLocalObjects.getHdfsApi(context1);
    HdfsApi hdfsApi2 = UserLocalObjects.getHdfsApi(context2);
    Assert.assertNotSame(hdfsApi1, hdfsApi2);

    HdfsApi hdfsApi1_2 = UserLocalObjects.getHdfsApi(context1);
    HdfsApi hdfsApi2_2 = UserLocalObjects.getHdfsApi(context1);
    Assert.assertSame(hdfsApi1_2, hdfsApi2_2);

    HdfsApi hdfsApi1_3 = UserLocalObjects.getHdfsApi(context1);
    HdfsApi hdfsApi3_3 = UserLocalObjects.getHdfsApi(context3);
    Assert.assertSame(hdfsApi1_3, hdfsApi3_3);
  }
Test cases that verify all services altogether
contrib/views/pig/src/test/java/org/apache/ambari/view/pig/test/IntegrationalTest.java