HDFS-12758. Ozone: Correcting assertEquals argument order in test cases. Contributed by Bharat Viswanadham.

This commit is contained in:
Chen Liang 2017-11-08 20:58:13 -08:00 committed by Owen O'Malley
parent cec96b296f
commit e395244e95
11 changed files with 78 additions and 78 deletions

View File

@ -109,33 +109,33 @@ public void testAclParse() {
public void testAclValues() {
OzoneAcl acl = OzoneAcl.parseAcl("user:bilbo:rw");
assertEquals(acl.getName(), "bilbo");
assertEquals(acl.getRights(), OzoneAcl.OzoneACLRights.READ_WRITE);
assertEquals(acl.getType(), OzoneAcl.OzoneACLType.USER);
assertEquals(OzoneAcl.OzoneACLRights.READ_WRITE, acl.getRights());
assertEquals(OzoneAcl.OzoneACLType.USER, acl.getType());
acl = OzoneAcl.parseAcl("user:bilbo:wr");
assertEquals(acl.getName(), "bilbo");
assertEquals(acl.getRights(), OzoneAcl.OzoneACLRights.READ_WRITE);
assertEquals(acl.getType(), OzoneAcl.OzoneACLType.USER);
assertEquals("bilbo", acl.getName());
assertEquals(OzoneAcl.OzoneACLRights.READ_WRITE, acl.getRights());
assertEquals(OzoneAcl.OzoneACLType.USER, acl.getType());
acl = OzoneAcl.parseAcl("user:bilbo:r");
assertEquals(acl.getName(), "bilbo");
assertEquals(acl.getRights(), OzoneAcl.OzoneACLRights.READ);
assertEquals(acl.getType(), OzoneAcl.OzoneACLType.USER);
assertEquals("bilbo", acl.getName());
assertEquals(OzoneAcl.OzoneACLRights.READ, acl.getRights());
assertEquals(OzoneAcl.OzoneACLType.USER, acl.getType());
acl = OzoneAcl.parseAcl("user:bilbo:w");
assertEquals(acl.getName(), "bilbo");
assertEquals(acl.getRights(), OzoneAcl.OzoneACLRights.WRITE);
assertEquals(acl.getType(), OzoneAcl.OzoneACLType.USER);
assertEquals("bilbo", acl.getName());
assertEquals(OzoneAcl.OzoneACLRights.WRITE, acl.getRights());
assertEquals(OzoneAcl.OzoneACLType.USER, acl.getType());
acl = OzoneAcl.parseAcl("group:hobbit:wr");
assertEquals(acl.getName(), "hobbit");
assertEquals(acl.getRights(), OzoneAcl.OzoneACLRights.READ_WRITE);
assertEquals(acl.getType(), OzoneAcl.OzoneACLType.GROUP);
assertEquals(OzoneAcl.OzoneACLRights.READ_WRITE, acl.getRights());
assertEquals(OzoneAcl.OzoneACLType.GROUP, acl.getType());
acl = OzoneAcl.parseAcl("world::wr");
assertEquals(acl.getName(), "");
assertEquals(acl.getRights(), OzoneAcl.OzoneACLRights.READ_WRITE);
assertEquals(acl.getType(), OzoneAcl.OzoneACLType.WORLD);
assertEquals(OzoneAcl.OzoneACLRights.READ_WRITE, acl.getRights());
assertEquals(OzoneAcl.OzoneACLType.WORLD, acl.getType());
}
}

View File

