-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfigTest.java
More file actions
40 lines (30 loc) · 1.12 KB
/
ConfigTest.java
File metadata and controls
40 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.Upwork.api;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Spy;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.*;
import org.powermock.modules.junit4.*;
import static org.mockito.Mockito.*;
import java.io.FileInputStream;
import java.util.Properties;
import com.Upwork.api.Config;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("jdk.internal.reflect.*")
@PrepareForTest({
Config.class
})
public class ConfigTest {
@Spy private final Properties properties = new Properties();
@Test public void getProperty() throws Exception {
when(properties.getProperty("key")).thenReturn("value");
final FileInputStream fileInputStreamMock = PowerMockito.mock(FileInputStream.class);
PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString())
.thenReturn(fileInputStreamMock);
Config config = new Config(properties);
String test = config.getProperty("key");
assertEquals("get config property", "value", test);
}
}