private void handleSpecialCases() { if (Properties.P_REFLECTION_ON_PRIVATE > 0 && Properties.REFLECTION_START_PERCENT < 1) { // Check if we should add // PrivateAccess.callDefaultConstructorOfTheClassUnderTest() Class<?> target = Properties.getTargetClassAndDontInitialise(); Constructor<?> constructor = null; try { constructor = target.getDeclaredConstructor(); } catch (NoSuchMethodException e) { } if (constructor != null && Modifier.isPrivate(constructor.getModifiers()) && target.getDeclaredConstructors().length == 1 // Not enums && !target.isEnum()) { Method m = null; try { m = PrivateAccess.class.getDeclaredMethod("callDefaultConstructorOfTheClassUnderTest"); } catch (NoSuchMethodException e) { logger.error("Missing method: " + e.toString()); return; } GenericMethod gm = new GenericMethod(m, PrivateAccess.class); // It is not really an environment method, but not sure how else // to handle it... TestCluster.getInstance().addEnvironmentTestCall(gm); } } }
/** * If System.in was used, add methods to handle/simulate it */ private void handleSystemIn() { if (!hasAddedSystemIn && SystemInUtil.getInstance().hasBeenUsed()) { hasAddedSystemIn = true; try { TestCluster.getInstance() .addEnvironmentTestCall(new GenericMethod( SystemInUtil.class.getMethod("addInputLine", new Class<?>[] { String.class }), new GenericClass(SystemInUtil.class))); } catch (SecurityException e) { logger.error("Error while handling Random: " + e.getMessage(), e); } catch (NoSuchMethodException e) { logger.error("Error while handling Random: " + e.getMessage(), e); } } }
TestCluster.getInstance().addEnvironmentTestCall(genericMethod); TestCluster.getInstance().addEnvironmentTestCall(genericMethod); TestCluster.getInstance().addEnvironmentTestCall(genericMethod); TestCluster.getInstance().addEnvironmentTestCall(genericMethod); TestCluster.getInstance().addEnvironmentTestCall(genericMethod);
TestCluster.getInstance().addEnvironmentTestCall(gc); GenericClass genclass = new GenericClass(klass); TestCluster.getInstance().invalidateGeneratorCache(genclass); TestCluster.getInstance().addEnvironmentTestCall(gm);
try { TestCluster.getInstance() .addEnvironmentTestCall(new GenericMethod( NetworkHandling.class.getMethod("createRemoteTextFile", new Class<?>[] { EvoSuiteURL.class, String.class }), try { TestCluster.getInstance() .addEnvironmentTestCall( new GenericMethod( NetworkHandling.class.getMethod("sendUdpPacket", new GenericClass(NetworkHandling.class))); TestCluster.getInstance() .addEnvironmentTestCall(new GenericMethod( NetworkHandling.class.getMethod("sendUdpPacket", new Class<?>[] { EvoSuiteLocalAddress.class, byte[].class }), .addEnvironmentTestCall(new GenericMethod( NetworkHandling.class.getMethod("sendDataOnTcp", new Class<?>[] { EvoSuiteLocalAddress.class, byte[].class }), new GenericClass(NetworkHandling.class))); TestCluster.getInstance() .addEnvironmentTestCall(new GenericMethod( NetworkHandling.class.getMethod("sendMessageOnTcp", new Class<?>[] { EvoSuiteLocalAddress.class, String.class }), .addEnvironmentTestCall(new GenericMethod( NetworkHandling.class.getMethod("openRemoteTcpServer",