{"action":"opened","issue":{"url":"https://api.github.com/repos/EvoSuite/evosuite/issues/42","repository_url":"https://api.github.com/repos/EvoSuite/evosuite","labels_url":"https://api.github.com/repos/EvoSuite/evosuite/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/EvoSuite/evosuite/issues/42/comments","events_url":"https://api.github.com/repos/EvoSuite/evosuite/issues/42/events","html_url":"https://github.com/EvoSuite/evosuite/issues/42","id":162004563,"number":42,"title":"Error while generating test cases for classes \"LookUtils\" and \"ClearLookUtils\"","user":{"login":"log6306-hp","id":14348904,"avatar_url":"https://avatars.githubusercontent.com/u/14348904?v=3","gravatar_id":"","url":"https://api.github.com/users/log6306-hp","html_url":"https://github.com/log6306-hp","followers_url":"https://api.github.com/users/log6306-hp/followers","following_url":"https://api.github.com/users/log6306-hp/following{/other_user}","gists_url":"https://api.github.com/users/log6306-hp/gists{/gist_id}","starred_url":"https://api.github.com/users/log6306-hp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/log6306-hp/subscriptions","organizations_url":"https://api.github.com/users/log6306-hp/orgs","repos_url":"https://api.github.com/users/log6306-hp/repos","events_url":"https://api.github.com/users/log6306-hp/events{/privacy}","received_events_url":"https://api.github.com/users/log6306-hp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-23T19:31:47Z","updated_at":"2016-06-23T19:31:47Z","closed_at":null,"body":"There is a key in its configuration named \"headless_mode\" which is set to true by default. The tool throws exception (Headless Exception) at the class \"LookUtils\".  I set this key to false and EvoSuite does not throw that error but shows another exception at the class \"ClearLookUtils\". Actually, I got stuck with this ...\r\n\r\nBelow is the LookUtils.java:\r\n\r\nimport java.awt.Color;\r\nimport java.awt.Component;\r\nimport java.awt.Insets;\r\nimport java.awt.Toolkit;\r\nimport java.util.Collections;\r\nimport java.util.List;\r\n\r\nimport javax.swing.AbstractButton;\r\nimport javax.swing.LookAndFeel;\r\nimport javax.swing.UIManager;\r\nimport javax.swing.UnsupportedLookAndFeelException;\r\nimport javax.swing.plaf.InsetsUIResource;\r\nimport javax.swing.plaf.UIResource;\r\n\r\npublic final class LookUtils\r\n{\r\n  private static final String JAVA_VERSION = getSystemProperty(\"java.version\");\r\n  private static final String OS_NAME = getSystemProperty(\"os.name\");\r\n  private static final String OS_VERSION = getSystemProperty(\"os.version\");\r\n  public static final boolean IS_JAVA_1_4 = startsWith(JAVA_VERSION, \"1.4\");\r\n  static final boolean IS_JAVA_1_4_0 = startsWith(JAVA_VERSION, \"1.4.0\");\r\n  public static final boolean IS_JAVA_1_4_2_OR_LATER = (!startsWith(JAVA_VERSION, \"1.4.0\")) && (!startsWith(JAVA_VERSION, \"1.4.1\"));\r\n  public static final boolean IS_OS_FREEBSD = startsWithIgnoreCase(OS_NAME, \"FreeBSD\");\r\n  public static final boolean IS_OS_LINUX = startsWithIgnoreCase(OS_NAME, \"Linux\");\r\n  public static final boolean IS_OS_OS2 = startsWith(OS_NAME, \"OS/2\");\r\n  public static final boolean IS_OS_MAC = startsWith(OS_NAME, \"Mac\");\r\n  public static final boolean IS_OS_WINDOWS = startsWith(OS_NAME, \"Windows\");\r\n  public static final boolean IS_OS_WINDOWS_MODERN = (startsWith(OS_NAME, \"Windows\")) && (!startsWith(OS_VERSION, \"4.0\"));\r\n  public static final boolean IS_OS_WINDOWS_XP = (startsWith(OS_NAME, \"Windows\")) && (startsWith(OS_VERSION, \"5.1\"));\r\n  public static final boolean IS_OS_SOLARIS = startsWith(OS_NAME, \"Solaris\");\r\n  public static final boolean IS_LAF_WINDOWS_XP_ENABLED = isWindowsXPLafEnabled();\r\n  public static final boolean IS_NETBEANS;\r\n  public static final boolean IS_LOW_RESOLUTION = isLowResolution();\r\n  private static boolean loggingEnabled = true;\r\n  \r\n  static\r\n  {\r\n    IS_NETBEANS = isNetBeans();\r\n    if (IS_NETBEANS) {\r\n      //ClearLookManager.getMode();\r\n    }\r\n  }\r\n  \r\n  public static String getSystemProperty(String key)\r\n  {\r\n    try\r\n    {\r\n      return System.getProperty(key);\r\n    }\r\n    catch (SecurityException e)\r\n    {\r\n      log(\"Can't read the System property \" + key + \".\");\r\n    }\r\n    return null;\r\n  }\r\n  \r\n  public static String getSystemProperty(String key, String defaultValue)\r\n  {\r\n    try\r\n    {\r\n      return System.getProperty(key, defaultValue);\r\n    }\r\n    catch (SecurityException e)\r\n    {\r\n      log(\"Can't read the System property \" + key + \".\");\r\n    }\r\n    return defaultValue;\r\n  }\r\n  \r\n  private static boolean isWindowsXPLafEnabled()\r\n  {\r\n    return (IS_OS_WINDOWS_XP) && (IS_JAVA_1_4_2_OR_LATER) && (Boolean.TRUE.equals(Toolkit.getDefaultToolkit().getDesktopProperty(\"win.xpstyle.themeActive\"))) && (getSystemProperty(\"swing.noxp\") == null);\r\n  }\r\n  \r\n  public static boolean isTrueColor(Component c)\r\n  {\r\n    return c.getToolkit().getColorModel().getPixelSize() >= 24;\r\n  }\r\n  \r\n  public static void installNarrowMargin(AbstractButton b, String propertyPrefix)\r\n  {\r\n    Object value = b.getClientProperty(\"jgoodies.isNarrow\");\r\n    boolean isNarrow = Boolean.TRUE.equals(value);\r\n    String defaultsKey = propertyPrefix + (isNarrow ? \"narrowMargin\" : \"margin\");\r\n    \r\n    Insets insets = b.getMargin();\r\n    if ((insets == null) || ((insets instanceof UIResource))) {\r\n      b.setMargin(UIManager.getInsets(defaultsKey));\r\n    }\r\n  }\r\n  \r\n  public static Insets createButtonMargin(boolean narrow)\r\n  {\r\n    int pad = narrow? 4 : 14;\r\n    return IS_LOW_RESOLUTION ? new InsetsUIResource(2, pad, 1, pad) : new InsetsUIResource(3, pad, 3, pad);\r\n  }\r\n  \r\n  public static Color getSlightlyBrighter(Color color)\r\n  {\r\n    return getSlightlyBrighter(color, 1.1F);\r\n  }\r\n  \r\n  public static Color getSlightlyBrighter(Color color, float factor)\r\n  {\r\n    float[] hsbValues = new float[3];\r\n    Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbValues);\r\n    \r\n    float hue = hsbValues[0];\r\n    float saturation = hsbValues[1];\r\n    float brightness = hsbValues[2];\r\n    float newBrightness = Math.min(brightness * factor, 1.0F);\r\n    return Color.getHSBColor(hue, saturation, newBrightness);\r\n  }\r\n  \r\n  public static void setLookAndTheme(LookAndFeel laf, Object theme)\r\n    throws UnsupportedLookAndFeelException\r\n  {\r\n    UIManager.setLookAndFeel(laf);\r\n  }\r\n  \r\n  public static Object getDefaultTheme(LookAndFeel laf)\r\n  {\r\n    return null;\r\n  }\r\n  \r\n  public static List getInstalledThemes(LookAndFeel laf)\r\n  {\r\n    return Collections.EMPTY_LIST;\r\n  }\r\n  \r\n  public static void setLoggingEnabled(boolean enabled)\r\n  {\r\n    loggingEnabled = enabled;\r\n  }\r\n  \r\n  public static void log()\r\n  {\r\n    if (loggingEnabled) {\r\n      System.out.println();\r\n    }\r\n  }\r\n  \r\n  public static void log(String message)\r\n  {\r\n    if (loggingEnabled) {\r\n      System.out.println(\"JGoodies Looks: \" + message);\r\n    }\r\n  }\r\n  \r\n  private static boolean isLowResolution()\r\n  {\r\n\t  System.out.println(Toolkit.getDefaultToolkit().getScreenResolution());\r\n\t  return Toolkit.getDefaultToolkit().getScreenResolution() < 120;\r\n  }\r\n  \r\n  private static boolean isNetBeans()\r\n  {\r\n    String property = getSystemProperty(\"netbeans.buildnumber\");\r\n    boolean hasNetBeansBuildNumber = (property != null) && (property.length() > 0);\r\n    if (hasNetBeansBuildNumber) {\r\n      log(\"NetBeans detected - dobry den!\");\r\n    }\r\n    return hasNetBeansBuildNumber;\r\n  }\r\n  \r\n  private static boolean startsWith(String str, String prefix)\r\n  {\r\n    return (str != null) && (str.startsWith(prefix));\r\n  }\r\n  \r\n  private static boolean startsWithIgnoreCase(String str, String prefix)\r\n  {\r\n    return (str != null) && (str.toUpperCase().startsWith(prefix.toUpperCase()));\r\n  }\r\n}\r\n\r\n******************************************************************************************************\r\n******************************************************************************************************\r\n******************************************************************************************************\r\nBelow is the ClearLookUtils.java:\r\n\r\nimport javax.swing.JComponent;\r\nimport javax.swing.border.Border;\r\n\r\npublic final class ClearLookUtils\r\n{\r\n  private static final String CLEARLOOK_KEY = \"ClearLook\";\r\n  private static final Object MARKER = \"marker\";\r\n  \r\n  public static boolean hasCheckedBorder(JComponent component)\r\n  {\r\n    return component.getClientProperty(\"ClearLook\") != null;\r\n  }\r\n  \r\n  public static Border getStoredBorder(JComponent component)\r\n  {\r\n    Object borderOrMarker = component.getClientProperty(\"ClearLook\");\r\n    return borderOrMarker == MARKER ? null : (Border)borderOrMarker;\r\n  }\r\n  \r\n  public static void storeBorder(JComponent component, Border border)\r\n  {\r\n    Object borderOrMarker;\r\n    //Object borderOrMarker;\r\n    if (border == null) {\r\n      borderOrMarker = MARKER;\r\n    } else {\r\n      borderOrMarker = border;\r\n    }\r\n    component.putClientProperty(\"ClearLook\", borderOrMarker);\r\n  }\r\n}\r\n"}}
{"actor":{"display_login":"log6306-hp"}}