java-5

Mockito isA(Class<T> clazz) How to resolve type safety?

安稳与你 提交于 2019-11-27 21:07:45
问题 in my test I have the following line: when(client.runTask(anyString(), anyString(), isA(Iterable.class)).thenReturn(...) isA(Iterable.class) produces warning that it needs unchecked conversion to conform to Iterable<Integer> . What is syntax for that? isA(Iterable<Integer>.class) isA((Iterable<Integer>)Iterable.class do not work. Any suggestions? 回答1: Mockito/Hamcrest and generic classes Yes, this is a general problem with Mockito/Hamcrest. Generally using isA() with generic classes produces

How to disable TestNG test based on a condition

蓝咒 提交于 2019-11-27 12:11:29
问题 Is there currently a way to disable TestNG test based on a condition I know you can currently disable test as so in TestNG: @Test(enabled=false, group={"blah"}) public void testCurrency(){ ... } I will like to disable the same test based on a condition but dont know how. something Like this: @Test(enabled={isUk() ? false : true), group={"blah"}) public void testCurrency(){ ... } Anyone has a clue on whether this is possible or not. 回答1: You have two options: Implement an annotation

ORA-28040: No matching authentication protocol : Oracle 12c Upgrade

好久不见. 提交于 2019-11-27 07:07:10
问题 We have migrated our Oracle database to 12c from 11g. We have a legacy application running in Java 1.5 and using ojdbc14.jar. Our application is not able to create connection to database error saying : java.sql.SQLException: ORA-28040: No matching authentication protocol I reffered to answer ORA-28040: No matching authentication protocol exception, and tried to upgrade my ojdbc14.jar to ojdbc6.jar. I now have a different error message saying : error: OracleCallableStatement is not public in

When should I use the java 5 method cast of Class?

≡放荡痞女 提交于 2019-11-27 06:42:44
问题 Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like to know if casting this way has any advantages over trTuDocPackTypdBd.update((TrTuDocPackTypeDto)packDto); I've asked the developer responsible and he said he used it because it was new (which doesn't seem like a particularly good reason to me), but I'm intrigued when I would want to use the method. 回答1: These statements are not identical. The cast method

How do I get the hosts mac address using Java 5?

有些话、适合烂在心里 提交于 2019-11-26 17:17:27
问题 I know you can do this with Java 6 using java.net.NetworkInterface->getHardwareAddress() . But the environment I am deploying on is restricted to Java 5. Does anyone know how to do this in Java 5 or earlier? Many thanks. 回答1: The standard way in Java 5 was to start a native process to run ipconfig or ifconfig and parse the OutputStream to get your answer. For example: private String getMacAddress() throws IOException { String command = “ipconfig /all”; Process pid = Runtime.getRuntime().exec