BufferedReader reader = null; try { inputStream = resourceUtils.getAsStream(VERSION_LOG_NAME);
@Test(expectedExceptions = InvalidVersionException.class) public void versionLogEmptyFirstLine() throws Exception { String content = "\n1.5.2.24"; when(resourceUtils.getAsStream(Matchers.anyString())).thenReturn(new ByteArrayInputStream(content.getBytes("UTF-8"))); reader.readVersion(); }
@Test public void versionLogCorrect() throws Exception { String content = "1.5.2.24"; when(resourceUtils.getAsStream(Matchers.anyString())).thenReturn(new ByteArrayInputStream(content.getBytes("UTF-8"))); Assert.assertEquals(reader.readVersion(), content); }
@Test(expectedExceptions = InvalidVersionException.class) public void versionLogNotFound() throws Exception { when(resourceUtils.getAsStream(Matchers.anyString())).thenReturn(null); reader.readVersion(); }
@Test(expectedExceptions = InvalidVersionException.class) public void versionLogEmpty() throws Exception { String content = ""; when(resourceUtils.getAsStream(Matchers.anyString())).thenReturn(new ByteArrayInputStream(content.getBytes("UTF-8"))); reader.readVersion(); }
@Test public void versionLogCorrectMoreLines() throws Exception { String version = "1.5.2.24"; String content = version + "\n\n"; when(resourceUtils.getAsStream(Matchers.anyString())).thenReturn(new ByteArrayInputStream(content.getBytes("UTF-8"))); Assert.assertEquals(reader.readVersion(), version); } }