@ -488,7 +488,7 @@ public static ContainerCommandRequestProto getKeyRequest(
public static void verifyGetKey(ContainerCommandRequestProto request,
ContainerCommandResponseProto response) {
Assert.assertEquals(request.getTraceID(), response.getTraceID());
Assert.assertEquals(response.getResult(), ContainerProtos.Result.SUCCESS);
Assert.assertEquals(ContainerProtos.Result.SUCCESS, response.getResult());
ContainerProtos.PutKeyRequestProto putKey = request.getPutKey();
ContainerProtos.GetKeyRequestProto getKey = request.getGetKey();
Assert.assertEquals(putKey.getKeyData().getChunksCount(),

View File

@ -119,10 +119,10 @@ public void testGetVersion() throws Exception {
SCMVersionResponseProto responseProto = rpcEndPoint.getEndPoint()
.getVersion(null);
Assert.assertNotNull(responseProto);
Assert.assertEquals(responseProto.getKeys(0).getKey(),
VersionInfo.DESCRIPTION_KEY);
Assert.assertEquals(responseProto.getKeys(0).getValue(),
VersionInfo.getLatestVersion().getDescription());
Assert.assertEquals(VersionInfo.DESCRIPTION_KEY,
responseProto.getKeys(0).getKey());
Assert.assertEquals(VersionInfo.getLatestVersion().getDescription(),
responseProto.getKeys(0).getValue());
}
}
@ -212,8 +212,8 @@ public void testRegister() throws Exception {
SCMRegisteredCmdResponseProto responseProto = rpcEndPoint.getEndPoint()
.register(nodeToRegister, scmAddressArray);
Assert.assertNotNull(responseProto);
Assert.assertEquals(responseProto.getDatanodeUUID(),
nodeToRegister.getDatanodeUuid());
Assert.assertEquals(nodeToRegister.getDatanodeUuid(),
responseProto.getDatanodeUUID());
Assert.assertNotNull(responseProto.getClusterID());
}
}

View File

@ -773,10 +773,10 @@ public void testUpdateContainer() throws IOException {
// Verify in-memory map
ContainerData actualNewData = containerManager.getContainerMap()
.get(containerName).getContainer();
Assert.assertEquals(actualNewData.getAllMetadata().get("VOLUME"),
"shire_new");
Assert.assertEquals(actualNewData.getAllMetadata().get("owner"),
"bilbo_new");
Assert.assertEquals("shire_new",
actualNewData.getAllMetadata().get("VOLUME"));
Assert.assertEquals("bilbo_new",
actualNewData.getAllMetadata().get("owner"));
// Verify container data on disk
File newContainerFile = containerManager.getContainerFile(actualNewData);
@ -791,10 +791,10 @@ public void testUpdateContainer() throws IOException {
ContainerProtos.ContainerData.parseDelimitedFrom(newIn);
ContainerData actualContainerData = ContainerData
.getFromProtBuf(actualContainerDataProto, conf);
Assert.assertEquals(actualContainerData.getAllMetadata().get("VOLUME"),
"shire_new");
Assert.assertEquals(actualContainerData.getAllMetadata().get("owner"),
"bilbo_new");
Assert.assertEquals("shire_new",
actualContainerData.getAllMetadata().get("VOLUME"));
Assert.assertEquals("bilbo_new",
actualContainerData.getAllMetadata().get("owner"));
}
// Test force update flag.
@ -818,10 +818,10 @@ public void testUpdateContainer() throws IOException {
// Verify in-memory map
actualNewData = containerManager.getContainerMap()
.get(containerName).getContainer();
Assert.assertEquals(actualNewData.getAllMetadata().get("VOLUME"),
"shire_new_1");
Assert.assertEquals(actualNewData.getAllMetadata().get("owner"),
"bilbo_new_1");
Assert.assertEquals("shire_new_1",
actualNewData.getAllMetadata().get("VOLUME"));
Assert.assertEquals("bilbo_new_1",
actualNewData.getAllMetadata().get("owner"));
// Update a non-existing container
exception.expect(StorageContainerException.class);

View File

@ -165,7 +165,7 @@ public void testDetectSingleContainerReplica() throws TimeoutException,
.getValue() == 1);
Assert.assertEquals(singleNodeContainer, containers.get(0).getKey());
int count = containers.get(0).getValue();
Assert.assertEquals(count, 1L);
Assert.assertEquals(1L, count);
}
@Test

View File

@ -211,7 +211,7 @@ public void testClientServerWithContainerDispatcher() throws Exception {
ContainerTestHelper.getCreateContainerRequest(containerName);
ContainerCommandResponseProto response = client.sendCommand(request);
Assert.assertTrue(request.getTraceID().equals(response.getTraceID()));
Assert.assertEquals(response.getResult(), ContainerProtos.Result.SUCCESS);
Assert.assertEquals(ContainerProtos.Result.SUCCESS, response.getResult());
Assert.assertTrue(dispatcher.
getContainerMetrics().
getContainerOpsMetrics(

View File

@ -184,8 +184,8 @@ public void testChangeVolumeQuota() throws IOException, OzoneException {
VolumeArgs getVolumeArgs = new VolumeArgs(volumeName, userArgs);
VolumeInfo retVolumeInfo = storageHandler.getVolumeInfo(getVolumeArgs);
Assert.assertEquals(retVolumeInfo.getQuota().sizeInBytes(),
createQuota.sizeInBytes());
Assert.assertEquals(createQuota.sizeInBytes(),
retVolumeInfo.getQuota().sizeInBytes());
// Set a new quota and test it
OzoneQuota setQuota =
@ -194,15 +194,15 @@ public void testChangeVolumeQuota() throws IOException, OzoneException {
storageHandler.setVolumeQuota(createVolumeArgs, false);
getVolumeArgs = new VolumeArgs(volumeName, userArgs);
retVolumeInfo = storageHandler.getVolumeInfo(getVolumeArgs);
Assert.assertEquals(retVolumeInfo.getQuota().sizeInBytes(),
setQuota.sizeInBytes());
Assert.assertEquals(setQuota.sizeInBytes(),
retVolumeInfo.getQuota().sizeInBytes());
// Remove the quota and test it again
storageHandler.setVolumeQuota(createVolumeArgs, true);
getVolumeArgs = new VolumeArgs(volumeName, userArgs);
retVolumeInfo = storageHandler.getVolumeInfo(getVolumeArgs);
Assert.assertEquals(retVolumeInfo.getQuota().sizeInBytes(),
OzoneConsts.MAX_QUOTA_IN_BYTES);
Assert.assertEquals(OzoneConsts.MAX_QUOTA_IN_BYTES,
retVolumeInfo.getQuota().sizeInBytes());
Assert.assertEquals(numVolumeCreateFail,
ksmMetrics.getNumVolumeCreateFails());
Assert.assertEquals(numVolumeInfoFail,

View File

@ -79,7 +79,7 @@ public void testCaching() throws IOException {
storageContainerLocationClient.allocateContainer(
clientManager.getType(), clientManager.getFactor(), containerName1);
XceiverClientSpi client1 = clientManager.acquireClient(pipeline1);
Assert.assertEquals(client1.getRefcount(), 1);
Assert.assertEquals(1, client1.getRefcount());
Assert.assertEquals(containerName1,
client1.getPipeline().getContainerName());
@ -88,13 +88,13 @@ public void testCaching() throws IOException {
storageContainerLocationClient.allocateContainer(
clientManager.getType(), clientManager.getFactor(), containerName2);
XceiverClientSpi client2 = clientManager.acquireClient(pipeline2);
Assert.assertEquals(client2.getRefcount(), 1);
Assert.assertEquals(1, client2.getRefcount());
Assert.assertEquals(containerName2,
client2.getPipeline().getContainerName());
XceiverClientSpi client3 = clientManager.acquireClient(pipeline1);
Assert.assertEquals(client3.getRefcount(), 2);
Assert.assertEquals(client1.getRefcount(), 2);
Assert.assertEquals(2, client3.getRefcount());
Assert.assertEquals(2, client1.getRefcount());
Assert.assertEquals(containerName1,
client3.getPipeline().getContainerName());
Assert.assertEquals(client1, client3);
@ -117,7 +117,7 @@ public void testFreeByReference() throws IOException {
clientManager.getType(), OzoneProtos.ReplicationFactor.ONE,
containerName1);
XceiverClientSpi client1 = clientManager.acquireClient(pipeline1);
Assert.assertEquals(client1.getRefcount(), 1);
Assert.assertEquals(1, client1.getRefcount());
Assert.assertEquals(containerName1,
client1.getPipeline().getContainerName());
@ -127,14 +127,14 @@ public void testFreeByReference() throws IOException {
clientManager.getType(),
OzoneProtos.ReplicationFactor.ONE, containerName2);
XceiverClientSpi client2 = clientManager.acquireClient(pipeline2);
Assert.assertEquals(client2.getRefcount(), 1);
Assert.assertEquals(1, client2.getRefcount());
Assert.assertEquals(containerName2,
client2.getPipeline().getContainerName());
Assert.assertNotEquals(client1, client2);
// least recent container (i.e containerName1) is evicted
XceiverClientSpi nonExistent1 = cache.getIfPresent(containerName1);
Assert.assertEquals(nonExistent1, null);
Assert.assertEquals(null, nonExistent1);
// However container call should succeed because of refcount on the client.
String traceID1 = "trace" + RandomStringUtils.randomNumeric(4);
ContainerProtocolCalls.createContainer(client1, traceID1);
@ -162,19 +162,19 @@ public void testFreeByEviction() throws IOException {
clientManager.getType(),
clientManager.getFactor(), containerName1);
XceiverClientSpi client1 = clientManager.acquireClient(pipeline1);
Assert.assertEquals(client1.getRefcount(), 1);
Assert.assertEquals(1, client1.getRefcount());
Assert.assertEquals(containerName1,
client1.getPipeline().getContainerName());
clientManager.releaseClient(client1);
Assert.assertEquals(client1.getRefcount(), 0);
Assert.assertEquals(0, client1.getRefcount());
String containerName2 = "container" + RandomStringUtils.randomNumeric(10);
Pipeline pipeline2 =
storageContainerLocationClient.allocateContainer(
clientManager.getType(), clientManager.getFactor(), containerName2);
XceiverClientSpi client2 = clientManager.acquireClient(pipeline2);
Assert.assertEquals(client2.getRefcount(), 1);
Assert.assertEquals(1, client2.getRefcount());
Assert.assertEquals(containerName2,
client2.getPipeline().getContainerName());
Assert.assertNotEquals(client1, client2);
@ -182,7 +182,7 @@ public void testFreeByEviction() throws IOException {
// now client 1 should be evicted
XceiverClientSpi nonExistent = cache.getIfPresent(containerName1);
Assert.assertEquals(nonExistent, null);
Assert.assertEquals(null, nonExistent);
// Any container operation should now fail
String traceID2 = "trace" + RandomStringUtils.randomNumeric(4);

View File

@ -88,8 +88,8 @@ public static void shutdown() {
@Test
public void testCreateVolumes() throws IOException {
super.testCreateVolumes(port);
Assert.assertEquals(cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails(), 0);
Assert.assertEquals(0, cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails());
}
/**
@ -100,8 +100,8 @@ public void testCreateVolumes() throws IOException {
@Test
public void testCreateVolumesWithQuota() throws IOException {
super.testCreateVolumesWithQuota(port);
Assert.assertEquals(cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails(), 0);
Assert.assertEquals(0, cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails());
}
/**
@ -112,8 +112,8 @@ public void testCreateVolumesWithQuota() throws IOException {
@Test
public void testCreateVolumesWithInvalidQuota() throws IOException {
super.testCreateVolumesWithInvalidQuota(port);
Assert.assertEquals(cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails(), 0);
Assert.assertEquals(0, cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails());
}
/**
@ -126,8 +126,8 @@ public void testCreateVolumesWithInvalidQuota() throws IOException {
@Test
public void testCreateVolumesWithInvalidUser() throws IOException {
super.testCreateVolumesWithInvalidUser(port);
Assert.assertEquals(cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails(), 0);
Assert.assertEquals(0, cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails());
}
/**
@ -141,8 +141,8 @@ public void testCreateVolumesWithInvalidUser() throws IOException {
@Test
public void testCreateVolumesWithOutAdminRights() throws IOException {
super.testCreateVolumesWithOutAdminRights(port);
Assert.assertEquals(cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails(), 0);
Assert.assertEquals(0, cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails());
}
/**
@ -153,8 +153,8 @@ public void testCreateVolumesWithOutAdminRights() throws IOException {
@Test
public void testCreateVolumesInLoop() throws IOException {
super.testCreateVolumesInLoop(port);
Assert.assertEquals(cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails(), 0);
Assert.assertEquals(0, cluster.getKeySpaceManager()
.getMetrics().getNumVolumeCreateFails());
}
/**
* Get volumes owned by the user.

View File

@ -236,14 +236,14 @@ static void runTestPutKey(PutHelper helper) throws Exception {
assertNotNull(helper.getBucket());
assertNotNull(helper.getFile());
List<OzoneKey> keyList = helper.getBucket().listKeys("100", null, null);
Assert.assertEquals(keyList.size(), 1);
Assert.assertEquals(1, keyList.size());
// test list key using a more efficient call
String newkeyName = OzoneUtils.getRequestID().toLowerCase();
client.putKey(helper.getVol().getVolumeName(),
helper.getBucket().getBucketName(), newkeyName, helper.getFile());
keyList = helper.getBucket().listKeys("100", null, null);
Assert.assertEquals(keyList.size(), 2);
Assert.assertEquals(2, keyList.size());
// test new put key with invalid volume/bucket name
try{
@ -425,8 +425,8 @@ static void runTestPutAndListKey(PutHelper helper) throws Exception {
List<OzoneKey> keyList2 = client.listKeys(helper.getVol().getVolumeName(),
helper.getBucket().getBucketName(), "100", null, null);
Assert.assertEquals(keyList1.size(), 11);
Assert.assertEquals(keyList2.size(), 11);
Assert.assertEquals(11, keyList1.size());
Assert.assertEquals(11, keyList2.size());
// Verify the key creation/modification time. Here we compare the time in
// second unit since the date string reparsed to millisecond will
// lose precision.
@ -448,15 +448,15 @@ static void runTestPutAndListKey(PutHelper helper) throws Exception {
keyList1 = helper.getBucket().listKeys("1", null, null);
keyList2 = client.listKeys(helper.getVol().getVolumeName(),
helper.getBucket().getBucketName(), "1", null, null);
Assert.assertEquals(keyList1.size(), 1);
Assert.assertEquals(keyList2.size(), 1);
Assert.assertEquals(1, keyList1.size());
Assert.assertEquals(1, keyList2.size());
// test startKey parameter of list keys
keyList1 = helper.getBucket().listKeys("100", "list-key4", "list-key");
keyList2 = client.listKeys(helper.getVol().getVolumeName(),
helper.getBucket().getBucketName(), "100", "list-key4", "list-key");
Assert.assertEquals(keyList1.size(), 5);
Assert.assertEquals(keyList2.size(), 5);
Assert.assertEquals(5, keyList1.size());
Assert.assertEquals(5, keyList2.size());
// test prefix parameter of list keys
keyList1 = helper.getBucket().listKeys("100", null, "list-key2");

View File

@ -99,7 +99,7 @@ public static void teardown() throws IOException {
@Test
public void testFileSystemInit() throws IOException {
Assert.assertTrue(fs instanceof OzoneFileSystem);
Assert.assertEquals(fs.getUri().getScheme(), Constants.OZONE_URI_SCHEME);
Assert.assertEquals(Constants.OZONE_URI_SCHEME, fs.getUri().getScheme());
}
@Test
@ -120,7 +120,7 @@ public void testOzFsReadWrite() throws IOException {
byte[] buffer = new byte[stringLen];
inputStream.readFully(0, buffer);
String out = new String(buffer, 0, buffer.length);
Assert.assertEquals(out, data);
Assert.assertEquals(data, out);
}
}
@ -132,10 +132,10 @@ public void testDirectory() throws IOException {
FileStatus status = fs.getFileStatus(path);
Assert.assertTrue(status.isDirectory());
Assert.assertEquals(status.getLen(), 0);
Assert.assertEquals(0, status.getLen());
FileStatus[] statusList = fs.listStatus(new Path("/"));
Assert.assertEquals(statusList.length, 1);
Assert.assertEquals(statusList[0], status);
Assert.assertEquals(1, statusList.length);
Assert.assertEquals(status, statusList[0]);
}
}