Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B3C9DFDE for ; Thu, 25 Oct 2012 14:09:11 +0000 (UTC) Received: (qmail 64680 invoked by uid 500); 25 Oct 2012 14:09:11 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 64592 invoked by uid 500); 25 Oct 2012 14:09:11 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 64564 invoked by uid 99); 25 Oct 2012 14:09:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 14:09:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 14:09:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D9F4023888FD for ; Thu, 25 Oct 2012 14:08:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1402157 - in /felix/trunk/ipojo/manipulator/manipulator/src/test/java: org/apache/felix/ipojo/manipulation/ManipulatorTest.java test/NonSunClass.java Date: Thu, 25 Oct 2012 14:08:25 -0000 To: commits@felix.apache.org From: clement@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121025140825.D9F4023888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: clement Date: Thu Oct 25 14:08:25 2012 New Revision: 1402157 URL: http://svn.apache.org/viewvc?rev=1402157&view=rev Log: Added a test checking the field duplication. Added: felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/NonSunClass.java Modified: felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/ManipulatorTest.java Modified: felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/ManipulatorTest.java URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/ManipulatorTest.java?rev=1402157&r1=1402156&r2=1402157&view=diff ============================================================================== --- felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/ManipulatorTest.java (original) +++ felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/ManipulatorTest.java Thu Oct 25 14:08:25 2012 @@ -109,6 +109,46 @@ public class ManipulatorTest extends Tes } + public void testManipulatingTheNonSunPOJO() throws Exception { + Manipulator manipulator = new Manipulator(); + byte[] clazz = manipulator.manipulate(getBytesFromFile(new File("target/test-classes/test/NonSunClass.class"))); + ManipulatedClassLoader classloader = new ManipulatedClassLoader("test.NonSunClass", clazz); + Class cl = classloader.findClass("test.NonSunClass"); + Assert.assertNotNull(cl); + Assert.assertNotNull(manipulator.getManipulationMetadata()); + + System.out.println(manipulator.getManipulationMetadata()); + + // The manipulation add stuff to the class. + Assert.assertTrue(clazz.length > getBytesFromFile(new File("target/test-classes/test/NonSunClass.class")).length); + + + boolean found = false; + Constructor cst = null; + Constructor[] csts = cl.getDeclaredConstructors(); + for (int i = 0; i < csts.length; i++) { + System.out.println(Arrays.asList(csts[i].getParameterTypes())); + if (csts[i].getParameterTypes().length == 1 && + csts[i].getParameterTypes()[0].equals(InstanceManager.class)) { + found = true; + cst = csts[i]; + } + } + Assert.assertTrue(found); + + // Check the POJO interface + Assert.assertTrue(Arrays.asList(cl.getInterfaces()).contains(Pojo.class)); + + cst.setAccessible(true); + Object pojo = cst.newInstance(new Object[] {new InstanceManager()}); + Assert.assertNotNull(pojo); + Assert.assertTrue(pojo instanceof Pojo); + + Method method = cl.getMethod("getS1", new Class[0]); + Assert.assertTrue(((Boolean) method.invoke(pojo, new Object[0])).booleanValue()); + + } + public void testManipulatingChild() throws Exception { Manipulator manipulator = new Manipulator(); byte[] clazz = manipulator.manipulate(getBytesFromFile(new File("target/test-classes/test/Child.class"))); Added: felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/NonSunClass.java URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/NonSunClass.java?rev=1402157&view=auto ============================================================================== --- felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/NonSunClass.java (added) +++ felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/NonSunClass.java Thu Oct 25 14:08:25 2012 @@ -0,0 +1,19 @@ +package test; + +/** + * Class that does not respect Sun conventions. + */ +public class NonSunClass { + + /** + * Does not match the Sun convention. + */ + private boolean S1 = true; + + public boolean getS1() { + return S1; + } + + + +}