This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. You can make a alias in your ~/.bashrc file : | |
alias curl="curl -x <proxy_host>:<proxy_port>" | |
2. Another solution is to use (maybe the better solution) the ~/.curlrc file (create it if it does not exist) : | |
``` | |
proxy = <proxy_host>:<proxy_port> | |
``` | |
e.g. | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mock side_effect | |
>>> iter_mock = mock.Mock(side_effect=[1, 2, 3]) | |
>>> iter_mock() | |
1 | |
>>> iter_mock() | |
2 | |
>>> iter_mock() | |
3 | |
# n days ago |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "14714368837763236677" -> -3732375235946314939 | |
long long_id = new BigInteger(str_id.trim()).longValue(); | |
// -3732375235946314939 -> "cc33f07f74f48345" | |
String str_hex_id = Long.toHexString(long_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Student> retList = gson.fromJson(s2, | |
new TypeToken<List<Student>>() { | |
}.getType()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(PowerMockRunner.class) | |
@PrepareForTest({DatasetInfoDao.class, DatasetResource.class}) | |
public class DatasetResourceTest { | |
@Test | |
public void testIsDumpTimingValidTrue() throws Exception { | |
DatasetInfoDao dao = PowerMockito.mock(DatasetInfoDao.class); | |
PowerMockito.when(dao, "getCreatetimeByGroupIdAndDocName", Mockito.any(String.class), Mockito.any(String.class)).thenReturn(null); | |
DatasetResource resource = PowerMockito.spy(new DatasetResource()); | |
MemberModifier.field(DatasetResource.class, "datasetInfoDao").set(resource, dao); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(PowerMockRunner.class) | |
@PrepareForTest(DriverManager.class) | |
public class Mocker { | |
@Test | |
public void testName() throws Exception { | |
//given | |
PowerMockito.mockStatic(DriverManager.class); | |
BDDMockito.given(DriverManager.getConnection(...)).willReturn(...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.jupiter.api.Assertions.assertThrows; | |
@Test | |
public void testUsernameIsNull() { | |
Exception exception = assertThrows(IllegalArgumentException.class, () -> { | |
User user = new User(); | |
user.setName(null); | |
}); | |
Assert.assertEquals("expected message", exception.getMessage()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"sig":"87058829e86fa3d345d0f72e6a72425c2ab8e60a29fdc2b03c43dc73d414c7ab25acf466e8a14fdefcaab8a07c2e5ff760b91642b878303f0d64d149bdc0c1a30","msghash":"4b3370128fe7e0899a9d23151ab0a425f296c2bda535470e7c1b3830c32e2826"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"sig":"87058829e86fa3d345d0f72e6a72425c2ab8e60a29fdc2b03c43dc73d414c7ab25acf466e8a14fdefcaab8a07c2e5ff760b91642b878303f0d64d149bdc0c1a30","msghash":"4b3370128fe7e0899a9d23151ab0a425f296c2bda535470e7c1b3830c32e2826"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"sig":"87058829e86fa3d345d0f72e6a72425c2ab8e60a29fdc2b03c43dc73d414c7ab25acf466e8a14fdefcaab8a07c2e5ff760b91642b878303f0d64d149bdc0c1a30","msghash":"4b3370128fe7e0899a9d23151ab0a425f296c2bda535470e7c1b3830c32e2826"} |
NewerOlder