// Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts2Transformer.java
// public class Struts2Transformer extends AbstractLeechTransformer {
// 
//     public Struts2Transformer() {
//         super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
//         addImportPackage(collectPackages());
//     }
// 
//     public static String[] collectPackages() {
//         return new String[]{
//                 "com.highway2urhell",
//                 "com.highway2urhell.domain",
//                 "com.opensymphony.xwork2.config",
//                 "com.opensymphony.xwork2.config.entities",
//                 "java.lang.reflect",
//                 "java.util",
//                 "org.apache.struts2.dispatcher"
//         };
//     }
// 
//     @Override
//     protected void doTransform(CtClass cc) throws Exception {
//         CtMethod m = cc
//                 .getMethod("postInit",
//                         "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
//         m.insertBefore(collectBody());
//     }
// 
//     public static String collectBody() {
//         return "{\n" +
//                 "    List listEntryPath = new ArrayList();\n" +
//                 "    ConfigurationManager cm = dispatcher.getConfigurationManager();\n" +
//                 "    Configuration cf = cm.getConfiguration();\n" +
//                 "    Collection colPackages = cf.getPackageConfigs().values();\n" +
//                 "    if (colPackages != null) {\n" +
//                 "        Iterator ite = colPackages.iterator();\n" +
//                 "        while (ite.hasNext()) {\n" +
//                 "            PackageConfig pack = (PackageConfig) ite.next();\n" +
//                 "            Collection colActionConfigs = pack.getActionConfigs().values();\n" +
//                 "            Iterator iteCol = colActionConfigs.iterator();\n" +
//                 "            while (iteCol.hasNext()) {\n" +
//                 "                ActionConfig action = (ActionConfig) iteCol.next();\n" +
//                 "                if (action.getClassName() != null && !\"\".equals(action.getClassName())) {\n" +
//                 "                    try {\n" +
//                 "                        Class c = Class.forName(action.getClassName());\n" +
//                 "                        Method[] tabM = c.getDeclaredMethods();\n" +
//                 "                        for (int i = 0; i < tabM.length; i++) {\n" +
//                 "                            String scope = Modifier.toString(tabM[i].getModifiers());\n" +
//                 "                            if (scope.startsWith(\"public\") && !\"wait\".equals(tabM[i].getName()) && !\"notifyall\".equals(tabM[i].getName().toLowerCase()) && !\"notify\".equals(tabM[i].getName().toLowerCase()) && !\"getclass\".equals(tabM[i].getName().toLowerCase()) && !\"equals\".equals(tabM[i].getName().toLowerCase()) && !\"tostring\".equals(tabM[i].getName().toLowerCase()) && !\"wait\".equals(tabM[i].getName().toLowerCase()) && !\"hashcode\".equals(tabM[i].getName().toLowerCase())) {\n" +
//                 "                                Method m = tabM[i];\n" +
//                 "                                EntryPathData entry = new EntryPathData();\n" +
//                 "                                entry.setTypePath(TypePath.DYNAMIC);\n" +
//                 "                                entry.setClassName(action.getClassName());\n" +
//                 "                                entry.setMethodName(m.getName());\n" +
//                 "                                entry.setUri(action.getName());\n" +
//                 "                                entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(m));\n" +
//                 "                                List listEntryPathData = new ArrayList();\n" +
//                 "                                for (int j = 0; j < m.getParameterTypes().length; j++) {\n" +
//                 "                                    EntryPathParam param = new EntryPathParam();\n" +
//                 "                                    param.setKey(\"\");\n" +
//                 "                                    param.setTypeParam(TypeParam.PARAM_DATA);\n" +
//                 "                                    param.setValue(m.getParameterTypes()[j].getName());\n" +
//                 "                                    listEntryPathData.add(param);\n" +
//                 "                                }\n" +
//                 "                                entry.setListEntryPathData(listEntryPathData);\n" +
//                 "                                listEntryPath.add(entry);\n" +
//                 "                            }\n" +
//                 "                        }\n" +
//                 "                    } catch (ClassNotFoundException e) {\n" +
//                 "                        e.printStackTrace();\n" +
//                 "                    }\n" +
//                 "                }\n" +
//                 "            }\n" +
//                 "        }\n" +
//                 "    }\n" +
//                 "    CoreEngine.getInstance().getFramework(\"STRUTS_2\").receiveData(listEntryPath);\n" +
//                 "}";
//     }
// }
// 
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
//     return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
// 
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
//     List<String> classes = extractImports(in);
//     Set<String> ret = new TreeSet<String>();
//     for (String aClass : classes) {
//         ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
//     }
// 
//     return ret.toArray(new String[]{});
// }


import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts2Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;




