new files to setup cdi-tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/648604f1 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/648604f1 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/648604f1 Branch: refs/heads/master Commit: 648604f110d243f432edf82a67701f8ac43226c2 Parents: bdae43a Author: Romain Manni-Bucau <[email protected]> Authored: Sat Mar 14 19:34:22 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Sat Mar 14 19:34:22 2015 +0100 ---------------------------------------------------------------------- .../apache/openejb/tck/cdi/tomee/BeansImpl.java | 102 ++++++++ .../openejb/tck/cdi/tomee/EnrichmentDumper.java | 44 ++++ .../apache/openejb/tck/cdi/tomee/Report.java | 260 +++++++++++++++++++ .../test/resources/META-INF/cdi-tck.properties | 24 ++ tck/cdi-tomee/src/test/resources/arquillian.xml | 58 +++++ tck/cdi-tomee/src/test/resources/failing.xml | 29 +++ .../apache/openejb/tck/testng/HTMLReporter.java | 60 +++++ 7 files changed, 577 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/BeansImpl.java ---------------------------------------------------------------------- diff --git a/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/BeansImpl.java b/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/BeansImpl.java new file mode 100644 index 0000000..79c08d9 --- /dev/null +++ b/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/BeansImpl.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.tck.cdi.tomee; + +import org.apache.openejb.core.ivm.IntraVmCopyMonitor; +import org.apache.openejb.core.ivm.IntraVmProxy; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamClass; +import java.lang.reflect.Proxy; + +/** + * @version $Rev$ $Date$ + */ +public class BeansImpl extends org.apache.webbeans.test.tck.BeansImpl { + @Override + public boolean isProxy(final Object instance) { + return instance instanceof IntraVmProxy || super.isProxy(instance); + } + + @Override + public byte[] passivate(Object instance) throws IOException { + IntraVmCopyMonitor.prePassivationOperation(); + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream os = new ObjectOutputStream(baos); + os.writeObject(instance); + os.flush(); + return baos.toByteArray(); + } finally { + IntraVmCopyMonitor.postPassivationOperation(); + } + } + + @Override + public Object activate(byte[] bytes) throws IOException, ClassNotFoundException { + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + ObjectInputStream is = new BeanObjectInputStream(bais); + return is.readObject(); + } + + + public static final class BeanObjectInputStream extends ObjectInputStream { + public BeanObjectInputStream(InputStream in) throws IOException { + super(in); + } + + protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { + try { + return Class.forName(classDesc.getName(), false, getClassloader()); + } catch (ClassNotFoundException e) { + String n = classDesc.getName(); + if (n.equals("boolean")) return boolean.class; + if (n.equals("byte")) return byte.class; + if (n.equals("char")) return char.class; + if (n.equals("short")) return short.class; + if (n.equals("int")) return int.class; + if (n.equals("long")) return long.class; + if (n.equals("float")) return float.class; + if (n.equals("double")) return double.class; + + throw e; + } + } + + protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { + Class[] cinterfaces = new Class[interfaces.length]; + for (int i = 0; i < interfaces.length; i++) + cinterfaces[i] = getClassloader().loadClass(interfaces[i]); + + try { + return Proxy.getProxyClass(getClassloader(), cinterfaces); + } catch (IllegalArgumentException e) { + throw new ClassNotFoundException(null, e); + } + } + + ClassLoader getClassloader() { + return Thread.currentThread().getContextClassLoader(); + } + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/EnrichmentDumper.java ---------------------------------------------------------------------- diff --git a/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/EnrichmentDumper.java b/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/EnrichmentDumper.java new file mode 100644 index 0000000..8e22b0b --- /dev/null +++ b/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/EnrichmentDumper.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.tck.cdi.tomee; + +import org.apache.openejb.loader.Files; +import org.apache.webbeans.test.tck.ELImpl; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +import java.io.File; + +import static org.apache.openejb.loader.JarLocation.jarLocation; + +public final class EnrichmentDumper { + public static void main(String[] args) { + final File output = new File(Files.mkdirs(new File(args[0])), "tomee-porting.jar"); + if (!output.exists() || output.delete()) { + ShrinkWrap.create(JavaArchive.class) + .merge(ShrinkWrap.createFromZipFile(JavaArchive.class, jarLocation(ELImpl.class))) + .addClasses(BeansImpl.class) + .as(ZipExporter.class) + .exportTo(output); + } + } + + private EnrichmentDumper() { + // no-op + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/Report.java ---------------------------------------------------------------------- diff --git a/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/Report.java b/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/Report.java new file mode 100644 index 0000000..e8a2bd6 --- /dev/null +++ b/tck/cdi-tomee/src/test/java/org/apache/openejb/tck/cdi/tomee/Report.java @@ -0,0 +1,260 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.tck.cdi.tomee; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @version $Rev$ $Date$ + */ +public class Report { + + public static void main(String[] args) throws Exception { + new Report().main(); + } + + private final LinkedList<TestClass> classes = new LinkedList<TestClass>(); + + private void main() throws Exception { +// final File file = new File("/Users/dblevins/work/uber/geronimo-tck-public-trunk/jcdi-tck-runner/target/surefire-reports/testng-results.xml"); + final File file = new File("/Users/dblevins/work/all/trunk/openejb/tck/cdi-tomee/target/failsafe-reports/testng-results.xml"); +// final File file = new File("/Users/dblevins/work/uber/testng-results.xml"); + + final SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); + + parser.parse(file, new DefaultHandler() { + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + final String name = qName; + if ("class".equals(name)) { + classes.add(new TestClass(attributes.getValue("name"))); + } + + if ("test-method".equals(name)) { + classes.getLast().addStatus(attributes.getValue("status"), attributes.getValue("name")); + } + } + }); + + Collections.sort(classes); + + textReport(file); + passingXml(file); + failingXml(file); + + } + + private void textReport(File file) throws FileNotFoundException { + final File report = new File(file.getParentFile(), file.getName().replaceAll(".xml$", ".txt")); + final PrintStream out = new PrintStream(new FileOutputStream(report)); + printResults(out); + out.close(); + } + + private void passingXml(File file) throws FileNotFoundException { + final File report = new File(file.getParentFile(), file.getName().replaceAll(".xml$", "-passing.xml")); + final PrintStream out = new PrintStream(new FileOutputStream(report)); + + out.println(header + + "<suite name=\"CDI TCK\" verbose=\"0\">\n" + + " <test name=\"CDI TCK\">\n" + + " <packages>\n" + + " <package name=\"org.jboss.jsr299.tck.tests.*\"/>\n" + + " <package name=\"org.jboss.jsr299.tck.interceptors.tests.*\"/>\n" + + " </packages>\n" + + " <classes>"); + + for (TestClass testClass : classes) { + + if (contains(testClass, Status.FAIL)) { + out.printf(" <class name=\"%s\">\n", testClass.name); + out.printf(" <methods>\n"); + + for (TestResult result : testClass.getResults()) { + if (result.status == Status.FAIL) { + out.printf(" <exclude name=\"%s\"/>\n", result.name); + } + } + + out.printf(" </methods>\n"); + out.printf(" </class>\n"); + } + } + out.println(" </classes>"); + out.println(" </test>"); + out.println("</suite>"); + + out.close(); + } + + private void failingXml(File file) throws FileNotFoundException { + final File report = new File(file.getParentFile(), file.getName().replaceAll(".xml$", "-failing.xml")); + final PrintStream out = new PrintStream(new FileOutputStream(report)); + + out.println(header); + out.println("<suite name=\"CDI TCK\" verbose=\"0\">"); + out.println(" <test name=\"CDI TCK\">"); + out.println(" <!--<packages>-->\n" + + " <!--<package name=\"org.jboss.jsr299.tck.tests.*\"/>-->\n" + + " <!--<package name=\"org.jboss.jsr299.tck.interceptors.tests.*\"/>-->\n" + + " <!--</packages>-->"); + out.println(" <classes>"); + + for (TestClass testClass : classes) { + + if (contains(testClass, Status.FAIL)) { + out.printf(" <class name=\"%s\"/>\n", testClass.name); + } + } + out.println(" </classes>"); + out.println(" </test>"); + out.println("</suite>"); + + out.close(); + } + + private boolean contains(TestClass testClass, Status status) { + + for (TestResult result : testClass.getResults()) { + if (result.name.equals("beforeClass")) continue; + if (result.name.equals("afterClass")) continue; + if (result.name.equals("afterSuite")) continue; + if (result.name.equals("beforeSuite")) continue; + + if (result.status == status) { + return true; + } + } + return false; + } + + private void printResults(PrintStream out) { + + Map<Status, AtomicInteger> totals = new HashMap<Status, AtomicInteger>(); + for (Status status : Status.values()) { + totals.put(status, new AtomicInteger()); + } + + for (TestClass testClass : classes) { + + for (TestResult result : testClass.getResults()) { + if (result.name.equals("beforeClass")) continue; + if (result.name.equals("afterClass")) continue; + if (result.name.equals("afterSuite")) continue; + if (result.name.equals("beforeSuite")) continue; +// if (result.status == Status.PASS) continue; + totals.get(result.status).getAndIncrement(); + + out.printf("%s - %s(%s)\n", result.status, result.name, testClass.name); + } + } + + out.println("\n\n"); + + int total = 0; + + for (Map.Entry<Status, AtomicInteger> entry : totals.entrySet()) { + final int i = entry.getValue().get(); + total += i; + out.printf("%5s %s\n", i, entry.getKey()); + } + + out.printf("%5s %s\n", total, "Total"); + + } + + public static enum Status { + PASS, FAIL, ERROR; + } + public static class TestResult { + private final String name; + private final Status status; + + public TestResult(String name, Status status) { + this.name = name; + this.status = status; + } + } + + public static class TestClass implements Comparable<TestClass>{ + + private final String name; + private int failed; + private int passed; + private int error; + private final List<TestResult> results = new ArrayList<TestResult>(); + + public TestClass(String name) { + this.name = name; + } + + public void addStatus(String status, String testName) { + results.add(new TestResult(testName, Status.valueOf(status))); + if ("PASS".equals(status)) passed++; + if ("FAIL".equals(status)) failed++; + if ("ERROR".equals(status)) error++; + } + + public List<TestResult> getResults() { + return results; + } + + public boolean hasFailures() { + return failed > 0 || error > 0; + } + + @Override + public int compareTo(TestClass o) { + return this.name.compareTo(o.name); + } + } + + private static final String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<!--\n" + + "\n" + + " Licensed to the Apache Software Foundation (ASF) under one or more\n" + + " contributor license agreements. See the NOTICE file distributed with\n" + + " this work for additional information regarding copyright ownership.\n" + + " The ASF licenses this file to You under the Apache License, Version 2.0\n" + + " (the \"License\"); you may not use this file except in compliance with\n" + + " the License. You may obtain a copy of the License at\n" + + "\n" + + " http://www.apache.org/licenses/LICENSE-2.0\n" + + "\n" + + " Unless required by applicable law or agreed to in writing, software\n" + + " distributed under the License is distributed on an \"AS IS\" BASIS,\n" + + " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + + " See the License for the specific language governing permissions and\n" + + " limitations under the License.\n" + + "-->\n"; +} http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/cdi-tomee/src/test/resources/META-INF/cdi-tck.properties ---------------------------------------------------------------------- diff --git a/tck/cdi-tomee/src/test/resources/META-INF/cdi-tck.properties b/tck/cdi-tomee/src/test/resources/META-INF/cdi-tck.properties new file mode 100644 index 0000000..2f1b7ae --- /dev/null +++ b/tck/cdi-tomee/src/test/resources/META-INF/cdi-tck.properties @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +org.jboss.cdi.tck.libraryDirectory = ${project.build.directory}/dependency/lib/ +org.jboss.cdi.tck.testDataSource = openejb:Resource/jdbc +org.jboss.cdi.tck.testJmsConnectionFactory = openejb:Resource/jms +org.jboss.cdi.tck.testJmsQueue = openejb:Resource/queue +org.jboss.cdi.tck.testJmsTopic = openejb:Resource/topic +org.jboss.cdi.tck.spi.Beans = org.apache.openejb.tck.cdi.tomee.BeansImpl +org.jboss.cdi.tck.spi.Contexts = org.apache.webbeans.test.tck.ContextsImpl +org.jboss.cdi.tck.spi.EL = org.apache.webbeans.test.tck.ELImpl http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/cdi-tomee/src/test/resources/arquillian.xml ---------------------------------------------------------------------- diff --git a/tck/cdi-tomee/src/test/resources/arquillian.xml b/tck/cdi-tomee/src/test/resources/arquillian.xml new file mode 100644 index 0000000..d684952 --- /dev/null +++ b/tck/cdi-tomee/src/test/resources/arquillian.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<arquillian xmlns="http://jboss.org/schema/arquillian" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://jboss.org/schema/arquillian + http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> + <container qualifier="tomee-remote" default="true"> + <configuration> + <property name="httpPort">-1</property> + <property name="ajpPort">-1</property> + <property name="stopPort">-1</property> + <property name="classifier">plus</property> + <property name="dir">target/tomee</property> + <property name="appWorkingDir">target/workdir</property> + <property name="cleanOnStartUp">true</property> + <property name="catalina_opts">-Xmx2048m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled</property> + <property name="properties"> + openejb.scan.webapp.container = true + openejb.deploymentId.format = {appId}/{ejbJarId}/{ejbName} + openejb.strict.interface.declaration = true + openejb.cdi.producer.interception = false + openejb.cdi.applicationScope.cached = false + openejb.classloader.forced-load = org.apache.webbeans.test.tck.,org.apache.openejb.tck.cdi.tomee. + + jmsRa = new://Resource?type=ActiveMQResourceAdapter + jms = new://Resource?type=javax.jms.ConnectionFactory + jms.ResourceAdapter = jmsRa + queue = new://Resource?type=Queue + topic = new://Resource?type=Topic + jdbc = new://Resource?type=DataSource + + cdiTckExcludeDummy = true + </property> + <property name="additionalLibs"> + target/test-classes/org + target/test-classes/META-INF + mvn:org.apache.openwebbeans:openwebbeans-porting:${org.apache.openwebbeans.version} + </property> + </configuration> + </container> +</arquillian> http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/cdi-tomee/src/test/resources/failing.xml ---------------------------------------------------------------------- diff --git a/tck/cdi-tomee/src/test/resources/failing.xml b/tck/cdi-tomee/src/test/resources/failing.xml new file mode 100644 index 0000000..9fc2ecc --- /dev/null +++ b/tck/cdi-tomee/src/test/resources/failing.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<suite name="CDI TCK" verbose="0"> + <!-- + Before any run execute: + + $ mvn test-compile + --> + <test name="CDI TCK"> + <classes> + <class name="org.jboss.cdi.tck.tests.context.application.async.ApplicationContextAsyncListenerTest" /> + </classes> + </test> +</suite> http://git-wip-us.apache.org/repos/asf/tomee/blob/648604f1/tck/tck-common/src/main/java/org/apache/openejb/tck/testng/HTMLReporter.java ---------------------------------------------------------------------- diff --git a/tck/tck-common/src/main/java/org/apache/openejb/tck/testng/HTMLReporter.java b/tck/tck-common/src/main/java/org/apache/openejb/tck/testng/HTMLReporter.java new file mode 100644 index 0000000..99b5d5b --- /dev/null +++ b/tck/tck-common/src/main/java/org/apache/openejb/tck/testng/HTMLReporter.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.tck.testng; + +import org.testng.ITestResult; +import org.testng.reporters.TestHTMLReporter; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.List; + +public class HTMLReporter extends TestHTMLReporter { + private static final Class<?>[] API = new Class<?>[]{ITestResult.class}; + + @Override + public List<ITestResult> getFailedTests() { + return doWrap(super.getFailedTests()); + } + + @Override + public List<ITestResult> getPassedTests() { + return doWrap(super.getPassedTests()); + } + + private List<ITestResult> doWrap(final List<ITestResult> raw) { + final List<ITestResult> wrapped = new ArrayList<>(raw.size()); + final ClassLoader loader = Thread.currentThread().getContextClassLoader(); + for (final ITestResult result : raw) { + wrapped.add(ITestResult.class.cast( + Proxy.newProxyInstance(loader, API, + new InvocationHandler() { + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + if (method.getName().equals("getParameters")) { + return new Object[method.getParameterTypes().length]; + } + return method.invoke(result, args); + } + }) + )); + } + return wrapped; + } +}
