TAP5-2588: applying more test patches by Dmitris Zenios
authorThiago H. de Paula Figueiredo <thiago@arsmachina.com.br>
Wed, 5 Dec 2018 23:37:07 +0000 (21:37 -0200)
committerThiago H. de Paula Figueiredo <thiago@arsmachina.com.br>
Wed, 5 Dec 2018 23:37:07 +0000 (21:37 -0200)
plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodProxying.groovy
plastic/src/test/java/testinterfaces/samemethodinterface/ResultRunner.java [new file with mode: 0644]
plastic/src/test/java/testinterfaces/samemethodinterface/SameMethodsInterface.java [new file with mode: 0644]
plastic/src/test/java/testinterfaces/samemethodinterface/pkg1/Result.java [new file with mode: 0644]
plastic/src/test/java/testinterfaces/samemethodinterface/pkg2/Result.java [new file with mode: 0644]
tapestry-ioc/build.gradle
tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/AdviceModule.java
tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/Main.java [deleted file]
tapestry-ioc/src/test/resources/hibernate.cfg.xml [deleted file]

index 22e41b6..18856c6 100644 (file)
@@ -1,5 +1,8 @@
 package org.apache.tapestry5.plastic
 
+import spock.lang.Issue
+import testinterfaces.samemethodinterface.ResultRunner
+import testinterfaces.samemethodinterface.SameMethodsInterface
 import testsubjects.Memory
 import testinterfaces.WithStatic
 
@@ -56,6 +59,32 @@ class MethodProxying extends AbstractPlasticSpecification {
         1 * mockRunnable.run()
     }
 
