Author: athimel Date: 2011-01-19 17:59:36 +0100 (Wed, 19 Jan 2011) New Revision: 2024 Url: http://nuiton.org/repositories/revision/nuiton-utils/2024 Log: Rename classes to avoid Test in class name Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeBean.java trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeService.java trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeServiceImpl.java Removed: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:53:27 UTC (rev 2023) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -20,31 +20,31 @@ public void testExportNullService() throws Exception { // It is mandatory to provide a service instance - ServiceExporter.registerService(TestService.class, null); + ServiceExporter.registerService(SomeService.class, null); } @Test(expected = NotBoundException.class) public void testProxyWithoutService() throws Exception { // Register and unregister (to make sure RMI registry is created) - TestServiceImpl impl = new TestServiceImpl(); - ServiceExporter.registerService(TestService.class, impl); - ServiceExporter.unregisterService(TestService.class); + SomeServiceImpl impl = new SomeServiceImpl(); + ServiceExporter.registerService(SomeService.class, impl); + ServiceExporter.unregisterService(SomeService.class); // This will throw an exception because service is not registered - RemoteProxyFactory.createProxy(TestService.class); + RemoteProxyFactory.createProxy(SomeService.class); } @Test public void testObjectIdentity() throws Exception { // Create and bind the service - TestServiceImpl impl = new TestServiceImpl(); + SomeServiceImpl impl = new SomeServiceImpl(); int realServiceIdentity = System.identityHashCode(impl); - ServiceExporter.registerService(TestService.class, impl); + ServiceExporter.registerService(SomeService.class, impl); // Get a proxy on this service and make sure this is not the same object - TestService clientSide = RemoteProxyFactory.createProxy(TestService.class); + SomeService clientSide = RemoteProxyFactory.createProxy(SomeService.class); int proxyIdentity = System.identityHashCode(clientSide); Assert.assertNotSame(proxyIdentity, realServiceIdentity); @@ -52,23 +52,23 @@ int serviceIdentityFromProxy = clientSide.getInstanceId(); Assert.assertEquals(realServiceIdentity, serviceIdentityFromProxy); - ServiceExporter.unregisterService(TestService.class); + ServiceExporter.unregisterService(SomeService.class); } @Test public void testComplexType() throws Exception { // Create and bind the service - TestServiceImpl impl = new TestServiceImpl(); + SomeServiceImpl impl = new SomeServiceImpl(); int realServiceIdentity = System.identityHashCode(impl); - ServiceExporter.registerService(TestService.class, impl); + ServiceExporter.registerService(SomeService.class, impl); // Get a proxy on this service and do the call to createComplexTypeObject - TestService clientSide = RemoteProxyFactory.createProxy(TestService.class); - TestBean bean = clientSide.createComplexTypeObject(); + SomeService clientSide = RemoteProxyFactory.createProxy(SomeService.class); + SomeBean bean = clientSide.createComplexTypeObject(); // Now check that the bean is exactly as expected - TestBean father = bean.getFather(); + SomeBean father = bean.getFather(); Assert.assertNotNull(father); Assert.assertEquals("I'm your father !", father.getMessage()); Assert.assertEquals(realServiceIdentity, father.getCreatedBy()); @@ -81,18 +81,18 @@ Assert.assertNull(bean.getCreatedOn()); // transient value Assert.assertEquals(0L, bean.getNumber()); // transient value - ServiceExporter.unregisterService(TestService.class); + ServiceExporter.unregisterService(SomeService.class); } @Test public void testExceptionPropagation() throws Exception { // Create and bind the service - TestServiceImpl impl = new TestServiceImpl(); - ServiceExporter.registerService(TestService.class, impl); + SomeServiceImpl impl = new SomeServiceImpl(); + ServiceExporter.registerService(SomeService.class, impl); // Get a proxy on this service and do the call to createComplexTypeObject - TestService clientSide = RemoteProxyFactory.createProxy(TestService.class); + SomeService clientSide = RemoteProxyFactory.createProxy(SomeService.class); // Does not fail clientSide.throwAnExceptionIfFalse(true); @@ -109,7 +109,7 @@ Assert.assertEquals("Wrong parameter !", cause.getMessage()); } - ServiceExporter.unregisterService(TestService.class); + ServiceExporter.unregisterService(SomeService.class); } } Copied: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeBean.java (from rev 2023, trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java) =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeBean.java (rev 0) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeBean.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -0,0 +1,88 @@ +/* + * #%L + * Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.rmi; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author Arnaud Thimel <thimel@codelutin.com> + */ +public class SomeBean implements Serializable { + + protected SomeBean father; + protected String message; + protected int createdBy; + protected transient Date createdOn; + protected transient long number; + + public SomeBean(String message, Object creator, long number) { + this.message = message; + this.createdBy = System.identityHashCode(creator); + this.createdOn = new Date(); + this.number = number; + } + + public SomeBean getFather() { + return father; + } + + public void setFather(SomeBean father) { + this.father = father; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(int createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + public long getNumber() { + return number; + } + + public void setNumber(long number) { + this.number = number; + } + +} Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeBean.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeService.java (from rev 2023, trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java) =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeService.java (rev 0) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeService.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -0,0 +1,57 @@ +/* + * #%L + * Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.rmi; + +/** + * Any service interface which will be used to test the RMI proxy. + * + * @author Arnaud Thimel <thimel@codelutin.com> + */ +public interface SomeService { + + /** + * This method will return a String that can only be known by itself + * + * @return an instance identifier + */ + int getInstanceId(); + + /** + * This method will return a complex object to validate that this is not + * working only with primitive types + * + * @return a newly created SomeBean + */ + SomeBean createComplexTypeObject(); + + /** + * Will throw an AnyException to test exception propagation + * + * @param bool true : will not fail, false will fail + * @throws AnyException if the given boolean is false + */ + void throwAnExceptionIfFalse(Boolean bool) throws AnyException; + +} Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeServiceImpl.java (from rev 2023, trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java) =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeServiceImpl.java (rev 0) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeServiceImpl.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -0,0 +1,55 @@ +/* + * #%L + * Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.rmi; + +import java.io.InvalidObjectException; + +/** + * @author Arnaud Thimel <thimel@codelutin.com> + */ +public class SomeServiceImpl implements SomeService { + + @Override + public int getInstanceId() { + return System.identityHashCode(this); + } + + @Override + public SomeBean createComplexTypeObject() { + SomeBean father = new SomeBean("I'm your father !", this, 123); + SomeBean result = new SomeBean("Son", this, 456); + result.setFather(father); + return result; + } + + @Override + public void throwAnExceptionIfFalse(Boolean bool) throws AnyException { + if (!bool) { + InvalidObjectException ioe = new InvalidObjectException("Wrong parameter !"); + throw new AnyException("Please provide 'true'", ioe); + } + } + +} Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/SomeServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java 2011-01-19 16:53:27 UTC (rev 2023) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -1,88 +0,0 @@ -/* - * #%L - * Nuiton Utils - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.util.rmi; - -import java.io.Serializable; -import java.util.Date; - -/** - * @author Arnaud Thimel <thimel@codelutin.com> - */ -public class TestBean implements Serializable { - - protected TestBean father; - protected String message; - protected int createdBy; - protected transient Date createdOn; - protected transient long number; - - public TestBean(String message, Object creator, long number) { - this.message = message; - this.createdBy = System.identityHashCode(creator); - this.createdOn = new Date(); - this.number = number; - } - - public TestBean getFather() { - return father; - } - - public void setFather(TestBean father) { - this.father = father; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(int createdBy) { - this.createdBy = createdBy; - } - - public Date getCreatedOn() { - return createdOn; - } - - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } - - public long getNumber() { - return number; - } - - public void setNumber(long number) { - this.number = number; - } - -} Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java 2011-01-19 16:53:27 UTC (rev 2023) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -1,57 +0,0 @@ -/* - * #%L - * Nuiton Utils - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.util.rmi; - -/** - * Any service interface which will be used to test the RMI proxy. - * - * @author Arnaud Thimel <thimel@codelutin.com> - */ -public interface TestService { - - /** - * This method will return a String that can only be known by itself - * - * @return an instance identifier - */ - int getInstanceId(); - - /** - * This method will return a complex object to validate that this is not - * working only with primitive types - * - * @return a newly created TestBean - */ - TestBean createComplexTypeObject(); - - /** - * Will throw an AnyException to test exception propagation - * - * @param bool true : will not fail, false will fail - * @throws AnyException if the given boolean is false - */ - void throwAnExceptionIfFalse(Boolean bool) throws AnyException; - -} Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java 2011-01-19 16:53:27 UTC (rev 2023) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java 2011-01-19 16:59:36 UTC (rev 2024) @@ -1,55 +0,0 @@ -/* - * #%L - * Nuiton Utils - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.util.rmi; - -import java.io.InvalidObjectException; - -/** - * @author Arnaud Thimel <thimel@codelutin.com> - */ -public class TestServiceImpl implements TestService{ - - @Override - public int getInstanceId() { - return System.identityHashCode(this); - } - - @Override - public TestBean createComplexTypeObject() { - TestBean father = new TestBean("I'm your father !", this, 123); - TestBean result = new TestBean("Son", this, 456); - result.setFather(father); - return result; - } - - @Override - public void throwAnExceptionIfFalse(Boolean bool) throws AnyException { - if (!bool) { - InvalidObjectException ioe = new InvalidObjectException("Wrong parameter !"); - throw new AnyException("Please provide 'true'", ioe); - } - } - -}