Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3157 discussions
r2025 - in trunk/nuiton-validator/src: main/java/org/nuiton/validator test/java/org/nuiton/validator
by tchemit@users.nuiton.org 20 Jan '11
by tchemit@users.nuiton.org 20 Jan '11
20 Jan '11
Author: tchemit
Date: 2011-01-20 11:15:07 +0100 (Thu, 20 Jan 2011)
New Revision: 2025
Url: http://nuiton.org/repositories/revision/nuiton-utils/2025
Log:
test result.isValid() and fix this method
Modified:
trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidatorResult.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/ValidatorTestHelper.java
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidatorResult.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidatorResult.java 2011-01-19 16:59:36 UTC (rev 2024)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidatorResult.java 2011-01-20 10:15:07 UTC (rev 2025)
@@ -24,6 +24,8 @@
*/
package org.nuiton.validator;
+import org.apache.commons.collections.MapUtils;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
@@ -55,7 +57,8 @@
public boolean hasMessagesForScope(NuitonValidatorScope scope) {
boolean result = false;
if (messages != null) {
- result = messages.containsKey(scope);
+ FieldMap<List<String>> map = messages.get(scope);
+ result = !MapUtils.isEmpty(map);
}
return result;
}
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/ValidatorTestHelper.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/ValidatorTestHelper.java 2011-01-19 16:59:36 UTC (rev 2024)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/ValidatorTestHelper.java 2011-01-20 10:15:07 UTC (rev 2025)
@@ -46,8 +46,10 @@
result = validator.validate(person);
+
// two errors : no name, no firstname
// one warning : no pet
+ Assert.assertFalse(result.isValid());
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_FIRSTNAME, "person.firstname.required");
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_NAME, "person.name.required");
assertFieldMessages(result, NuitonValidatorScope.WARNING, Person.PROPERTY_PET, "person.with.no.pet");
@@ -57,6 +59,7 @@
// one error : no name
// one warning : no pet
+ Assert.assertFalse(result.isValid());
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_FIRSTNAME);
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_NAME, "person.name.required");
assertFieldMessages(result, NuitonValidatorScope.WARNING, Person.PROPERTY_PET, "person.with.no.pet");
@@ -66,6 +69,7 @@
// no error
// one warning : no pet
+ Assert.assertTrue(result.isValid());
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_FIRSTNAME);
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_NAME);
assertFieldMessages(result, NuitonValidatorScope.WARNING, Person.PROPERTY_PET, "person.with.no.pet");
@@ -75,6 +79,7 @@
// no error
// no warning
+ Assert.assertTrue(result.isValid());
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_FIRSTNAME);
assertFieldMessages(result, NuitonValidatorScope.ERROR, Person.PROPERTY_NAME);
assertFieldMessages(result, NuitonValidatorScope.WARNING, Person.PROPERTY_PET);
@@ -91,6 +96,7 @@
// no messages
boolean hasMessages = result.hasMessagesForScope(field, scope);
Assert.assertFalse(hasMessages);
+
} else {
// with messages
1
0
19 Jan '11
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(a)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(a)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(a)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(a)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(a)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(a)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);
- }
- }
-
-}
1
0
19 Jan '11
Author: athimel
Date: 2011-01-19 17:53:27 +0100 (Wed, 19 Jan 2011)
New Revision: 2023
Url: http://nuiton.org/repositories/revision/nuiton-utils/2023
Log:
Replace exception used for testing by a standard java exception
Modified:
trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.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
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:48:42 UTC (rev 2022)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:53:27 UTC (rev 2023)
@@ -5,8 +5,8 @@
import org.junit.Assert;
import org.junit.Test;
+import java.io.InvalidObjectException;
import java.rmi.NotBoundException;
-import java.security.InvalidParameterException;
/**
* @author Arnaud Thimel <thimel(a)codelutin.com>
@@ -105,7 +105,7 @@
Assert.assertEquals("Please provide 'true'", ae.getMessage());
// Exception is the good one. Now check its cause
- InvalidParameterException cause = (InvalidParameterException)ae.getCause();
+ InvalidObjectException cause = (InvalidObjectException)ae.getCause();
Assert.assertEquals("Wrong parameter !", cause.getMessage());
}
Modified: 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:48:42 UTC (rev 2022)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java 2011-01-19 16:53:27 UTC (rev 2023)
@@ -24,7 +24,7 @@
*/
package org.nuiton.util.rmi;
-import java.security.InvalidParameterException;
+import java.io.InvalidObjectException;
/**
* @author Arnaud Thimel <thimel(a)codelutin.com>
@@ -47,8 +47,8 @@
@Override
public void throwAnExceptionIfFalse(Boolean bool) throws AnyException {
if (!bool) {
- InvalidParameterException ipe = new InvalidParameterException("Wrong parameter !");
- throw new AnyException("Please provide 'true'", ipe);
+ InvalidObjectException ioe = new InvalidObjectException("Wrong parameter !");
+ throw new AnyException("Please provide 'true'", ioe);
}
}
1
0
19 Jan '11
Author: athimel
Date: 2011-01-19 17:48:42 +0100 (Wed, 19 Jan 2011)
New Revision: 2022
Url: http://nuiton.org/repositories/revision/nuiton-utils/2022
Log:
Ooops, unsued imports
Modified:
trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.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
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:45:00 UTC (rev 2021)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:48:42 UTC (rev 2022)
@@ -1,11 +1,8 @@
package org.nuiton.util.rmi;
-import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import java.rmi.NotBoundException;
Modified: 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:45:00 UTC (rev 2021)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java 2011-01-19 16:48:42 UTC (rev 2022)
@@ -24,8 +24,6 @@
*/
package org.nuiton.util.rmi;
-import com.sun.javaws.exceptions.InvalidArgumentException;
-
import java.security.InvalidParameterException;
/**
1
0
r2021 - in trunk/nuiton-utils/src: main/java/org/nuiton/util/rmi test/java/org/nuiton/util test/java/org/nuiton/util/rmi
by athimel@users.nuiton.org 19 Jan '11
by athimel@users.nuiton.org 19 Jan '11
19 Jan '11
Author: athimel
Date: 2011-01-19 17:45:00 +0100 (Wed, 19 Jan 2011)
New Revision: 2021
Url: http://nuiton.org/repositories/revision/nuiton-utils/2021
Log:
Evolution #1209 : Add a method to unregister a service ; Implement tests
Added:
trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/
trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/AnyException.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java
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/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java 2011-01-18 07:06:31 UTC (rev 2020)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -1,23 +1,23 @@
/*
* #%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
+ * 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
+ *
+ * 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%
@@ -47,7 +47,7 @@
// TODO AThimel 12/01/2011 This settings has to be externalized
protected final static int PORT = 12345;
- protected final static String REGISTRY_IP = "10.1.1.85";
+ protected final static String REGISTRY_IP = "127.0.0.1";
/**
* Create a RMI proxy on the wanted service interface. The default RMI name
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2011-01-18 07:06:31 UTC (rev 2020)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -1,23 +1,23 @@
/*
* #%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
+ * 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
+ *
+ * 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%
@@ -28,6 +28,7 @@
import org.apache.commons.logging.LogFactory;
import java.rmi.ConnectException;
+import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
@@ -41,7 +42,7 @@
*
* @author Arnaud Thimel <thimel(a)codelutin.com>
*/
-public class ServiceExporter {
+public final class ServiceExporter {
private final static Log log = LogFactory.getLog(ServiceExporter.class);
@@ -51,7 +52,7 @@
/**
* Does some checks on RMI configuration
*/
- protected void testRmiConfig() {
+ protected static void testRmiConfig() {
String rmiHost = System.getProperty("java.rmi.server.hostname");
if ((rmiHost == null || "".equals(rmiHost.trim()))
&& log.isWarnEnabled()) {
@@ -67,7 +68,7 @@
* @return the registry found or created
* @throws RemoteException in case it is not possible to get the registry
*/
- protected Registry getRegistry() throws RemoteException {
+ protected static Registry getRegistry() throws RemoteException {
Registry result;
try {
result = LocateRegistry.getRegistry(PORT);
@@ -92,7 +93,7 @@
* @param <E> some interface class
* @throws RemoteException in case the registry is not reachable
*/
- public <E> void registerService(Class<E> serviceInterface, E instance)
+ public static <E> void registerService(Class<E> serviceInterface, E instance)
throws RemoteException {
String rmiName = serviceInterface.getName();
registerService(rmiName, instance);
@@ -106,7 +107,7 @@
* @param <E> some interface class
* @throws RemoteException in case the registry is not reachable
*/
- public <E> void registerService(String rmiName, E instance)
+ public static <E> void registerService(String rmiName, E instance)
throws RemoteException {
testRmiConfig();
@@ -121,4 +122,33 @@
registry.rebind(rmiName, stub);
}
+ /**
+ * Will unregister a service using the default name.
+ *
+ * @param serviceInterface the interface used to unbind the service. The RMI
+ * name will be generated from this class name
+ * @throws RemoteException in case the registry is not reachable
+ * @throws NotBoundException in case the given name is not bound
+ */
+ public static void unregisterService(Class<?> serviceInterface)
+ throws RemoteException, NotBoundException {
+ String rmiName = serviceInterface.getName();
+ unregisterService(rmiName);
+ }
+
+ /**
+ * Will unregister a service using the given RMI name.
+ *
+ * @param rmiName the RMI name used to unbind the service in the registry
+ * @throws RemoteException in case the registry is not reachable
+ * @throws NotBoundException in case the given name is not bound
+ */
+ public static void unregisterService(String rmiName)
+ throws RemoteException, NotBoundException {
+
+ // Bind into the registry
+ Registry registry = getRegistry();
+ registry.unbind(rmiName);
+ }
+
}
Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/AnyException.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/AnyException.java (rev 0)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/AnyException.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -0,0 +1,36 @@
+/*
+ * #%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;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class AnyException extends Exception {
+
+ public AnyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/AnyException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java (rev 0)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -0,0 +1,118 @@
+package org.nuiton.util.rmi;
+
+import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.rmi.NotBoundException;
+import java.security.InvalidParameterException;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class RmiExporterAndProxyTest {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(RmiExporterAndProxyTest.class);
+
+ @Test(expected = NullPointerException.class)
+ public void testExportNullService() throws Exception {
+
+ // It is mandatory to provide a service instance
+ ServiceExporter.registerService(TestService.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);
+
+ // This will throw an exception because service is not registered
+ RemoteProxyFactory.createProxy(TestService.class);
+ }
+
+ @Test
+ public void testObjectIdentity() throws Exception {
+
+ // Create and bind the service
+ TestServiceImpl impl = new TestServiceImpl();
+ int realServiceIdentity = System.identityHashCode(impl);
+ ServiceExporter.registerService(TestService.class, impl);
+
+ // Get a proxy on this service and make sure this is not the same object
+ TestService clientSide = RemoteProxyFactory.createProxy(TestService.class);
+ int proxyIdentity = System.identityHashCode(clientSide);
+ Assert.assertNotSame(proxyIdentity, realServiceIdentity);
+
+ // Get the remote identifier and compare
+ int serviceIdentityFromProxy = clientSide.getInstanceId();
+ Assert.assertEquals(realServiceIdentity, serviceIdentityFromProxy);
+
+ ServiceExporter.unregisterService(TestService.class);
+ }
+
+ @Test
+ public void testComplexType() throws Exception {
+
+ // Create and bind the service
+ TestServiceImpl impl = new TestServiceImpl();
+ int realServiceIdentity = System.identityHashCode(impl);
+ ServiceExporter.registerService(TestService.class, impl);
+
+ // Get a proxy on this service and do the call to createComplexTypeObject
+ TestService clientSide = RemoteProxyFactory.createProxy(TestService.class);
+ TestBean bean = clientSide.createComplexTypeObject();
+
+ // Now check that the bean is exactly as expected
+ TestBean father = bean.getFather();
+ Assert.assertNotNull(father);
+ Assert.assertEquals("I'm your father !", father.getMessage());
+ Assert.assertEquals(realServiceIdentity, father.getCreatedBy());
+ Assert.assertNull(father.getFather());
+ Assert.assertNull(father.getCreatedOn()); // transient value
+ Assert.assertEquals(0L, father.getNumber()); // transient value
+
+ Assert.assertEquals("Son", bean.getMessage());
+ Assert.assertEquals(realServiceIdentity, bean.getCreatedBy());
+ Assert.assertNull(bean.getCreatedOn()); // transient value
+ Assert.assertEquals(0L, bean.getNumber()); // transient value
+
+ ServiceExporter.unregisterService(TestService.class);
+ }
+
+ @Test
+ public void testExceptionPropagation() throws Exception {
+
+ // Create and bind the service
+ TestServiceImpl impl = new TestServiceImpl();
+ ServiceExporter.registerService(TestService.class, impl);
+
+ // Get a proxy on this service and do the call to createComplexTypeObject
+ TestService clientSide = RemoteProxyFactory.createProxy(TestService.class);
+
+ // Does not fail
+ clientSide.throwAnExceptionIfFalse(true);
+
+ try {
+ clientSide.throwAnExceptionIfFalse(false);
+ Assert.fail("An axeption should have been thrown");
+ } catch (AnyException ae) {
+
+ Assert.assertEquals("Please provide 'true'", ae.getMessage());
+
+ // Exception is the good one. Now check its cause
+ InvalidParameterException cause = (InvalidParameterException)ae.getCause();
+ Assert.assertEquals("Wrong parameter !", cause.getMessage());
+ }
+
+ ServiceExporter.unregisterService(TestService.class);
+ }
+
+}
Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java (rev 0)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -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(a)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;
+ }
+
+}
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java (rev 0)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -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(a)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;
+
+}
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java (rev 0)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java 2011-01-19 16:45:00 UTC (rev 2021)
@@ -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;
+
+import com.sun.javaws.exceptions.InvalidArgumentException;
+
+import java.security.InvalidParameterException;
+
+/**
+ * @author Arnaud Thimel <thimel(a)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) {
+ InvalidParameterException ipe = new InvalidParameterException("Wrong parameter !");
+ throw new AnyException("Please provide 'true'", ipe);
+ }
+ }
+
+}
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/TestServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
18 Jan '11
Author: tchemit
Date: 2011-01-18 08:06:31 +0100 (Tue, 18 Jan 2011)
New Revision: 2020
Url: http://nuiton.org/repositories/revision/nuiton-utils/2020
Log:
improve ApplicationConfig code
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2011-01-18 06:51:43 UTC (rev 2019)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2011-01-18 07:06:31 UTC (rev 2020)
@@ -587,14 +587,17 @@
this.value = value;
}
+ protected <T> List<T> convertListOption(Class<T> type) {
+ List<T> result= (List<T>) config.convertOption(type, key, value, true);
+ return result;
+ }
/**
* Get option value as {@link String}.
*
* @return value as String
*/
public List<String> getOption() {
- List<String> result = (List<String>)config.convertOption(
- String.class, key, value, true);
+ List<String> result = convertListOption(String.class);
return result;
}
@@ -604,8 +607,7 @@
* @return value as file
*/
public List<File> getOptionAsFile() {
- List<File> tmp = (List<File>)config.convertOption(
- File.class, key, value, true);
+ List<File> tmp = convertListOption(File.class);
List<File> result = new ArrayList<File>(tmp.size());
for (File file : tmp) {
result.add(file.getAbsoluteFile());
@@ -619,8 +621,7 @@
* @return value as URL
*/
public List<URL> getOptionAsURL() {
- List<URL> result = (List<URL>)config.convertOption(
- URL.class, key, value, true);
+ List<URL> result = convertListOption(URL.class);
return result;
}
@@ -630,8 +631,7 @@
* @return value as Class
*/
public List<Class> getOptionAsClass() {
- List<Class> result = (List<Class>)config.convertOption(
- Class.class, key, value, true);
+ List<Class> result = convertListOption(Class.class);
return result;
}
@@ -641,8 +641,7 @@
* @return value as Date
*/
public List<Date> getOptionAsDate() {
- List<Date> result = (List<Date>)config.convertOption(
- Date.class, key, value, true);
+ List<Date> result = convertListOption(Date.class);
return result;
}
@@ -652,8 +651,7 @@
* @return value as Time
*/
public List<Time> getOptionAsTime() {
- List<Time> result = (List<Time>)config.convertOption(
- Time.class, key, value, true);
+ List<Time> result = convertListOption(Time.class);
return result;
}
@@ -663,8 +661,7 @@
* @return value as Timestamp
*/
public List<Timestamp> getOptionAsTimestamp() {
- List<Timestamp> result = (List<Timestamp>)config.convertOption(
- Timestamp.class, key, value, true);
+ List<Timestamp> result = convertListOption(Timestamp.class);
return result;
}
@@ -674,8 +671,7 @@
* @return value as {@code int}
*/
public List<Integer> getOptionAsInt() {
- List<Integer> result = (List<Integer>)config.convertOption(
- Integer.class, key, value, true);
+ List<Integer> result = convertListOption(Integer.class);
return result;
}
@@ -685,8 +681,7 @@
* @return value as {@code double}
*/
public List<Double> getOptionAsDouble() {
- List<Double> result = (List<Double>)config.convertOption(
- Double.class, key, value, true);
+ List<Double> result = convertListOption(Double.class);
return result;
}
@@ -696,8 +691,7 @@
* @return value as {@code boolean}.
*/
public List<Boolean> getOptionAsBoolean() {
- List<Boolean> result = (List<Boolean>)config.convertOption(
- Boolean.class, key, value, true);
+ List<Boolean> result = convertListOption(Boolean.class);
return result;
}
}
@@ -723,11 +717,11 @@
* method is automaticaly called
*
* @param configFilename name of wikitty config file
+ * @throws ArgumentsParserException
*/
public ApplicationConfig(String configFilename) throws ArgumentsParserException {
this();
- parse(new String[]{
- "--option", ApplicationConfig.CONFIG_FILE_NAME, configFilename});
+ parse("--option", CONFIG_FILE_NAME, configFilename);
}
/**
@@ -751,7 +745,7 @@
* Get user home directory (system property {@code user.home}).
* @return user home directory
*/
- static public String getUserHome() {
+ public static String getUserHome() {
String result = System.getProperty("user.home");
return result;
}
@@ -895,7 +889,7 @@
}
/**
- * Add action to list of action to do
+ * Add action to list of action to do.
*
* @param action action to add, can be null.
*/
@@ -955,7 +949,7 @@
/**
* Add alias for action. This method put just -- front the actionMethod and
- * call {@link #addAlias(String, String...)}
+ * call {@link #addAlias(String, String...)}.
*
* @param alias the alias to add for the given method action
* @param actionMethod must be fully qualified method path:
@@ -967,7 +961,7 @@
/**
* Set name of file where options are read (in /etc, $HOME, $CURDIR)
- * This set used {@link #setDefaultOption(String, String)}
+ * This set used {@link #setDefaultOption(String, String)}.
*
* @param name file name
*/
@@ -978,6 +972,7 @@
/**
* Get name of file where options are read (in /etc, $HOME, $CURDIR).
+ *
* @return name of file
*/
public String getConfigFileName() {
@@ -1293,9 +1288,12 @@
* @param key option key
* @param value value to convert
* @param asList value is string that represente a list
- * @return
+ * @return the converted option in the required type
*/
- protected <T> Object convertOption(Class<T> clazz, String key, String value, boolean asList) {
+ protected <T> Object convertOption(Class<T> clazz,
+ String key,
+ String value,
+ boolean asList) {
String cacheKey = key + "-" + asList + "-" + clazz.getName();
int hash = 0;
1
0
18 Jan '11
Author: tchemit
Date: 2011-01-18 07:51:43 +0100 (Tue, 18 Jan 2011)
New Revision: 2019
Url: http://nuiton.org/repositories/revision/nuiton-utils/2019
Log:
fix javadoc + Evolution #852: [ApplicationConfig] change parse signature from parse(String[]) to parse(String...)
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2011-01-18 06:43:11 UTC (rev 2018)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2011-01-18 06:51:43 UTC (rev 2019)
@@ -590,7 +590,6 @@
/**
* Get option value as {@link String}.
*
- * @param key the option's key
* @return value as String
*/
public List<String> getOption() {
@@ -602,7 +601,6 @@
/**
* Get option value as {@link File}.
*
- * @param key the option's key
* @return value as file
*/
public List<File> getOptionAsFile() {
@@ -618,7 +616,6 @@
/**
* Get option value as {@link URL}.
*
- * @param key the option's key
* @return value as URL
*/
public List<URL> getOptionAsURL() {
@@ -630,7 +627,6 @@
/**
* Get option value as {@link Class}.
*
- * @param key the option's key
* @return value as Class
*/
public List<Class> getOptionAsClass() {
@@ -642,7 +638,6 @@
/**
* Get option value as {@link Date}.
*
- * @param key the option's key
* @return value as Date
*/
public List<Date> getOptionAsDate() {
@@ -654,7 +649,6 @@
/**
* Get option value as {@link Time}.
*
- * @param key the option's key
* @return value as Time
*/
public List<Time> getOptionAsTime() {
@@ -666,7 +660,6 @@
/**
* Get option value as {@link Timestamp}.
*
- * @param key the option's key
* @return value as Timestamp
*/
public List<Timestamp> getOptionAsTimestamp() {
@@ -678,7 +671,6 @@
/**
* Get option value as {@code int}.
*
- * @param key the option's key
* @return value as {@code int}
*/
public List<Integer> getOptionAsInt() {
@@ -690,7 +682,6 @@
/**
* Get option value as {@code double}.
*
- * @param key the option's key
* @return value as {@code double}
*/
public List<Double> getOptionAsDouble() {
@@ -702,7 +693,6 @@
/**
* Get option value as {@code boolean}.
*
- * @param key the option's key
* @return value as {@code boolean}.
*/
public List<Boolean> getOptionAsBoolean() {
@@ -1685,7 +1675,7 @@
* @param args argument as main(String[] args)
* @throws ArgumentsParserException if parsing failed
*/
- public void parse(String[] args) throws ArgumentsParserException {
+ public void parse(String... args) throws ArgumentsParserException {
if (args == null) {
args = ArrayUtil.EMPTY_STRING_ARRAY;
}
1
0
r2018 - in trunk/nuiton-validator/src: main/java/org/nuiton/validator main/java/org/nuiton/validator/xwork2 test/java/org/nuiton/validator/xwork2
by tchemit@users.nuiton.org 18 Jan '11
by tchemit@users.nuiton.org 18 Jan '11
18 Jan '11
Author: tchemit
Date: 2011-01-18 07:43:11 +0100 (Tue, 18 Jan 2011)
New Revision: 2018
Url: http://nuiton.org/repositories/revision/nuiton-utils/2018
Log:
suppression de la methode getModel du contrat de NuitonValidator
Modified:
trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2NuitonValidator.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorProviderTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorTest.java
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidator.java 2011-01-17 18:50:24 UTC (rev 2017)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/NuitonValidator.java 2011-01-18 06:43:11 UTC (rev 2018)
@@ -33,14 +33,6 @@
public interface NuitonValidator<O> {
/**
- * Obtain the model of a validator.
- *
- * @return the model of this validator
- * @see NuitonValidatorModel
- */
- NuitonValidatorModel<O> getModel();
-
- /**
* Validates the given object and returns the result of validation.
*
* @param object the object to validate
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2NuitonValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2NuitonValidator.java 2011-01-17 18:50:24 UTC (rev 2017)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2NuitonValidator.java 2011-01-18 06:43:11 UTC (rev 2018)
@@ -37,7 +37,7 @@
import java.util.Set;
/**
- * Implementation of {@link NuitonValidator} using {@code XWorks2} validators.
+ * Implementation of {@link NuitonValidator} using {@code XWork2} validators.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
@@ -86,17 +86,12 @@
}
@Override
- public NuitonValidatorModel<O> getModel() {
- return model;
- }
-
- @Override
public NuitonValidatorResult validate(O object) throws NullPointerException {
if (object == null) {
throw new NullPointerException("object parameter can not be null.");
}
-
+
NuitonValidatorResult result = new NuitonValidatorResult();
for (NuitonValidatorScope scope : validators.keySet()) {
@@ -109,4 +104,8 @@
}
return result;
}
+
+ protected NuitonValidatorModel<O> getModel() {
+ return model;
+ }
}
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorProviderTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorProviderTest.java 2011-01-17 18:50:24 UTC (rev 2017)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorProviderTest.java 2011-01-18 06:43:11 UTC (rev 2018)
@@ -75,9 +75,6 @@
NuitonValidator<Person> validator = provider.newValidator(model);
Assert.assertNotNull(validator);
- Assert.assertNotNull(validator.getModel());
- Assert.assertEquals(model, validator.getModel());
-
}
}
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorTest.java 2011-01-17 18:50:24 UTC (rev 2017)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/xwork2/XWork2NuitonValidatorTest.java 2011-01-18 06:43:11 UTC (rev 2018)
@@ -52,8 +52,6 @@
NuitonValidator<Person> validator = provider.newValidator(model);
Assert.assertNotNull(validator);
- Assert.assertNotNull(validator.getModel());
- Assert.assertEquals(model, validator.getModel());
ValidatorTestHelper.testPerson(validator);
1
0
r2017 - in trunk: . nuiton-utils/src/main/java/org/nuiton/util/beans nuiton-utils/src/main/java/org/nuiton/util/rmi nuiton-utils/src/test/java/org/nuiton/util/beans
by tchemit@users.nuiton.org 17 Jan '11
by tchemit@users.nuiton.org 17 Jan '11
17 Jan '11
Author: tchemit
Date: 2011-01-17 19:50:24 +0100 (Mon, 17 Jan 2011)
New Revision: 2017
Url: http://nuiton.org/repositories/revision/nuiton-utils/2017
Log:
remove deprecated binder api + fix docs
Removed:
trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderBuilder.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderProvider.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderBuilderTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderProviderTest.java
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/package-info.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutor.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java
trunk/pom.xml
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderBuilder.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderBuilder.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderBuilder.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,459 +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.beans;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * A builder of {@link Binder.BinderModel} and {@link Binder}.
- * <p/>
- * A {@code binder} permits to copy some properties from a bean to another one.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @see Binder.BinderModel
- * @see Binder
- * @since 1.1.5
- * @deprecated since 1.5.3, prefer use the {@link BinderModelBuilder} instead, will be removed in version 2.0
- */
-@Deprecated
-public class BinderBuilder {
-
- /** current model used to build the binder */
- protected Binder.BinderModel<?, ?> model;
-
- /** source properties descriptors */
- protected Map<String, PropertyDescriptor> sourceDescriptors;
-
- /** target properties descriptors */
- protected Map<String, PropertyDescriptor> targetDescriptors;
-
- public BinderBuilder() {
- }
-
- /**
- * Creates a mirrored binder for the given {@code type} and add the given
- * simple properties.
- *
- * @param type the type of mirrored binder
- * @param properties simple properties to add
- */
- public BinderBuilder(Class<?> type, String... properties) {
- createBinderModel(type);
- addSimpleProperties(properties);
- }
-
- /**
- * Creates a binder for the given types and add the given simple properties.
- *
- * @param sourceType type of the source of the binder
- * @param targetType type of the target of the binder
- * @param properties simple properties to add
- */
- public BinderBuilder(Class<?> sourceType,
- Class<?> targetType,
- String... properties) {
- createBinderModel(sourceType, targetType);
- addSimpleProperties(properties);
- }
-
- /**
- * Creates a new binder model for a mirrored binder (source type = target
- * type).
- * <p/>
- * <b>Note:</b> If a previous model was created, but not released via the
- * method {@link #createBinder(Class)}, the method will failed.
- *
- * @param type the type of source and target
- * @return the instance of the builder
- * @throws IllegalStateException if a previous builder model was created
- * without been released
- * @throws NullPointerException if a parameter is null
- */
- public BinderBuilder createBinderModel(Class<?> type)
- throws IllegalStateException, NullPointerException {
- createBinderModel(type, type);
- return this;
- }
-
- /**
- * Creates a new binder model.
- * <p/>
- * <b>Note:</b> If a previous model was created, but not released via the
- * method {@link #createBinder(Class)}, the method will failed.
- *
- * @param sourceType the type of the source
- * @param targetType the type of the target
- * @return the instance of the builder
- * @throws IllegalStateException if a previous builder model was created
- * without been released
- * @throws NullPointerException if a parameter is null
- */
- public BinderBuilder createBinderModel(Class<?> sourceType,
- Class<?> targetType)
- throws IllegalStateException, NullPointerException {
- if (sourceType == null) {
- throw new NullPointerException("sourceType can not be null");
- }
- if (targetType == null) {
- throw new NullPointerException("targetType can not be null");
- }
-
- if (model != null) {
- throw new IllegalStateException(
- "there is already a binderModel in construction, release " +
- "it with the method createBinder before using this method."
- );
- }
-
- // init model
- model = new Binder.BinderModel(sourceType, targetType);
-
- // obtain source descriptors
- sourceDescriptors = new TreeMap<String, PropertyDescriptor>();
- loadDescriptors(model.getSourceType(), sourceDescriptors);
-
- // obtain target descriptors
- targetDescriptors = new TreeMap<String, PropertyDescriptor>();
- loadDescriptors(model.getTargetType(), targetDescriptors);
-
- return this;
- }
-
- /**
- * Creates a new binder given using the {@link Binder} type of binder
- * from the internal binder model
- * previously created via the method {@code createBinderModel<XXX>} and
- * then filled with methods {@code addXXX(XXX)}.
- * <p/>
- * <b>Note:</b> If no model is present, the method will fail.
- *
- * @return the instance of the new buinder.
- * @throws IllegalStateException if no model was previously created.
- * @throws NullPointerException if the parameter is {@code null}
- */
- public Binder<?, ?> createBinder()
- throws NullPointerException, IllegalStateException {
-
- Binder<?, ?> binder = createBinder(Binder.class);
- return binder;
- }
-
- /**
- * Creates a new binder given his type from the internal binder model
- * previously created via the method {@code createBinderModel<XXX>} and
- * then filled with methods {@code addXXX(XXX)}.
- * <p/>
- * <b>Note:</b> If no model is present, the method will fail.
- *
- * @param binderType the type of binder to instanciate
- * @param <B> the type of binder to instanciate
- * @return the instance of the new buinder.
- * @throws IllegalStateException if no model was previously created.
- * @throws NullPointerException if the parameter is {@code null}
- */
- public <B extends Binder<?, ?>> B createBinder(Class<B> binderType)
- throws NullPointerException, IllegalStateException {
- checkModelExists();
- if (binderType == null) {
- throw new NullPointerException("binderType can not be null");
- }
- try {
- Binder binder = binderType.newInstance();
- binder.setModel(model);
- return (B)binder;
- } catch (Exception e) {
- throw new IllegalStateException(
- "could not instanciate binder " + binderType, e);
- } finally {
- // release resources of the model
- model = null;
- sourceDescriptors.clear();
- sourceDescriptors = null;
- targetDescriptors.clear();
- targetDescriptors = null;
- }
- }
-
- /**
- * Add to the binder model some simple properties (says source property name
- * = target property name).
- * <p/>
- * <b>Note:</b> If no model is present, the method will fail.
- *
- * @param properties the name of mirrored property
- * @return the instance of the builder
- * @throws IllegalStateException if no model was previously created
- * @throws NullPointerException if a property is {@code null}
- */
- public BinderBuilder addSimpleProperties(String... properties)
- throws IllegalStateException, NullPointerException {
- checkModelExists();
- for (String property : properties) {
- if (property == null) {
- throw new NullPointerException(
- "parameter 'properties' can not contains a null value");
- }
- addProperty0(property, property);
- }
- return this;
- }
-
- /**
- * Add to the binder model some simple properties (says source property name
- * = target property name).
- * <p/>
- * <b>Note:</b> If no model is present, the method will fail.
- *
- * @param sourceProperty the name of the source property to bind
- * @param targetProperty the name of the target property to bind
- * @return the instance of the builder
- * @throws IllegalStateException if no model was previously created
- * @throws NullPointerException if a parameter is {@code null}
- */
-
- public BinderBuilder addProperty(String sourceProperty,
- String targetProperty)
- throws IllegalStateException, NullPointerException {
- if (sourceProperty == null) {
- throw new NullPointerException(
- "parameter 'sourceProperty' can not be null");
- }
- if (targetProperty == null) {
- throw new NullPointerException(
- "parameter 'targetProperty' can not be null");
- }
- checkModelExists();
- addProperty0(sourceProperty, targetProperty);
- return this;
- }
-
- /**
- * Add to the binder model some properties.
- * <p/>
- * Parameter {@code sourceAndTargetProperties} must be a array of couple
- * of {@code sourceProperty}, {@code targetProperty}.
- * <p/>
- * Example :
- * <pre>
- * builder.addProperties("name","name2","text","text");
- * </pre>
- * <p/>
- * <b>Note:</b> If no model is present, the method will fail.
- *
- * @param sourceAndTargetProperties the couple of (sourceProperty -
- * targetProperty) to bind
- * @return the instance of the builder
- * @throws IllegalStateException if no model was previously created
- * @throws IllegalArgumentException if there is not the same number of
- * source and target properties
- * @throws NullPointerException if a parameter is {@code null}
- */
- public BinderBuilder addProperties(String... sourceAndTargetProperties)
- throws IllegalStateException, IllegalArgumentException,
- NullPointerException {
- checkModelExists();
- if (sourceAndTargetProperties.length % 2 != 0) {
- throw new IllegalArgumentException(
- "must have couple(s) of sourceProperty,targetProperty) " +
- "but had " + Arrays.toString(sourceAndTargetProperties));
- }
- for (int i = 0, max = sourceAndTargetProperties.length / 2;
- i < max; i++) {
- String sourceProperty = sourceAndTargetProperties[2 * i];
- String targetProperty = sourceAndTargetProperties[2 * i + 1];
- if (sourceProperty == null) {
- throw new NullPointerException(
- "parameter 'sourceAndTargetProperties' can not " +
- "contains a null value");
- }
- if (targetProperty == null) {
- throw new NullPointerException(
- "parameter 'sourceAndTargetProperties' can not " +
- "contains a null value");
- }
- addProperty0(sourceProperty, targetProperty);
- }
- return this;
- }
-
- public BinderBuilder addCollectionStrategy(Binder.CollectionStrategy strategy,
- String... propertyNames) {
-
- for (String propertyName : propertyNames) {
-
- // check property is registred
- if (!model.containsSourceProperty(propertyName)) {
- throw new IllegalArgumentException(
- "source property '" + propertyName + "' " +
- " is NOT registred.");
- }
-
- // check property is collection type
- PropertyDescriptor descriptor = sourceDescriptors.get(propertyName);
- Class<?> type = descriptor.getPropertyType();
- if (!Collection.class.isAssignableFrom(type)) {
- throw new IllegalStateException(
- "source property '" + propertyName +
- "' is not a collection type [" + type + "]");
- }
-
- // can safely add the strategy
- model.addCollectionStrategy(propertyName, strategy);
- }
- return this;
- }
-
- public BinderBuilder addBinder(String propertyName, Binder<?, ?> binder) {
-
- // check property is registred
- if (!model.containsSourceProperty(propertyName)) {
- throw new IllegalArgumentException(
- "source property '" + propertyName + "' " +
- " is NOT registred.");
- }
-
- // check property is the same type of given binder
- PropertyDescriptor descriptor = sourceDescriptors.get(propertyName);
- Class<?> type = descriptor.getPropertyType();
-
- if (!Collection.class.isAssignableFrom(type) &&
- !binder.model.getSourceType().isAssignableFrom(type)) {
- throw new IllegalStateException(
- "source property '" + propertyName +
- "' has not the same type [" + type +
- "] of the binder [" + binder.model.getSourceType() + "].");
- }
-
- // can safely add the strategy
- model.addBinder(propertyName, binder);
-
- return this;
- }
-
- protected void addProperty0(String sourceProperty,
- String targetProperty) {
- // check srcProperty does not exist
- if (model.containsSourceProperty(sourceProperty)) {
- throw new IllegalArgumentException("source property '" +
- sourceProperty + "' " + " was already registred.");
- }
- // check dstProperty does not exist
- if (model.containsTargetProperty(targetProperty)) {
- throw new IllegalArgumentException("destination property '" +
- targetProperty + "' " + " was already registred.");
- }
-
- // obtain source descriptor
- PropertyDescriptor sourceDescriptor =
- sourceDescriptors.get(sourceProperty);
- if (sourceDescriptor == null) {
- throw new IllegalArgumentException("no property '" +
- sourceProperty + "' " + "found on type " +
- model.getSourceType());
- }
- // check srcProperty is readable
- Method readMethod = sourceDescriptor.getReadMethod();
- if (readMethod == null) {
- throw new IllegalArgumentException("property '" + sourceProperty +
- "' " + "is not readable on type " + model.getSourceType());
- }
-
- // obtain dst descriptor
- PropertyDescriptor targetDescriptor =
- targetDescriptors.get(targetProperty);
- if (targetDescriptor == null) {
- throw new IllegalArgumentException("no property '" +
- targetProperty + "' " + "found on type " +
- model.getTargetType());
- }
- // check dstProperty is writable
- Method writeMethod = sourceDescriptor.getWriteMethod();
- if (writeMethod == null) {
- throw new IllegalArgumentException("property '" + targetProperty +
- "' " + "is not writable on type " + model.getTargetType());
- }
-
- // check types are ok
- Class<?> sourceType = sourceDescriptor.getPropertyType();
- Class<?> targetType = targetDescriptor.getPropertyType();
- //TODO-TC20100221 : should check if primitive and boxed it in such case
- if (!sourceType.equals(targetType)) {
- throw new IllegalArgumentException("source property '" +
- sourceProperty + "' and target property '" +
- targetProperty + "' are not compatible ( sourceType : " +
- sourceType + " vs targetType :" + targetType + ')');
- }
-
- // safe to add the binding
- model.addBinding(sourceDescriptor, targetDescriptor);
- }
-
-
- protected void checkModelExists() throws IllegalStateException {
- if (model == null) {
- throw new IllegalStateException("there is not model, must " +
- "create one with createBinderModel method");
- }
- }
-
- protected Binder.BinderModel<?, ?> getModel() {
- return model;
- }
-
- protected static void loadDescriptors(
- Class<?> type,
- Map<String, PropertyDescriptor> descriptors) {
- try {
-
- BeanInfo beanInfo = Introspector.getBeanInfo(type);
- for (PropertyDescriptor descriptor :
- beanInfo.getPropertyDescriptors()) {
- if (!descriptors.containsKey(descriptor.getName())) {
- descriptors.put(descriptor.getName(), descriptor);
- }
- }
- } catch (IntrospectionException e) {
- throw new RuntimeException("Could not obtain bean properties " +
- "descriptors for source type " + type, e);
- }
- Class<?>[] interfaces = type.getInterfaces();
- for (Class<?> i : interfaces) {
- loadDescriptors(i, descriptors);
- }
- Class<?> superClass = type.getSuperclass();
- if (superClass != null && !Object.class.equals(superClass)) {
- loadDescriptors(superClass, descriptors);
- }
- }
-}
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderProvider.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderProvider.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,337 +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.beans;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Manage a cache of {@link Binder} objects.
- * <p/>
- * You must first register some binders via the {@code registerBinder} api.
- * <pre>
- * Binder<User,UserDTO> mybinder = ...;
- * registerBinder(myNewBinder);
- * </pre>
- * To use several binders of the the same types, you can moreover specify
- * a context name of your binder :
- * <pre>
- * Binder<User,UserDTO> mybinder = ...;
- * registerBinder(myBinder, "One");
- * </pre>
- * <p/>
- * Then you can obtained them back via the api
- * <pre>
- * Binder<User,UserDTO> mybinder = getBinder(User.class,UserDTO);
- * </pre>
- * <p/>
- * or with a context name :
- * <pre>
- * Binder<User,UserDTO> mybinder = getBinder(User.class,UserDTO.class, "One");
- * </pre>
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @see Binder
- * @see BinderBuilder
- * @since 1.1.5
- * @deprecated since 1.5.3, use now the {@link BinderFactory} instead, will be remove in version {@code 1.6}.
- */
-@Deprecated
-public class BinderProvider {
-
- /** Logger */
- private static final Log log = LogFactory.getLog(BinderProvider.class);
-
- /** Cache of registred binders indexed by their unique entry */
- protected static Map<BinderEntry, Binder<?, ?>> binders;
-
- /**
- * Gets the registred mirror binder (source type = target type) with no
- * context name specified.
- *
- * @param sourceType the type of source and target
- * @param <S> the type of source and target
- * @return the registred binder or {@code null} if not found.
- */
- public static <S> Binder<S, S> getBinder(Class<S> sourceType) {
- return getBinder(sourceType, sourceType, null);
- }
-
- /**
- * Gets the registred mirror binder (source type = target type) with the
- * given context name.
- *
- * @param sourceType the type of source and target
- * @param name the context's name of the searched binder
- * @param <S> the type of source and target
- * @return the registred binder or {@code null} if not found.
- */
- public static <S> Binder<S, S> getBinder(Class<S> sourceType,
- String name) {
- return getBinder(sourceType, sourceType, name);
- }
-
-
- /**
- * Gets the registred binder given his types with no context name.
- *
- * @param sourceType the type of source
- * @param targetType the type of target
- * @param <S> the type of source
- * @param <T> the type of target
- * @return the registred binder or {@code null} if not found.
- */
- public static <S, T> Binder<S, T> getBinder(Class<S> sourceType,
- Class<T> targetType) {
- return getBinder(sourceType, targetType, null);
- }
-
- /**
- * Gets the registred binder given his types and his context's name.
- *
- * @param sourceType the type of source
- * @param targetType the type of target
- * @param name the context's name of the searched binder
- * @param <S> the type of source
- * @param <T> the type of target
- * @return the registred binder or {@code null} if not found.
- */
- public static <S, T> Binder<S, T> getBinder(Class<S> sourceType,
- Class<T> targetType,
- String name) {
- BinderEntry entry = new BinderEntry(sourceType, targetType, name);
- if (log.isDebugEnabled()) {
- log.debug("for entry " + entry);
- }
- Binder<?, ?> result = getBinders().get(entry);
- if (result == null) {
- // binder not found
- if (log.isWarnEnabled()) {
- log.warn("Could not find binder " + entry);
- }
- }
- return (Binder<S, T>) result;
- }
-
- /**
- * Register a binder with no context name.
- * <p/>
- * <b>Note: </b> If a previous binder with same definition exists, it will
- * be overriden by the new binder.
- *
- * @param binder the binder to register.
- */
- public static void registerBinder(Binder<?, ?> binder) {
- registerBinder(binder, null);
- }
-
- /**
- * Register a binder with no context's name from a {@link BinderBuilder}.
- * <p/>
- * <b>Note: </b> If a previous binder with same definition exists, it will
- * be overriden by the new binder.
- *
- * @param builder the builder which contains builder model to use
- * @see BinderBuilder#createBinder(Class)
- */
- public static void registerBinder(BinderBuilder builder) {
- registerBinder(builder, Binder.class);
- }
-
- /**
- * Register a binder with no context's name from a {@link BinderBuilder}.
- * <p/>
- * <b>Note: </b> If a previous binder with same definition exists, it will
- * be overriden by the new binder.
- *
- * @param builder the builder which contains builder model to use
- * @param binderType the type of binder to instanciate and register.
- * @see BinderBuilder#createBinder(Class)
- */
- public static <B extends Binder<?, ?>> void registerBinder(BinderBuilder builder,
- Class<B> binderType) {
-
- registerBinder(builder, binderType, null);
- }
-
- /**
- * Register a binder with a context's name from a {@link BinderBuilder}.
- * <p/>
- * <b>Note: </b> If a previous binder with same definition exists, it will
- * be overriden by the new binder.
- *
- * @param builder the builder which contains builder model to use
- * @param name the context's name
- * @see BinderBuilder#createBinder(Class)
- */
- public static void registerBinder(BinderBuilder builder, String name) {
-
- registerBinder(builder, Binder.class, name);
- }
-
- /**
- * Register a binder with a context's name from a {@link BinderBuilder}.
- * <p/>
- * <b>Note: </b> If a previous binder with same definition exists, it will
- * be overriden by the new binder.
- *
- * @param builder the builder which contains builder model to use
- * @param binderType the type of binder to instanciate and register.
- * @param name the context's name
- * @see BinderBuilder#createBinder(Class)
- */
- public static <B extends Binder<?, ?>> void registerBinder(BinderBuilder builder,
- Class<B> binderType,
- String name) {
- // instanciate the binder
- B binder = builder.createBinder(binderType);
- // register it
- registerBinder(binder, name);
- }
-
- /**
- * Register a binder with a context name.
- * <p/>
- * <b>Note: </b> If a previous binder with same definition exists, it will
- * be overriden by the new binder.
- *
- * @param binder the binder to register.
- * @param name the context's name
- */
- public static void registerBinder(Binder<?, ?> binder, String name) {
- Binder.BinderModel<?, ?> model = binder.getModel();
- BinderEntry entry = new BinderEntry(
- model.getSourceType(),
- model.getTargetType(),
- name
- );
- if (log.isDebugEnabled()) {
- log.debug("binder to seek : " + entry);
- }
- Binder<?, ?> oldBinder = getBinders().get(entry);
- if (oldBinder != null) {
- // already a binder for this entry
- if (log.isWarnEnabled()) {
- log.warn("Binder already registred for " + entry + " : " +
- oldBinder);
- log.warn("Will be replace by the new binder " + binder);
- }
- }
- // register the binder
- if (log.isDebugEnabled()) {
- log.debug("entry : " + entry + " : " + binder);
- }
- getBinders().put(entry, binder);
- }
-
- protected static Map<BinderEntry, Binder<?, ?>> getBinders() {
- if (binders == null) {
- binders = new HashMap<BinderEntry, Binder<?, ?>>();
- }
- return binders;
- }
-
- public static void clear() {
- if (binders != null) {
- binders.clear();
- binders = null;
- }
- }
-
- /**
- * Definition of an binder entry (source and target types + context name).
- * <p/>
- * <b>Note :</b>When no context is specified, we always use a
- * {@code null} context name.
- */
- public static class BinderEntry {
-
- protected final Class<?> sourceType;
-
- protected final Class<?> targetType;
-
- protected final String name;
-
-
- public BinderEntry(Class<?> sourceType,
- Class<?> targetType,
- String name) {
- this.sourceType = sourceType;
- this.targetType = targetType;
- this.name = name;
- }
-
- public Class<?> getSourceType() {
- return sourceType;
- }
-
- public Class<?> getTargetType() {
- return targetType;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- BinderEntry that = (BinderEntry) o;
-
- return (name == null ? that.name == null : name.equals(that.name)) &&
- sourceType.equals(that.sourceType) &&
- targetType.equals(that.targetType);
- }
-
- @Override
- public int hashCode() {
- int result = sourceType.hashCode();
- result = 31 * result + targetType.hashCode();
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder("<");
- buffer.append(super.toString());
- buffer.append(", sourceType: ").append(getSourceType()).append(',');
- buffer.append(" targetType: ").append(getTargetType()).append(',');
- buffer.append(" name: ").append(getName()).append('>');
-
- return buffer.toString();
- }
- }
-}
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/package-info.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/package-info.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/package-info.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -84,17 +84,17 @@
* org.nuiton.util.beans.BinderModelBuilderTest
* </pre>
*
- * <h1> JavaBeans api</h1>
+ * <h1>JavaBeans api</h1>
*
* <h2>{@link BeanMonitor} class</h2>
* This object permits to listen javaBeans and keep modifications made on a bean.
*
- * More exalanations will come soon, meanwhile you can see the test class :
+ * More explanations will come soon, meanwhile you can see the test class :
* <pre>
* org.nuiton.util.beans.BeanMonitorTest
* </pre>
*
- *
+ *
* @since 1.1.5
*/
package org.nuiton.util.beans;
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutor.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutor.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutor.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,23 +1,23 @@
/*
* #%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
+ * 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
+ *
+ * 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%
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,23 +1,23 @@
/*
* #%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
+ * 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
+ *
+ * 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%
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,23 +1,23 @@
/*
* #%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
+ * 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
+ *
+ * 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%
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,23 +1,23 @@
/*
* #%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
+ * 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
+ *
+ * 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%
Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderBuilderTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderBuilderTest.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderBuilderTest.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,344 +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.beans;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.xml.ws.BindingProvider;
-import java.beans.PropertyDescriptor;
-import java.util.Map;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @deprecated since 1.5.3, will be removed when {@link BindingProvider} will be removed.
- */
-@Deprecated
-public class BinderBuilderTest {
-
- private BinderBuilder builder;
-
- protected static final String PROPERTY_CLASS = "class";
-
- @Before
- public void setUp() {
-
- builder = new BinderBuilder();
- }
-
- @Test(expected = NullPointerException.class)
- public void testCreateMirroredBinderModel_NPE() throws Exception {
- builder.createBinderModel(null);
- }
-
- @Test
- public void testCreateMirroredBinderModel() throws Exception {
- builder.createBinderModel(BeanA.class);
- Assert.assertNotNull(builder.getModel());
- Map<String, PropertyDescriptor> sourceDescriptors;
- Map<String, PropertyDescriptor> targetDescriptors;
-
- sourceDescriptors = builder.sourceDescriptors;
- Assert.assertNotNull(sourceDescriptors);
- Assert.assertEquals(8, sourceDescriptors.size());
- Assert.assertTrue(sourceDescriptors.containsKey(PROPERTY_CLASS));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_AA));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_C));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_D));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_E));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_F));
-
-
- targetDescriptors = builder.targetDescriptors;
- Assert.assertNotNull(targetDescriptors);
- Assert.assertEquals(8, targetDescriptors.size());
- Assert.assertTrue(targetDescriptors.containsKey(PROPERTY_CLASS));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_AA));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_C));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_D));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_F));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_F));
-
- Assert.assertEquals(BeanA.class, builder.getModel().getSourceType());
- Assert.assertEquals(BeanA.class, builder.getModel().getTargetType());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testCreateMirroredBinderModel_Twice() throws Exception {
- builder.createBinderModel(BeanA.class);
- Assert.assertNotNull(builder.getModel());
- Assert.assertEquals(BeanA.class, builder.getModel().getSourceType());
- Assert.assertEquals(BeanA.class, builder.getModel().getTargetType());
- builder.createBinderModel(BeanA.class);
- }
-
- @Test(expected = NullPointerException.class)
- public void testCreateBinderModel_NPE() throws Exception {
- builder.createBinderModel(null, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testCreateBinderModel_NPE2() throws Exception {
- builder.createBinderModel(BeanA.class, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testCreateBinderModel_NPE3() throws Exception {
- builder.createBinderModel(null, BeanA.class);
- }
-
- @Test
- public void testCreateBinderModel() throws Exception {
- builder.createBinderModel(BeanA.class, BeanB.class);
- Assert.assertNotNull(builder.getModel());
- Map<String, PropertyDescriptor> sourceDescriptors;
- Map<String, PropertyDescriptor> targetDescriptors;
-
- sourceDescriptors = builder.sourceDescriptors;
- Assert.assertNotNull(sourceDescriptors);
- Assert.assertEquals(8, sourceDescriptors.size());
- Assert.assertTrue(sourceDescriptors.containsKey(PROPERTY_CLASS));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_AA));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_C));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_D));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_E));
- Assert.assertTrue(sourceDescriptors.containsKey(BeanA.PROPERTY_F));
-
-
- targetDescriptors = builder.targetDescriptors;
- Assert.assertNotNull(targetDescriptors);
- Assert.assertEquals(15, targetDescriptors.size());
- Assert.assertTrue(targetDescriptors.containsKey(PROPERTY_CLASS));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_AA));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_C));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_D));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_E));
- Assert.assertTrue(targetDescriptors.containsKey(BeanA.PROPERTY_F));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_BB));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_A2));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_B2));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_C2));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_D2));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_E2));
- Assert.assertTrue(targetDescriptors.containsKey(BeanB.PROPERTY_F2));
-
- Assert.assertEquals(BeanA.class, builder.getModel().getSourceType());
- Assert.assertEquals(BeanB.class, builder.getModel().getTargetType());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testCreateBinderModel_Twice() throws Exception {
- builder.createBinderModel(BeanA.class, BeanB.class);
- Assert.assertNotNull(builder.getModel());
- Assert.assertEquals(BeanA.class, builder.getModel().getSourceType());
- Assert.assertEquals(BeanB.class, builder.getModel().getTargetType());
- builder.createBinderModel(BeanA.class, BeanB.class);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testCreateBinder_NO_Model() throws Exception {
- builder.createBinder(Binder.class);
- }
-
- @Test(expected = NullPointerException.class)
- public void testCreateBinder_NPE() throws Exception {
- builder.createBinderModel(BeanA.class, BeanB.class);
- builder.createBinder(null);
- }
-
- @Test
- public void testAddSimpleProperties() throws Exception {
-
- builder.createBinderModel(BeanA.class);
- Binder.BinderModel<?, ?> model = builder.getModel();
-
- try {
- builder.addSimpleProperties((String) null);
- Assert.fail();
- } catch (NullPointerException e) {
- Assert.assertTrue(true);
- }
- builder.addSimpleProperties(BeanA.PROPERTY_A);
- Assert.assertEquals(1, model.getSourceDescriptors().length);
- Assert.assertEquals(1, model.getTargetDescriptors().length);
- Map<String, String> map = model.getPropertiesMapping();
- Assert.assertEquals(1, map.size());
- Assert.assertTrue(map.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(map.containsValue(BeanA.PROPERTY_A));
- Assert.assertEquals(BeanA.PROPERTY_A, map.get(BeanA.PROPERTY_A));
-
- try {
- builder.addSimpleProperties(BeanA.PROPERTY_A);
- Assert.fail();
- } catch (IllegalArgumentException e) {
- Assert.assertTrue(true);
- }
-
- try {
- builder.addSimpleProperties(BeanB.PROPERTY_A2);
- Assert.fail();
- } catch (IllegalArgumentException e) {
- Assert.assertTrue(true);
- }
-
- builder.addSimpleProperties(BeanA.PROPERTY_B);
- Assert.assertEquals(2, model.getSourceDescriptors().length);
- Assert.assertEquals(2, model.getTargetDescriptors().length);
- Assert.assertEquals(2, map.size());
- Assert.assertTrue(map.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(map.containsValue(BeanA.PROPERTY_B));
- Assert.assertEquals(BeanA.PROPERTY_B, map.get(BeanA.PROPERTY_B));
-
- }
-
- @Test
- public void testAddProperty() throws Exception {
- builder.createBinderModel(BeanA.class, BeanB.class);
- Binder.BinderModel<?, ?> model = builder.getModel();
-
- try {
- builder.addProperty(null, null);
- Assert.fail();
- } catch (NullPointerException e) {
- Assert.assertTrue(true);
- }
- try {
- builder.addProperty(BeanA.PROPERTY_A, null);
- Assert.fail();
- } catch (NullPointerException e) {
- Assert.assertTrue(true);
- }
- try {
- builder.addProperty(null, BeanA.PROPERTY_A);
- Assert.fail();
- } catch (NullPointerException e) {
- Assert.assertTrue(true);
- }
- builder.addProperty(BeanA.PROPERTY_A, BeanA.PROPERTY_A);
- Assert.assertEquals(1, model.getSourceDescriptors().length);
- Assert.assertEquals(1, model.getTargetDescriptors().length);
- Map<String, String> map = model.getPropertiesMapping();
- Assert.assertEquals(1, map.size());
- Assert.assertTrue(map.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(map.containsValue(BeanA.PROPERTY_A));
- Assert.assertEquals(BeanA.PROPERTY_A, map.get(BeanA.PROPERTY_A));
-
- try {
- builder.addProperty(BeanB.PROPERTY_A, BeanB.PROPERTY_A2);
- Assert.fail();
- } catch (IllegalArgumentException e) {
- Assert.assertTrue(true);
- }
-
- try {
- builder.addProperty(BeanB.PROPERTY_A2, BeanB.PROPERTY_A);
- Assert.fail();
- } catch (IllegalArgumentException e) {
- Assert.assertTrue(true);
- }
-
- builder.addProperty(BeanA.PROPERTY_B, BeanB.PROPERTY_B2);
- Assert.assertEquals(2, model.getSourceDescriptors().length);
- Assert.assertEquals(2, model.getTargetDescriptors().length);
- Assert.assertEquals(2, map.size());
- Assert.assertTrue(map.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(map.containsValue(BeanB.PROPERTY_B2));
- Assert.assertEquals(BeanB.PROPERTY_B2, map.get(BeanB.PROPERTY_B));
- }
-
- @Test
- public void testAddProperties() throws Exception {
- builder.createBinderModel(BeanA.class, BeanB.class);
-
- try {
- builder.addProperties(BeanB.PROPERTY_A, BeanB.PROPERTY_A2,
- BeanB.PROPERTY_B);
- Assert.fail();
- } catch (IllegalArgumentException e) {
- Assert.assertTrue(true);
- }
-
- try {
- builder.addProperties(BeanB.PROPERTY_A, null,
- BeanB.PROPERTY_B, BeanB.PROPERTY_B);
- Assert.fail();
- } catch (NullPointerException e) {
- Assert.assertTrue(true);
- }
-
- builder.addProperties(BeanB.PROPERTY_A, BeanB.PROPERTY_A,
- BeanB.PROPERTY_B, BeanB.PROPERTY_B2);
-
- Binder.BinderModel<?, ?> model = builder.getModel();
- Assert.assertEquals(2, model.getSourceDescriptors().length);
- Assert.assertEquals(2, model.getTargetDescriptors().length);
- Map<String, String> map = model.getPropertiesMapping();
- Assert.assertEquals(2, map.size());
- Assert.assertTrue(map.containsKey(BeanA.PROPERTY_A));
- Assert.assertTrue(map.containsValue(BeanA.PROPERTY_A));
- Assert.assertEquals(BeanA.PROPERTY_A, map.get(BeanA.PROPERTY_A));
-
- Assert.assertTrue(map.containsKey(BeanA.PROPERTY_B));
- Assert.assertTrue(map.containsValue(BeanB.PROPERTY_B2));
- Assert.assertEquals(BeanB.PROPERTY_B2, map.get(BeanB.PROPERTY_B));
- }
-
- @Test
- public void testCreateBinder() throws Exception {
- builder.createBinderModel(BeanA.class, BeanB.class);
- builder.addProperties(BeanB.PROPERTY_A, BeanB.PROPERTY_A,
- BeanB.PROPERTY_B, BeanB.PROPERTY_B2);
-
- Binder<BeanA, BeanB> binder =
- (Binder<BeanA, BeanB>) builder.createBinder();
-
- Assert.assertNull(builder.getModel());
- Assert.assertNull(builder.sourceDescriptors);
- Assert.assertNull(builder.targetDescriptors);
-
- BeanA a = new BeanA();
- BeanB b = new BeanB();
-
- a.setA("a");
- a.setB("b");
- b.setA("a2");
- b.setB2("b2");
-
- binder.copy(a, b);
- Assert.assertEquals("a", b.getA());
- Assert.assertEquals("b", b.getB2());
- Assert.assertNull(b.getB());
- }
-}
Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderProviderTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderProviderTest.java 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderProviderTest.java 2011-01-17 18:50:24 UTC (rev 2017)
@@ -1,199 +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.beans;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.xml.ws.BindingProvider;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @deprecated since 1.5.3, will be removed when {@link BindingProvider} will be removed.
- */
-@Deprecated
-public class BinderProviderTest {
-
- Binder<BeanA, BeanA> binderA;
- Binder<BeanA, BeanB> binderB;
- private static final String MY_BINDER_NAME = "myBinder";
- private static final String MY_BINDER2_NAME = "myBinder2";
-
- @Before
- public void setUp() {
-
- BinderProvider.binders = null;
-
- BinderBuilder builder = new BinderBuilder();
- binderA = (Binder<BeanA, BeanA>)
- builder.createBinderModel(BeanA.class).
- addSimpleProperties(BeanA.PROPERTY_A).
- createBinder();
- binderB = (Binder<BeanA, BeanB>)
- builder.createBinderModel(BeanA.class, BeanB.class).
- addSimpleProperties(BeanA.PROPERTY_A, BeanA.PROPERTY_B).
- addProperty(BeanA.PROPERTY_C, BeanB.PROPERTY_C2).
- createBinder();
-
- }
-
- @Test
- public void testRegisterBinder() throws Exception {
-
- Assert.assertNull(BinderProvider.binders);
-
- try {
- BinderProvider.registerBinder((Binder<?,?>) null);
- Assert.fail();
- } catch (NullPointerException e) {
-
- Assert.assertTrue(true);
- }
- try {
- BinderProvider.registerBinder((BinderBuilder) null);
- Assert.fail();
- } catch (NullPointerException e) {
-
- Assert.assertTrue(true);
- }
-
- BinderProvider.registerBinder(binderA);
-
- Assert.assertNotNull(BinderProvider.binders);
- Assert.assertEquals(1, BinderProvider.getBinders().size());
- Assert.assertTrue(BinderProvider.getBinders().containsValue(binderA));
-
- }
-
- @Test
- public void testRegisterBinderWithName() throws Exception {
- Assert.assertNull(BinderProvider.binders);
-
- String yo = "yo";
- try {
- BinderProvider.registerBinder((Binder<?,?>) null, null);
- Assert.fail();
- } catch (NullPointerException e) {
-
- Assert.assertTrue(true);
- }
-
- try {
- BinderProvider.registerBinder((Binder<?,?>) null, MY_BINDER_NAME);
- Assert.fail();
- } catch (NullPointerException e) {
-
- Assert.assertTrue(true);
- }
- try {
- BinderProvider.registerBinder((BinderBuilder) null, (String) null);
- Assert.fail();
- } catch (NullPointerException e) {
-
- Assert.assertTrue(true);
- }
- try {
- BinderProvider.registerBinder((BinderBuilder) null, MY_BINDER_NAME);
- Assert.fail();
- } catch (NullPointerException e) {
-
- Assert.assertTrue(true);
- }
-
- BinderProvider.registerBinder(binderA, MY_BINDER_NAME);
-
- Assert.assertNotNull(BinderProvider.binders);
- Assert.assertEquals(1, BinderProvider.getBinders().size());
- Assert.assertTrue(BinderProvider.getBinders().containsValue(binderA));
- }
-
- @Test
- public void testGetMirroredBinder() throws Exception {
- BinderProvider.registerBinder(binderA);
- Binder<BeanA, BeanA> aBeanABinder = BinderProvider.getBinder(BeanA.class);
- Assert.assertNotNull(aBeanABinder);
- Assert.assertEquals(binderA, aBeanABinder);
- Binder<BeanB, BeanB> beanBBinder = BinderProvider.getBinder(BeanB.class);
- Assert.assertNull(beanBBinder);
-
-
- }
-
- @Test
- public void testGetMirroredBinderWithName() throws Exception {
- BinderProvider.registerBinder(binderA, MY_BINDER_NAME);
- Binder<BeanA, BeanA> beanABinder;
- Binder<BeanB, BeanB> beanBBinder;
-
- beanABinder = BinderProvider.getBinder(BeanA.class);
- Assert.assertNull(beanABinder);
- beanABinder = BinderProvider.getBinder(BeanA.class, MY_BINDER_NAME);
- Assert.assertNotNull(beanABinder);
- Assert.assertEquals(binderA, beanABinder);
- beanBBinder = BinderProvider.getBinder(BeanB.class);
-
- Assert.assertNull(beanBBinder);
- beanBBinder = BinderProvider.getBinder(BeanB.class, MY_BINDER_NAME);
-
- Assert.assertNull(beanBBinder);
- }
-
- @Test
- public void testGetBinder() throws Exception {
-
- BinderProvider.registerBinder(binderB);
- Binder<BeanA, BeanA> beanABinder;
- Binder<BeanA, BeanB> beanBBinder;
-
- beanABinder = BinderProvider.getBinder(BeanA.class);
- Assert.assertNull(beanABinder);
-
- beanBBinder = BinderProvider.getBinder(BeanA.class, BeanB.class);
- Assert.assertNotNull(beanBBinder);
- Assert.assertEquals(binderB, beanBBinder);
-
- }
-
- @Test
- public void testGetBinderWithName() throws Exception {
- BinderProvider.registerBinder(binderB, MY_BINDER2_NAME);
- Binder<BeanA, BeanA> beanABinder;
- Binder<BeanA, BeanB> beanBBinder;
-
- beanABinder = BinderProvider.getBinder(BeanA.class);
- Assert.assertNull(beanABinder);
-
- beanBBinder = BinderProvider.getBinder(BeanA.class, BeanB.class);
- Assert.assertNull(beanBBinder);
-
- beanBBinder = BinderProvider.getBinder(BeanA.class, BeanB.class, MY_BINDER2_NAME);
- Assert.assertNotNull(beanBBinder);
- Assert.assertEquals(binderB, beanBBinder);
-
-
- }
-}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-17 18:49:58 UTC (rev 2016)
+++ trunk/pom.xml 2011-01-17 18:50:24 UTC (rev 2017)
@@ -57,14 +57,14 @@
<version>${nuitonI18nVersion}</version>
</dependency>
- <!-- Dependency for WarLauncher deprecated since 2.0, will be removed in 2.1 -->
+ <!-- Dependency for WarLauncher deprecated since 2.0, will be removed in 2.1 -->
<dependency>
<groupId>org.jvnet.hudson.winstone</groupId>
<artifactId>winstone</artifactId>
<version>0.9.10-hudson-24</version>
</dependency>
- <!-- Dependency for WarLauncher deprecated since 2.0, will be removed in 2.1 -->
+ <!-- Dependency for WarLauncher deprecated since 2.0, will be removed in 2.1 -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-webapp</artifactId>
@@ -200,6 +200,8 @@
<nuitonI18nVersion>2.0.1</nuitonI18nVersion>
+ <hibernateValidatorVersion>4.1.0.Final</hibernateValidatorVersion>
+
<aspectwerkzVersion>2.0</aspectwerkzVersion>
<tapestryVersion>5.1.0.5</tapestryVersion>
1
0
r2016 - in trunk/nuiton-validator/src/main/java/org/nuiton/validator: . xwork2
by tchemit@users.nuiton.org 17 Jan '11
by tchemit@users.nuiton.org 17 Jan '11
17 Jan '11
Author: tchemit
Date: 2011-01-17 19:49:58 +0100 (Mon, 17 Jan 2011)
New Revision: 2016
Url: http://nuiton.org/repositories/revision/nuiton-utils/2016
Log:
begin of documentation for the new validator api
Added:
trunk/nuiton-validator/src/main/java/org/nuiton/validator/package-info.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/package-info.java
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/package-info.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/package-info.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/package-info.java 2011-01-17 18:49:58 UTC (rev 2016)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 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 of Nuiton-validator api.
+ *
+ * <h1>The <b>Validator</b> api</h1>
+ * <p>
+ * The {@link NuitonValidator} is the object responsible to launch validation
+ * for a given object and then return the result of validation in a
+ * {@link NuitonValidatorResult} via the method {@code validate}.
+ * </p>
+ *
+ * <pre>
+ * NuitonValidator<O> validator = XXX;
+ * NuitonValidatorResult result = validator.validate(o);
+ * </pre>
+ *
+ * <h2>Obtain a validator</h2>
+ * To obtain a validator use the factory of validators ({@link NuitonValidatorFactory}.
+ * <br/>
+ * <pre>
+ * NuitonValidator<O> validator = NuitonValidatorFactory.newValidator(O.class);
+ * </pre>
+ *
+ * <h2>Implements the validator api</h2>
+ *
+ * At the moment, there is an offered implementation based on xwork2 framework.
+ *
+ * <strong>To be continued...</strong>
+ *
+ * @since 2.0
+ */
+package org.nuiton.validator;
+
+
+import org.nuiton.validator.NuitonValidator;
+import org.nuiton.validator.NuitonValidatorFactory;
+import org.nuiton.validator.NuitonValidatorResult;
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/package-info.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/package-info.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/package-info.java 2011-01-17 18:49:58 UTC (rev 2016)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 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 of xworks2 implementation of the Nuiton-validator api.
+ *
+ * <strong>To be continued...</strong>
+ *
+ * @since 2.0
+ */
+package org.nuiton.validator.xwork2;
+
+import org.nuiton.validator.NuitonValidator;
+import org.nuiton.validator.NuitonValidatorFactory;
+import org.nuiton.validator.NuitonValidatorResult;
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0