Skip to content

Commit

Permalink
#000 - Fix some warnings. Only in test files.
Browse files Browse the repository at this point in the history
  • Loading branch information
arvindsv committed Jul 28, 2014
1 parent 97c980f commit 50e187e
Show file tree
Hide file tree
Showing 100 changed files with 292 additions and 920 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.fail;
import static org.junit.Assert.fail;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyInt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.thoughtworks.go.agent.functional;

import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertTrue;

import java.io.File;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.thoughtworks.go.agent;

import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.security.GeneralSecurityException;
Expand Down
5 changes: 4 additions & 1 deletion base/test/com/thoughtworks/go/util/DateUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.thoughtworks.go.util;

import java.util.Calendar;
import java.util.Date;

import org.joda.time.DateTime;
Expand All @@ -33,7 +34,9 @@ public class DateUtilsTest {

@Test
public void shouldFormatDateToDisplayOnUI() {
Date date = new Date(109, 10, 5);
Calendar instance = Calendar.getInstance();
instance.set(2009, Calendar.NOVEMBER, 5);
Date date = instance.getTime();
String formattedDate = DateUtils.formatToSimpleDate(date);
assertThat(formattedDate, is("05 Nov 2009"));
}
Expand Down
21 changes: 4 additions & 17 deletions base/test/com/thoughtworks/go/util/FileDigesterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,16 @@

package com.thoughtworks.go.util;

import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Test;

import static junit.framework.Assert.fail;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class FileDigesterTest {
private List<File> tempFiles = new ArrayList<File>();

@After
public void tearDown() throws Exception {
for (File tempFile : tempFiles) {
tempFile.delete();
}
}

private File createFileWithSampleData() throws IOException {
File tempFile = TestFileUtil.createTempFile("test.txt");
FileUtil.writeContentToFile("sample data", tempFile);
Expand All @@ -58,8 +46,7 @@ public void shouldThrowExceptionIfITryToGetMd5WithoutDigestingFile() {
try {
fileDigester.md5();
fail("Should have thrown an invalid state exception");
} catch (Exception e) {

} catch (Exception ignored) {
}
}
}
5 changes: 3 additions & 2 deletions base/test/com/thoughtworks/go/util/SystemTimeClockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package com.thoughtworks.go.util;

import com.thoughtworks.go.utils.Timeout;
import org.junit.Test;
import static org.junit.Assert.assertThat;
import org.joda.time.DateTime;
import org.junit.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class SystemTimeClockTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static junit.framework.Assert.assertNotNull;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

@RunWith(JunitExtRunner.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
import static com.thoughtworks.go.matchers.FileExistsMatcher.exists;
import static com.thoughtworks.go.util.command.ProcessOutputStreamConsumer.inMemoryConsumer;
import static java.lang.String.format;
import static junit.framework.Assert.fail;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.nullValue;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class GitMaterialTest {
@Rule public TestName name = new TestName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
import static com.thoughtworks.go.util.DateUtils.parseISO8601;
import static com.thoughtworks.go.util.command.ProcessOutputStreamConsumer.inMemoryConsumer;
import static java.lang.String.format;
import static junit.framework.Assert.fail;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.nullValue;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class HgMaterialTest {
private HgMaterial hgMaterial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import org.junit.matchers.JUnitMatchers;

import static java.lang.String.format;
import static junit.framework.Assert.fail;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.fail;

public abstract class P4MaterialTestBase extends PerforceFixture {
protected static final String VIEW = "//depot/... //something/...";
Expand Down Expand Up @@ -249,7 +249,7 @@ public void shouldLogRepoInfoToConsoleOutWithoutFolder() throws Exception {
P4Material p4Material = p4Fixture.material(VIEW);
p4Material.updateTo(outputconsumer, new StringRevision("2"), clientFolder, new TestSubprocessExecutionContext());
String message = format("Start updating %s at revision %s from %s", "files", "2", p4Material.getUrl());
assertThat(outputconsumer.getStdOut(), JUnitMatchers.containsString(message));
assertThat(outputconsumer.getStdOut(), containsString(message));
}

@Test public void shouldGenerateSqlCriteriaMapInSpecificOrder() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.fail;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class ArtifactMd5ChecksumsTest {

Expand Down
7 changes: 3 additions & 4 deletions common/test/com/thoughtworks/go/domain/BuildPlansTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

package com.thoughtworks.go.domain;

import static junit.framework.Assert.fail;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import com.thoughtworks.go.config.CaseInsensitiveString;
import com.thoughtworks.go.config.JobConfig;
Expand Down Expand Up @@ -49,7 +48,7 @@ public void shouldBombIfABuildPlanWithSameNameIsAdded() throws Exception {
try {
jobConfigs.add(jobConfig("Test"));
fail("Should not be able to add build plan with the same name again");
} catch (RuntimeException expected) {
} catch (RuntimeException ignored) {
}
}

Expand All @@ -60,7 +59,7 @@ public void shouldBombIfABuildPlanWithSameNameWithDifferentCaseIsAdded() throws
try {
jobConfigs.add(jobConfig("test"));
fail("Should not be able to add build plan with the same name again");
} catch (RuntimeException expected) {
} catch (RuntimeException ignored) {
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/test/com/thoughtworks/go/domain/DirHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.fail;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down
16 changes: 6 additions & 10 deletions common/test/com/thoughtworks/go/domain/FileHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,22 @@

package com.thoughtworks.go.domain;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

import com.thoughtworks.go.util.CachedDigestUtils;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.notNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.*;

public class FileHandlerTest {

Expand Down
14 changes: 11 additions & 3 deletions common/test/com/thoughtworks/go/domain/JobInstancesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.thoughtworks.go.domain;

import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -180,11 +181,18 @@ public void shouldReturnNullObjectWhenNoMostRecentPassedInstance() {

@Test
public void shouldReturnLatestTransitionDate() {
Date expectedLatest = new Date(2008, 10, 12);
Date expectedLatest = date(2008, 10, 12);
Date actualLatest = new JobInstances(
completed(completed("job1"), JobResult.Failed, expectedLatest),
completed(completed("job1"), JobResult.Failed, new Date(2008, 10, 11)),
completed(completed("job1"), JobResult.Failed, new Date(2008, 10, 5))).latestTransitionDate();
completed(completed("job1"), JobResult.Failed, date(2008, 10, 11)),
completed(completed("job1"), JobResult.Failed, date(2008, 10, 5))).latestTransitionDate();
assertThat(actualLatest,is(expectedLatest));
}

private Date date(int year, int month, int day) {
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
}
4 changes: 2 additions & 2 deletions common/test/com/thoughtworks/go/domain/ParamsConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import org.junit.Test;

import static com.thoughtworks.go.util.TestUtils.contains;
import static junit.framework.Assert.fail;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -48,7 +48,7 @@ public void setUp() {
@Test
public void shouldPopulateParamFromMapIgnoringEmptyPairs() {
paramsConfig = new ParamsConfig();
List paramsMap = new ArrayList<Map>();
List<Map> paramsMap = new ArrayList<Map>();

paramsMap.add(createParamMap("param-name", "param-value"));
paramsMap.add(createParamMap("", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@

import static com.thoughtworks.go.util.DataStructureUtils.a;
import static com.thoughtworks.go.util.DataStructureUtils.m;
import static junit.framework.Assert.fail;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package com.thoughtworks.go.domain;

import static junit.framework.Assert.fail;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import org.junit.Ignore;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import org.junit.Test;

import static junit.framework.Assert.fail;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsCollectionContaining.hasItems;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

public class StageResultTest {

Expand Down
4 changes: 3 additions & 1 deletion common/test/com/thoughtworks/go/domain/StubGoPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.thoughtworks.go.server.service.AgentRuntimeInfo;
import com.thoughtworks.go.work.DefaultGoPublisher;

import static org.junit.Assert.fail;

public class StubGoPublisher extends DefaultGoPublisher {
private String message = "";
private Map<File, String> uploadedFiles = new HashMap<File, String>();
Expand Down Expand Up @@ -71,6 +73,6 @@ public void assertPublished(String endOfFileName, String destination) {
return;
}
}
junit.framework.Assert.fail(endOfFileName + " was not published to " + destination + ".\n" + uploadedFiles);
fail(endOfFileName + " was not published to " + destination + ".\n" + uploadedFiles);
}
}
Loading

0 comments on commit 50e187e

Please sign in to comment.