public class Struts2CollectorTest {
    @Test
    public void checkScript() throws FileNotFoundException, ParseException {
// Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts2Transformer.java
// public class Struts2Transformer extends AbstractLeechTransformer {
// 
//     public Struts2Transformer() {
//         super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
//         addImportPackage(collectPackages());
//     }
// 
//     public static String[] collectPackages() {
//         return new String[]{
//                 "com.highway2urhell",
//                 "com.highway2urhell.domain",
//                 "com.opensymphony.xwork2.config",
//                 "com.opensymphony.xwork2.config.entities",
//                 "java.lang.reflect",
//                 "java.util",
//                 "org.apache.struts2.dispatcher"
//         };
//     }
// 
//     @Override
//     protected void doTransform(CtClass cc) throws Exception {
//         CtMethod m = cc
//                 .getMethod("postInit",
//                         "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
//         m.insertBefore(collectBody());
//     }
// 
//     public static String collectBody() {
//         return "{\n" +
//                 "    List listEntryPath = new ArrayList();\n" +
//                 "    ConfigurationManager cm = dispatcher.getConfigurationManager();\n" +
//                 "    Configuration cf = cm.getConfiguration();\n" +
//                 "    Collection colPackages = cf.getPackageConfigs().values();\n" +
//                 "    if (colPackages != null) {\n" +
//                 "        Iterator ite = colPackages.iterator();\n" +
//                 "        while (ite.hasNext()) {\n" +
//                 "            PackageConfig pack = (PackageConfig) ite.next();\n" +
//                 "            Collection colActionConfigs = pack.getActionConfigs().values();\n" +
//                 "            Iterator iteCol = colActionConfigs.iterator();\n" +
//                 "            while (iteCol.hasNext()) {\n" +
//                 "                ActionConfig action = (ActionConfig) iteCol.next();\n" +
//                 "                if (action.getClassName() != null && !\"\".equals(action.getClassName())) {\n" +
//                 "                    try {\n" +
//                 "                        Class c = Class.forName(action.getClassName());\n" +
//                 "                        Method[] tabM = c.getDeclaredMethods();\n" +
//                 "                        for (int i = 0; i < tabM.length; i++) {\n" +
//                 "                            String scope = Modifier.toString(tabM[i].getModifiers());\n" +
//                 "                            if (scope.startsWith(\"public\") && !\"wait\".equals(tabM[i].getName()) && !\"notifyall\".equals(tabM[i].getName().toLowerCase()) && !\"notify\".equals(tabM[i].getName().toLowerCase()) && !\"getclass\".equals(tabM[i].getName().toLowerCase()) && !\"equals\".equals(tabM[i].getName().toLowerCase()) && !\"tostring\".equals(tabM[i].getName().toLowerCase()) && !\"wait\".equals(tabM[i].getName().toLowerCase()) && !\"hashcode\".equals(tabM[i].getName().toLowerCase())) {\n" +
//                 "                                Method m = tabM[i];\n" +
//                 "                                EntryPathData entry = new EntryPathData();\n" +
//                 "                                entry.setTypePath(TypePath.DYNAMIC);\n" +
//                 "                                entry.setClassName(action.getClassName());\n" +
//                 "                                entry.setMethodName(m.getName());\n" +
//                 "                                entry.setUri(action.getName());\n" +
//                 "                                entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(m));\n" +
//                 "                                List listEntryPathData = new ArrayList();\n" +
//                 "                                for (int j = 0; j < m.getParameterTypes().length; j++) {\n" +
//                 "                                    EntryPathParam param = new EntryPathParam();\n" +
//                 "                                    param.setKey(\"\");\n" +
//                 "                                    param.setTypeParam(TypeParam.PARAM_DATA);\n" +
//                 "                                    param.setValue(m.getParameterTypes()[j].getName());\n" +
//                 "                                    listEntryPathData.add(param);\n" +
//                 "                                }\n" +
//                 "                                entry.setListEntryPathData(listEntryPathData);\n" +
//                 "                                listEntryPath.add(entry);\n" +
//                 "                            }\n" +
//                 "                        }\n" +
//                 "                    } catch (ClassNotFoundException e) {\n" +
//                 "                        e.printStackTrace();\n" +
//                 "                    }\n" +
//                 "                }\n" +
//                 "            }\n" +
//                 "        }\n" +
//                 "    }\n" +
//                 "    CoreEngine.getInstance().getFramework(\"STRUTS_2\").receiveData(listEntryPath);\n" +
//                 "}";
//     }
// }
// 
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
//     return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
// 
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
//     List<String> classes = extractImports(in);
//     Set<String> ret = new TreeSet<String>();
//     for (String aClass : classes) {
//         ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
//     }
// 
//     return ret.toArray(new String[]{});
// }


// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts2CollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts2Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;

package com.highway2urhell.collector;




public class Struts2CollectorTest {
    @Test
    public void checkScript() throws FileNotFoundException, ParseException {
        assertThat(Struts2Transformer.collectBody())