+    @Issue("TAP5-2582")
+    def "Proxying with multiple methods of the same signature"() {
+        setup:
+
+        def mockRunner = Mock(SameMethodsInterface.class) {
+            run() >> new testinterfaces.samemethodinterface.pkg2.Result();
+        }
+
+        def o = mgr.createClass(Object, { PlasticClass pc ->
+
+            def field = pc.introduceField(SameMethodsInterface, "delegate").inject(mockRunner)
+
+            pc.proxyInterface(ResultRunner, field)
+        } as PlasticClassTransformer).newInstance()
+
+        when:
+
+        def result = o.run();
+
+        then:
+
+        result instanceof testinterfaces.samemethodinterface.pkg1.Result;
+
+        result instanceof testinterfaces.samemethodinterface.pkg2.Result;
+    }
+
     def "proxy method with arguments and return value"() {
         setup:
 
diff --git a/plastic/src/test/java/testinterfaces/samemethodinterface/ResultRunner.java b/plastic/src/test/java/testinterfaces/samemethodinterface/ResultRunner.java
new file mode 100644 (file)
index 0000000..e1048da
--- /dev/null
@@ -0,0 +1,5 @@
+package testinterfaces.samemethodinterface;
+
+public interface ResultRunner {
+    testinterfaces.samemethodinterface.pkg1.Result run();
+}
diff --git a/plastic/src/test/java/testinterfaces/samemethodinterface/SameMethodsInterface.java b/plastic/src/test/java/testinterfaces/samemethodinterface/SameMethodsInterface.java
new file mode 100644 (file)
index 0000000..c696bd6
--- /dev/null
@@ -0,0 +1,6 @@
+package testinterfaces.samemethodinterface;
+
+public interface SameMethodsInterface extends ResultRunner {
+    @Override
+    testinterfaces.samemethodinterface.pkg2.Result run();
+}
diff --git a/plastic/src/test/java/testinterfaces/samemethodinterface/pkg1/Result.java b/plastic/src/test/java/testinterfaces/samemethodinterface/pkg1/Result.java
new file mode 100644 (file)
index 0000000..cddf07c
--- /dev/null
@@ -0,0 +1,4 @@
+package testinterfaces.samemethodinterface.pkg1;
+
+public class Result {
+}
diff --git a/plastic/src/test/java/testinterfaces/samemethodinterface/pkg2/Result.java b/plastic/src/test/java/testinterfaces/samemethodinterface/pkg2/Result.java
new file mode 100644 (file)
index 0000000..f499832
--- /dev/null
@@ -0,0 +1,4 @@
+package testinterfaces.samemethodinterface.pkg2;
+
+public class Result extends testinterfaces.samemethodinterface.pkg1.Result {
+}
index 75dca1c..7637d50 100644 (file)
@@ -17,8 +17,6 @@ dependencies {
 
     testCompile "commons-lang:commons-lang:2.6"
     testCompile "org.apache.commons:commons-lang3:3.4"
-    testCompile "org.hibernate:hibernate-core:5.2.10.Final"
-    testRuntime "org.hsqldb:hsqldb:2.2.8"
     
     provided "org.testng:testng:${versions.testng}", { transitive = false }
 }
index 8ea3ee9..3c63806 100644 (file)
@@ -816,7 +816,6 @@ class PropertyAccessImplSpec extends Specification {
   }
   
   public enum ById implements IdentifiableEnum<ById, Byte> {
-    ;
     public Byte getId() {
       return null
     }
index f943152..1a90aa3 100644 (file)
@@ -15,13 +15,8 @@ package org.apache.tapestry5.ioc.internal;
 
 
 import org.apache.tapestry5.ioc.MethodAdviceReceiver;
-import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.Registry;
-import org.apache.tapestry5.ioc.RegistryBuilder;
 import org.apache.tapestry5.ioc.ServiceBinder;
 import org.apache.tapestry5.ioc.annotations.Advise;
-import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
 
 public class AdviceModule
 {
@@ -51,19 +46,4 @@ public class AdviceModule
             final MethodAdviceReceiver methodAdviceReceiver) {
         methodAdviceReceiver.adviseAllMethods(new TestAdvice());
     }
-    
-//    public static void main(String[] args) {
-//     Registry registry = RegistryBuilder.buildAndStartupRegistry(AdviceModule.class);
-//     Session session = registry.getService(Session.class);
-//    }
-    
-    // TAP5-2582
-    public static Session buildHibernateSession(
-           ObjectLocator objectLocator
-       ) {
-           return new Configuration()
-               .configure("hibernate.cfg.xml")
-               .buildSessionFactory()
-               .openSession();
-       }
 }
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/Main.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/Main.java
deleted file mode 100644 (file)
index c42fd56..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2013 The Apache Software Foundation
-//
-// Licensed 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.tapestry5.ioc.internal;
-
-
-import java.util.List;
-
-import org.apache.tapestry5.ioc.MethodAdviceReceiver;
-import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.Registry;
-import org.apache.tapestry5.ioc.RegistryBuilder;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Advise;
-import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
-
-public class Main
-{
-
-    public static void main(String[] args) {
-       Registry registry = RegistryBuilder.buildAndStartupRegistry(AdviceModule.class);
-       Session session = registry.getService(Session.class);
-       final List list = session.createSQLQuery("select 1").list();
-       System.out.println(list);
-    }
-    
-}
diff --git a/tapestry-ioc/src/test/resources/hibernate.cfg.xml b/tapestry-ioc/src/test/resources/hibernate.cfg.xml
deleted file mode 100644 (file)
index d02951b..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 
-   Copyright 2007, 2008 The Apache Software Foundation
-
-   Licensed 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.
--->
-
-<!DOCTYPE hibernate-configuration PUBLIC
-        "-//Hibernate/Hibernate Configuration DTD//EN"
-        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
-
-    <session-factory>
-        <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
-        <property name="hibernate.connection.url">jdbc:hsqldb:mem:test</property>
-        <property name="hibernate.connection.username">sa</property>
-        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
-
-        <property name="show_sql">true</property>
-        <property name="format_sql">true</property>
-        <property name="hbm2ddl.auto">update</property>
-
-        <property name="hibernate.c3p0.min_size">5</property>
-        <property name="hibernate.c3p0.max_size">20</property>
-        <property name="hibernate.c3p0.timeout">300</property>
-        <property name="hibernate.c3p0.max_statements">50</property>
-        <property name="hibernate.c3p0.idle_test_period">3000</property>
-    </session-factory>
-
-
-</hibernate-configuration>