
org.webpieces.webserver.test.Asserts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-webserver-test Show documentation
Show all versions of http-webserver-test Show documentation
The full webpieces server AS A library
The newest version!
package org.webpieces.webserver.test;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import org.webpieces.util.exceptions.SneakyThrow;
public class Asserts {
public static void assertWasCompiledWithParamNames(String param) {
//This is here for those that forget to configure their IDE to compile with param names
//We do this on eclipse generation and need to try to do it for intellij generation too
Class> clazz;
try {
clazz = Class.forName(Asserts.class.getName());
} catch (ClassNotFoundException e) {
throw SneakyThrow.sneak(e);
}
Method[] method = clazz.getDeclaredMethods();
Method target = null;
for(Method m : method) {
if("assertWasCompiledWithParamNames".equals(m.getName()))
target = m;
}
if(target == null)
throw new IllegalStateException("method not found...you must have changed the method in this class");
Parameter[] parameters = target.getParameters();
String name = parameters[0].getName();
if(!"param".equals(name))
throw new IllegalStateException("Compiler option for compiling with param names is not on so we can't run this test. arg name="+name+" when it should be 'param'");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy