Removing client-side validation from GWT 2.2 as it is not yet in a working state. git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/2.2@9531 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/build.xml b/samples/build.xml index b5061e1..adef8a9 100644 --- a/samples/build.xml +++ b/samples/build.xml
@@ -38,14 +38,6 @@ <gwt.ant dir="showcase" /> </target> - <target name="validation" description="Build validation"> - <gwt.ant dir="validation" /> - </target> - - <target name="validationtck" description="Build validation TCK"> - <gwt.ant dir="validationtck" /> - </target> - <target name="-do" description="Run all subprojects" > <antcall target="dynatable" /> <antcall target="dynatablerf" /> @@ -55,7 +47,6 @@ <antcall target="logexample" /> <antcall target="mail" /> <antcall target="showcase" /> - <antcall target="validation" /> <!-- don't include validationtck, it is not really a sample --> </target>
diff --git a/samples/validation/build.xml b/samples/validation/build.xml deleted file mode 100755 index 6c25136..0000000 --- a/samples/validation/build.xml +++ /dev/null
@@ -1,35 +0,0 @@ -<project name="validation" default="build" basedir="."> - <property name="sample.root" value="validation" /> - <property name="sample.module" value="Validation" /> - <property name="sample.path" value="src" /> - <import file="../common.ant.xml" /> - - <!-- these are after the common.ant.xml so they have gwt.tools etc. --> - <path id="sample.extraclasspath"> - <pathelement location="${gwt.tools.lib}/apache/log4j/log4j-1.2.16.jar" /> - <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar" /> - <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar" /> - <pathelement location="${gwt.tools.lib}/hibernate/validator/hibernate-validator-4.1.0.Final.jar" /> - <pathelement location="${gwt.tools.lib}/hibernate/validator/hibernate-validator-4.1.0.Final-sources.jar" /> - <pathelement location="${gwt.tools.lib}/slf4j/slf4j-api/slf4j-api-1.6.1.jar" /> - <pathelement location="${gwt.tools.lib}/slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" /> - <!-- Needed for JDK 1.5--> - <pathelement location="${gwt.tools.lib}/javax/activation/activation-1.1.jar" /> - <pathelement location="${gwt.tools.lib}/javax/xml/bind/jaxb-api-2.1.jar" /> - <pathelement location="${gwt.tools.lib}/sun/jaxb/jaxb-impl-2.1.3.jar" /> - <pathelement location="${gwt.tools.lib}/javax/xml/stream/stax-api-1.0-2.jar" /> - </path> - <fileset id="sample.server.libs" dir="${gwt.tools.lib}"> - <include name="javax/validation/validation-api-1.0.0.GA-sources.jar" /> - <include name="hibernate/validator/hibernate-validator-4.1.0.Final.jar" /> - <include name="hibernate/validator/hibernate-validator-4.1.0.Final-sources.jar" /> - <include name="apache/log4j/log4j-1.2.16.jar" /> - <include name="slf4j/slf4j-api/slf4j-api-1.6.1.jar" /> - <include name="slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" /> - <!-- Needed for JDK 1.5--> - <include name="javax/activation/activation-1.1.jar" /> - <include name="javax/xml/bind/jaxb-api-2.1.jar" /> - <include name="sun/jaxb/jaxb-impl-2.1.3.jar" /> - <include name="javax/xml/stream/stax-api-1.0-2.jar" /> - </fileset> -</project>
diff --git a/samples/validation/src/com/google/gwt/sample/validation/COPYING b/samples/validation/src/com/google/gwt/sample/validation/COPYING deleted file mode 100644 index d9a10c0..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/COPYING +++ /dev/null
@@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS
diff --git a/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml b/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml deleted file mode 100644 index 23173e9..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml +++ /dev/null
@@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright 2010 Google Inc. --> -<!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> -<!-- may not use this file except in compliance with the License. You may --> -<!-- may obtain a copy of the License at --> -<!-- --> -<!-- http://www.apache.org/licenses/LICENSE-2.0 --> -<!-- --> -<!-- Unless required by applicable law or agreed to in writing, software --> -<!-- distributed under the License is distributed on an "AS IS" BASIS, --> -<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> -<!-- implied. License for the specific language governing permissions and --> -<!-- limitations under the License. --> - -<module rename-to='validation'> - <inherits name='com.google.gwt.rpc.RPC' /> - <inherits name='com.google.gwt.user.User' /> - <inherits name='com.google.gwt.user.theme.standard.Standard' /> - <inherits name='org.hibernate.validator.HibernateValidator' /> - - <entry-point class='com.google.gwt.sample.validation.client.Validation' /> - - <source path='client' /> - <source path='shared' /> - <super-source path="super" /> - - <!-- Specify the Validator for the Validation bootstrap to use. --> - <replace-with - class="com.google.gwt.sample.validation.client.SampleValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory" /> - </replace-with> - - <!-- TODO(nchalko) figure out how to make this a attribute of the GwtValidation - annotation --> - <!-- specify the ValidationMessageResolver to use for your custom validation messages --> - <replace-with - class="com.google.gwt.sample.validation.client.CustomValidationMessagesResolver"> - <when-type-is - class="com.google.gwt.validation.client.UserValidationMessagesResolver" /> - </replace-with> -</module>
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/CustomValidationMessagesResolver.java b/samples/validation/src/com/google/gwt/sample/validation/client/CustomValidationMessagesResolver.java deleted file mode 100644 index b81c63d..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/CustomValidationMessagesResolver.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.client.ConstantsWithLookup; -import com.google.gwt.validation.client.AbstractValidationMessageResolver; -import com.google.gwt.validation.client.UserValidationMessagesResolver; - -/** - * {@link UserValidationMessageResolver} that uses the - * {@link ValidationMessages}. - */ -public class CustomValidationMessagesResolver extends AbstractValidationMessageResolver - implements UserValidationMessagesResolver { - - // TODO(nchalko) implement this as part of the GWtValidation annotation - // instead of a separate class. - protected CustomValidationMessagesResolver() { - super((ConstantsWithLookup) GWT.create(ValidationMessages.class)); - } -} \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java b/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java deleted file mode 100644 index 9ed0787..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -import com.google.gwt.rpc.client.RpcService; -import com.google.gwt.safehtml.shared.SafeHtml; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; - -import javax.validation.ConstraintViolationException; - -/** - * The client side stub for the RPC service. - */ -@RemoteServiceRelativePath("greet") -public interface GreetingService extends RpcService { - SafeHtml greetServer(Person name) throws IllegalArgumentException, - ConstraintViolationException; -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java b/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java deleted file mode 100644 index 1309e56..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java +++ /dev/null
@@ -1,30 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -import com.google.gwt.safehtml.shared.SafeHtml; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.user.client.rpc.AsyncCallback; - -import javax.validation.ConstraintViolationException; - -/** - * The async counterpart of <code>GreetingService</code>. - */ -public interface GreetingServiceAsync { - void greetServer(Person person, AsyncCallback<SafeHtml> callback) - throws IllegalArgumentException, ConstraintViolationException; -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidatorFactory.java b/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidatorFactory.java deleted file mode 100644 index fd5ae12..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidatorFactory.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.sample.validation.shared.ClientGroup; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; -import javax.validation.groups.Default; - -/** - * {@link AbstractGwtValidatorFactory} that creates the specified {@link GwtValidator}. - */ -public final class SampleValidatorFactory extends AbstractGwtValidatorFactory { - - /** - * Validator marker for the Validation Sample project. Only the classes listed - * in the {@link GwtValidation} annotation can be validated. - */ - @GwtValidation(value = Person.class, - groups = {Default.class, ClientGroup.class}) - public interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/Validation.java b/samples/validation/src/com/google/gwt/sample/validation/client/Validation.java deleted file mode 100644 index 86bb36e..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/Validation.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.user.client.ui.RootPanel; - -/** - * Entry point classes define <code>onModuleLoad()</code>. - */ -public class Validation implements EntryPoint { - - /** - * Create a remote service proxy to talk to the server-side Greeting service. - */ - private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class); - - /** - * This is the entry point method. - */ - public void onModuleLoad() { - Person person = new Person(); - ValidationView view = new ValidationView(person, greetingService); - RootPanel.get("view").add(view); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationMessages.java b/samples/validation/src/com/google/gwt/sample/validation/client/ValidationMessages.java deleted file mode 100644 index ae526ff..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationMessages.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -/** - * Custom validation messages. Interface to represent the constants contained in - * resource bundle: - * 'com/google/gwt/sample/validation/client/ValidationMessages.properties' - * TODO(nchalko) move this to the root package so client and server can share - * the same properties files. - */ -public interface ValidationMessages extends - com.google.gwt.i18n.client.ConstantsWithLookup { - - /** - * Translated "Name must be at least {size} characters long.". - * - * @return translated "Name must be at least {min} characters long." - */ - @DefaultStringValue("Name must be at least {min} characters long.") - @Key("custom.name.size.message") - String custom_name_size_message(); -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationMessages.properties b/samples/validation/src/com/google/gwt/sample/validation/client/ValidationMessages.properties deleted file mode 100644 index a9ea8f1..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationMessages.properties +++ /dev/null
@@ -1,2 +0,0 @@ -# Put custom messages here. -custom.name.size.message=Name must be at least {min} characters long.
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java b/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java deleted file mode 100644 index e113e83..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java +++ /dev/null
@@ -1,183 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.resources.client.CssResource; -import com.google.gwt.safehtml.shared.SafeHtml; -import com.google.gwt.sample.validation.shared.ClientGroup; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.groups.Default; - -/** - * Display the Validation sample. - */ -public class ValidationView extends Composite { - interface MyStyle extends CssResource { - String error(); - } - - interface ValidationViewUiBinder extends UiBinder<Widget, ValidationView> { - } - - /** - * The message displayed to the user when the server cannot be reached or - * returns an error. - */ - private static final String SERVER_ERROR = "An error occurred while " - + "attempting to contact the server. Please check your network " - + "connection and try again."; - - private static ValidationViewUiBinder uiBinder = GWT.create(ValidationViewUiBinder.class); - - @UiField - Button closeButton; - - @UiField - DialogBox dialogBox; - - @UiField - Label errorLabel; - - @UiField - TextBox nameField; - - @UiField - Button sendButton; - - @UiField - HTML serverResponse; - - @UiField - MyStyle style; - - @UiField - Label textToServer; - - private final GreetingServiceAsync greetingService; - - private final Person person; - - public ValidationView(Person person, GreetingServiceAsync greetingService) { - - this.person = person; - - this.greetingService = greetingService; - initWidget(uiBinder.createAndBindUi(this)); - - nameField.setText(person.getName()); - } - - @UiHandler("closeButton") - public void doClick(ClickEvent e) { - dialogBox.hide(); - sendButton.setEnabled(true); - sendButton.setFocus(true); - } - - @UiHandler("sendButton") - void onClick(ClickEvent e) { - sendPersonToServer(); - } - - @UiHandler("sendButton") - void onKeyPress(KeyUpEvent e) { - if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - sendPersonToServer(); - } - } - - /** - * Send the person from the nameField to the server and wait for a response. - */ - private void sendPersonToServer() { - errorLabel.setText(""); - person.setName(nameField.getText()); - - Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); - Set<ConstraintViolation<Person>> violations = validator.validate(person, - Default.class, ClientGroup.class); - if (!violations.isEmpty()) { - StringBuffer errorMessage = new StringBuffer(); - for (ConstraintViolation<Person> constraintViolation : violations) { - if (errorMessage.length() == 0) { - errorMessage.append('\n'); - } - errorMessage.append(constraintViolation.getMessage()); - } - errorLabel.setText(errorMessage.toString()); - return; - } - sendButton.setEnabled(false); - textToServer.setText(person.getName()); - serverResponse.setText(""); - greetingService.greetServer(person, new AsyncCallback<SafeHtml>() { - public void onFailure(Throwable caught) { - if (caught instanceof ConstraintViolationException) { - ConstraintViolationException violationException = (ConstraintViolationException) caught; - Set<ConstraintViolation<?>> violations = violationException.getConstraintViolations(); - StringBuffer sb = new StringBuffer(); - for (ConstraintViolation<?> constraintViolation : violations) { - sb.append(constraintViolation.getPropertyPath().toString()) // - .append(":") // - .append(constraintViolation.getMessage()) // - .append("\n"); - } - errorLabel.setText(sb.toString()); - sendButton.setEnabled(true); - sendButton.setFocus(true); - return; - } - - // Show the RPC error message to the user - dialogBox.setText("Remote Procedure Call - Failure"); - serverResponse.addStyleName(style.error()); - serverResponse.setHTML(SERVER_ERROR); - dialogBox.center(); - closeButton.setFocus(true); - } - - public void onSuccess(SafeHtml result) { - dialogBox.setText("Remote Procedure Call"); - serverResponse.removeStyleName(style.error()); - serverResponse.setHTML(result); - dialogBox.center(); - closeButton.setFocus(true); - } - }); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.ui.xml b/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.ui.xml deleted file mode 100644 index dc7c5a6..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.ui.xml +++ /dev/null
@@ -1,52 +0,0 @@ -<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> -<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" - xmlns:g="urn:import:com.google.gwt.user.client.ui"> - <ui:style type ="com.google.gwt.sample.validation.client.ValidationView.MyStyle"> - @external .gwt-DialogBox; - .gwt-DialogBox { - width: 400px; - } - .panel { - align: center; - } - .send { - display: block; - font-size: 16pt; - } - .error { - color: red; - } - .dialogPanel { - margin: 5px; - } - .close { - margin: 15px 6px 6px; - } - </ui:style> - <g:VerticalPanel styleName="{style.panel}"> - <g:FlowPanel> - <g:Label>Please enter your name:</g:Label> - <g:TextBox ui:field="nameField">GWT User</g:TextBox> - </g:FlowPanel> - <g:Button styleName="{style.send}" ui:field="sendButton">Send</g:Button> - <g:Label styleName="{style.error}" ui:field="errorLabel" /> - <g:DialogBox ui:field="dialogBox" - animationEnabled="true" - text="Remote Procedure Call" - visible="false" - width="400"> - <g:VerticalPanel styleName="dialogPanel"> - <g:HTML> - <b>Sending name to the server:</b> - </g:HTML> - <g:Label ui:field="textToServer" /> - <g:HTML> - <br /> - <b>Server replies:</b> - </g:HTML> - <g:HTML ui:field="serverResponse" /> - <g:Button styleName="{style.close}" ui:field="closeButton">Close</g:Button> - </g:VerticalPanel> - </g:DialogBox> - </g:VerticalPanel> -</ui:UiBinder> \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java b/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java deleted file mode 100644 index f8712c7..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java +++ /dev/null
@@ -1,70 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.server; - -import com.google.gwt.rpc.server.RpcServlet; -import com.google.gwt.safehtml.shared.SafeHtml; -import com.google.gwt.safehtml.shared.SafeHtmlBuilder; -import com.google.gwt.sample.validation.client.GreetingService; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.sample.validation.shared.ServerGroup; - -import java.util.HashSet; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.groups.Default; - -/** - * The server side implementation of the RPC service. - */ -@SuppressWarnings("serial") -public class GreetingServiceImpl extends RpcServlet implements - GreetingService { - - private final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); - - public SafeHtml greetServer(Person person) throws IllegalArgumentException, - ConstraintViolationException { - // Verify that the input is valid. - Set<ConstraintViolation<Person>> violations = validator.validate(person, - Default.class, ServerGroup.class); - if (!violations.isEmpty()) { - Set<ConstraintViolation<?>> temp = new HashSet<ConstraintViolation<?>>( - violations); - throw new ConstraintViolationException(temp); - } - - String serverInfo = getServletContext().getServerInfo(); - String userAgent = getThreadLocalRequest().getHeader("User-Agent"); - - // Escape data from the client to avoid cross-site script vulnerabilities. - SafeHtmlBuilder builder = new SafeHtmlBuilder(); - - SafeHtml safeHtml = builder// - .appendEscapedLines("Hello, " + person.getName() + "!")// - .appendHtmlConstant("<br>")// - .appendEscaped("I am running " + serverInfo + ".")// - .appendHtmlConstant("<br><br>")// - .appendEscaped("It looks like you are using: ")// - .appendEscaped(userAgent)// - .toSafeHtml(); - return safeHtml; - } -} \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/Address.java b/samples/validation/src/com/google/gwt/sample/validation/shared/Address.java deleted file mode 100644 index f340eab..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/Address.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import javax.validation.constraints.NotNull; - -/** - * Sample address for validation - */ -public class Address implements IsSerializable { - - @NotNull - public String street; - - @Zip - public String zip; - - -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/ClientGroup.java b/samples/validation/src/com/google/gwt/sample/validation/shared/ClientGroup.java deleted file mode 100644 index 0acd314..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/ClientGroup.java +++ /dev/null
@@ -1,22 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -/** - * Client Validation Group - */ -public interface ClientGroup { -} \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/NoOp.java b/samples/validation/src/com/google/gwt/sample/validation/shared/NoOp.java deleted file mode 100644 index 1459303..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/NoOp.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.Payload; - -/** - * Test constraint that is always valid - */ -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE}) -@Retention(RUNTIME) -@Documented -@Constraint(validatedBy = {NoOpValidator.class}) -public @interface NoOp { - String message() default "Hey, this can't fail!"; - - Class<?>[] groups() default {}; - - Class<? extends Payload>[] payload() default {}; -} \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/NoOpValidator.java b/samples/validation/src/com/google/gwt/sample/validation/shared/NoOpValidator.java deleted file mode 100644 index 348befe..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/NoOpValidator.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -/** - * This is always valid. - */ -public class NoOpValidator implements ConstraintValidator<NoOp, Object> { - - public void initialize(NoOp constraintAnnotation) { - } - - public boolean isValid(Object value, ConstraintValidatorContext context) { - return true; - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java b/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java deleted file mode 100644 index 607bb11..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -/** - * A sample bean to show validation on. - */ -@ServerConstraint(groups = ServerGroup.class) -public class Person implements IsSerializable { - - @Valid - private Address address; - - @NotNull - @Size(min = 4, message = "{custom.name.size.message}") - private String name; - - private long ssn; - - public Address getAddress() { - return address; - } - - public String getName() { - return name; - } - - public void setAddress(Address address) { - this.address = address; - } - - public void setName(String name) { - this.name = name; - } - - public void setSsn(long ssn) { - this.ssn = ssn; - } - - @Max(999999999) - protected long getSsn() { - return ssn; - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/ServerConstraint.java b/samples/validation/src/com/google/gwt/sample/validation/shared/ServerConstraint.java deleted file mode 100644 index 290062b..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/ServerConstraint.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.Payload; - -/** - * Sample constraint that is designed to only run on the server. It will fail if - * the Persons name is "Fail" - */ -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE}) -@Retention(RUNTIME) -@Documented -@Constraint(validatedBy = {ServerValidator.class}) -public @interface ServerConstraint { - String message() default "Not valid at the server"; - - Class<?>[] groups() default {}; - - Class<? extends Payload>[] payload() default {}; -} \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/ServerGroup.java b/samples/validation/src/com/google/gwt/sample/validation/shared/ServerGroup.java deleted file mode 100644 index dce02cf..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/ServerGroup.java +++ /dev/null
@@ -1,22 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -/** - * Server Validation Group. - */ -public interface ServerGroup { -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/ServerValidator.java b/samples/validation/src/com/google/gwt/sample/validation/shared/ServerValidator.java deleted file mode 100644 index ead810a..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/ServerValidator.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import java.lang.reflect.Method; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -/** - * Fails only on the server if the persons name is "Fail". - */ -public class ServerValidator implements - ConstraintValidator<ServerConstraint, Person> { - - public void initialize(ServerConstraint constraintAnnotation) { - // Here I do something that will not compile on GWT - Method[] methods = constraintAnnotation.getClass().getMethods(); - } - - public boolean isValid(Person person, ConstraintValidatorContext context) { - if (person == null) { - return true; - } - String name = person.getName(); - return name == null || !name.equals("Fail"); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/Zip.java b/samples/validation/src/com/google/gwt/sample/validation/shared/Zip.java deleted file mode 100644 index ffc8ec3..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/Zip.java +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.Payload; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; - -/** - * Example composite constraint. - */ -@Pattern(regexp = "[0-9]*") -@Size(min = 5, max = 5) -@Constraint(validatedBy = {}) -@Documented -@Target({ANNOTATION_TYPE, METHOD, FIELD, CONSTRUCTOR, PARAMETER}) -@Retention(RUNTIME) -public @interface Zip { - /** - * Defines several @Zip annotations on the same element - * - * @see {@link Zip} - */ - @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) - @Retention(RUNTIME) - @Documented - @interface List { - Zip[] value(); - } - - Class<?>[] groups() default {}; - - String message() default "Wrong zipcode"; - - Class<? extends Payload>[] payload() default {}; -} \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java b/samples/validation/src/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java deleted file mode 100644 index c633d58..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validation.shared; - -import com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator; - -/** - * Always invalid. - * <p> - * Server validator is overriden so it compiles, but it is always invalid. - */ -public class ServerValidator extends - NotGwtCompatibleValidator<ServerConstraint, Person> { -} \ No newline at end of file
diff --git a/samples/validation/src/log4j.properties b/samples/validation/src/log4j.properties deleted file mode 100644 index bf638d2..0000000 --- a/samples/validation/src/log4j.properties +++ /dev/null
@@ -1,5 +0,0 @@ -#log4j configuration, needed by hibernate validator. -log4j.rootLogger=INFO, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout \ No newline at end of file
diff --git a/samples/validation/war/Validation.css b/samples/validation/war/Validation.css deleted file mode 100644 index ebf683e..0000000 --- a/samples/validation/war/Validation.css +++ /dev/null
@@ -1,15 +0,0 @@ -/** Add css rules here for your application. */ - - -/** Example rules used by the template application (remove for your app) */ -h1 { - font-size: 2em; - font-weight: bold; - color: #777777; - margin: 40px 0px 70px; - text-align: center; -} - -.serverResponseLabelError { - color: red; -}
diff --git a/samples/validation/war/Validation.html b/samples/validation/war/Validation.html deleted file mode 100644 index 32654de..0000000 --- a/samples/validation/war/Validation.html +++ /dev/null
@@ -1,58 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- --> -<!-- Copyright 2010 Google Inc. --> -<!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> -<!-- may not use this file except in compliance with the License. You may --> -<!-- may obtain a copy of the License at --> -<!-- --> -<!-- http://www.apache.org/licenses/LICENSE-2.0 --> -<!-- --> -<!-- Unless required by applicable law or agreed to in writing, software --> -<!-- distributed under the License is distributed on an "AS IS" BASIS, --> -<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> -<!-- implied. License for the specific language governing permissions and --> -<!-- limitations under the License. --> -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - - <!-- --> - <!-- Consider inlining CSS to reduce the number of requested files --> - <!-- --> - <link type="text/css" rel="stylesheet" href="Validation.css"> - - <!-- --> - <!-- Any title is fine --> - <!-- --> - <title>javax.validation Starter Project</title> - - <!-- --> - <!-- This script loads your compiled module. --> - <!-- If you add any GWT meta tags, they must --> - <!-- be added before this line. --> - <!-- --> - <script type="text/javascript" language="javascript" src="validation/validation.nocache.js"></script> - </head> - - <!-- --> - <!-- The body can have arbitrary html, or --> - <!-- you can leave the body empty if you want --> - <!-- to create a completely dynamic UI. --> - <!-- --> - <body> - - <!-- OPTIONAL: include this if you want history support --> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - - <!-- RECOMMENDED if your web app will not function without JavaScript enabled --> - <noscript> - <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> - Your web browser must have JavaScript enabled - in order for this application to display correctly. - </div> - </noscript> - - <h1>javax.validation Starter Project</h1> - <div id="view" /> - </body> -</html>
diff --git a/samples/validation/war/WEB-INF/classes/marker b/samples/validation/war/WEB-INF/classes/marker deleted file mode 100644 index e69de29..0000000 --- a/samples/validation/war/WEB-INF/classes/marker +++ /dev/null
diff --git a/samples/validation/war/WEB-INF/lib/gwt-servlet.jar b/samples/validation/war/WEB-INF/lib/gwt-servlet.jar deleted file mode 100644 index bc41164..0000000 --- a/samples/validation/war/WEB-INF/lib/gwt-servlet.jar +++ /dev/null Binary files differ
diff --git a/samples/validation/war/WEB-INF/web.xml b/samples/validation/war/WEB-INF/web.xml deleted file mode 100644 index 9f79f03..0000000 --- a/samples/validation/war/WEB-INF/web.xml +++ /dev/null
@@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<web-app> - - <!-- Servlets --> - <servlet> - <servlet-name>greetServlet</servlet-name> - <servlet-class>com.google.gwt.sample.validation.server.GreetingServiceImpl</servlet-class> - </servlet> - - <servlet-mapping> - <servlet-name>greetServlet</servlet-name> - <url-pattern>/validation/greet</url-pattern> - </servlet-mapping> - - <!-- Default page to serve --> - <welcome-file-list> - <welcome-file>Validation.html</welcome-file> - </welcome-file-list> - -</web-app>
diff --git a/samples/validation/war/favicon.ico b/samples/validation/war/favicon.ico deleted file mode 100644 index d7ccc73..0000000 --- a/samples/validation/war/favicon.ico +++ /dev/null Binary files differ
diff --git a/samples/validationtck/README.txt b/samples/validationtck/README.txt deleted file mode 100644 index f6fe5e8..0000000 --- a/samples/validationtck/README.txt +++ /dev/null
@@ -1,11 +0,0 @@ -This is not actually a sample. -It is a GWT HACK to run the JSR 303 Technology Compatibility Kit. - -See -http://docs.jboss.org/hibernate/stable/beanvalidation/tck/reference/html_single/ - -from this dir run -ant tck - -A html report will be generated. -
diff --git a/samples/validationtck/build.xml b/samples/validationtck/build.xml deleted file mode 100755 index 863f851..0000000 --- a/samples/validationtck/build.xml +++ /dev/null
@@ -1,210 +0,0 @@ -<project name="validationtck" default="build" basedir="."> - <property name="sample.root" value="validationtck" /> - <property name="sample.module" value="ValidationTck" /> - <property name="sample.path" value="src" /> - <property name="test.args" value="-ea" /> - <property name="test.jvmargs" value="-ea -Dcom.google.gwt.sample.validationtck.util.Failing.include=true -Dcom.google.gwt.sample.validationtck.util.NonTckTest.exclude=true" /> - <import file="../common.ant.xml" /> - - <!-- these are after the common.ant.xml so they have gwt.tools etc. --> - <path id="sample.extraclasspath"> - <pathelement location="${gwt.tools.lib}/apache/log4j/log4j-1.2.16.jar" /> - <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar" /> - <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar" /> - <pathelement location="${gwt.tools.lib}/hibernate/validator/hibernate-validator-4.1.0.Final.jar" /> - <pathelement location="${gwt.tools.lib}/hibernate/validator/hibernate-validator-4.1.0.Final-sources.jar" /> - <pathelement location="${gwt.tools.lib}/slf4j/slf4j-api/slf4j-api-1.6.1.jar" /> - <pathelement location="${gwt.tools.lib}/slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" /> - <!-- TCK jars --> - <pathelement location="${gwt.tools.lib}/hibernate/validator/tck/jsr303-tck-1.0.3.GA-sources.jar" /> - <pathelement location="${gwt.tools.lib}/hibernate/validator/tck/jsr303-tck-1.0.3.GA.jar" /> - <pathelement location="${gwt.tools.lib}/jboss/test-audit/jboss-test-audit-api-1.0.0-sources.jar" /> - <pathelement location="${gwt.tools.lib}/jboss/test-audit/jboss-test-audit-api-1.0.0.jar" /> - <pathelement location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-1.0.0-sources.jar" /> - <pathelement location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-1.0.0.jar" /> - <pathelement location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-api-1.0.0-sources.jar" /> - <pathelement location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-api-1.0.0.jar" /> - <pathelement location="${gwt.tools.lib}/testng/testng-5.14.1-sources.jar" /> - <pathelement location="${gwt.tools.lib}/testng/testng-5.14.1.jar" /> - <!-- Needed for JDK 1.5--> - <pathelement location="${gwt.tools.lib}/javax/activation/activation-1.1.jar" /> - <pathelement location="${gwt.tools.lib}/javax/xml/bind/jaxb-api-2.1.jar" /> - <pathelement location="${gwt.tools.lib}/sun/jaxb/jaxb-impl-2.1.3.jar" /> - <pathelement location="${gwt.tools.lib}/javax/xml/stream/stax-api-1.0-2.jar" /> - </path> - <fileset id="sample.server.libs" dir="${gwt.tools.lib}"> - <include name="hibernate/validator/hibernate-validator-4.1.0.Final.jar" /> - <include name="apache/log4j/log4j-1.2.16.jar" /> - <include name="slf4j/slf4j-api/slf4j-api-1.6.1.jar" /> - <include name="slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" /> - <!-- Needed for JDK 1.5--> - <include name="javax/activation/activation-1.1.jar" /> - <include name="javax/xml/bind/jaxb-api-2.1.jar" /> - <include name="sun/jaxb/jaxb-impl-2.1.3.jar" /> - <include name="javax/xml/stream/stax-api-1.0-2.jar" /> - </fileset> - - - <!-- - Classpaths added for test cases - --> - <path id="test.extraclasspath"> - <pathelement location="${gwt.build}/out/dev/bin-test" /> - <pathelement location="${gwt.dev.jar}" /> - <pathelement location="${gwt.build.lib}/gwt-user.jar" /> - <path refid="sample.extraclasspath" /> - </path> - - - <property name="test.timeout" value="4" /> - <property name="emma.merged.out" value="${junit.out}/emma-coverage" /> - <property name="gwt.junit.testcase.web.includes" value="${gwt.junit.testcase.includes}" /> - <property name="gwt.junit.testcase.web.excludes" value="" /> - <property name="gwt.junit.testcase.dev.includes" value="org/hibernate/jsr303/tck/tests/**/*GwtSuite.class" /> - <property name="gwt.junit.testcase.dev.excludes" value="org/hibernate/jsr303/tck/util/*.class" /> - - <!-- - Compiles the test code for this project - --> - <target name="compile.tests" - depends="compile.emma.if.enabled" - unless="compile.tests.complete"> - <mkdir dir="${javac.junit.out}" /> - <gwt.javac srcdir="test" excludes="**/super/**" - destdir="${javac.junit.out}"> - <classpath> - <pathelement location="${javac.out}" /> - <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" /> - <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" /> - <path refid="sample.extraclasspath" /> - <path refid="test.extraclasspath" /> - </classpath> - </gwt.javac> - </target> - - - <target name="tck" - depends="tck.run,tck.report" - description="Run all tests for this project."> - <fail - message="One or more junit tests failed for target: @{test.name} @{test.args}" - if="junit.failure" status="2" /> - </target> - - <target name="tck.run" - depends="compile, compile.tests" - description="Run all tests for this project."> - <!-- Prevent compilation for every target. --> - <property name="compile.complete" value="true"/> - <property name="compile.tests.complete" value="true"/> - - <property.ensure name="distro.built" location="${gwt.dev.staging.jar}" - message="GWT must be built before performing any tests. This can be fixed by running ant in the ${gwt.root} directory." /> - <limit failonerror="true" hours="${test.timeout}"> - <parallel threadsPerProcessor="${gwt.threadsPerProcessor}" - threadCount="${gwt.threadCount}"> - <!-- - The remote targets must be run sequentially or BrowserManager will queue - requests, which will cause some tests to timeout while waiting. - --> - <!--sequential> - <antcall target="test.dev.remote"/> - <antcall target="test.emma.remote"/> - <antcall target="test.web.remote"/> - <antcall target="test.draft.remote"/> - <antcall target="test.nometa.remote"/> - </sequential> - <antcall target="test.dev.selenium"/> - <antcall target="test.emma.selenium"/> - <antcall target="test.web.selenium"/> - <antcall target="test.draft.selenium"/> - <antcall target="test.nometa.selenium"/--> - <antcall target="test.dev.htmlunit"/> - <!--antcall target="test.emma.htmlunit"/> - <antcall target="test.web.htmlunit"/> - <antcall target="test.draft.htmlunit"/> - <antcall target="test.nometa.htmlunit"/--> - </parallel> - </limit> - - <fail - message="One or more junit tests failed for target: @{test.name} @{test.args}" - if="junit.failure" status="2" /> - </target> - - <macrodef name="countMarkedTests"> - <attribute name="annotation" default="NOT SET" /> - <attribute name="outputproperty" default="jsr303.marked.@{annotation}" /> - <sequential> - <!--TODO(nchalko) find a way to count annotations in windows --> - <exec dir="${basedir}" - executable="${basedir}/countMarkedTests.sh" - outputproperty="@{outputproperty}" - os="Mac OS X,Linux" - > - <arg line="@{annotation}" /> - </exec> - </sequential> - </macrodef> - - <target name="tck.report"> - <mkdir dir="${junit.out}/tck-report" /> - <mkdir dir="${junit.out}/tck-report/text" /> - - <!-- Greping for annotation currently only works on OS X and Linux --> - <!-- The reports will still run but the total count will not be reduced --> - <countMarkedTests annotation="Failing" /> - <countMarkedTests annotation="NonTckTest" /> - <countMarkedTests annotation="NotSupported" /> - - <echo message="Marked Failing = ${jsr303.marked.Failing}" /> - <echo message="Marked NonTckTest = ${jsr303.marked.NonTckTest}" /> - <echo message="Marked NotSupported = ${jsr303.marked.NotSupported}" /> - - <junitreport todir="${junit.out}/tck-report"> - <fileset dir="${junit.out}"> - <include name="*/reports/TEST-*.xml" /> - </fileset> - <report format="noframes" todir="${junit.out}/tck-report" styledir="style/html"> - <param name="markedFailing" expression="${jsr303.marked.Failing}" /> - <param name="markedNonTckTest" expression="${jsr303.marked.NonTckTest}" /> - <param name="markedNotSupported" expression="${jsr303.marked.NotSupported}" /> - </report> - <report format="noframes" todir="${junit.out}/tck-report/text" styledir="style/text"> - <param name="markedFailing" expression="${jsr303.marked.Failing}" /> - <param name="markedNonTckTest" expression="${jsr303.marked.NonTckTest}" /> - <param name="markedNotSupported" expression="${jsr303.marked.NotSupported}" /> - </report> - </junitreport> - - <concat taskname="JSR 303 TCK Result"> - <filelist> - <file name="${junit.out}/tck-report/text/junit-noframes.html" /> - </filelist> - </concat> - - </target> - - <target name="test.dev.htmlunit" - depends="compile, compile.tests" - description="Run dev-mode tests with HtmlUnit." - unless="test.dev.htmlunit.disable"> - <fileset id="test.dev.htmlunit.tests" dir="${javac.junit.out}" - includes="${gwt.junit.testcase.dev.includes}" - excludes="${gwt.junit.testcase.dev.excludes}" /> - <gwt.junit test.name="test.dev.htmlunit" - test.args="${test.args} -standardsMode " - test.jvmargs="${test.jvmargs}" - test.out="${junit.out}/dev-htmlunit" - test.cases="test.dev.htmlunit.tests" - haltonfailure="false" - > - <extraclasspaths> - <path refid="test.extraclasspath" /> - </extraclasspaths> - </gwt.junit> - - - </target> - -</project>
diff --git a/samples/validationtck/countMarkedTests.sh b/samples/validationtck/countMarkedTests.sh deleted file mode 100755 index 061b6d0..0000000 --- a/samples/validationtck/countMarkedTests.sh +++ /dev/null
@@ -1,6 +0,0 @@ -#!/bin/sh -name=$1 -count=$(grep -r @${name} test |wc -l) -echo "$((${count} -1))" - -
diff --git a/samples/validationtck/src/com/google/gwt/sample/validationtck/SampleValidationTck.gwt.xml b/samples/validationtck/src/com/google/gwt/sample/validationtck/SampleValidationTck.gwt.xml deleted file mode 100644 index 24885ee..0000000 --- a/samples/validationtck/src/com/google/gwt/sample/validationtck/SampleValidationTck.gwt.xml +++ /dev/null
@@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module rename-to="validationtck"> - <inherits name="com.google.gwt.user.User" /> - <inherits name="org.hibernate.validator.HibernateValidator" /> - <source path=""> - <exclude name="super" /> - </source> - <entry-point class="com.google.gwt.sample.validationtck.Tck" /> -</module> \ No newline at end of file
diff --git a/samples/validationtck/src/com/google/gwt/sample/validationtck/Tck.java b/samples/validationtck/src/com/google/gwt/sample/validationtck/Tck.java deleted file mode 100644 index f5fd5d3..0000000 --- a/samples/validationtck/src/com/google/gwt/sample/validationtck/Tck.java +++ /dev/null
@@ -1,31 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.sample.validationtck; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.RootPanel; - -/** - * Just a place holder Entry point. - */ -public class Tck implements EntryPoint { - - public void onModuleLoad() { - Label label = new Label("tck"); - RootPanel.get("view").add(label); - } -}
diff --git a/samples/validationtck/style/html/junit-noframes.xsl b/samples/validationtck/style/html/junit-noframes.xsl deleted file mode 100644 index c9759de..0000000 --- a/samples/validationtck/style/html/junit-noframes.xsl +++ /dev/null
@@ -1,507 +0,0 @@ -<?xml version="1.0"?> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" - xmlns:lxslt="http://xml.apache.org/xslt" - xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils"> -<xsl:output method="html" indent="yes" encoding="UTF-8" - doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" /> -<xsl:decimal-format decimal-separator="." grouping-separator="," /> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<xsl:param name="TITLE">JSR-303 TCK report</xsl:param> - -<!-- - - Modified from the default stylesheet. - Changed so counts are relative to the TOTAL tests in the TCK - ---> - -<xsl:param name="markedFailing" /> -<xsl:param name="markedNonTckTest" /> -<xsl:param name="markedNotSupported" /> - -<xsl:template match="testsuites"> - <html> - <head> - <title><xsl:value-of select="$TITLE"/></title> - <style type="text/css"> - body { - font:normal 68% verdana,arial,helvetica; - color:#000000; - } - table tr td, table tr th { - font-size: 68%; - } - table.details tr th{ - font-weight: bold; - text-align:left; - background:#a6caf0; - } - table.details tr td{ - background:#eeeee0; - } - - p { - line-height:1.5em; - margin-top:0.5em; margin-bottom:1.0em; - } - h1 { - margin: 0px 0px 5px; font: 165% verdana,arial,helvetica - } - h2 { - margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica - } - h3 { - margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica - } - h4 { - margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica - } - h5 { - margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica - } - h6 { - margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica - } - .Error { - font-weight:bold; color:red; - } - .Failure { - font-weight:bold; color:purple; - } - .Properties { - text-align:right; - } - </style> - <script type="text/javascript" language="JavaScript"> - var TestCases = new Array(); - var cur; - <xsl:for-each select="./testsuite"> - <xsl:apply-templates select="properties"/> - </xsl:for-each> - - </script> - <script type="text/javascript" language="JavaScript"><![CDATA[ - function displayProperties (name) { - var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1'); - var doc = win.document; - doc.open(); - doc.write("<html><head><title>Properties of " + name + "</title>"); - doc.write("<style>") - doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }"); - doc.write("table tr td, table tr th { font-size: 68%; }"); - doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }"); - doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }"); - doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }"); - doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }"); - doc.write("</style>"); - doc.write("</head><body>"); - doc.write("<h3>Properties of " + name + "</h3>"); - doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>"); - doc.write("<table class='properties'>"); - doc.write("<tr><th>Name</th><th>Value</th></tr>"); - for (prop in TestCases[name]) { - doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>"); - } - doc.write("</table>"); - doc.write("</body></html>"); - doc.close(); - win.focus(); - } - ]]> - </script> - </head> - <body> - <a name="top"></a> - <xsl:call-template name="pageHeader"/> - - <!-- Summary part --> - <xsl:call-template name="summary"/> - <hr size="1" width="95%" align="left"/> - - <!-- Package List part --> - <xsl:call-template name="packagelist"/> - <hr size="1" width="95%" align="left"/> - - <!-- For each package create its part --> - <xsl:call-template name="packages"/> - <hr size="1" width="95%" align="left"/> - - <!-- For each class create the part --> - <xsl:call-template name="classes"/> - - </body> - </html> -</xsl:template> - - - - <!-- ================================================================== --> - <!-- Write a list of all packages with an hyperlink to the anchor of --> - <!-- of the package name. --> - <!-- ================================================================== --> - <xsl:template name="packagelist"> - <h2>Packages</h2> - Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers. - <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> - <xsl:call-template name="testsuite.test.header"/> - <!-- list all packages recursively --> - <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]"> - <xsl:sort select="@package"/> - <xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/> - <xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/> - <xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/> - <xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/> - <xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/> - - <!-- write a summary for the package --> - <tr valign="top"> - <!-- set a nice color depending if there is an error/failure --> - <xsl:attribute name="class"> - <xsl:choose> - <xsl:when test="$failureCount > 0">Failure</xsl:when> - <xsl:when test="$errorCount > 0">Error</xsl:when> - </xsl:choose> - </xsl:attribute> - <td><a href="#{@package}"><xsl:value-of select="@package"/></a></td> - <td><xsl:value-of select="$testCount"/></td> - <td><xsl:value-of select="$errorCount"/></td> - <td><xsl:value-of select="$failureCount"/></td> - <td> - <xsl:call-template name="display-time"> - <xsl:with-param name="value" select="$timeCount"/> - </xsl:call-template> - </td> - <td><xsl:value-of select="$testsuites-in-package/@timestamp"/></td> - <td><xsl:value-of select="$testsuites-in-package/@hostname"/></td> - </tr> - </xsl:for-each> - </table> - </xsl:template> - - - <!-- ================================================================== --> - <!-- Write a package level report --> - <!-- It creates a table with values from the document: --> - <!-- Name | Tests | Errors | Failures | Time --> - <!-- ================================================================== --> - <xsl:template name="packages"> - <!-- create an anchor to this package name --> - <xsl:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]"> - <xsl:sort select="@package"/> - <a name="{@package}"></a> - <h3>Package <xsl:value-of select="@package"/></h3> - - <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> - <xsl:call-template name="testsuite.test.header"/> - - <!-- match the testsuites of this package --> - <xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/> - </table> - <a href="#top">Back to top</a> - <p/> - <p/> - </xsl:for-each> - </xsl:template> - - <xsl:template name="classes"> - <xsl:for-each select="testsuite"> - <xsl:sort select="@name"/> - <!-- create an anchor to this class name --> - <a name="{@name}"></a> - <h3>TestCase <xsl:value-of select="@name"/></h3> - - <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> - <xsl:call-template name="testcase.test.header"/> - <!-- - test can even not be started at all (failure to load the class) - so report the error directly - --> - <xsl:if test="./error"> - <tr class="Error"> - <td colspan="4"><xsl:apply-templates select="./error"/></td> - </tr> - </xsl:if> - <xsl:apply-templates select="./testcase" mode="print.test"/> - </table> - <div class="Properties"> - <a> - <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute> - Properties » - </a> - </div> - <p/> - - <a href="#top">Back to top</a> - </xsl:for-each> - </xsl:template> - - <xsl:template name="summary"> - <h2>Summary</h2> - <xsl:variable name="rawTestCount" select="258"/> - <!-- - rawTestCount from - jar -xf jsr303-tck-1.0.3.GA-sources.jar - grep -r \@Test org/hibernate/jsr303/tck/tests/| grep -v "enabled = false" | wc -l - --> - <xsl:variable name="testCount" select="($rawTestCount - $markedNotSupported)"/> - <xsl:variable name="testExecutedCount" select="sum(testsuite/@tests)"/> - <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/> - <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/> - <xsl:variable name="timeCount" select="sum(testsuite/@time)"/> - <xsl:variable name="passedCount" select="($testExecutedCount - $failureCount - $errorCount)"/> - <xsl:variable name="successRate" select="($passedCount) div $testCount"/> - <h3> - <xsl:value-of select="$passedCount" /> <xsl:text> of </xsl:text> - <xsl:value-of select="$testCount"/> <xsl:text> (</xsl:text> - <xsl:call-template name="display-percent"> - <xsl:with-param name="value" select="$successRate"/> - </xsl:call-template> - <xsl:text>) Pass with </xsl:text> - <xsl:value-of select="$failureCount"/> <xsl:text> Failures and </xsl:text> - <xsl:value-of select="$errorCount" /> <xsl:text> Errors.</xsl:text> - </h3> - - <xsl:if test="($failureCount + $errorCount) != ($markedFailing)"> - <p style="color:red"><strong>WARINING</strong> expected Failures + Errors to match the - <xsl:value-of select="$markedFailing" /> - test marked @Failing</p> - </xsl:if> - <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> - <tr valign="top"> - <th>Tests</th> - <th>Passed</th> - <th>Failures</th> - <th>Errors</th> - <th>Success rate</th> - <th>Time</th> - </tr> - <tr valign="top"> - <xsl:attribute name="class"> - <xsl:choose> - <xsl:when test="$failureCount > 0">Failure</xsl:when> - <xsl:when test="$errorCount > 0">Error</xsl:when> - </xsl:choose> - </xsl:attribute> - <td><xsl:value-of select="$testCount"/></td> - <td><xsl:value-of select="$passedCount"/></td> - <td><xsl:value-of select="$failureCount"/></td> - <td><xsl:value-of select="$errorCount"/></td> - <td> - <xsl:call-template name="display-percent"> - <xsl:with-param name="value" select="$successRate"/> - </xsl:call-template> - </td> - <td> - <xsl:call-template name="display-time"> - <xsl:with-param name="value" select="$timeCount"/> - </xsl:call-template> - </td> - - </tr> - </table> - <table border="0" width="95%"> - <tr> - <td style="text-align: justify;"> - Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated. - </td> - </tr> - </table> - </xsl:template> - - <!-- - Write properties into a JavaScript data structure. - This is based on the original idea by Erik Hatcher (ehatcher@apache.org) - --> - <xsl:template match="properties"> - cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array(); - <xsl:for-each select="property"> - <xsl:sort select="@name"/> - cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>'; - </xsl:for-each> - </xsl:template> - -<!-- Page HEADER --> -<xsl:template name="pageHeader"> - <h1><xsl:value-of select="$TITLE"/></h1> - <table width="100%"> - <tr> - <td align="left"></td> - <td align="right">Designed for use with <a href='http://www.junit.org'>JUnit</a> and <a href='http://ant.apache.org/ant'>Ant</a>.</td> - </tr> - </table> - <hr size="1"/> -</xsl:template> - -<xsl:template match="testsuite" mode="header"> - <tr valign="top"> - <th width="80%">Name</th> - <th>Tests</th> - <th>Errors</th> - <th>Failures</th> - <th nowrap="nowrap">Time(s)</th> - </tr> -</xsl:template> - -<!-- class header --> -<xsl:template name="testsuite.test.header"> - <tr valign="top"> - <th width="80%">Name</th> - <th>Tests</th> - <th>Errors</th> - <th>Failures</th> - <th nowrap="nowrap">Time(s)</th> - <th nowrap="nowrap">Time Stamp</th> - <th>Host</th> - </tr> -</xsl:template> - -<!-- method header --> -<xsl:template name="testcase.test.header"> - <tr valign="top"> - <th>Name</th> - <th>Status</th> - <th width="80%">Type</th> - <th nowrap="nowrap">Time(s)</th> - </tr> -</xsl:template> - - -<!-- class information --> -<xsl:template match="testsuite" mode="print.test"> - <tr valign="top"> - <!-- set a nice color depending if there is an error/failure --> - <xsl:attribute name="class"> - <xsl:choose> - <xsl:when test="@failures[.> 0]">Failure</xsl:when> - <xsl:when test="@errors[.> 0]">Error</xsl:when> - </xsl:choose> - </xsl:attribute> - - <!-- print testsuite information --> - <td><a href="#{@name}"><xsl:value-of select="@name"/></a></td> - <td><xsl:value-of select="@tests"/></td> - <td><xsl:value-of select="@errors"/></td> - <td><xsl:value-of select="@failures"/></td> - <td> - <xsl:call-template name="display-time"> - <xsl:with-param name="value" select="@time"/> - </xsl:call-template> - </td> - <td><xsl:apply-templates select="@timestamp"/></td> - <td><xsl:apply-templates select="@hostname"/></td> - </tr> -</xsl:template> - -<xsl:template match="testcase" mode="print.test"> - <tr valign="top"> - <xsl:attribute name="class"> - <xsl:choose> - <xsl:when test="failure | error">Error</xsl:when> - </xsl:choose> - </xsl:attribute> - <td><xsl:value-of select="@name"/></td> - <xsl:choose> - <xsl:when test="failure"> - <td>Failure</td> - <td><xsl:apply-templates select="failure"/></td> - </xsl:when> - <xsl:when test="error"> - <td>Error</td> - <td><xsl:apply-templates select="error"/></td> - </xsl:when> - <xsl:otherwise> - <td>Success</td> - <td></td> - </xsl:otherwise> - </xsl:choose> - <td> - <xsl:call-template name="display-time"> - <xsl:with-param name="value" select="@time"/> - </xsl:call-template> - </td> - </tr> -</xsl:template> - - -<xsl:template match="failure"> - <xsl:call-template name="display-failures"/> -</xsl:template> - -<xsl:template match="error"> - <xsl:call-template name="display-failures"/> -</xsl:template> - -<!-- Style for the error and failure in the tescase template --> -<xsl:template name="display-failures"> - <xsl:choose> - <xsl:when test="not(@message)">N/A</xsl:when> - <xsl:otherwise> - <xsl:value-of select="@message"/> - </xsl:otherwise> - </xsl:choose> - <!-- display the stacktrace --> - <code> - <br/><br/> - <xsl:call-template name="br-replace"> - <xsl:with-param name="word" select="."/> - </xsl:call-template> - </code> - <!-- the later is better but might be problematic for non-21" monitors... --> - <!--pre><xsl:value-of select="."/></pre--> -</xsl:template> - -<xsl:template name="JS-escape"> - <xsl:param name="string"/> - <xsl:param name="tmp1" select="stringutils:replace(string($string),'\','\\')"/> - <xsl:param name="tmp2" select="stringutils:replace(string($tmp1),"'","\'")"/> - <xsl:value-of select="$tmp2"/> -</xsl:template> - - -<!-- - template that will convert a carriage return into a br tag - @param word the text from which to convert CR to BR tag ---> -<xsl:template name="br-replace"> - <xsl:param name="word"/> - <xsl:choose> - <xsl:when test="contains($word, '
')"> - <xsl:value-of select="substring-before($word, '
')"/> - <br/> - <xsl:call-template name="br-replace"> - <xsl:with-param name="word" select="substring-after($word, '
')"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$word"/> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:template name="display-time"> - <xsl:param name="value"/> - <xsl:value-of select="format-number($value,'0.000')"/> -</xsl:template> - -<xsl:template name="display-percent"> - <xsl:param name="value"/> - <xsl:value-of select="format-number($value,'0.00%')"/> -</xsl:template> - -</xsl:stylesheet>
diff --git a/samples/validationtck/style/text/junit-noframes.xsl b/samples/validationtck/style/text/junit-noframes.xsl deleted file mode 100644 index f0e3e26..0000000 --- a/samples/validationtck/style/text/junit-noframes.xsl +++ /dev/null
@@ -1,72 +0,0 @@ -<?xml version="1.0"?> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" - xmlns:lxslt="http://xml.apache.org/xslt" - xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils"> -<xsl:output method="text" indent="no" encoding="UTF-8" /> -<xsl:decimal-format decimal-separator="." grouping-separator="," /> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<xsl:param name="TITLE">JSR-303 TCK report</xsl:param> - -<!-- - - Modified from the default stylesheet. - Changed so counts are relative to the TOTAL tests in the TCK - ---> - -<xsl:param name="markedFailing" /> -<xsl:param name="markedNonTckTest" /> -<xsl:param name="markedNotSupported" /> -<xsl:template match="testsuites"> - - <xsl:variable name="rawTestCount" select="258"/> - <!-- - rawTestCount from - jar -xf jsr303-tck-1.0.3.GA-sources.jar - grep -r \@Test org/hibernate/jsr303/tck/tests/| grep -v "enabled = false" | wc -l - --> - <xsl:variable name="testCount" select="($rawTestCount - $markedNotSupported)"/> - <xsl:variable name="testExecutedCount" select="sum(testsuite/@tests)"/> - <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/> - <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/> - <xsl:variable name="timeCount" select="sum(testsuite/@time)"/> - <xsl:variable name="passedCount" select="($testExecutedCount - $failureCount - $errorCount)"/> - <xsl:variable name="successRate" select="($passedCount) div $testCount"/> - <xsl:if test="($failureCount + $errorCount) != ($markedFailing)"> - <xsl:text>WARINING expected Failures + Errors to match the </xsl:text> - <xsl:value-of select="$markedFailing" /> - <xsl:text> test marked @Failing -</xsl:text> - </xsl:if> - <xsl:value-of select="$passedCount" /> <xsl:text> of </xsl:text> - <xsl:value-of select="$testCount"/> <xsl:text> (</xsl:text> - <xsl:call-template name="display-percent"> - <xsl:with-param name="value" select="$successRate"/> - </xsl:call-template> - <xsl:text>) Pass with </xsl:text> - <xsl:value-of select="$failureCount"/> <xsl:text> Failures and </xsl:text> - <xsl:value-of select="$errorCount" /> <xsl:text> Errors.</xsl:text> -</xsl:template> - -<xsl:template name="display-percent"> - <xsl:param name="value"/> - <xsl:value-of select="format-number($value,'0.00%')"/> -</xsl:template> - -</xsl:stylesheet>
diff --git a/samples/validationtck/test/log4j.properties b/samples/validationtck/test/log4j.properties deleted file mode 100644 index bf638d2..0000000 --- a/samples/validationtck/test/log4j.properties +++ /dev/null
@@ -1,5 +0,0 @@ -#log4j configuration, needed by hibernate validator. -log4j.rootLogger=INFO, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/Jsr303Tck.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/Jsr303Tck.gwt.xml deleted file mode 100644 index 73bb554..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/Jsr303Tck.gwt.xml +++ /dev/null
@@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -This is a HACK, is not a complete Validation TCK solution. -It is only enough to run the tests in the GWT Validation TCK. ---> -<module> - <inherits name='com.google.gwt.validation.Validation' /> - <inherits name='org.jboss.test.audit.JbossTestAudit' /> - <inherits name='org.jboss.testharness.JbossTestHarness' /> - <inherits name='org.testng.TestNg' /> - <source path=""> - <include name="common/*.java" /> - <include name="util/*.java" /> - <exclude name="util/StandaloneContainersImpl.java" /> - <exclude name="util/TckTestSuite*.java" /> - <exclude name="util/UtilJreSuite.java" /> - </source> - <super-source path="super" /> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/common/TCKValidationProvider.java b/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/common/TCKValidationProvider.java deleted file mode 100644 index cfd70d5..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/common/TCKValidationProvider.java +++ /dev/null
@@ -1,79 +0,0 @@ -// $Id: TCKValidationProvider.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jsr303.tck.common; - -import javax.validation.Configuration; -import javax.validation.MessageInterpolator; -import javax.validation.Validator; -import javax.validation.ValidatorContext; -import javax.validation.ValidatorFactory; -import javax.validation.TraversableResolver; -import javax.validation.ConstraintValidatorFactory; -import javax.validation.spi.BootstrapState; -import javax.validation.spi.ConfigurationState; -import javax.validation.spi.ValidationProvider; - -/** - * - * Modified by Google: - * <ul> - * <li>Replaced cast with a simple new.</li> - * </ul> - * @author Hardy Ferentschik - */ -public class TCKValidationProvider implements ValidationProvider<TCKValidatorConfiguration> { - - public TCKValidatorConfiguration createSpecializedConfiguration(BootstrapState state) { - return new TCKValidatorConfiguration( this ); - } - - public Configuration<?> createGenericConfiguration(BootstrapState state) { - return new TCKValidatorConfiguration( this ); - } - - public ValidatorFactory buildValidatorFactory(ConfigurationState configurationState) { - return new DummyValidatorFactory(); - } - - public static class DummyValidatorFactory implements ValidatorFactory { - - public Validator getValidator() { - throw new UnsupportedOperationException(); - } - - public ValidatorContext usingContext() { - throw new UnsupportedOperationException(); - } - - public MessageInterpolator getMessageInterpolator() { - throw new UnsupportedOperationException(); - } - - public TraversableResolver getTraversableResolver() { - throw new UnsupportedOperationException(); - } - - public ConstraintValidatorFactory getConstraintValidatorFactory() { - throw new UnsupportedOperationException(); - } - - public <T> T unwrap(Class<T> type) { - throw new UnsupportedOperationException(); - } - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java b/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java deleted file mode 100644 index d308384..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java +++ /dev/null
@@ -1,85 +0,0 @@ -// $Id: TCKValidatorConfiguration.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jsr303.tck.common; - -import javax.validation.Configuration; -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; -import javax.validation.ValidatorFactory; -import javax.validation.spi.ValidationProvider; - -/** - * Modified by Google: - * <ul> - * <li>Changed InputStream to String</li> - * </ul> - * @author Hardy Ferentschik - */ -public class TCKValidatorConfiguration implements Configuration<TCKValidatorConfiguration> { - private final ValidationProvider provider; - - public TCKValidatorConfiguration() { - provider = null; - } - - public TCKValidatorConfiguration(ValidationProvider provider) { - this.provider = provider; - } - - public TCKValidatorConfiguration ignoreXmlConfiguration() { - throw new UnsupportedOperationException(); - } - - public TCKValidatorConfiguration messageInterpolator(MessageInterpolator interpolator) { - throw new UnsupportedOperationException(); - } - - public TCKValidatorConfiguration traversableResolver(TraversableResolver resolver) { - throw new UnsupportedOperationException(); - } - - public TCKValidatorConfiguration constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) { - throw new UnsupportedOperationException(); - } - - public TCKValidatorConfiguration addMapping(String stream) { - throw new UnsupportedOperationException(); - } - - public TCKValidatorConfiguration addProperty(String name, String value) { - throw new UnsupportedOperationException(); - } - - public MessageInterpolator getDefaultMessageInterpolator() { - throw new UnsupportedOperationException(); - } - - public TraversableResolver getDefaultTraversableResolver() { - throw new UnsupportedOperationException(); - } - - public ConstraintValidatorFactory getDefaultConstraintValidatorFactory() { - throw new UnsupportedOperationException(); - } - - public ValidatorFactory buildValidatorFactory() { - return provider.buildValidatorFactory( null ); - } - -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java deleted file mode 100644 index 2f753d6..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java +++ /dev/null
@@ -1,299 +0,0 @@ -// $Id: MessageInterpolationTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jsr303.tck.tests.messageinterpolation; - -import java.util.Date; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.shared.GwtLocale; -import com.google.gwt.i18n.shared.GwtLocaleFactory; - -import java.util.Set; -import javax.validation.ConstraintViolation; -import javax.validation.MessageInterpolator; -import javax.validation.Validator; -import javax.validation.constraints.Max; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Past; -import javax.validation.constraints.Size; -import javax.validation.metadata.ConstraintDescriptor; - -import org.jboss.test.audit.annotations.SpecAssertion; -import org.jboss.test.audit.annotations.SpecAssertions; -import org.jboss.testharness.AbstractTest; -import org.jboss.testharness.impl.packaging.Artifact; -import org.jboss.testharness.impl.packaging.ArtifactType; -import org.jboss.testharness.impl.packaging.Classes; -import org.jboss.testharness.impl.packaging.IntegrationTest; -import org.jboss.testharness.impl.packaging.Resource; -import org.jboss.testharness.impl.packaging.Resources; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -import org.hibernate.jsr303.tck.util.TestUtil; -import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages; -import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations; -import static org.hibernate.jsr303.tck.util.TestUtil.getDefaultMessageInterpolator; -import static org.hibernate.jsr303.tck.util.TestUtil.getValidatorUnderTest; - -/** - * Modified by Google: - * <ul> - * <li>Changed Local to GwtLocale</li> - * </ul> - * @author Hardy Ferentschik - */ -@Artifact(artifactType = ArtifactType.JSR303) -@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) -@Resources({ - @Resource(source = "ValidationMessages.properties", - destination = "WEB-INF/classes/ValidationMessages.properties"), - @Resource(source = "ValidationMessages_de.properties", - destination = "WEB-INF/classes/ValidationMessages_de.properties") -}) -@IntegrationTest -public class MessageInterpolationTest extends AbstractTest { - - @Test - @SpecAssertion(section = "4.3.1", id = "a") - public void testDefaultMessageInterpolatorIsNotNull() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - assertNotNull( interpolator, "Each bean validation provider must provide a default message interpolator." ); - } - - @Test - @SpecAssertions({ - @SpecAssertion(section = "4.3.1", id = "e"), - @SpecAssertion(section = "4.3.1.1", id = "a") - }) - public void testSuccessfulInterpolationOfValidationMessagesValue() { - - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "replacement worked"; - String actual = interpolator.interpolate( "{foo}", context ); - assertEquals( actual, expected, "Wrong substitution" ); - - expected = "replacement worked replacement worked"; - actual = interpolator.interpolate( "{foo} {foo}", context ); - assertEquals( actual, expected, "Wrong substitution" ); - - expected = "This replacement worked just fine"; - actual = interpolator.interpolate( "This {foo} just fine", context ); - assertEquals( actual, expected, "Wrong substitution" ); - - expected = "{} replacement worked {unknown}"; - actual = interpolator.interpolate( "{} {foo} {unknown}", context ); - assertEquals( actual, expected, "Wrong substitution" ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "b") - public void testRecursiveMessageInterpolation() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "fubar" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "recursion worked"; - String actual = interpolator.interpolate( ( String ) descriptor.getAttributes().get( "message" ), context ); - assertEquals( - expected, actual, "Expansion should be recursive" - ); - } - - @Test - @SpecAssertion(section = "4.3.1", id = "d") - public void testMessagesCanBeOverriddenAtConstraintLevel() { - Validator validator = TestUtil.getValidatorUnderTest(); - Set<ConstraintViolation<DummyEntity>> constraintViolations = validator.validateProperty( - new DummyEntity(), "snafu" - ); - assertCorrectNumberOfViolations( constraintViolations, 1 ); - assertCorrectConstraintViolationMessages( - constraintViolations, "messages can also be overridden at constraint declaration." - ); - } - - - @Test - @SpecAssertions({ - @SpecAssertion(section = "4.3.1", id = "f"), - @SpecAssertion(section = "4.3.1", id = "g"), - @SpecAssertion(section = "4.3.1", id = "h") - }) - public void testLiteralCurlyBraces() { - - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "{"; - String actual = interpolator.interpolate( "\\{", context ); - assertEquals( actual, expected, "Wrong substitution" ); - - expected = "}"; - actual = interpolator.interpolate( "\\}", context ); - assertEquals( actual, expected, "Wrong substitution" ); - - expected = "\\"; - actual = interpolator.interpolate( "\\", context ); - assertEquals( actual, expected, "Wrong substitution" ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "a") - public void testUnSuccessfulInterpolation() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "foo"; // missing {} - String actual = interpolator.interpolate( "foo", context ); - assertEquals( actual, expected, "Wrong substitution" ); - - expected = "#{foo {}"; - actual = interpolator.interpolate( "#{foo {}", context ); - assertEquals( actual, expected, "Wrong substitution" ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "a") - public void testUnknownTokenInterpolation() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "{bar}"; // unknown token {} - String actual = interpolator.interpolate( "{bar}", context ); - assertEquals( actual, expected, "Wrong substitution" ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "c") - public void testParametersAreExtractedFromBeanValidationProviderBundle() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( Person.class, "birthday" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String key = "{javax.validation.constraints.Past.message}"; // Past is a built-in constraint so the provider must provide a default message - String actual = interpolator.interpolate( key, context ); - assertFalse( - key.equals( actual ), - "There should have been a message interpolation from the bean validator provider bundle." - ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "g") - public void testConstraintAttributeValuesAreInterpolated() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "bar" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "size must be between 5 and 10"; - String actual = interpolator.interpolate( ( String ) descriptor.getAttributes().get( "message" ), context ); - assertEquals( actual, expected, "Wrong substitution" ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "h") - public void testMessageInterpolationWithLocale() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String expected = "kann nicht null sein"; - // TODO(nchalko) i18n - //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class); - GwtLocale german = null; //localeFactory.fromComponents("de","","",""); - String actual = interpolator.interpolate( - ( String ) descriptor.getAttributes().get( "message" ), context, german - ); - assertEquals( actual, expected, "Wrong substitution" ); - } - - @Test - @SpecAssertion(section = "4.3.1.1", id = "i") - public void testIfNoLocaleIsSpecifiedTheDefaultLocaleIsAssumed() { - MessageInterpolator interpolator = getDefaultMessageInterpolator(); - ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" ); - String messageTemplate = ( String ) descriptor.getAttributes().get( "message" ); - MessageInterpolator.Context context = new TestContext( descriptor ); - - String messageInterpolatedWithNoLocale = interpolator.interpolate( messageTemplate, context ); - // TODO(nchalko) i18n - //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class); - GwtLocale defaultLocale = null; // localeFactory.getDefault(); - String messageInterpolatedWithDefaultLocale = interpolator.interpolate( - messageTemplate, context,defaultLocale - ); - - assertEquals( messageInterpolatedWithNoLocale, messageInterpolatedWithDefaultLocale, "Wrong substitution" ); - } - - private ConstraintDescriptor<?> getDescriptorFor(Class<?> clazz, String propertyName) { - Validator validator = getValidatorUnderTest(); - return validator.getConstraintsForClass( clazz ) - .getConstraintsForProperty( propertyName ) - .getConstraintDescriptors() - .iterator() - .next(); - } - - public class TestContext implements MessageInterpolator.Context { - ConstraintDescriptor<?> descriptor; - - TestContext(ConstraintDescriptor<?> descriptor) { - this.descriptor = descriptor; - } - - public ConstraintDescriptor<?> getConstraintDescriptor() { - return descriptor; - } - - public Object getValidatedValue() { - return null; - } - } - - public class DummyEntity { - @NotNull - String foo; - - @Size(min = 5, max = 10, message = "size must be between {min} and {max}") - String bar; - - @Max(value = 10, message = "{replace.in.user.bundle1}") - String fubar; - - @NotNull(message = "messages can also be overridden at constraint declaration.") - String snafu; - } - - public class Person { - - String name; - - @Past - Date birthday; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java deleted file mode 100644 index 74bb26d..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java +++ /dev/null
@@ -1,118 +0,0 @@ -// $Id: ValidationTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.hibernate.jsr303.tck.tests.validation; - -import java.util.ArrayList; -import java.util.List; -import javax.validation.Configuration; -import javax.validation.Validation; -import javax.validation.ValidationProviderResolver; -import javax.validation.ValidatorFactory; -import javax.validation.bootstrap.GenericBootstrap; -import javax.validation.bootstrap.ProviderSpecificBootstrap; -import javax.validation.spi.ValidationProvider; - -import org.jboss.test.audit.annotations.SpecAssertion; -import org.jboss.test.audit.annotations.SpecAssertions; -import org.jboss.testharness.AbstractTest; -import org.jboss.testharness.impl.packaging.Artifact; -import org.jboss.testharness.impl.packaging.ArtifactType; -import org.jboss.testharness.impl.packaging.Classes; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import org.testng.annotations.Test; - -import org.hibernate.jsr303.tck.common.TCKValidationProvider; -import org.hibernate.jsr303.tck.common.TCKValidatorConfiguration; -import org.hibernate.jsr303.tck.util.TestUtil; - -/** - * Tests for the implementation of <code>Validation</code>. - * - *Modified by google. - *<ul> - *<li>Removed testVerifyMethodsOfValidationObjects - *</ul - * - * @author Hardy Ferentschik - */ -@Artifact(artifactType = ArtifactType.JSR303) -@Classes({ - TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class, TCKValidationProvider.class, - TCKValidationProvider.DummyValidatorFactory.class, TCKValidatorConfiguration.class -}) -public class ValidationTest extends AbstractTest { - - @Test - @SpecAssertion(section = "4.4.5", id = "a") - public void testBuildDefaultValidatorFactory() { - ValidatorFactory defaultFactory = Validation.buildDefaultValidatorFactory(); - assertNotNull( defaultFactory, "We should be able to get a factory." ); - - ValidatorFactory defaultProviderFactory = Validation.byDefaultProvider().configure().buildValidatorFactory(); - assertNotNull( defaultProviderFactory, "We should be able to get a factory." ); - - assertEquals( defaultFactory.getClass(), defaultFactory.getClass(), "The factories have to be identical." ); - } - - @Test - @SpecAssertions({ - @SpecAssertion(section = "4.4.5", id = "b"), - @SpecAssertion(section = "4.4.5", id = "e") - }) - public void testCustomValidationProviderResolution() { - ValidationProviderResolver resolver = new ValidationProviderResolver() { - - public List<ValidationProvider<?>> getValidationProviders() { - List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>(); - list.add( new TCKValidationProvider() ); - return list; - } - }; - - GenericBootstrap bootstrap = Validation.byDefaultProvider(); - Configuration<?> config = bootstrap.providerResolver( resolver ).configure(); - - ValidatorFactory factory = config.buildValidatorFactory(); - assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory ); - } - - @Test - @SpecAssertions({ - @SpecAssertion(section = "4.4.5", id = "c"), - @SpecAssertion(section = "4.4.5", id = "e") - }) - public void testSpecificValidationProvider() { - ValidationProviderResolver resolver = new ValidationProviderResolver() { - - public List<ValidationProvider<?>> getValidationProviders() { - List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>(); - list.add( new TCKValidationProvider() ); - return list; - } - }; - - // with resolver - ProviderSpecificBootstrap<TCKValidatorConfiguration> bootstrap = Validation.byProvider( TCKValidationProvider.class ); - Configuration<?> config = bootstrap.providerResolver( resolver ).configure(); - ValidatorFactory factory = config.buildValidatorFactory(); - assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory ); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/util/TestUtil.java b/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/util/TestUtil.java deleted file mode 100644 index f93a305..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/util/TestUtil.java +++ /dev/null
@@ -1,406 +0,0 @@ -// $Id: TestUtil.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* - * JBoss, Home of Professional Open Source Copyright 2009, Red Hat, Inc. and/or - * its affiliates, and individual contributors by the @authors tag. See the - * copyright.txt in the distribution for a full listing of individual - * contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by - * applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS - * OF ANY KIND, either express or implied. See the License for the specific - * language governing permissions and limitations under the License. - */ - -package org.hibernate.jsr303.tck.util; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import javax.validation.Configuration; -import javax.validation.ConstraintViolation; -import javax.validation.MessageInterpolator; -import javax.validation.Path; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import javax.validation.Validation; -import javax.validation.bootstrap.ProviderSpecificBootstrap; -import javax.validation.metadata.ConstraintDescriptor; -import javax.validation.metadata.ElementDescriptor; -import javax.validation.metadata.PropertyDescriptor; -import javax.validation.spi.ValidationProvider; - -/** - * Modified by Google. - * <ul> - * <li>Use RegExp instead of Pattern</li> - * </ul> - * @author Hardy Ferentschik - */ -public final class TestUtil { - - private static String VALIDATION_PROVIDER_TEST_CLASS = "validation.provider"; - - private static ValidationProvider<?> validationProviderUnderTest; - - private TestUtil() { - } - - public static Validator getValidatorUnderTest() { - return getValidatorFactoryUnderTest().getValidator(); - } - - public static ValidationProvider<?> getValidationProviderUnderTest() { - if (validationProviderUnderTest == null) { - instantiateValidationProviderUnderTest(); - } - return validationProviderUnderTest; - } - - public static ValidatorFactory getValidatorFactoryUnderTest() { - Configuration<?> config = getConfigurationUnderTest(); - return config.buildValidatorFactory(); - } - - public static Configuration<?> getConfigurationUnderTest() { - if (validationProviderUnderTest == null) { - instantiateValidationProviderUnderTest(); - } - - ProviderSpecificBootstrap<?> bootstrap = - Validation.byProvider(validationProviderUnderTest.getClass()); - return bootstrap.configure(); - } - - public static MessageInterpolator getDefaultMessageInterpolator() { - Configuration<?> config = getConfigurationUnderTest(); - return config.getDefaultMessageInterpolator(); - } - - public static <T> void assertCorrectNumberOfViolations( - Set<ConstraintViolation<T>> violations, int expectedViolations) { - assertEquals(violations.size(), expectedViolations, - "Wrong number of constraint violations. Expected: " - + expectedViolations + " Actual: " + violations.size()); - } - - public static <T> void assertCorrectConstraintViolationMessages( - Set<ConstraintViolation<T>> violations, String... messages) { - List<String> actualMessages = new ArrayList<String>(); - for (ConstraintViolation<?> violation : violations) { - actualMessages.add(violation.getMessage()); - } - - assertTrue(actualMessages.size() == messages.length, - "Wrong number or error messages. Expected: " + messages.length - + " Actual: " + actualMessages.size()); - - for (String expectedMessage : messages) { - assertTrue(actualMessages.contains(expectedMessage), "The message '" - + expectedMessage - + "' should have been in the list of actual messages: " - + actualMessages); - actualMessages.remove(expectedMessage); - } - assertTrue(actualMessages.isEmpty(), - "Actual messages contained more messages as specified expected messages"); - } - - public static <T> void assertCorrectConstraintTypes( - Set<ConstraintViolation<T>> violations, - Class<?>... expectedConsraintTypes) { - List<String> actualConstraintTypes = new ArrayList<String>(); - for (ConstraintViolation<?> violation : violations) { - actualConstraintTypes.add(((Annotation) violation.getConstraintDescriptor().getAnnotation()).annotationType().getName()); - } - - assertEquals(expectedConsraintTypes.length, actualConstraintTypes.size(), - "Wrong number of constraint types."); - - for (Class<?> expectedConstraintType : expectedConsraintTypes) { - assertTrue( - actualConstraintTypes.contains(expectedConstraintType.getName()), - "The constraint type " + expectedConstraintType.getName() - + " is not in the list of actual violated constraint types: " - + actualConstraintTypes); - } - } - - public static <T> void assertCorrectPropertyPaths( - Set<ConstraintViolation<T>> violations, String... propertyPaths) { - List<Path> propertyPathsOfViolations = new ArrayList<Path>(); - for (ConstraintViolation<?> violation : violations) { - propertyPathsOfViolations.add(violation.getPropertyPath()); - } - - assertEquals(propertyPaths.length, propertyPathsOfViolations.size(), - "Wrong number of property paths. Expected: " + propertyPaths.length - + " Actual: " + propertyPathsOfViolations.size()); - - for (String propertyPath : propertyPaths) { - Path expectedPath = PathImpl.createPathFromString(propertyPath); - boolean containsPath = false; - for (Path actualPath : propertyPathsOfViolations) { - if (assertEqualPaths(expectedPath, actualPath)) { - containsPath = true; - break; - } - } - if (!containsPath) { - fail(expectedPath - + " is not in the list of path instances contained in the actual constraint violations: " - + propertyPathsOfViolations); - } - } - } - - public static <T> void assertConstraintViolation( - ConstraintViolation<T> violation, Class<?> rootBean, Object invalidValue, - String propertyPath) { - Path expectedPath = PathImpl.createPathFromString(propertyPath); - if (!assertEqualPaths(violation.getPropertyPath(), expectedPath)) { - fail("Property paths differ. Actual: " + violation.getPropertyPath() - + " Expected: " + expectedPath); - } - - assertEquals(violation.getRootBeanClass(), rootBean, "Wrong root bean."); - assertEquals(violation.getInvalidValue(), invalidValue, - "Wrong invalid value."); - } - - public static boolean assertEqualPaths(Path p1, Path p2) { - Iterator<Path.Node> p1Iterator = p1.iterator(); - Iterator<Path.Node> p2Iterator = p2.iterator(); - while (p1Iterator.hasNext()) { - Path.Node p1Node = p1Iterator.next(); - if (!p2Iterator.hasNext()) { - return false; - } - Path.Node p2Node = p2Iterator.next(); - - // do the comparison on the node values - if (p2Node.getName() == null) { - if (p1Node.getName() != null) { - return false; - } - } else if (!p2Node.getName().equals(p1Node.getName())) { - return false; - } - - if (p2Node.isInIterable() != p1Node.isInIterable()) { - return false; - } - - if (p2Node.getIndex() == null) { - if (p1Node.getIndex() != null) { - return false; - } - } else if (!p2Node.getIndex().equals(p1Node.getIndex())) { - return false; - } - - if (p2Node.getKey() == null) { - if (p1Node.getKey() != null) { - return false; - } - } else if (!p2Node.getKey().equals(p1Node.getKey())) { - return false; - } - } - - return !p2Iterator.hasNext(); - } - - public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, - String property) { - Validator validator = getValidatorUnderTest(); - return validator.getConstraintsForClass(clazz).getConstraintsForProperty( - property); - } - - public static Set<ConstraintDescriptor<?>> getConstraintDescriptorsFor( - Class<?> clazz, String property) { - ElementDescriptor elementDescriptor = getPropertyDescriptor(clazz, property); - return elementDescriptor.getConstraintDescriptors(); - } - - public static Object getInputStreamForPath(String path) { - - return null; - } - - private static <U extends ValidationProvider<?>> void instantiateValidationProviderUnderTest() { - validationProviderUnderTest = GWT.create(ValidationProvider.class); - } - - public static class PathImpl implements Path { - - /** - * Regular expression used to split a string path into its elements. - * - * @see <a href="http://www.regexplanet.com/simple/index.jsp">Regular - * expression tester</a> - */ - private static final RegExp pathPattern = RegExp.compile("(\\w+)(\\[(\\w*)\\])?(\\.(.*))*"); - - private static final String PROPERTY_PATH_SEPARATOR = "."; - - private final List<Node> nodeList; - - public static PathImpl createPathFromString(String propertyPath) { - if (propertyPath == null) { - throw new IllegalArgumentException( - "null is not allowed as property path."); - } - - if (propertyPath.length() == 0) { - return createNewPath(null); - } - - return parseProperty(propertyPath); - } - - public static PathImpl createNewPath(String name) { - PathImpl path = new PathImpl(); - NodeImpl node = new NodeImpl(name); - path.addNode(node); - return path; - } - - private PathImpl() { - nodeList = new ArrayList<Node>(); - } - - public void addNode(Node node) { - nodeList.add(node); - } - - public Iterator<Path.Node> iterator() { - return nodeList.iterator(); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - Iterator<Path.Node> iter = iterator(); - while (iter.hasNext()) { - Node node = iter.next(); - builder.append(node.toString()); - if (iter.hasNext()) { - builder.append(PROPERTY_PATH_SEPARATOR); - } - } - return builder.toString(); - } - - private static PathImpl parseProperty(String property) { - PathImpl path = new PathImpl(); - String tmp = property; - do { - MatchResult matcher = pathPattern.exec(tmp); - if (matcher != null) { - String value = matcher.getGroup(1); - String indexed = matcher.getGroup(2); - String index = matcher.getGroup(3); - NodeImpl node = new NodeImpl(value); - if (indexed != null) { - node.setInIterable(true); - } - if (index != null && index.length() > 0) { - try { - Integer i = Integer.parseInt(index); - node.setIndex(i); - } catch (NumberFormatException e) { - node.setKey(index); - } - } - path.addNode(node); - tmp = matcher.getGroup(5); - } else { - throw new IllegalArgumentException("Unable to parse property path " - + property); - } - } while (tmp != null); - return path; - } - } - - public static class NodeImpl implements Path.Node { - - private static final String INDEX_OPEN = "["; - private static final String INDEX_CLOSE = "]"; - - private final String name; - private boolean isInIterable; - private Integer index; - private Object key; - - public NodeImpl(String name) { - this.name = name; - } - - NodeImpl(Path.Node node) { - this.name = node.getName(); - this.isInIterable = node.isInIterable(); - this.index = node.getIndex(); - this.key = node.getKey(); - } - - public String getName() { - return name; - } - - public boolean isInIterable() { - return isInIterable; - } - - public void setInIterable(boolean inIterable) { - isInIterable = inIterable; - } - - public Integer getIndex() { - return index; - } - - public void setIndex(Integer index) { - isInIterable = true; - this.index = index; - } - - public Object getKey() { - return key; - } - - public void setKey(Object key) { - isInIterable = true; - this.key = key; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(name == null ? "" : name); - if (isInIterable) { - builder.append(INDEX_OPEN); - if (getIndex() != null) { - builder.append(getIndex()); - } else if (getKey() != null) { - builder.append(getKey()); - } - builder.append(INDEX_CLOSE); - } - return builder.toString(); - } - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintApplicationGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintApplicationGwtSuite.java deleted file mode 100644 index 1baea81..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintApplicationGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.constraints.application.ValidationRequirementGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code constraints application} package. - */ -public class ConstraintApplicationGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, constraints application package"); - suite.addTestSuite(ValidationRequirementGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintCompositionGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintCompositionGwtSuite.java deleted file mode 100644 index b20e164..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintCompositionGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.ConstraintCompositionGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code constraints composition} package. - */ -public class ConstraintCompositionGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, constraints composition package"); - suite.addTestSuite(ConstraintCompositionGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintsGroupsGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintsGroupsGwtSuite.java deleted file mode 100644 index 40e730a..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintsGroupsGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.constraints.groups.GroupGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code constraints groups} package. - */ -public class ConstraintsGroupsGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, constraints groups package"); - suite.addTestSuite(GroupGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintsInheritanceGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintsInheritanceGwtSuite.java deleted file mode 100644 index 62347f7..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ConstraintsInheritanceGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.constraints.inheritance.ConstraintInheritanceGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code constraints inheritance} package. - */ -public class ConstraintsInheritanceGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, constraints inheritance package"); - suite.addTestSuite(ConstraintInheritanceGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/CustomConstraintGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/CustomConstraintGwtSuite.java deleted file mode 100644 index 02891ef..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/CustomConstraintGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code constraints customconstraint} package. - */ -public class CustomConstraintGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, constraints customconstraint package"); - suite.addTestSuite(CustomConstraintValidatorGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/MessageInterpolationGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/MessageInterpolationGwtSuite.java deleted file mode 100644 index 8cf690b..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/MessageInterpolationGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.messageinterpolation.MessageInterpolationGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code messageinterpolation} package. - */ -public class MessageInterpolationGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, messageinterpolation package"); - suite.addTestSuite(MessageInterpolationGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/MetadataGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/MetadataGwtSuite.java deleted file mode 100644 index 8cc4d27..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/MetadataGwtSuite.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.metadata.BeanDescriptorGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code metadata} package. - */ -public class MetadataGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, metadata package"); - suite.addTestSuite(BeanDescriptorGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidationGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidationGwtSuite.java deleted file mode 100644 index 2860955..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidationGwtSuite.java +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.validation.PropertyPathGwtTest; -import org.hibernate.jsr303.tck.tests.validation.ValidatePropertyGwtTest; -import org.hibernate.jsr303.tck.tests.validation.ValidateValueGwtTest; -import org.hibernate.jsr303.tck.tests.validation.ValidationGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code validation} package. - */ -public class ValidationGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, validation package"); - suite.addTestSuite(PropertyPathGwtTest.class); - suite.addTestSuite(ValidatePropertyGwtTest.class); - suite.addTestSuite(ValidateValueGwtTest.class); - suite.addTestSuite(ValidationGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidationTck.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidationTck.gwt.xml deleted file mode 100644 index 8a58706..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidationTck.gwt.xml +++ /dev/null
@@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module > - <!-- all tck test inherit this module --> - <inherits name="com.google.gwt.user.User" /> - <inherits name="org.hibernate.jsr303.tck.Jsr303Tck" /> - <inherits name="org.hibernate.validator.HibernateValidator" /> - <source path=""> - <include name="none" /> - </source> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidatorFactoryGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidatorFactoryGwtSuite.java deleted file mode 100644 index 2d97050..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidatorFactoryGwtSuite.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.validatorfactory.CustomConstraintValidatorGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code validatorfactory} package. - */ -public class ValidatorFactoryGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, validatorfactory package"); - suite.addTestSuite(CustomConstraintValidatorGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidatorResolutionGwtSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidatorResolutionGwtSuite.java deleted file mode 100644 index f5dede2..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/ValidatorResolutionGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests; - - -import junit.framework.Test; - -import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionGwtTest; -import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper; - -/** - * Tck Tests for the {@code validator resolution} package. - */ -public class ValidatorResolutionGwtSuite { - public static Test suite() { - TckTestSuiteWrapper suite = new TckTestSuiteWrapper( - "TCK for GWT Validation, validator resolution package"); - suite.addTestSuite(ValidatorResolutionGwtTest.class); - return suite; - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/TckTest.gwt.xml deleted file mode 100644 index cacbec4..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.constraints.application.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/TckTestValidatorFactory.java deleted file mode 100644 index 2916689..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/TckTestValidatorFactory.java +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.application; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface for {@link GWT#create(Class)}. - */ - @GwtValidation(value = { - Building.class, SuperWoman.class, Visibility.class, Woman.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java deleted file mode 100644 index 057a315..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java +++ /dev/null
@@ -1,62 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.application; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Wraps {@link ValidationRequirementTest} . - */ -public class ValidationRequirementGwtTest extends GWTTestCase { - ValidationRequirementTest delegate = new ValidationRequirementTest(); - - /** - * This test is disabled in the TCK. - */ - public void disabledTestIgnoreStaticFieldsAndProperties() { - delegate.testIgnoreStaticFieldsAndProperties(); - } - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.constraints.application.TckTest"; - } - - @Failing(issue = 5798) - public void testClassLevelConstraints() { - delegate.testClassLevelConstraints(); - } - - @Failing(issue = 5798) - public void testConstraintAppliedOnFieldAndProperty() { - delegate.testConstraintAppliedOnFieldAndProperty(); - } - - public void testFieldAccess() { - delegate.testFieldAccess(); - } - - @Failing(issue = 5798) - public void testFieldAndPropertyVisibilityIsNotConstrained() { - delegate.testFieldAndPropertyVisibilityIsNotConstrained(); - } - - public void testPropertyAccess() { - delegate.testPropertyAccess(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java deleted file mode 100644 index 64a1509..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java +++ /dev/null
@@ -1,80 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.constraintcomposition; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Wraps {@link ConstraintCompositionTest}. - */ -public class ConstraintCompositionGwtTest extends GWTTestCase { - private final ConstraintCompositionTest delegate = new ConstraintCompositionTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.TckTest"; - } - - @Failing(issue = 5799) - public void testAllComposingConstraintsMustBeApplicableToAnnotatedType() { - delegate.testAllComposingConstraintsMustBeApplicableToAnnotatedType(); - } - - @Failing(issue = 5799) - public void testAttributesDefinedOnComposingConstraints() { - delegate.testAttributesDefinedOnComposingConstraints(); - } - - @Failing(issue = 5799) - public void testComposedConstraints() { - delegate.testComposedConstraints(); - } - - @Failing(issue = 5799) - public void testComposedConstraintsAreRecursive() { - delegate.testComposedConstraintsAreRecursive(); - } - - @Failing(issue = 5799) - public void testEachFailingConstraintCreatesConstraintViolation() { - delegate.testEachFailingConstraintCreatesConstraintViolation(); - } - - public void testGroupsDefinedOnMainAnnotationAreInherited() { - delegate.testGroupsDefinedOnMainAnnotationAreInherited(); - } - - @Failing(issue = 5799) - public void testOnlySingleConstraintViolation() { - delegate.testOnlySingleConstraintViolation(); - } - - @Failing(issue = 5799) - public void testOverriddenAttributesMustMatchInType() { - delegate.testOverriddenAttributesMustMatchInType(); - } - - public void testPayloadPropagationInComposedConstraints() { - delegate.testPayloadPropagationInComposedConstraints(); - } - - @Failing(issue = 5799) - public void testValidationOfMainAnnotationIsAlsoApplied() { - delegate.testValidationOfMainAnnotationIsAlsoApplied(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml deleted file mode 100644 index 23c3a02..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java deleted file mode 100644 index 38aaa79..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.constraintcomposition; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface for {@link GWT#create(Class)}. - */ - @GwtValidation(value = { - Address.class, FrenchAddress.class, Friend.class, GermanAddress.class, - Shoe.class - // TODO(nchalko) handle ConstraintDefinitionException - // ConstraintCompositionGwtTest.DummyEntityWithZipCode.class - }) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java deleted file mode 100644 index cff9882..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java +++ /dev/null
@@ -1,67 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.customconstraint; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Test wrapper for {@link CustomConstraintValidatorTest}. - */ -public class CustomConstraintValidatorGwtTest extends GWTTestCase { - private final CustomConstraintValidatorTest delegate = new CustomConstraintValidatorTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.constraints.customconstraint.TckTest"; - } - - @Failing(issue = 5800) - public void testDefaultPropertyPath() { - delegate.testDefaultPropertyPath(); - } - - @Failing(issue = 5800) - public void testIsValidIsCalledForEachValidation() { - delegate.testIsValidIsCalledForEachValidation(); - } - - public void testNonInterpolatedMessageParameterIsUsed() { - delegate.testNonInterpolatedMessageParameterIsUsed(); - } - - public void testOneConstraintViolationPerFailingConstraint() { - delegate.testOneConstraintViolationPerFailingConstraint(); - } - - @Failing(issue = 5800) - public void testRightValidatorIsSelectedAndInitializedCalled() { - delegate.testRightValidatorIsSelectedAndInitializedCalled(); - } - - public void testRuntimeExceptionFromInitializeIsWrapped() { - delegate.testRuntimeExceptionFromInitializeIsWrapped(); - } - - public void testRuntimeExceptionFromIsValidIsWrapped() { - delegate.testRuntimeExceptionFromIsValidIsWrapped(); - } - - public void testUnexpectedTypeExceptionIsRaisedForInvalidType() { - delegate.testUnexpectedTypeExceptionIsRaisedForInvalidType(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml deleted file mode 100644 index 12a7dfd..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.constraints.customconstraint.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java deleted file mode 100644 index c224a78..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.customconstraint; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.Freezer; -import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.OddShoe; -import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.Shoe; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface to {@link GWT#create(Class)}. - */ - @GwtValidation(value = { - Author.class, Freezer.class, OddShoe.class, Shoe.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupGwtTest.java deleted file mode 100644 index f6ec82e..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupGwtTest.java +++ /dev/null
@@ -1,74 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.groups; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Test wrapper for {@link GroupTest}. - */ -public class GroupGwtTest extends GWTTestCase { - private final GroupTest delegate = new GroupTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.constraints.groups.TckTest"; - } - - public void testConstraintCanBelongToMoreThanOneGroup() { - delegate.testConstraintCanBelongToMoreThanOneGroup(); - } - - public void testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault() { - delegate.testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault(); - } - - public void testCyclicGroupSequence() { - delegate.testCyclicGroupSequence(); - } - - @Failing(issue = 5801) - public void testGroups() { - delegate.testGroups(); - } - - @Failing(issue = 5801) - public void testGroupSequence() { - delegate.testGroupSequence(); - } - - @Failing(issue = 5801) - public void testGroupSequenceFollowedByGroup() { - delegate.testGroupSequenceFollowedByGroup(); - } - - @Failing(issue = 5801) - public void testImplicitGrouping() { - delegate.testImplicitGrouping(); - } - - @Failing(issue = 5801) - public void testValidateAgainstDifferentGroups() { - delegate.testValidateAgainstDifferentGroups(); - } - - public void testValidationFailureInMultipleGroups() { - delegate.testValidationFailureInMultipleGroups(); - } - -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTest.gwt.xml deleted file mode 100644 index 6b1a69f..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.constraints.groups.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTestValidatorFactory.java deleted file mode 100644 index 709ee5b..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTestValidatorFactory.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.groups; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface to {@link GWT#create(Class)}. - */ - @GwtValidation(value = {Animal.class, Book.class, Order.class, User.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceGwtTest.java deleted file mode 100644 index 5b71fb4..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceGwtTest.java +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.inheritance; - -import com.google.gwt.junit.client.GWTTestCase; - -/** - * Test wrapper for {@link ConstraintInheritanceTest}. . - */ -public class ConstraintInheritanceGwtTest extends GWTTestCase { - private final ConstraintInheritanceTest delegate = new ConstraintInheritanceTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.constraints.inheritance.TckTest"; - } - - public void testConstraintsOnInterfaceAreInherited() { - delegate.testConstraintsOnInterfaceAreInherited(); - } - - public void testConstraintsOnSuperClassAreInherited() { - delegate.testConstraintsOnSuperClassAreInherited(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/TckTest.gwt.xml deleted file mode 100644 index bda35dc..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.constraints.inheritance.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module>
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/TckTestValidatorFactory.java deleted file mode 100644 index 0686d7d..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/inheritance/TckTestValidatorFactory.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.inheritance; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface to {@link GWT#create(Class)}. - */ - @GwtValidation(value = {Bar.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml deleted file mode 100644 index 5bddcc0..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.constraints.validatorresolution.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java deleted file mode 100644 index 2475214..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.validatorresolution; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionTest.CustomClass; -import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionTest.CustomInterfaceImpl; -import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionTest.SubClassAHolder; -import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionTest.SubClassBHolder; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface for {@link GWT#create(Class)}. - */ - @GwtValidation(value = { - Bar.class, CustomInterfaceImpl.class, CustomClass.class, Foo.class, - MinMax.class, SubClassAHolder.class, SubClassBHolder.class, Suburb.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java deleted file mode 100644 index e96fee4..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.constraints.validatorresolution; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Wraps {@link ValidatorResolutionTest} . - */ -public class ValidatorResolutionGwtTest extends GWTTestCase { - ValidatorResolutionTest delegate = new ValidatorResolutionTest(); - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.constraints.validatorresolution.TckTest"; - } - - @Failing(issue = 5806) - public void testAmbiguousValidatorResolution() { - delegate.testAmbiguousValidatorResolution(); - } - - @Failing(issue = 5806) - public void testResolutionOfMinMaxForDifferentTypes() { - delegate.testResolutionOfMinMaxForDifferentTypes(); - } - - @Failing(issue = 5806) - public void testResolutionOfMultipleSizeValidators() { - delegate.testResolutionOfMultipleSizeValidators(); - } - - public void testTargetedTypeIsField() { - delegate.testTargetedTypeIsField(); - } - - public void testTargetedTypeIsGetter() { - delegate.testTargetedTypeIsGetter(); - } - - public void testTargetTypeIsClass() { - delegate.testTargetTypeIsClass(); - } - - @Failing(issue = 5806) - public void testTargetTypeIsInterface() { - delegate.testTargetTypeIsInterface(); - } - - @Failing(issue = 5806) - public void testUnexpectedTypeInValidatorResolution() { - delegate.testUnexpectedTypeInValidatorResolution(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationGwtTest.java deleted file mode 100644 index 250e02b..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationGwtTest.java +++ /dev/null
@@ -1,78 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.messageinterpolation; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Wraps {@link MessageInterpolationTest}. - */ -public class MessageInterpolationGwtTest extends GWTTestCase { - private final MessageInterpolationTest delegate = new MessageInterpolationTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.messageinterpolation.TckTest"; - } - - public void testConstraintAttributeValuesAreInterpolated() { - delegate.testConstraintAttributeValuesAreInterpolated(); - } - - public void testDefaultMessageInterpolatorIsNotNull() { - delegate.testDefaultMessageInterpolatorIsNotNull(); - } - - public void testIfNoLocaleIsSpecifiedTheDefaultLocaleIsAssumed() { - delegate.testIfNoLocaleIsSpecifiedTheDefaultLocaleIsAssumed(); - } - - public void testLiteralCurlyBraces() { - delegate.testLiteralCurlyBraces(); - } - - @Failing(issue = 5763) - public void testMessageInterpolationWithLocale() { - delegate.testMessageInterpolationWithLocale(); - } - - public void testMessagesCanBeOverriddenAtConstraintLevel() { - delegate.testMessagesCanBeOverriddenAtConstraintLevel(); - } - - public void testParametersAreExtractedFromBeanValidationProviderBundle() { - delegate.testParametersAreExtractedFromBeanValidationProviderBundle(); - } - - public void testRecursiveMessageInterpolation() { - delegate.testRecursiveMessageInterpolation(); - } - - public void testSuccessfulInterpolationOfValidationMessagesValue() { - delegate.testSuccessfulInterpolationOfValidationMessagesValue(); - } - - public void testUnknownTokenInterpolation() { - delegate.testUnknownTokenInterpolation(); - } - - public void testUnSuccessfulInterpolation() { - delegate.testUnSuccessfulInterpolation(); - } - -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckTest.gwt.xml deleted file mode 100644 index 734efca..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckTest.gwt.xml +++ /dev/null
@@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.messageinterpolation.TckUserValidationMessageProvider"> - <when-type-is class="com.google.gwt.validation.client.UserValidationMessagesResolver" /> - </replace-with> - <replace-with class="org.hibernate.jsr303.tck.tests.messageinterpolation.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckTestValidatorFactory.java deleted file mode 100644 index e4dadc9..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckTestValidatorFactory.java +++ /dev/null
@@ -1,44 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.messageinterpolation; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import org.hibernate.jsr303.tck.tests.messageinterpolation.MessageInterpolationTest.DummyEntity; -import org.hibernate.jsr303.tck.tests.messageinterpolation.MessageInterpolationTest.Person; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface for {@link GWT#create(Class)}. - */ - @GwtValidation(value = {DummyEntity.class, Person.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckUserValidationMessageProvider.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckUserValidationMessageProvider.java deleted file mode 100644 index 1e06390..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/TckUserValidationMessageProvider.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.messageinterpolation; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.client.ConstantsWithLookup; -import com.google.gwt.validation.client.AbstractValidationMessageResolver; -import com.google.gwt.validation.client.UserValidationMessagesResolver; - -/** - * Custom messages from {@link ValidationMessages}. - */ -public class TckUserValidationMessageProvider extends - AbstractValidationMessageResolver implements - UserValidationMessagesResolver { - - public TckUserValidationMessageProvider() { - super((ConstantsWithLookup) GWT.create(ValidationMessages.class)); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.java deleted file mode 100644 index 0f1e9cc..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.java +++ /dev/null
@@ -1,59 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.messageinterpolation; - -/** - * Interface to represent the constants contained in resource bundle: - * 'ValidationMessages.properties'. - */ -public interface ValidationMessages extends com.google.gwt.i18n.client.ConstantsWithLookup { - - /** - * Translated "replacement worked". - * - * @return translated "replacement worked" - */ - @DefaultStringValue("replacement worked") - @Key("foo") - String foo(); - - /** - * Translated "may not be null". - * - * @return translated "may not be null" - */ - @DefaultStringValue("may not be null") - @Key("javax.validation.constraints.NotNull.message") - String javax_validation_constraints_NotNull_message(); - - /** - * Translated "{replace.in.user.bundle2}". - * - * @return translated "{replace.in.user.bundle2}" - */ - @DefaultStringValue("{replace.in.user.bundle2}") - @Key("replace.in.user.bundle1") - String replace_in_user_bundle1(); - - /** - * Translated "recursion worked". - * - * @return translated "recursion worked" - */ - @DefaultStringValue("recursion worked") - @Key("replace.in.user.bundle2") - String replace_in_user_bundle2(); -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties deleted file mode 100644 index f22947e..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages.properties +++ /dev/null
@@ -1,4 +0,0 @@ -javax.validation.constraints.NotNull.message=may not be null -foo=replacement worked -replace.in.user.bundle1={replace.in.user.bundle2} -replace.in.user.bundle2=recursion worked \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties deleted file mode 100644 index 5485599..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/messageinterpolation/ValidationMessages_de.properties +++ /dev/null
@@ -1 +0,0 @@ -javax.validation.constraints.NotNull.message=kann nicht null sein \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorGwtTest.java deleted file mode 100644 index d3c6943..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorGwtTest.java +++ /dev/null
@@ -1,77 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.metadata; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Test wrapper for {@link BeanDescriptorTest}. - */ -public class BeanDescriptorGwtTest extends GWTTestCase { - private final BeanDescriptorTest delegate = new BeanDescriptorTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.metadata.TckTest"; - } - - public void testGetConstrainedProperties() { - delegate.testGetConstrainedProperties(); - } - - public void testGetConstrainedPropertiesForUnconstrainedEntity() { - delegate.testGetConstrainedPropertiesForUnconstrainedEntity(); - } - - public void testGetConstraintForConstrainedProperty() { - delegate.testGetConstraintForConstrainedProperty(); - } - - public void testGetConstraintForUnConstrainedProperty() { - delegate.testGetConstraintForUnConstrainedProperty(); - } - - public void testGetConstraintsForNonExistingProperty() { - delegate.testGetConstraintsForNonExistingProperty(); - } - - public void testGetConstraintsForNullProperty() { - delegate.testGetConstraintsForNullProperty(); - } - - @Failing(issue = 5802) - public void testIsBeanConstrainedDueToConstraintOnEntity() { - delegate.testIsBeanConstrainedDueToConstraintOnEntity(); - } - - public void testIsBeanConstrainedDueToConstraintOnInterface() { - delegate.testIsBeanConstrainedDueToConstraintOnInterface(); - } - - public void testIsBeanConstrainedDueToConstraintProperty() { - delegate.testIsBeanConstrainedDueToConstraintProperty(); - } - - public void testIsBeanConstrainedDueToValidAnnotation() { - delegate.testIsBeanConstrainedDueToValidAnnotation(); - } - - public void testUnconstrainedClass() { - delegate.testUnconstrainedClass(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/TckTest.gwt.xml deleted file mode 100644 index 1685e92..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.metadata.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module>
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/TckTestValidatorFactory.java deleted file mode 100644 index 2c2915a..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/metadata/TckTestValidatorFactory.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.metadata; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; - -/** - * Test {@link AbstractGwtValidatorFactory} for - * {@link org.hibernate.jsr303.tck.tests.MetadataGwtSuite}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface to {@link GWT#create(Class)}. - */ - @GwtValidation(value = { - Account.class, Customer.class, Man.class, Order.class, - UnconstraintEntity.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/AbstractValidationTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/AbstractValidationTest.java deleted file mode 100644 index a51d70b..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/AbstractValidationTest.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validation; - -import com.google.gwt.junit.client.GWTTestCase; - -/** - * Abstract Validation test for the {@code validation} package. - */ -public abstract class AbstractValidationTest extends GWTTestCase { - - public AbstractValidationTest() { - super(); - } - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.validation.TckTest"; - } -} \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/PropertyPathGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/PropertyPathGwtTest.java deleted file mode 100644 index 6da41ea..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/PropertyPathGwtTest.java +++ /dev/null
@@ -1,55 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validation; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Test wrapper for {@link PropertyPathTest}. - */ -public class PropertyPathGwtTest extends AbstractValidationTest { - - private final PropertyPathTest delegate = new PropertyPathTest(); - - @Failing(issue = 5803) - public void testPropertyPathSet() { - delegate.testPropertyPathSet(); - } - - @Failing(issue = 5803) - public void testPropertyPathTraversedObject() { - delegate.testPropertyPathTraversedObject(); - } - - @Failing(issue = 5803) - public void testPropertyPathWithArray() { - delegate.testPropertyPathWithArray(); - } - - public void testPropertyPathWithConstraintViolationForRootObject() { - delegate.testPropertyPathWithConstraintViolationForRootObject(); - } - - @Failing(issue = 5803) - public void testPropertyPathWithList() { - delegate.testPropertyPathWithList(); - } - - @Failing(issue = 5803) - public void testPropertyPathWithMap() { - delegate.testPropertyPathWithMap(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/TckTest.gwt.xml deleted file mode 100644 index 053bf2a..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.validation.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/TckTestValidatorFactory.java deleted file mode 100644 index df5b82c..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/TckTestValidatorFactory.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validation; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import org.hibernate.jsr303.tck.tests.validation.PropertyPathTest.ActorDB; -import org.hibernate.jsr303.tck.tests.validation.PropertyPathTest.VerySpecialClass; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface for {@link GWT#create(Class)}. - */ - @GwtValidation(value = { - Actor.class, ActorDB.class, ActorArrayBased.class, ActorListBased.class, - Address.class, BadlyBehavedEntity.class, Customer.class, Engine.class, - Order.class, VerySpecialClass.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java deleted file mode 100644 index c8c819d..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java +++ /dev/null
@@ -1,67 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validation; - -import org.hibernate.jsr303.tck.util.Failing; - -import javax.validation.ValidationException; - -/** - * Test wrapper for {@link ValidatePropertyTest}. - */ -public class ValidatePropertyGwtTest extends AbstractValidationTest { - - private final ValidatePropertyTest delegate = new ValidatePropertyTest(); - - public void testIllegalArgumentExceptionIsThrownForNullValue() { - delegate.testIllegalArgumentExceptionIsThrownForNullValue(); - } - - public void testPassingNullAsGroup() { - delegate.testPassingNullAsGroup(); - } - - @Failing(issue = 5804) - public void testUnexpectedExceptionsInValidatePropertyGetWrappedInValidationExceptions() { - // Wrap the test to catch the @Test expected exception. - try { - delegate.testUnexpectedExceptionsInValidatePropertyGetWrappedInValidationExceptions(); - fail("Expected a " + ValidationException.class); - } catch (ValidationException expected) { - } - } - - @Failing(issue = 5804) - public void testValidateProperty() { - delegate.testValidateProperty(); - } - - public void testValidatePropertyWithEmptyProperty() { - delegate.testValidatePropertyWithEmptyProperty(); - } - - public void testValidatePropertyWithInvalidPropertyPath() { - delegate.testValidatePropertyWithInvalidPropertyPath(); - } - - public void testValidatePropertyWithNullProperty() { - delegate.testValidatePropertyWithNullProperty(); - } - - public void testValidIsNotHonoredValidateProperty() { - delegate.testValidIsNotHonoredValidateProperty(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidateValueGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidateValueGwtTest.java deleted file mode 100644 index 98107e8..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidateValueGwtTest.java +++ /dev/null
@@ -1,70 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validation; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Test wrapper for {@link ValidateValueTest}. - */ -public class ValidateValueGwtTest extends AbstractValidationTest { - - private final ValidateValueTest delegate = new ValidateValueTest(); - - @Failing(issue = 5804) - public void testExistingPropertyWoConstraintsNorCascaded() { - delegate.testExistingPropertyWoConstraintsNorCascaded(); - } - - @Failing(issue = 5804) - public void testValidateValue() { - delegate.testValidateValue(); - } - - @Failing(issue = 5804) - public void testValidateValueFailure() { - delegate.testValidateValueFailure(); - } - - public void testValidateValuePassingNullAsGroup() { - delegate.testValidateValuePassingNullAsGroup(); - } - - public void testValidateValueSuccess() { - delegate.testValidateValueSuccess(); - } - - public void testValidateValueWithEmptyPropertyPath() { - delegate.testValidateValueWithEmptyPropertyPath(); - } - - public void testValidateValueWithInvalidPropertyPath() { - delegate.testValidateValueWithInvalidPropertyPath(); - } - - public void testValidateValueWithNullObject() { - delegate.testValidateValueWithNullObject(); - } - - public void testValidateValueWithNullPropertyName() { - delegate.testValidateValueWithNullPropertyName(); - } - - // This passes but the desired behavior is still not working - public void testValidIsNotHonoredValidateValue() { - delegate.testValidIsNotHonoredValidateValue(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidationGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidationGwtTest.java deleted file mode 100644 index b8d4b22..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validation/ValidationGwtTest.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validation; - -/** - * Test wrapper for {@link ValidationTest}. - */ -public class ValidationGwtTest extends AbstractValidationTest { - - private final ValidationTest delegate = new ValidationTest(); - - public void notGwtCompatibleTestVerifyMethodsOfValidationObjects() { - // This test relies on reflection so it is not run. - // delegate.testVerifyMethodsOfValidationObjects(); - } - - public void testBuildDefaultValidatorFactory() { - delegate.testBuildDefaultValidatorFactory(); - } - - public void testCustomValidationProviderResolution() { - delegate.testCustomValidationProviderResolution(); - } - - public void testSpecificValidationProvider() { - delegate.testSpecificValidationProvider(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java deleted file mode 100644 index 73df34e..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validatorfactory; - -import com.google.gwt.junit.client.GWTTestCase; - -import org.hibernate.jsr303.tck.util.Failing; - -/** - * Wraps - * {@link org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest} - * . - */ -public class CustomConstraintValidatorGwtTest extends GWTTestCase { - CustomConstraintValidatorTest delegate = new CustomConstraintValidatorTest(); - - @Override - public String getModuleName() { - return "org.hibernate.jsr303.tck.tests.validatorfactory.TckTest"; - } - - @Failing(issue = 5805) - public void testDefaultConstructorInValidatorCalled() { - delegate.testDefaultConstructorInValidatorCalled(); - } - - public void testRuntimeExceptionInValidatorCreationIsWrapped() { - delegate.testRuntimeExceptionInValidatorCreationIsWrapped(); - } - - public void testValidationExceptionIsThrownInCaseFactoryReturnsNull() { - delegate.testValidationExceptionIsThrownInCaseFactoryReturnsNull(); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/TckTest.gwt.xml b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/TckTest.gwt.xml deleted file mode 100644 index c5445cb..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/TckTest.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" /> - <source path=""> - <include name="*.java" /> - <exclude name="super" /> - </source> - <replace-with class="org.hibernate.jsr303.tck.tests.validatorfactory.TckTestValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory"/> - </replace-with> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/TckTestValidatorFactory.java b/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/TckTestValidatorFactory.java deleted file mode 100644 index 2ae5b00..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/tests/validatorfactory/TckTestValidatorFactory.java +++ /dev/null
@@ -1,44 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.tests.validatorfactory; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import org.hibernate.jsr303.tck.tests.validatorfactory.CustomConstraintValidatorTest.Dummy; -import org.hibernate.jsr303.tck.tests.validatorfactory.CustomConstraintValidatorTest.SecondDummy; - -import javax.validation.Validator; - -/** - * {@link AbstractGwtValidatorFactory} implementation that uses - * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}. - */ -public final class TckTestValidatorFactory extends AbstractGwtValidatorFactory { - /** - * Marker Interface for {@link GWT#create(Class)}. - */ - @GwtValidation(value = {Dummy.class, SecondDummy.class}) - public static interface GwtValidator extends Validator { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/util/Failing.java b/samples/validationtck/test/org/hibernate/jsr303/tck/util/Failing.java deleted file mode 100644 index d4fc0e9..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/util/Failing.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.util; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Marks a testMethod as Failing to prevent it from running in the standard TCK - * tests. Used by the {@link TckTestSuiteWrapper}. - */ -@Target({METHOD}) -@Retention(RUNTIME) -@Documented -public @interface Failing { - /** - * The JVM property name checked by {@link TckTestSuiteWrapper}. If the JVM - * property {@value} is set to true the {@link TckTestSuiteWrapper} will run - * tests annotated {@link Failing}. - */ - String INCLUDE = "com.google.gwt.sample.validationtck.util.Failing.include"; - - /** - * The GWT issue for fixing this failing test. - * <p> - * The issue is at - * http://code.google.com/p/google-web-toolkit/issues/detail?id={@code <issue>} - */ - int issue(); -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/util/NonTckTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/util/NonTckTest.java deleted file mode 100644 index 4fe665e..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/util/NonTckTest.java +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.util; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Marks a testMethod as not part of the TCK. The test is run by default but it - * is excluded from TCK reports. Used by the {@link TckTestSuiteWrapper}. - */ -@Target({METHOD}) -@Retention(RUNTIME) -@Documented -public @interface NonTckTest { - /** - * The JVM property name checked by {@link TckTestSuiteWrapper}. If the JVM - * property {@value} is set to true the {@link TckTestSuiteWrapper} will not - * run the tests annotated {@link Failing}. - */ - String EXCLUDE = "com.google.gwt.sample.validationtck.util.NotTckTest.exclude"; -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/util/NotSupported.java b/samples/validationtck/test/org/hibernate/jsr303/tck/util/NotSupported.java deleted file mode 100644 index d3e8605..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/util/NotSupported.java +++ /dev/null
@@ -1,49 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.util; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Marks a testMethod as not supported to prevent it from running in the - * standard tests. Use this when the behavior being tested is not supported by - * GWT Validation. Used by the {@link TckTestSuiteWrapper}. - */ -@Target({METHOD}) -@Retention(RUNTIME) -@Documented -public @interface NotSupported { - /** - * Constants for why a test is not supported. - */ - public enum Reason { - XML, IO, CALENDAR - } - - /** - * The JVM property name checked by {@link TckTestSuiteWrapper}. If the JVM - * property {@value} is set to true the {@link TckTestSuiteWrapper} will run - * tests annotated {@link NotSupported}. - */ - String INCLUDE = "com.google.gwt.sample.validationtck.util.NotSupported.include"; - - Reason reason(); -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/util/TckTestSuiteWrapper.java b/samples/validationtck/test/org/hibernate/jsr303/tck/util/TckTestSuiteWrapper.java deleted file mode 100644 index 51214da..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/util/TckTestSuiteWrapper.java +++ /dev/null
@@ -1,153 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.util; - -import static com.google.gwt.thirdparty.guava.common.base.Predicates.and; -import static com.google.gwt.thirdparty.guava.common.base.Predicates.not; -import static com.google.gwt.thirdparty.guava.common.base.Predicates.or; -import static com.google.gwt.thirdparty.guava.common.collect.ImmutableList.copyOf; -import static com.google.gwt.thirdparty.guava.common.collect.Iterables.filter; - -import com.google.gwt.junit.tools.GWTTestSuite; -import com.google.gwt.thirdparty.guava.common.base.Predicate; - -import junit.framework.Test; -import junit.framework.TestCase; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Vector; - -/** - * Wrapper for {@link GWTTestSuite} to prevent selected methods from running. - * - * Copied code from {@link junit.framework.TestSuite} and modified to exclude - * test methods with select annotations. - */ -public class TckTestSuiteWrapper extends GWTTestSuite { - - private static final Predicate<Method> HAS_FAILING = createHasAnnotationPredicate(Failing.class); - private static final Predicate<Method> HAS_NON_TCK_TEST = createHasAnnotationPredicate(NonTckTest.class); - private static final Predicate<Method> HAS_NOT_SUPPORTED = createHasAnnotationPredicate(NotSupported.class); - - private static final Predicate<Method> INCLUDE_FAILING = createHasProperty(Failing.INCLUDE); - private static final Predicate<Method> INCLUDE_NOT_SUPPORTED = createHasProperty(NotSupported.INCLUDE); - private static final Predicate<Method> EXCLUDE_NON_TCK_TEST = createHasProperty(NonTckTest.EXCLUDE); - - @SuppressWarnings("unchecked") - private static final Predicate<Method> METHOD_FILTER = and( - or(INCLUDE_NOT_SUPPORTED, not(HAS_NOT_SUPPORTED)), - not(and(EXCLUDE_NON_TCK_TEST, HAS_NON_TCK_TEST)), - or(INCLUDE_FAILING, not(HAS_FAILING)) - ); - - public static Predicate<Method> createHasAnnotationPredicate( - final Class<? extends Annotation> annotationClass) { - return new Predicate<Method>() { - - public boolean apply(Method method) { - return method.getAnnotation(annotationClass) != null; - } - }; - } - - private static <T> Predicate<T> createHasProperty(final String property) { - return new Predicate<T>() { - public boolean apply(T arg0) { - String include = System.getProperty(property); - return Boolean.parseBoolean(include); - } - }; - } - - /** - * Returns a test which will fail and log a warning message. - */ - private static Test warning(final String message) { - return new TestCase("warning") { - protected void runTest() { - fail(message); - } - }; - } - - public TckTestSuiteWrapper(String name) { - super(name); - } - - /** - * Adds the tests from the given class to the suite. - */ - @Override - public void addTestSuite(Class theClass) { - - String fName = theClass.getName(); - try { - getTestConstructor(theClass); // Avoid generating multiple error messages - } catch (NoSuchMethodException e) { - addTest(warning("Class " + theClass.getName() - + " has no public constructor TestCase(String name) or TestCase()")); - return; - } - - if (!Modifier.isPublic(theClass.getModifiers())) { - addTest(warning("Class " + theClass.getName() + " is not public")); - return; - } - - Class superClass = theClass; - Vector names = new Vector(); - while (Test.class.isAssignableFrom(superClass)) { - for (Method method : filter(copyOf(superClass.getDeclaredMethods()), - METHOD_FILTER)) { - addTestMethod(method, names, theClass); - } - superClass = superClass.getSuperclass(); - } - if (testCount() == 0) - addTest(warning("No tests found in " + theClass.getName())); - } - - private void addTestMethod(Method m, Vector names, Class theClass) { - String name = m.getName(); - if (names.contains(name)) - return; - if (!isPublicTestMethod(m)) { - if (isTestMethod(m)) - addTest(warning("Test method isn't public: " + m.getName())); - return; - } - names.addElement(name); - addTest(createTest(theClass, name)); - } - - private boolean ingoreMethod(Method m) { - return HAS_FAILING.apply(m); - } - - private boolean isPublicTestMethod(Method m) { - return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); - } - - private boolean isTestMethod(Method m) { - String name = m.getName(); - Class[] parameters = m.getParameterTypes(); - Class returnType = m.getReturnType(); - return parameters.length == 0 && name.startsWith("test") - && returnType.equals(Void.TYPE); - } -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/util/TckTestSuiteWrapperTest.java b/samples/validationtck/test/org/hibernate/jsr303/tck/util/TckTestSuiteWrapperTest.java deleted file mode 100644 index dc427e8..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/util/TckTestSuiteWrapperTest.java +++ /dev/null
@@ -1,141 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.util; - -import com.google.gwt.junit.client.GWTTestCase; - -import junit.framework.TestCase; - -import org.hibernate.jsr303.tck.util.NotSupported.Reason; - -/** - * Tests for {@link TckTestSuiteWrapper}. - */ -public class TckTestSuiteWrapperTest extends TestCase { - - /** - * Sample test with a method annotated as {@link Failing}. - */ - public static class Fail extends Base { - - public Fail() { - } - - @Failing(issue = 123) - public void testFailing() { - } - - public void testOne() { - } - - public void testTwo() { - } - } - - /** - * Sample test with a method annotated as {@link NonTckTest}. - */ - public static class Non extends Base { - - public Non() { - } - - @NonTckTest - public void testNon() { - } - - public void testOne() { - } - - public void testTwo() { - } - } - - /** - * Sample test without annotated test messages. - */ - public static class Normal extends Base { - - public Normal() { - } - - public void testOne() { - } - - public void testTwo() { - } - } - - /** - * Sample test with a method annotated as {@link NotSupported}. - */ - public static class Not extends Base { - - public Not() { - } - - @NotSupported(reason = Reason.IO) - public void testFailing() { - } - - public void testOne() { - } - - public void testTwo() { - } - } - - private abstract static class Base extends GWTTestCase { - - public Base() { - } - - @Override - public final String getModuleName() { - return "org.hibernate.jsr303.tck.tests.metadata.TckTest"; - } - } - - private TckTestSuiteWrapper suite; - - public void checkAddTest(Class<? extends GWTTestCase> clazz, int expected) { - suite.addTestSuite(clazz); - assertEquals(expected, suite.testAt(0).countTestCases()); - } - - public void testAddTestMarkedFailing() throws Exception { - checkAddTest(Fail.class, 2); - } - - public void testAddTestMarkedNotSupported() throws Exception { - checkAddTest(Not.class, 2); - } - - public void testAddTestNon() throws Exception { - checkAddTest(Non.class, 3); - } - - public void testAddTestNormal() throws Exception { - checkAddTest(Normal.class, 2); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - suite = new TckTestSuiteWrapper("Test"); - } - -}
diff --git a/samples/validationtck/test/org/hibernate/jsr303/tck/util/UtilJreSuite.java b/samples/validationtck/test/org/hibernate/jsr303/tck/util/UtilJreSuite.java deleted file mode 100644 index 4800375..0000000 --- a/samples/validationtck/test/org/hibernate/jsr303/tck/util/UtilJreSuite.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.jsr303.tck.util; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test Suite for non GWT tests. - */ -public class UtilJreSuite { - - public static Test suite() { - TestSuite suite = new TestSuite("Test suite for tck utility classes"); - suite.addTestSuite(TckTestSuiteWrapperTest.class); - return suite; - } - -}
diff --git a/samples/validationtck/test/org/jboss/test/audit/JbossTestAudit.gwt.xml b/samples/validationtck/test/org/jboss/test/audit/JbossTestAudit.gwt.xml deleted file mode 100644 index 3e95704..0000000 --- a/samples/validationtck/test/org/jboss/test/audit/JbossTestAudit.gwt.xml +++ /dev/null
@@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -This is a HACK, is not a general solution for using JBoss Test Audit. -It is only enough to run the tests in the GWT Validation TCK. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <source path=""> - <exclude name="super/" /> - </source> - <super-source path="super" /> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/jboss/testharness/JbossTestHarness.gwt.xml b/samples/validationtck/test/org/jboss/testharness/JbossTestHarness.gwt.xml deleted file mode 100644 index bb851ef..0000000 --- a/samples/validationtck/test/org/jboss/testharness/JbossTestHarness.gwt.xml +++ /dev/null
@@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -This is a HACK, is not a general solution for using JBoss Test Harness. -It is only enough to run the tests in the GWT Validation TCK. ---> -<module> - <inherits name="org.testng.TestNg" /> - <source path=""> - <exclude name="super/" /> - <include name="api/DeploymentException.java"/> - </source> - <super-source path="super" /> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/AbstractTest.java b/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/AbstractTest.java deleted file mode 100644 index 8773ba6..0000000 --- a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/AbstractTest.java +++ /dev/null
@@ -1,200 +0,0 @@ -//Modified by Google. -package org.jboss.testharness; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import java.util.logging.Logger; -import org.jboss.testharness.api.Configuration; -import org.jboss.testharness.api.DeploymentException; -//import org.jboss.testharness.api.TestResult; -//import org.jboss.testharness.api.TestResult.Status; -//import org.jboss.testharness.impl.ConfigurationImpl; -//import org.jboss.testharness.impl.packaging.ArtifactGenerator; -import org.jboss.testharness.impl.packaging.TCKArtifact; -import org.testng.IHookCallBack; -import org.testng.IHookable; -//import org.testng.ITestContext; -import org.testng.ITestResult; -//import org.testng.annotations.AfterClass; -//import org.testng.annotations.AfterSuite; -//import org.testng.annotations.BeforeClass; -//import org.testng.annotations.BeforeSuite; - -/** - * Abstract Test - * <p> - * Modified by Google to only include the minimum needed to run the JSR-303 tck. - */ -public abstract class AbstractTest implements IHookable -{ - - private static Logger log = Logger.getLogger(AbstractTest.class.getName()); - - private static boolean inContainer = false; - - public static boolean isInContainer() - { - return inContainer; - } - - public static void setInContainer(boolean inContainer) - { - AbstractTest.inContainer = inContainer; - } - - private TCKArtifact artifact; - private DeploymentException deploymentException; - private boolean skipTest = false; - - private boolean isSuiteDeployingTestsToContainer() - { - return !isInContainer() && (!getCurrentConfiguration().isStandalone() || getCurrentConfiguration().isRunIntegrationTests()); - } - - private void generateArtifact() - { - - } - - protected TCKArtifact postCreate(TCKArtifact artifact) - { - return artifact; - } - - private boolean isDeployToContainerNeeded() - { - /* - * If this isn't running inside the container AND there is an artifact to - * deploy AND EITHER we are in standalone mode and it isn't a unit test OR - * we aren't in standalone mode THEN we need to deploy - */ - return !isInContainer() && artifact != null && ((getCurrentConfiguration().isStandalone() && !artifact.isUnit() && getCurrentConfiguration().isRunIntegrationTests()) || !getCurrentConfiguration().isStandalone()); - } - - private void deployArtifact() - { - - } - - protected DeploymentException handleDeploymentFailure(DeploymentException deploymentException) - { - return deploymentException; - } - - - private void undeployArtifact() throws Exception - { - if (isDeployToContainerNeeded()) - { - getCurrentConfiguration().getContainers().undeploy(artifact.getDefaultName()); - } - if (getCurrentConfiguration().isStandalone() && artifact != null && artifact.isUnit()) - { - getCurrentConfiguration().getStandaloneContainers().undeploy(); - } - } - - private void checkAssertionsEnabled() - { - boolean assertionsEnabled = false; - try - { - assert false; - } - catch (AssertionError error) - { - assertionsEnabled = true; - } - if (!assertionsEnabled) - { - throw new IllegalStateException("Assertions must be enabled!"); - } - } - - //@BeforeSuite(alwaysRun = true, groups = "scaffold") -// public void beforeSuite(ITestContext context) throws Exception -// { -// if (isSuiteDeployingTestsToContainer()) -// { -// getCurrentConfiguration().getContainers().setup(); -// } -// if (getCurrentConfiguration().isStandalone()) -// { -// getCurrentConfiguration().getStandaloneContainers().setup(); -// } -// checkAssertionsEnabled(); -// } - - //@AfterSuite(alwaysRun = true, groups = "scaffold") - public void afterSuite() throws Exception - { - if (isSuiteDeployingTestsToContainer()) - { - getCurrentConfiguration().getContainers().cleanup(); - } - if (getCurrentConfiguration().isStandalone()) - { - getCurrentConfiguration().getStandaloneContainers().cleanup(); - } - } - - //@BeforeClass(alwaysRun = true, groups = "scaffold") - public void beforeClass() throws Throwable - { - generateArtifact(); - deployArtifact(); - - } - - //@AfterClass(alwaysRun = true, groups = "scaffold") - public void afterClass() throws Exception - { - undeployArtifact(); - this.artifact = null; - this.deploymentException = null; - skipTest = false; - } - - public void beforeMethod() - { - - } - - public void afterMethod() - { - - } - - public final void run(IHookCallBack callback, ITestResult testResult) - { - } - - protected Configuration getCurrentConfiguration() - { - return null; //ConfigurationImpl.get(); - } - - protected String getContextPath() - { - return "http://" + getCurrentConfiguration().getHost() + "/" + this.getClass().getName() + "/"; - } - - protected boolean isThrowablePresent(Class<? extends Throwable> throwableType, Throwable throwable) - { - if (throwable == null) - { - return false; - } -// else if (throwableType.isAssignableFrom(throwable.getClass())) -// { -// return true; -// } -// else -// { -// return isThrowablePresent(throwableType, throwable.getCause()); -// } - return true; - } -} \ No newline at end of file
diff --git a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/api/Configuration.java b/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/api/Configuration.java deleted file mode 100644 index cf7c5a0..0000000 --- a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/api/Configuration.java +++ /dev/null
@@ -1,138 +0,0 @@ -package org.jboss.testharness.api; - -import java.util.List; - -import org.jboss.testharness.spi.Containers; -import org.jboss.testharness.spi.StandaloneContainers; - -/** - * The configuration of the TCK. - * - * The TCK may be configured using system properties or placed in a properties - * file called META-INF/web-beans-tck.properties. - * - * Porting package property names are the FQCN of the SPI class. Other property - * names (one for each non-porting package SPI configuration option) are - * specified here. The defaults are also listed here. - * - * The TCK may also be configured programatically through this interface - * - * <p> - * Modified by Google. - * <ul> - * <li>Removed references to TestLauncher</li> - * <li>Removed revernces to the output dir.</li> - * <ul> - * - * @author Pete Muir - * - */ -public interface Configuration -{ - - public static final String OUTPUT_DIRECTORY_PROPERTY_NAME = "org.jboss.testharness.outputDirectory"; - public static final String STANDALONE_PROPERTY_NAME = "org.jboss.testharness.standalone"; - public static final String RUN_INTEGRATION_TESTS_PROPERTY_NAME = "org.jboss.testharness.runIntegrationTests"; - public static final String CONNECT_TIMEOUT_PROPERTY_NAME = "org.jboss.testharness.connectTimeout"; - public static final String LIBRARY_DIRECTORY_PROPERTY_NAME = "org.jboss.testharness.libraryDirectory"; - public static final String HOST_PROPERTY_NAME = "org.jboss.testharness.host"; - public static final String TEST_PACKAGE_PROPERTY_NAME = "org.jboss.testharness.testPackage"; - - public static final boolean DEFAULT_STANDALONE = true; - public static final boolean DEFAULT_RUN_INTEGRATION_TESTS = false; - public static final int DEFAULT_CONNECT_DELAY = 5000; - public static final boolean DEFAULT_WRITE_DEPLOYED_ARCHIVES_TO_DISK = false; - public static final String DEFAULT_LIBRARY_DIRECTORY = null; - public static final String DEFAULT_HOST = "localhost:8080"; - - /** - * The output directory to put TCK specific output. The TestNG output - * directory is configured via TestNG. - * - * By default set to ${tmp}/jsr-299-tck - */ - public String getOutputDirectory(); - - /** - * Whether the TCK is in standalone mode or not. - * - * By default true - */ - public boolean isStandalone(); - - /** - * When the TCK is running in container tests it will attempt to connect to - * the server every 200ms until the timeout is reached. - * - * By default 5000ms - */ - public int getConnectTimeout(); - - /** - * The TCK allows additional libraries to be put in the deployed test - * artifacts (for example the porting package for the implementation). Any - * jars in this directory will be added to the deployed artifact. - * - * By default no directory is used. - */ - public String getLibraryDirectory(); - - /** - * The TCK test launcher - * - * @see TestLauncher - * - */ - public Object getInContainerTestLauncher(); - - /** - * The implementation of {@link Containers} in use. - */ - public Containers getContainers(); - - /** - * Whether to run integration tests, by default false. - */ - public boolean isRunIntegrationTests(); - - public void setOutputDirectory(String outputDirectory); - - public void setStandalone(boolean standalone); - - public void setConnectTimeout(int connectTimeout); - - public void setLibraryDirectory(String libraryDir); - - public void setInContainerTestLauncher(Object testLauncher); - - public void setContainers(Containers containers); - - /** - * The implementation of {@link StandaloneContainers} in use. - */ - public StandaloneContainers getStandaloneContainers(); - - public void setStandaloneContainers(StandaloneContainers standaloneContainers); - - public void setRunIntegrationTests(boolean runIntegrationTests); - - /** - * The TCK will use this as the remote host to connect to run in container - * tests. By default localhost:8080 - * - */ - public String getHost(); - - public void setHost(String host); - - public List<String> getExtraPackages(); - - public List<ResourceDescriptor> getExtraResources(); - - public List<String> getExtraDeploymentProperties(); - - public String getTestPackage(); - - public void setTestPackage(String packageName); - -} \ No newline at end of file
diff --git a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/api/ResourceDescriptor.java b/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/api/ResourceDescriptor.java deleted file mode 100644 index 772f06b..0000000 --- a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/api/ResourceDescriptor.java +++ /dev/null
@@ -1,14 +0,0 @@ -//Modified by Google: -//Removed URL -package org.jboss.testharness.api; - - -public interface ResourceDescriptor -{ - - public String getName(); - - //public URL getSource(); - public Object getSource(); - -} \ No newline at end of file
diff --git a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/impl/packaging/TCKArtifact.java b/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/impl/packaging/TCKArtifact.java deleted file mode 100644 index 49f70c1..0000000 --- a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/impl/packaging/TCKArtifact.java +++ /dev/null
@@ -1,77 +0,0 @@ -package org.jboss.testharness.impl.packaging; - -import java.util.Set; - -import org.jboss.testharness.api.ResourceDescriptor; - -/** - * @author Hardy Ferentschik - */ -public interface TCKArtifact { - TCKArtifact initialize(); - - Object getJarAsStream(); - - Object getJar(); - - Object getExplodedJar(); - - void create(); - - void writeArtifactToDisk(String outputDirectory); - - void writeArtifactToDisk(String outputDirectory, String ObjectName); - - String getDefaultName(); - - Set<Class<?>> getClasses(); - - Set<ResourceDescriptor> getResources(); - - void addPackage(Object pkg); - - void addPackage(String packageName, boolean addRecursively); - - Object getClassesRoot(Object archiveRoot); - - String getClassesRoot(); - - void setClassesRoot(String classesRoot); - - Class<?> getDeclaringClass(); - - String getExtension(); - - void setExtension(String extension); - - Set<ResourceDescriptor> getLibraries(); - - Object getLibraryRoot(Object archiveRoot); - - void setLibrariesRoot(String libraryRoot); - - boolean isLibrariesSupported(); - - void setLibrariesSupported(boolean librariesSupported); - - boolean isUnit(); - - void setUnit(boolean unit); - - Class<? extends Throwable> getExpectedDeploymentException(); - - void setExpectedDeploymentException(Class<? extends Throwable> expectedDeploymentException); - - boolean isRunLocally(); - - void setRunLocally(boolean runLocally); - - String getXmlConfigDestination(); - - void setXmlConfigDestination(String xmlConfigDest); - - ResourceDescriptor getXmlConfig(); - - void skipIncludeXmlConfig(boolean skip); -} -
diff --git a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/spi/Containers.java b/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/spi/Containers.java deleted file mode 100644 index 9456642..0000000 --- a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/spi/Containers.java +++ /dev/null
@@ -1,85 +0,0 @@ -//Modified by Google -package org.jboss.testharness.spi; - -//import java.io.IOException; -//import java.io.InputStream; - -import org.jboss.testharness.api.DeploymentException; - -/** - * Incontainer mode deployment related operations - * - * The TCK porting package must provide an implementation of this interface - * which is suitable for the target implementation and application server - * - * <p> - * Modified by Google. - * <ul> - * <li>Removed refrences to java.io.</li> - * <ul> - * - * @author Pete Muir - * - */ -public interface Containers -{ - - public static final String PROPERTY_NAME = Containers.class.getName(); - - /** - * The war/ear to deploy to the container, it should be read using a - * JarInputStream. Any deployment exceptions can be found through - * {@link #getDeploymentException()}. - * - * For a successful deployment, a symmetric {@link #undeploy(String)} will be - * called. - * - * @see #undeploy(String) - * - * @param archive the archive - * @param name the name the TCK uses to refer to this archive, unique within - * this tck run - * @return true if the deployment suceeded, otherwise false - * @throws IOException if any communication problems with the server occur - * during deployment. These will cause the test suite to fail. - */ - public boolean deploy(Object archive, String name); - - public DeploymentException getDeploymentException(); - - /** - * Undeploy the war/ear from the container. - * - * @see #deploy(InputStream, String) - * - * @param name the name the TCK uses to refer to this archive, unique within - * this tck run - * @throws IOException if any communication problems with the server occur - * during deployment. These will cause the test suite to fail. - */ - public void undeploy(String name); - - /** - * Called before the TCK starts executing the testsuite, but after the suite - * has been configured. - * - * A TCK suite lifecycle callback, useful for setting up the container. This - * method may be a no-op if no setup is required. - * - * @throws IOException if any communication problems with the server occur - * during setup. These will cause the test suite to fail. - */ - public void setup(); - - /** - * Called after the TCK finishes executing the testsuite. - * - * A TCK suite lifecycle callback, useful for cleaning up and shutting down - * the container. This method may be a no-op if no setup is required. - * - * @throws IOException if any communication problems with the server occur - * during cleanup. These will cause the test suite to fail. - */ - public void cleanup() ; - -} \ No newline at end of file
diff --git a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/spi/StandaloneContainers.java b/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/spi/StandaloneContainers.java deleted file mode 100644 index 354fb13..0000000 --- a/samples/validationtck/test/org/jboss/testharness/super/org/jboss/testharness/spi/StandaloneContainers.java +++ /dev/null
@@ -1,102 +0,0 @@ -//Modified by Google -package org.jboss.testharness.spi; - -import java.util.Collection; - -import org.jboss.testharness.api.DeploymentException; - -/** - * Standalone mode deployment related operations. If the TCK is placed in - * standalone mode, unit tests will be deployed via this interface. - * - * You must implement this as part of the porting package if you intend to run - * the TCK in standalone mode - * - * @author Pete Muir - * - */ -public interface StandaloneContainers -{ - - public static final String PROPERTY_NAME = StandaloneContainers.class.getName(); - - /** - * <p>Bootstrap the container by registering Beans and Observers, raising - * @Initialized event, validating the deployment, and raising the - * @Deployed event.</p> - * - * <p>Any classes passed in should be fully deployed. This includes:</p> - * - * <ul> - * <li>Simple beans</li> - * <li>Session beans</li> - * <li>Producer methods and producer fields</li> - * <li>Observer methods</li> - * <li>support for Event and Instance injection points</li> - * </ul> - * - * The container should be in an fully initialized state when the - * method returns - * - * @param classes the classes to deploy - */ - public void deploy(Collection<Class<?>> classes) throws DeploymentException; - - /** - * <p>Bootstrap the container for a test by registering Beans and Observers, - * raising @Initialized event, validating the deployment, and raising the - * @Deployed event.</p> - * - * <p>Any classes passed in should be fully deployed. This includes:</p> - * - * <ul> - * <li>Simple beans</li> - * <li>Session beans</li> - * <li>Producer methods and producer fields</li> - * <li>Observer methods</li> - * <li>support for Event and Instance injection points</li> - * </ul> - * - * The container should be in an fully initialized state when the - * method returns - * - * @param classes the classes to deploy - * @param beansXmls the beans.xml files to deploy - * - * @return true if the deployment suceeded, otherwise false - */ - public boolean deploy(Collection<Class<?>> classes, Collection<Object> beansXmls); - - /** - * Any deployment exception, or null if the deployment suceeded - * - * @return - */ - public DeploymentException getDeploymentException(); - - /** - * Cleanup the container after this test - * - */ - public void undeploy(); - - /** - * Called before the TCK starts executing the testsuite, but after the suite - * has been configured. - * - * A TCK suite lifecycle callback, useful for setting up the container. This - * method may be a no-op if no setup is required. - * - */ - public void setup(); - - /** - * Called after the TCK finishes executing the testsuite. - * - * A TCK suite lifecycle callback, useful for cleaning up and shutting down - * the container. This method may be a no-op if no setup is required. - * - */ - public void cleanup(); - -}
diff --git a/samples/validationtck/test/org/testng/TestNg.gwt.xml b/samples/validationtck/test/org/testng/TestNg.gwt.xml deleted file mode 100644 index d0a2fcb..0000000 --- a/samples/validationtck/test/org/testng/TestNg.gwt.xml +++ /dev/null
@@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -This is a HACK, is not a general solution for using TestNg. -It is only enough to run the tests in the GWT Validation TCK. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.junit.JUnit" /> - <source path="annotations"> - <exclude name="ITestAnnotation.java" /> - <exclude name="Listeners.java" /> - <exclude name="Optional.java" /> - </source> - <source path="collections" /> - <source path=""> - <include name="Assert.java" /> - <include name="AssertJUnit.java" /> - <include name="IClass.java" /> - <include name="IHookable.java" /> - <include name="IHookCallBack.java" /> - <include name="ITestResult.java" /> - <include name="ITestNGListener.java" /> - <include name="ITestNGMethod.java" /> - <include name="IAttributes.java" /> - <include name="IRetryAnalyzer.java" /> - <include name="ITestClass.java" /> - </source> - <super-source path="super" /> -</module> \ No newline at end of file
diff --git a/samples/validationtck/test/org/testng/super/org/testng/Assert.java b/samples/validationtck/test/org/testng/super/org/testng/Assert.java deleted file mode 100644 index 7326ef0..0000000 --- a/samples/validationtck/test/org/testng/super/org/testng/Assert.java +++ /dev/null
@@ -1,700 +0,0 @@ -package org.testng; - -import org.testng.collections.Lists; - -//import java.lang.reflect.Array; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - - -/** - * Assertion tool class. Presents assertion methods with a more natural parameter order. - * The order is always <B>actualValue</B>, <B>expectedValue</B> [, message]. - * - * <p> - * Modified by Google - * <ul> - * <li>Removed java.lang.reflect</li> - * <li>Delegate fail messages to junit</li> - * </ul> - * - * @author <a href='mailto:the_mindstorm@evolva.ro'>Alexandru Popescu</a> - */ -public class Assert { - - /** - * Protect constructor since it is a static only class - */ - protected Assert() { - // hide constructor - } - - /** - * Asserts that a condition is true. If it isn't, - * an AssertionError, with the given message, is thrown. - * @param condition the condition to evaluate - * @param message the assertion error message - */ - static public void assertTrue(boolean condition, String message) { - if(!condition) { - failNotEquals( Boolean.valueOf(condition), Boolean.TRUE, message); - } - } - - /** - * Asserts that a condition is true. If it isn't, - * an AssertionError is thrown. - * @param condition the condition to evaluate - */ - static public void assertTrue(boolean condition) { - assertTrue(condition, null); - } - - /** - * Asserts that a condition is false. If it isn't, - * an AssertionError, with the given message, is thrown. - * @param condition the condition to evaluate - * @param message the assertion error message - */ - static public void assertFalse(boolean condition, String message) { - if(condition) { - failNotEquals( Boolean.valueOf(condition), Boolean.FALSE, message); // TESTNG-81 - } - } - - /** - * Asserts that a condition is false. If it isn't, - * an AssertionError is thrown. - * @param condition the condition to evaluate - */ - static public void assertFalse(boolean condition) { - assertFalse(condition, null); - } - - /** - * Fails a test with the given message and wrapping the original exception. - * - * @param message the assertion error message - * @param realCause the original exception - */ - static public void fail(String message, Throwable realCause) { - if(message == null){ - if (realCause != null){ - message = realCause.getMessage(); - } - } else { - message = message + ": " + realCause.getMessage(); - } - junit.framework.Assert.fail(message); - } - - /** - * Fails a test with the given message. - * @param message the assertion error message - */ - static public void fail(String message) { - junit.framework.Assert.fail(message); - } - - /** - * Fails a test with no message. - */ - static public void fail() { - fail(null); - } - - /** - * Asserts that two objects are equal. If they are not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(Object actual, Object expected, String message) { - if((expected == null) && (actual == null)) { - return; - } - if(expected != null) { - if (expected.getClass().isArray()) { - assertArrayEquals(actual, expected, message); - return; - } else if (expected.equals(actual)) { - return; - } - } - failNotEquals(actual, expected, message); - } - - /** - * Asserts that two objects are equal. It they are not, an AssertionError, - * with given message, is thrown. - * @param actual the actual value - * @param expected the expected value (should be an non-null array value) - * @param message the assertion error message - */ - private static void assertArrayEquals(Object actual, Object expected, String message) { - //is called only when expected is an array -// if (actual.getClass().isArray()) { -// int expectedLength = Array.getLength(expected); -// if (expectedLength == Array.getLength(actual)) { -// for (int i = 0 ; i < expectedLength ; i++) { -// Object _actual = Array.get(actual, i); -// Object _expected = Array.get(expected, i); -// try { -// assertEquals(_actual, _expected); -// } catch (AssertionError ae) { -// failNotEquals(actual, expected, message == null ? "" : message -// + " (values as index " + i + " are not the same)"); -// } -// } -// //array values matched -// return; -// } else { -// failNotEquals(Array.getLength(actual), expectedLength, message == null ? "" : message -// + " (Array lengths are not the same)"); -// } -// } -// failNotEquals(actual, expected, message); - fail("assertArrayEquals not implemented"); - } - -/** - * Asserts that two objects are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(Object actual, Object expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two Strings are equal. If they are not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(String actual, String expected, String message) { - assertEquals((Object) actual, (Object) expected, message); - } - - /** - * Asserts that two Strings are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(String actual, String expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two doubles are equal concerning a delta. If they are not, - * an AssertionError, with the given message, is thrown. If the expected - * value is infinity then the delta value is ignored. - * @param actual the actual value - * @param expected the expected value - * @param delta the absolute tolerate value value between the actual and expected value - * @param message the assertion error message - */ - static public void assertEquals(double actual, double expected, double delta, String message) { - // handle infinity specially since subtracting to infinite values gives NaN and the - // the following test fails - if(Double.isInfinite(expected)) { - if(!(expected == actual)) { - failNotEquals(new Double(actual), new Double(expected), message); - } - } - else if(!(Math.abs(expected - actual) <= delta)) { // Because comparison with NaN always returns false - failNotEquals(new Double(actual), new Double(expected), message); - } - } - - /** - * Asserts that two doubles are equal concerning a delta. If they are not, - * an AssertionError is thrown. If the expected value is infinity then the - * delta value is ignored. - * @param actual the actual value - * @param expected the expected value - * @param delta the absolute tolerate value value between the actual and expected value - */ - static public void assertEquals(double actual, double expected, double delta) { - assertEquals(actual, expected, delta, null); - } - - /** - * Asserts that two floats are equal concerning a delta. If they are not, - * an AssertionError, with the given message, is thrown. If the expected - * value is infinity then the delta value is ignored. - * @param actual the actual value - * @param expected the expected value - * @param delta the absolute tolerate value value between the actual and expected value - * @param message the assertion error message - */ - static public void assertEquals(float actual, float expected, float delta, String message) { - // handle infinity specially since subtracting to infinite values gives NaN and the - // the following test fails - if(Float.isInfinite(expected)) { - if(!(expected == actual)) { - failNotEquals(new Float(actual), new Float(expected), message); - } - } - else if(!(Math.abs(expected - actual) <= delta)) { - failNotEquals(new Float(actual), new Float(expected), message); - } - } - - /** - * Asserts that two floats are equal concerning a delta. If they are not, - * an AssertionError is thrown. If the expected - * value is infinity then the delta value is ignored. - * @param actual the actual value - * @param expected the expected value - * @param delta the absolute tolerate value value between the actual and expected value - */ - static public void assertEquals(float actual, float expected, float delta) { - assertEquals(actual, expected, delta, null); - } - - /** - * Asserts that two longs are equal. If they are not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(long actual, long expected, String message) { - assertEquals(Long.valueOf(actual), Long.valueOf(expected), message); - } - - /** - * Asserts that two longs are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(long actual, long expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two booleans are equal. If they are not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(boolean actual, boolean expected, String message) { - assertEquals( Boolean.valueOf(actual), Boolean.valueOf(expected), message); - } - - /** - * Asserts that two booleans are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(boolean actual, boolean expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two bytes are equal. If they are not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(byte actual, byte expected, String message) { - assertEquals(Byte.valueOf(actual), Byte.valueOf(expected), message); - } - - /** - * Asserts that two bytes are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(byte actual, byte expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two chars are equal. If they are not, - * an AssertionFailedError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(char actual, char expected, String message) { - assertEquals(Character.valueOf(actual), Character.valueOf(expected), message); - } - - /** - * Asserts that two chars are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(char actual, char expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two shorts are equal. If they are not, - * an AssertionFailedError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(short actual, short expected, String message) { - assertEquals(Short.valueOf(actual), Short.valueOf(expected), message); - } - - /** - * Asserts that two shorts are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(short actual, short expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two ints are equal. If they are not, - * an AssertionFailedError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(int actual, int expected, String message) { - assertEquals(Integer.valueOf(actual), Integer.valueOf(expected), message); - } - - /** - * Asserts that two ints are equal. If they are not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(int actual, int expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that an object isn't null. If it is, - * an AssertionError is thrown. - * @param object the assertion object - */ - static public void assertNotNull(Object object) { - assertNotNull(object, null); - } - - /** - * Asserts that an object isn't null. If it is, - * an AssertionFailedError, with the given message, is thrown. - * @param object the assertion object - * @param message the assertion error message - */ - static public void assertNotNull(Object object, String message) { - assertTrue(object != null, message); - } - - /** - * Asserts that an object is null. If it is not, - * an AssertionError, with the given message, is thrown. - * @param object the assertion object - */ - static public void assertNull(Object object) { - assertNull(object, null); - } - - /** - * Asserts that an object is null. If it is not, - * an AssertionFailedError, with the given message, is thrown. - * @param object the assertion object - * @param message the assertion error message - */ - static public void assertNull(Object object, String message) { - assertTrue(object == null, message); - } - - /** - * Asserts that two objects refer to the same object. If they do not, - * an AssertionFailedError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertSame(Object actual, Object expected, String message) { - if(expected == actual) { - return; - } - failNotSame(actual, expected, message); - } - - /** - * Asserts that two objects refer to the same object. If they do not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertSame(Object actual, Object expected) { - assertSame(actual, expected, null); - } - - /** - * Asserts that two objects do not refer to the same objects. If they do, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertNotSame(Object actual, Object expected, String message) { - if(expected == actual) { - failSame(actual, expected, message); - } - } - - /** - * Asserts that two objects do not refer to the same object. If they do, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertNotSame(Object actual, Object expected) { - assertNotSame(actual, expected, null); - } - - static private void failSame(Object actual, Object expected, String message) { - String formatted = ""; - if(message != null) { - formatted = message + " "; - } - fail(formatted + "expected not same with:<" + expected +"> but was same:<" + actual + ">"); - } - - static private void failNotSame(Object actual, Object expected, String message) { - String formatted = ""; - if(message != null) { - formatted = message + " "; - } - fail(formatted + "expected same with:<" + expected + "> but was:<" + actual + ">"); - } - - static private void failNotEquals(Object actual , Object expected, String message ) { - fail(format(actual, expected, message)); - } - - static String format(Object actual, Object expected, String message) { - String formatted = ""; - if (null != message) { - formatted = message + " "; - } - - return formatted + "expected:<" + expected + "> but was:<" + actual + ">"; - } - - /** - * Asserts that two collections contain the same elements in the same order. If they do not, - * an AssertionError is thrown. - * - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(Collection actual, Collection expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two collections contain the same elements in the same order. If they do not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(Collection actual, Collection expected, String message) { - if(actual == expected) return; - - if (actual == null || expected == null) { - if (message != null) fail(message); - else fail("Collections not equal: expected: " + expected + " and actual: " + actual); - } - - assertEquals(actual.size(), expected.size(), message + ": lists don't have the same size"); - - Iterator actIt = actual.iterator(); - Iterator expIt = expected.iterator(); - int i = -1; - while(actIt.hasNext() && expIt.hasNext()) { - i++; - Object e = expIt.next(); - Object a = actIt.next(); - String errorMessage = message == null - ? "Lists differ at element [" + i + "]: " + e + " != " + a - : message + ": Lists differ at element [" + i + "]: " + e + " != " + a; - - assertEquals(a, e, errorMessage); - } - } - - /** - * Asserts that two arrays contain the same elements in the same order. If they do not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(Object[] actual, Object[] expected, String message) { - if(actual == expected) return; - - if ((actual == null && expected != null) || (actual != null && expected == null)) { - if (message != null) fail(message); - else fail("Arrays not equal: " + Arrays.toString(expected) + " and " + Arrays.toString(actual)); - } - assertEquals(Arrays.asList(actual), Arrays.asList(expected), message); - } - - /** - * Asserts that two arrays contain the same elements in no particular order. If they do not, - * an AssertionError, with the given message, is thrown. - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEqualsNoOrder(Object[] actual, Object[] expected, String message) { - if(actual == expected) return; - - if ((actual == null && expected != null) || (actual != null && expected == null)) { - failAssertNoEqual(actual, expected, - "Arrays not equal: " + Arrays.toString(expected) + " and " + Arrays.toString(actual), - message); - } - - if (actual.length != expected.length) { - failAssertNoEqual(actual, expected, - "Arrays do not have the same size:" + actual.length + " != " + expected.length, - message); - } - - List actualCollection = Lists.newArrayList(); - for (Object a : actual) { - actualCollection.add(a); - } - for (Object o : expected) { - actualCollection.remove(o); - } - if (actualCollection.size() != 0) { - failAssertNoEqual(actual, expected, - "Arrays not equal: " + Arrays.toString(expected) + " and " + Arrays.toString(actual), - message); - } - } - - private static void failAssertNoEqual(Object[] actual, Object[] expected, - String message, String defaultMessage) - { - if (message != null) fail(message); - else fail(defaultMessage); - } - - /** - * Asserts that two arrays contain the same elements in the same order. If they do not, - * an AssertionError is thrown. - * - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(Object[] actual, Object[] expected) { - assertEquals(actual, expected, null); - } - - /** - * Asserts that two arrays contain the same elements in no particular order. If they do not, - * an AssertionError is thrown. - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEqualsNoOrder(Object[] actual, Object[] expected) { - assertEqualsNoOrder(actual, expected, null); - } - - /** - * Asserts that two arrays contain the same elements in the same order. If they do not, - * an AssertionError is thrown. - * - * @param actual the actual value - * @param expected the expected value - */ - static public void assertEquals(final byte[] actual, final byte[] expected) { - assertEquals(actual, expected, ""); - } - - /** - * Asserts that two arrays contain the same elements in the same order. If they do not, - * an AssertionError, with the given message, is thrown. - * - * @param actual the actual value - * @param expected the expected value - * @param message the assertion error message - */ - static public void assertEquals(final byte[] actual, final byte[] expected, final String message) { - if(expected == actual) { - return; - } - if(null == expected) { - fail("expected a null array, but not null found. " + message); - } - if(null == actual) { - fail("expected not null array, but null found. " + message); - } - - assertEquals(actual.length, expected.length, "arrays don't have the same size. " + message); - - for(int i= 0; i < expected.length; i++) { - if(expected[i] != actual[i]) { - fail("arrays differ firstly at element [" + i +"]; " - + "expected value is <" + expected[i] +"> but was <" - + actual[i] + ">. " - + message); - } - } - } - - /** - * Asserts that two sets are equal. - */ - static public void assertEquals(Set actual, Set expected) { - if(actual == expected) return; - - if (actual == null || expected == null) { - fail("Sets not equal: expected: " + expected + " and actual: " + actual); - } - - if (!actual.equals(expected)) { - fail("Sets differ: expected " + expected + " but got " + actual); - } - } - - /** - * Asserts that two maps are equal. - */ - static public void assertEquals(Map actual, Map expected) { - if(actual == expected) return; - - if (actual == null || expected == null) { - fail("Maps not equal: expected: " + expected + " and actual: " + actual); - } - - if (!actual.equals(expected)) { - fail("Maps differ: expected " + expected + " but got " + actual); - } - } - -}
diff --git a/samples/validationtck/test/org/testng/super/org/testng/IClass.java b/samples/validationtck/test/org/testng/super/org/testng/IClass.java deleted file mode 100644 index d957929..0000000 --- a/samples/validationtck/test/org/testng/super/org/testng/IClass.java +++ /dev/null
@@ -1,53 +0,0 @@ -// Modified by Google -// Removed xml classes -package org.testng; - -import java.io.Serializable; - - -/** - * <code>IClass</code> represents a test class and a collection of its instances. - * - * <p> - * Modified by Google - * <ul><li>Removed xml classes</li> - * </ul> - * - * @author <a href = "mailto:cedric@beust.com">Cedric Beust</a> - */ -public interface IClass extends Serializable { - - /** - * @return this test class name. This is the name of the - * corresponding Java class. - */ - String getName(); - - /** - * @return the <test> tag this class was found in. - */ - Object getXmlTest(); - - /** - * @return the *lt;class> tag this class was found in. - */ - Object getXmlClass(); - - /** - * If this class implements ITest, returns its test name, otherwise returns null. - */ - String getTestName(); - - /** - * @return the Java class corresponding to this IClass. - */ - Class getRealClass(); - - Object[] getInstances(boolean create); - - int getInstanceCount(); - - long[] getInstanceHashCodes(); - - void addInstance(Object instance); -}
diff --git a/samples/validationtck/test/org/testng/super/org/testng/ITestNGMethod.java b/samples/validationtck/test/org/testng/super/org/testng/ITestNGMethod.java deleted file mode 100644 index df2683b..0000000 --- a/samples/validationtck/test/org/testng/super/org/testng/ITestNGMethod.java +++ /dev/null
@@ -1,238 +0,0 @@ -package org.testng; - - -import java.io.Serializable; -import java.util.List; - -/** - * Describes a TestNG annotated method and the instance on which it will be invoked. - * - * This interface is not meant to be implemented by users. - * - * <p> - * Modified by Google - * <ul> - * <li>removed java.reflect.Method</li> - * </ul> - * - * @author Cedric Beust, May 3, 2004 - */ -public interface ITestNGMethod extends Comparable, Serializable, Cloneable { - - /** - * @return The real class on which this method was declared - * (can be different from getMethod().getDeclaringClass() if - * the test method was defined in a superclass). - */ - Class getRealClass(); - - ITestClass getTestClass(); - - /** - * Sets the test class having this method. This is not necessarily the declaring class. - * - * @param cls The test class having this method. - */ - void setTestClass(ITestClass cls); - - /** - * Returns the corresponding Java test method. - * @return the corresponding Java test method. - */ - Object getMethod(); - - /** - * Returns the method name. This is needed for serialization because - * methods are not Serializable. - * @return the method name. - */ - String getMethodName(); - - /** - * @return All the instances the methods will be invoked upon. - * This will typically be an array of one object in the absence - * of an @Factory annotation. - */ - Object[] getInstances(); - - /** - * Needed for serialization. - */ - long[] getInstanceHashCodes(); - - /** - * @return The groups this method belongs to, possibly added to the groups - * declared on the class. - */ - String[] getGroups(); - - /** - * @return The groups this method depends on, possibly added to the groups - * declared on the class. - */ - String[] getGroupsDependedUpon(); - - /** - * If a group was not found. - */ - String getMissingGroup(); - public void setMissingGroup(String group); - - /** - * Before and After groups - */ - public String[] getBeforeGroups(); - public String[] getAfterGroups(); - - /** - * @return The methods this method depends on, possibly added to the methods - * declared on the class. - */ - String[] getMethodsDependedUpon(); - void addMethodDependedUpon(String methodName); - - /** - * @return true if this method was annotated with @Test - */ - boolean isTest(); - - /** - * @return true if this method was annotated with @Configuration - * and beforeTestMethod = true - */ - boolean isBeforeMethodConfiguration(); - - /** - * @return true if this method was annotated with @Configuration - * and beforeTestMethod = false - */ - boolean isAfterMethodConfiguration(); - - /** - * @return true if this method was annotated with @Configuration - * and beforeClassMethod = true - */ - boolean isBeforeClassConfiguration(); - - /** - * @return true if this method was annotated with @Configuration - * and beforeClassMethod = false - */ - boolean isAfterClassConfiguration(); - - /** - * @return true if this method was annotated with @Configuration - * and beforeSuite = true - */ - boolean isBeforeSuiteConfiguration(); - - /** - * @return true if this method was annotated with @Configuration - * and afterSuite = true - */ - boolean isAfterSuiteConfiguration(); - - /** - * @return <tt>true</tt> if this method is a @BeforeTest (@Configuration beforeTest=true) - */ - boolean isBeforeTestConfiguration(); - - /** - * @return <tt>true</tt> if this method is an @AfterTest (@Configuration afterTest=true) - */ - boolean isAfterTestConfiguration(); - - boolean isBeforeGroupsConfiguration(); - - boolean isAfterGroupsConfiguration(); - - /** - * @return The timeout in milliseconds. - */ - long getTimeOut(); - void setTimeOut(long timeOut); - - /** - * @return the number of times this method needs to be invoked. - */ - int getInvocationCount(); - void setInvocationCount(int count); - - /** - * @return the success percentage for this method (between 0 and 100). - */ - int getSuccessPercentage(); - - /** - * @return The id of the thread this method was run in. - */ - String getId(); - - void setId(String id); - - long getDate(); - - void setDate(long date); - - /** - * Returns if this ITestNGMethod can be invoked from within IClass. - */ - boolean canRunFromClass(IClass testClass); - - /** - * @return true if this method is alwaysRun=true - */ - boolean isAlwaysRun(); - - /** - * @return the number of threads to be used when invoking the method on parallel - */ - int getThreadPoolSize(); - - void setThreadPoolSize(int threadPoolSize); - - public String getDescription(); - - public void incrementCurrentInvocationCount(); - public int getCurrentInvocationCount(); - public void setParameterInvocationCount(int n); - public int getParameterInvocationCount(); - - public ITestNGMethod clone(); - - public IRetryAnalyzer getRetryAnalyzer(); - public void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer); - - public boolean skipFailedInvocations(); - public void setSkipFailedInvocations(boolean skip); - - /** - * The time under which all invocationCount methods need to complete by. - */ - public long getInvocationTimeOut(); - - public boolean ignoreMissingDependencies(); - public void setIgnoreMissingDependencies(boolean ignore); - - /** - * Which invocation numbers of this method should be used (only applicable - * if it uses a data provider). If this value is an empty list, use all the values - * returned from the data provider. These values are read from the XML file in - * the <include invocationNumbers="..."> tag. - */ - public List<Integer> getInvocationNumbers(); - public void setInvocationNumbers(List<Integer> numbers); - - /** - * The list of invocation numbers that failed, which is only applicable for - * methods that have a data provider. - */ - public void addFailedInvocationNumber(int number); - public List<Integer> getFailedInvocationNumbers(); - - /** - * The scheduling priority. Lower priorities get scheduled first. - */ - public int getPriority(); - public void setPriority(int priority); -}
diff --git a/samples/validationtck/test/org/testng/super/org/testng/collections/Maps.java b/samples/validationtck/test/org/testng/super/org/testng/collections/Maps.java deleted file mode 100644 index 778f637..0000000 --- a/samples/validationtck/test/org/testng/super/org/testng/collections/Maps.java +++ /dev/null
@@ -1,15 +0,0 @@ -package org.testng.collections; - -import java.util.HashMap; -import java.util.Map; - -public class Maps { - - public static <K, V> Map<K,V> newHashMap() { - return new HashMap<K, V>(); - } - - public static <K, V> Map<K,V> newHashtable() { - throw new RuntimeException("Hashtable are not supported in GWT"); - } -}
diff --git a/user/src/com/google/gwt/validation/Validation.gwt.xml b/user/src/com/google/gwt/validation/Validation.gwt.xml deleted file mode 100644 index 063a83e..0000000 --- a/user/src/com/google/gwt/validation/Validation.gwt.xml +++ /dev/null
@@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" - "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.regexp.RegExp" /> - <inherits name="javax.validation.Validation" /> - <source path="client" /> - <super-source path="super" /> - - <replace-with - class="com.google.gwt.validation.client.GwtConstraintValidatorFactory"> - <when-type-is class="javax.validation.ConstraintValidatorFactory" /> - </replace-with> - <replace-with - class="com.google.gwt.validation.client.GwtMessageInterpolator"> - <when-type-is class="javax.validation.MessageInterpolator" /> - </replace-with> - <replace-with - class="com.google.gwt.validation.client.GwtTraversableResolver"> - <when-type-is class="javax.validation.TraversableResolver" /> - </replace-with> - - <replace-with - class="com.google.gwt.validation.client.GwtValidationProviderResolver"> - <when-type-is class="javax.validation.ValidationProviderResolver" /> - </replace-with> - <replace-with class="com.google.gwt.validation.client.GwtValidatorContext"> - <when-type-is class="javax.validation.ValidatorContext" /> - </replace-with> - <replace-with class="com.google.gwt.validation.client.NullUserValidationMessageResolver"> - <!-- User can override this to have Custom messages --> - <when-type-is class="com.google.gwt.validation.client.UserValidationMessagesResolver" /> - </replace-with> - <replace-with - class="com.google.gwt.validation.client.spi.GwtValidationProvider"> - <when-type-is class="javax.validation.spi.ValidationProvider" /> - </replace-with> - - <!-- Generators --> - <generate-with class="com.google.gwt.validation.rebind.ValidatorGenerator"> - <when-type-assignable class="javax.validation.Validator" /> - </generate-with> - <generate-with - class="com.google.gwt.validation.rebind.GwtSpecificValidatorGenerator"> - <when-type-assignable - class="com.google.gwt.validation.client.impl.GwtSpecificValidator" /> - </generate-with> -</module>
diff --git a/user/src/com/google/gwt/validation/client/AbstractGwtValidatorFactory.java b/user/src/com/google/gwt/validation/client/AbstractGwtValidatorFactory.java deleted file mode 100644 index c4fbaa0..0000000 --- a/user/src/com/google/gwt/validation/client/AbstractGwtValidatorFactory.java +++ /dev/null
@@ -1,91 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; -import javax.validation.Validator; -import javax.validation.ValidatorContext; -import javax.validation.ValidatorFactory; - -/** - * Abstract {@link ValidatorFactory} that delegates to a GWT generated - * {@link Validator}. - * <p> - * Extend this class create and implement createValidator - * - * <pre> - * public class MyValidatorFactory extends AbstractGwtValidatorFactory { - * @GwtValidation(value = {Pojo.class,Other.class}) - * public static interface GwtValidator extends Validator { - * } - * - * public AbstractGwtValidator createValidator (){ - * return GWT.create(GwtValidator.class)); - * } - * } - * </pre> - * <p> - * Then add a line like this to your Gwt Module config (gwt.xml) file. - * - * <pre> - * <replace-with class="com.example.MyValidatorFactory"> - * <when-type-is class="javax.validation.ValidatorFactory"/> - * </replace-with> - * </pre> - */ -public abstract class AbstractGwtValidatorFactory implements ValidatorFactory { - - /** - * Implement this method to returns a {@link GWT#create}ed {@link Validator} - * annotated with {@link GwtValidation}. - * - * @return newly created Validator - */ - public abstract AbstractGwtValidator createValidator(); - - public final ConstraintValidatorFactory getConstraintValidatorFactory() { - return GWT.create(ConstraintValidatorFactory.class); - } - - public final MessageInterpolator getMessageInterpolator() { - return new GwtMessageInterpolator(); - } - - public final TraversableResolver getTraversableResolver() { - return GWT.create(TraversableResolver.class); - } - - public final Validator getValidator() { - AbstractGwtValidator validator = createValidator(); - validator.init(getConstraintValidatorFactory(), getMessageInterpolator(), - getTraversableResolver()); - return validator; - } - - public final <T> T unwrap(Class<T> type) { - // TODO(nchalko implement - return null; - } - - public final ValidatorContext usingContext() { - return GWT.create(ValidatorContext.class); - } -}
diff --git a/user/src/com/google/gwt/validation/client/AbstractValidationMessageResolver.java b/user/src/com/google/gwt/validation/client/AbstractValidationMessageResolver.java deleted file mode 100644 index 6c7eaa0..0000000 --- a/user/src/com/google/gwt/validation/client/AbstractValidationMessageResolver.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.i18n.client.ConstantsWithLookup; - -import java.util.MissingResourceException; - -/** - * ValidationMessageResolver using a {@link ConstantsWithLookup} source. - */ -public abstract class AbstractValidationMessageResolver { - private final ConstantsWithLookup messages; - - protected AbstractValidationMessageResolver(ConstantsWithLookup messages) { - this.messages = messages; - } - - public final String get(String key) { - try { - // Replace "." with "_" in the key to match what ConstantsImplCreator - // does. - return key == null ? null : messages.getString(key.replace(".", "_")); - } catch (MissingResourceException e) { - return null; - } - } -}
diff --git a/user/src/com/google/gwt/validation/client/BaseGwtConfiguration.java b/user/src/com/google/gwt/validation/client/BaseGwtConfiguration.java deleted file mode 100644 index bdaa2f8..0000000 --- a/user/src/com/google/gwt/validation/client/BaseGwtConfiguration.java +++ /dev/null
@@ -1,90 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.spi.GwtConfigurationState; -import com.google.gwt.validation.client.spi.GwtValidationProvider; - -import javax.validation.Configuration; -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; -import javax.validation.ValidatorFactory; -import javax.validation.spi.BootstrapState; -import javax.validation.spi.ConfigurationState; - -/** - * Base GWT {@link Configuration}. - */ -public abstract class BaseGwtConfiguration implements - Configuration<BaseGwtConfiguration> { - - protected final GwtValidationProvider provider; - protected final BootstrapState state; - - public BaseGwtConfiguration(GwtValidationProvider gwtValidationProvider, - BootstrapState state) { - provider = gwtValidationProvider; - this.state = state; - } - - public final BaseGwtConfiguration addProperty(String name, String value) { - // TODO(nchalko) implement. - return this; - } - - public final ValidatorFactory buildValidatorFactory() { - ConfigurationState configurationState = new GwtConfigurationState(); - return provider.buildValidatorFactory(configurationState); - } - - public final BaseGwtConfiguration constraintValidatorFactory( - ConstraintValidatorFactory constraintValidatorFactory) { - // TODO(nchalko) implement. - return this; - } - - public final ConstraintValidatorFactory getDefaultConstraintValidatorFactory() { - return GWT.create(ConstraintValidatorFactory.class); - } - - public final MessageInterpolator getDefaultMessageInterpolator() { - return GWT.create(MessageInterpolator.class); - } - - public final TraversableResolver getDefaultTraversableResolver() { - return GWT.create(TraversableResolver.class); - } - - public final BaseGwtConfiguration ignoreXmlConfiguration() { - // TODO(nchalko) implement. - return this; - } - - public final BaseGwtConfiguration messageInterpolator( - MessageInterpolator interpolator) { - // TODO(nchalko) implement. - return this; - } - - public final BaseGwtConfiguration traversableResolver( - TraversableResolver resolver) { - // TODO(nchalko) implement. - return this; - } - -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/BaseMessageInterpolator.java b/user/src/com/google/gwt/validation/client/BaseMessageInterpolator.java deleted file mode 100644 index 9feb57d..0000000 --- a/user/src/com/google/gwt/validation/client/BaseMessageInterpolator.java +++ /dev/null
@@ -1,162 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.shared.GwtLocale; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; - -import java.util.Map; - -import javax.validation.MessageInterpolator; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * Base GWT {@link MessageInterpolator}. - */ -public abstract class BaseMessageInterpolator implements MessageInterpolator { - - /** - * Implementation of {@link Context}. - */ - public static class ContextImpl implements Context { - - private final ConstraintDescriptor<?> constraintDescriptor; - private final Object value; - - public ContextImpl(ConstraintDescriptor<?> constraintDescriptor, Object value) { - this.constraintDescriptor = constraintDescriptor; - this.value = value; - } - - public ConstraintDescriptor<?> getConstraintDescriptor() { - return constraintDescriptor; - } - - public Object getValidatedValue() { - return value; - } - } - - // local version because guava is included. - private static interface Function<F, T> { - T apply(F from); - } - - /** - * Regular expression used to do message interpolation. - */ - private static final RegExp MESSAGE_PARAMETER_PATTERN = RegExp.compile( - "(\\{[^\\}]+?\\})", "g"); - - // Visible for testing - static Function<String, String> createAnnotationReplacer( - final Map<String, Object> map) { - return new Function<String, String>() { - - public String apply(String from) { - Object object = map.get(from); - return object == null ? null : object.toString(); - } - }; - } - - private static Function<String, String> createReplacer( - final ValidationMessageResolver messageResolver) { - return new Function<String, String>() { - public String apply(String from) { - Object object = messageResolver.get(from); - return object == null ? null : object.toString(); - } - }; - } - - /** - * Replaces keys using the Default Validation Provider properties. - */ - private final Function<String, String> providerReplacer = - createReplacer((ValidationMessageResolver) - GWT.create(ProviderValidationMessageResolver.class)); - - /** - * Replaces keys using the Validation User custom properties. - */ - private final Function<String, String> userReplacer = - createReplacer((ValidationMessageResolver) - GWT.create(UserValidationMessagesResolver.class)); - - public String interpolate(String messageTemplate, Context context) { - return gwtInterpolate(messageTemplate, context, null); - } - - protected String gwtInterpolate(String message, Context context, - GwtLocale locale) { - // see Section 4.3.1.1 - String resolvedMessage = message; - String step1message; - - // TODO(nchalko) Add a safety to make sure this does not loop forever. - do { - do { - step1message = resolvedMessage; - - // Step 1 Replace message parameters using custom user messages - // repeat - resolvedMessage = replaceParameters(resolvedMessage, userReplacer); - } while (!step1message.equals(resolvedMessage)); - - // Step2 Replace message parameter using the default provider messages. - resolvedMessage = replaceParameters(resolvedMessage, providerReplacer); - - // Step 3 repeat from step 1 if step 2 made changes. - } while (!step1message.equals(resolvedMessage)); - - // step 4 resolve annotation attributes - resolvedMessage = replaceParameters( - resolvedMessage, - createAnnotationReplacer(context.getConstraintDescriptor().getAttributes())); - - // Remove escapes (4.3.1) - resolvedMessage = resolvedMessage.replace("\\{", "{"); - resolvedMessage = resolvedMessage.replace("\\}", "}"); - resolvedMessage = resolvedMessage.replace("\\\\", "\\"); - return resolvedMessage; - } - - protected String replaceParameters(String message, - Function<String, String> replacer) { - StringBuffer sb = new StringBuffer(); - int index = 0; - - MatchResult matcher; - while ((matcher = MESSAGE_PARAMETER_PATTERN.exec(message)) != null) { - String matched = matcher.getGroup(0); - sb.append(message.substring(index, matcher.getIndex())); - Object value = replacer.apply(removeCurlyBrace(matched)); - sb.append(value == null ? matched : value); - index = MESSAGE_PARAMETER_PATTERN.getLastIndex(); - } - if (index < message.length()) { - sb.append(message.substring(index)); - } - return sb.toString(); - } - - private String removeCurlyBrace(String parameter) { - return parameter.substring(1, parameter.length() - 1); - } -}
diff --git a/user/src/com/google/gwt/validation/client/GwtConfiguration.java b/user/src/com/google/gwt/validation/client/GwtConfiguration.java deleted file mode 100644 index 4f81609..0000000 --- a/user/src/com/google/gwt/validation/client/GwtConfiguration.java +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.validation.client.spi.GwtValidationProvider; - -import java.io.InputStream; - -import javax.validation.spi.BootstrapState; - -/** - * Extends {@link BaseGwtConfiguration} with just the parts that are not GWT - * compatible. - */ -public class GwtConfiguration extends BaseGwtConfiguration { - - public GwtConfiguration(GwtValidationProvider gwtValidationProvider, - BootstrapState state) { - super(gwtValidationProvider, state); - } - - public GwtConfiguration addMapping(InputStream stream) { - throw new UnsupportedOperationException("GWT does not support InputStreams"); - } -}
diff --git a/user/src/com/google/gwt/validation/client/GwtConstraintValidatorFactory.java b/user/src/com/google/gwt/validation/client/GwtConstraintValidatorFactory.java deleted file mode 100644 index 5a567da..0000000 --- a/user/src/com/google/gwt/validation/client/GwtConstraintValidatorFactory.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorFactory; - -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -/** - * GWT does not support {@link ConstraintValidatorFactory} use - * {@link com.google.gwt.core.client.GWT;#create(Class)} instead. Using this - * class throws a {@link UnsupportedOperationException}. - */ -public class GwtConstraintValidatorFactory implements - ConstraintValidatorFactory { - - /** - * Always throws {@link UnsupportedOperationException}. - * - * @throws UnsupportedOperationException - */ - public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) { - throw new UnsupportedOperationException("GWT does not support " - + ConstraintValidatorFactory.class.getName() - + " use GWT.create instead"); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/GwtMessageInterpolator.java b/user/src/com/google/gwt/validation/client/GwtMessageInterpolator.java deleted file mode 100644 index 7d2578c..0000000 --- a/user/src/com/google/gwt/validation/client/GwtMessageInterpolator.java +++ /dev/null
@@ -1,30 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import java.util.Locale; - -/** - * Simple GWT {@link javax.validation.MessageInterpolator}. - */ -public class GwtMessageInterpolator extends BaseMessageInterpolator { - // This class only has the parts the need to overridden for GWT - - public String interpolate(String messageTemplate, Context context, - Locale locale) { - return messageTemplate; - } -}
diff --git a/user/src/com/google/gwt/validation/client/GwtTraversableResolver.java b/user/src/com/google/gwt/validation/client/GwtTraversableResolver.java deleted file mode 100644 index 38d3880..0000000 --- a/user/src/com/google/gwt/validation/client/GwtTraversableResolver.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import java.lang.annotation.ElementType; - -import javax.validation.Path; -import javax.validation.Path.Node; -import javax.validation.TraversableResolver; - -/** - * GWT {@link TraversableResolver}. - */ -public class GwtTraversableResolver implements TraversableResolver { - - public boolean isCascadable(Object traversableObject, - Node traversableProperty, Class<?> rootBeanType, - Path pathToTraversableObject, ElementType elementType) { - // TODO(nchalko) implement - return false; - } - - public boolean isReachable(Object traversableObject, - Node traversableProperty, Class<?> rootBeanType, - Path pathToTraversableObject, ElementType elementType) { - // TODO(nchalko) implement - return false; - } - -}
diff --git a/user/src/com/google/gwt/validation/client/GwtValidation.java b/user/src/com/google/gwt/validation/client/GwtValidation.java deleted file mode 100644 index 70f82c8..0000000 --- a/user/src/com/google/gwt/validation/client/GwtValidation.java +++ /dev/null
@@ -1,98 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Annotates a {@code javax.validation.Validator} explicitly listing the classes - * that can be validated in GWT. - * <p> - * Define the Validator you want, explicitly listing the class you want to - * validate. - * - * <pre> - * @GwtValidation(MyBean.class, MyOther.class) - * public interface MyValidator extends javax.validation.Validator { - * } - * </pre> - * Create and use the validator. - * - * <pre> - * MyValidator validator = GWT.create(MyValidator.class); - * MyBean bean = new MyBean(); - * ... - * Set<ConstraintViolation<MyBean>> violations = validator.validate(bean); - * </pre> - * - * <p> - * NOTE: Validation is done using only the Constraints found on the Classes - * listed in the annotation. If you have - * - * <pre> - * class MyBean { - * @Null - * String getName(){return name;} - * } - * class MySubBean extends MyBean { - * @Size(min = 5) - * String getName(){return super.getName();} - * } - * </pre> - * - * And then create your {@link javax.validation.ValidatorFactory - * ValidatorFactory} using - * - * <pre> - * @GwtValidation(MyBean.class, MyOther.class)} - * </pre> - * - * but call validator with the subclass like - * - * <pre> - * MySubBean bean = new MySubBean(); - * Set<ConstraintViolation<MyBean>> violations = validator.validate(bean); - * </pre> - * - * The {@code Size} constraint will not be validated. - * - * Instead make sure you list the all BeanTypes that will be directly validated - * in the {@link GwtValidation} annotation. - * - * - */ -@Documented -@Target(TYPE) -@Retention(RUNTIME) -public @interface GwtValidation { - - /** - * The list of Groups which can be processed by the annotated - * {@code Validator}, empty means all groups. - */ - Class<?>[] groups() default {}; - - /** - * The list of Classes which can be validated by the annotated - * {@code Validator}. - */ - Class<?>[] value(); -}
diff --git a/user/src/com/google/gwt/validation/client/GwtValidationProviderResolver.java b/user/src/com/google/gwt/validation/client/GwtValidationProviderResolver.java deleted file mode 100644 index 66ea36b..0000000 --- a/user/src/com/google/gwt/validation/client/GwtValidationProviderResolver.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.core.client.GWT; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.validation.ValidationProviderResolver; -import javax.validation.spi.ValidationProvider; - -/** - * The default GWT {@link ValidationProviderResolver}. This always returns the - * single default ValidationProvider using {@link GWT#create(Class)}. - */ -public class GwtValidationProviderResolver implements - ValidationProviderResolver { - - private static final List<ValidationProvider<?>> defaultList = - Collections.unmodifiableList(createValidationProviderList()); - - private static ArrayList<ValidationProvider<?>> createValidationProviderList() { - ArrayList<ValidationProvider<?>> temp = new ArrayList<ValidationProvider<?>>(); - ValidationProvider<?> provider = GWT.create(ValidationProvider.class); - temp.add(provider); - return temp; - } - - public List<ValidationProvider<?>> getValidationProviders() { - return defaultList; - } -}
diff --git a/user/src/com/google/gwt/validation/client/GwtValidatorContext.java b/user/src/com/google/gwt/validation/client/GwtValidatorContext.java deleted file mode 100644 index 259b869..0000000 --- a/user/src/com/google/gwt/validation/client/GwtValidatorContext.java +++ /dev/null
@@ -1,76 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; -import javax.validation.Validator; -import javax.validation.ValidatorContext; -import javax.validation.ValidatorFactory; - -/** - * GWT {@link ValidatorContext}. - */ -public class GwtValidatorContext implements ValidatorContext { - - private final AbstractGwtValidatorFactory validatorFactory = GWT.create(ValidatorFactory.class); - - private ConstraintValidatorFactory constraintValidatorfactory = validatorFactory.getConstraintValidatorFactory(); - private MessageInterpolator messageInterpolator = validatorFactory.getMessageInterpolator(); - private TraversableResolver traversableResolver = validatorFactory.getTraversableResolver(); - - public ValidatorContext constraintValidatorFactory( - ConstraintValidatorFactory factory) { - if (factory == null) { - this.constraintValidatorfactory = GWT.create(ConstraintValidatorFactory.class); - } else { - this.constraintValidatorfactory = factory; - } - return this; - } - - public Validator getValidator() { - AbstractGwtValidator validator = validatorFactory.createValidator(); - validator.init(constraintValidatorfactory, messageInterpolator, - traversableResolver); - return validator; - } - - public ValidatorContext messageInterpolator( - MessageInterpolator messageInterpolator) { - if (messageInterpolator == null) { - this.messageInterpolator = GWT.create(MessageInterpolator.class); - } else { - this.messageInterpolator = messageInterpolator; - } - return this; - } - - public ValidatorContext traversableResolver( - TraversableResolver traversableResolver) { - if (traversableResolver == null) { - this.traversableResolver = GWT.create(TraversableResolver.class); - } else { - this.traversableResolver = traversableResolver; - } - return this; - } - -}
diff --git a/user/src/com/google/gwt/validation/client/NullUserValidationMessageResolver.java b/user/src/com/google/gwt/validation/client/NullUserValidationMessageResolver.java deleted file mode 100644 index 0cc8a3f..0000000 --- a/user/src/com/google/gwt/validation/client/NullUserValidationMessageResolver.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -/** - * Always resolves message keys to null. - */ -public class NullUserValidationMessageResolver implements - UserValidationMessagesResolver { - - public String get(String key) { - return null; - } -}
diff --git a/user/src/com/google/gwt/validation/client/ProviderValidationMessageResolver.java b/user/src/com/google/gwt/validation/client/ProviderValidationMessageResolver.java deleted file mode 100644 index 51a461c..0000000 --- a/user/src/com/google/gwt/validation/client/ProviderValidationMessageResolver.java +++ /dev/null
@@ -1,22 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -/** - * Validation Providers implement this to resolve Validation Messages. - */ -public interface ProviderValidationMessageResolver extends ValidationMessageResolver { -}
diff --git a/user/src/com/google/gwt/validation/client/UserValidationMessagesResolver.java b/user/src/com/google/gwt/validation/client/UserValidationMessagesResolver.java deleted file mode 100644 index 41a0620..0000000 --- a/user/src/com/google/gwt/validation/client/UserValidationMessagesResolver.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -/** - * Validation Providers implement this to resolve Validation Messages. including - * overriding the default {@link ProviderValidationMessageResolver}. - */ -public interface UserValidationMessagesResolver extends ValidationMessageResolver { -}
diff --git a/user/src/com/google/gwt/validation/client/Validation.java b/user/src/com/google/gwt/validation/client/Validation.java deleted file mode 100644 index c111e1a..0000000 --- a/user/src/com/google/gwt/validation/client/Validation.java +++ /dev/null
@@ -1,277 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.core.client.GWT; - -import java.util.List; - -import javax.validation.Configuration; -import javax.validation.ValidationException; -import javax.validation.ValidationProviderResolver; -import javax.validation.ValidatorFactory; -import javax.validation.bootstrap.GenericBootstrap; -import javax.validation.bootstrap.ProviderSpecificBootstrap; -import javax.validation.spi.BootstrapState; -import javax.validation.spi.ValidationProvider; - -/** - * This class is the entry point for Bean Validation. There are three ways to - * bootstrap it: - * <ul> - * <li> - * The easiest approach is to build the default <code>ValidatorFactory</code>. - * - * <pre>{@code ValidatorFactory factory = Validation.buildDefaultValidatorFactory();}</pre> - * In this case, the default validation provider resolver will be used to locate - * available providers. The chosen provider is defined as followed: - * <ul> - * <li>Since GWT does not support XML configuration, the first provider returned - * by the <code>ValidationProviderResolver</code> instance is used.</li> - * </ul> - * </li> - * <li> - * The second bootstrap approach allows to choose a custom - * <code>ValidationProviderResolver</code>. The chosen - * <code>ValidationProvider</code> is then determined in the same way as in the - * default bootstrapping case (see above). - * - * <pre>{@code - * Configuration<?> configuration = Validation - * .byDefaultProvider() - * .providerResolver( new MyResolverStrategy() ) - * .configure(); - * ValidatorFactory factory = configuration.buildValidatorFactory();} - * </pre> - * </li> - * <li> - * The third approach allows you to specify explicitly and in a type safe - * fashion the expected provider. - * <p/> - * Optionally you can choose a custom <code>ValidationProviderResolver</code>. - * - * <pre>{@code - * ACMEConfiguration configuration = Validation - * .byProvider(ACMEProvider.class) - * .providerResolver( new MyResolverStrategy() ) // optionally set the provider resolver - * .configure(); - * ValidatorFactory factory = configuration.buildValidatorFactory();} - * </pre> - * </li> - * </ul> - * Note:<br/> - * <ul> - * <li> - * The <code>ValidatorFactory</code> object built by the bootstrap process - * should be cached and shared amongst <code>Validator</code> consumers.</li> - * <li> - * This class is thread-safe.</li> - * </ul> - * - * This class was modified by Google from the original - * javax.validation.Validation source to make it suitable for GWT. - */ -public class Validation { - - // private class, not exposed - private static class GenericBootstrapImpl implements GenericBootstrap, - BootstrapState { - - private ValidationProviderResolver defaultResolver; - private ValidationProviderResolver resolver; - - public Configuration<?> configure() { - ValidationProviderResolver aResolver = this.resolver == null - ? getDefaultValidationProviderResolver() : this.resolver; - - List<ValidationProvider<?>> resolvers; - try { - resolvers = aResolver.getValidationProviders(); - } catch (RuntimeException re) { - throw new ValidationException( - "Unable to get available provider resolvers.", re); - } - - if (resolvers.size() == 0) { - // FIXME looks like an assertion error almost - throw new ValidationException("Unable to find a default provider"); - } - - Configuration<?> config; - try { - config = aResolver.getValidationProviders().get(0).createGenericConfiguration( - this); - } catch (RuntimeException re) { - throw new ValidationException("Unable to instantiate Configuration.", - re); - } - - return config; - } - - public ValidationProviderResolver getDefaultValidationProviderResolver() { - if (defaultResolver == null) { - defaultResolver = GWT.create(ValidationProviderResolver.class); - } - return defaultResolver; - } - - public ValidationProviderResolver getValidationProviderResolver() { - return resolver; - } - - public GenericBootstrap providerResolver(ValidationProviderResolver resolver) { - this.resolver = resolver; - return this; - } - } - - // private class, not exposed - private static class ProviderSpecificBootstrapImpl - <T extends Configuration<T>, U extends ValidationProvider<T>> - implements ProviderSpecificBootstrap<T> { - - private ValidationProviderResolver resolver; - private final Class<U> validationProviderClass; - - public ProviderSpecificBootstrapImpl(Class<U> validationProviderClass) { - this.validationProviderClass = validationProviderClass; - } - - /** - * Determine the provider implementation suitable for byProvider(Class) and - * delegate the creation of this specific Configuration subclass to the - * provider. - * - * @return a Configuration sub interface implementation - */ - public T configure() { - if (validationProviderClass == null) { - throw new ValidationException( - "builder is mandatory. Use Validation.byDefaultProvider() to use the generic provider discovery mechanism"); - } - // used mostly as a BootstrapState - GenericBootstrapImpl state = new GenericBootstrapImpl(); - if (resolver == null) { - resolver = state.getDefaultValidationProviderResolver(); - } else { - // stay null if no resolver is defined - state.providerResolver(resolver); - } - - List<ValidationProvider<?>> resolvers; - try { - resolvers = resolver.getValidationProviders(); - } catch (RuntimeException re) { - throw new ValidationException( - "Unable to get available provider resolvers.", re); - } - - for (ValidationProvider<?> provider : resolvers) { - // GWT validation only support exact matches. - if (validationProviderClass.equals(provider.getClass())) { - @SuppressWarnings("unchecked") - ValidationProvider<T> specificProvider = (ValidationProvider<T>) provider; - return specificProvider.createSpecializedConfiguration(state); - } - } - throw new ValidationException("Unable to find provider: " - + validationProviderClass); - } - - /** - * Optionally define the provider resolver implementation used. If not - * defined, use the default ValidationProviderResolver - * - * @param resolver ValidationProviderResolver implementation used - * - * @return self - */ - public ProviderSpecificBootstrap<T> providerResolver( - ValidationProviderResolver resolver) { - this.resolver = resolver; - return this; - } - } - - /** - * Build and return a <code>ValidatorFactory</code> instance based on the - * default Bean Validation provider. - * <p/> - * The provider list is resolved using the default validation provider - * resolver logic. - * <p/> - * The code is semantically equivalent to - * <code>Validation.byDefaultProvider().configure().buildValidatorFactory()</code> - * - * @return <code>ValidatorFactory</code> instance. - * - * @throws ValidationException if the ValidatorFactory cannot be built - */ - public static ValidatorFactory buildDefaultValidatorFactory() { - return byDefaultProvider().configure().buildValidatorFactory(); - } - - /** - * Build a <code>Configuration</code>. The provider list is resolved using the - * strategy provided to the bootstrap state. - * - * <pre> - * Configuration<?> configuration = Validation - * .byDefaultProvider() - * .providerResolver( new MyResolverStrategy() ) - * .configure(); - * ValidatorFactory factory = configuration.buildValidatorFactory(); - * </pre> - * - * The first available provider will be returned. - * - * @return instance building a generic <code>Configuration</code> complaint - * with the bootstrap state provided. - */ - public static GenericBootstrap byDefaultProvider() { - return new GenericBootstrapImpl(); - } - - /** - * Build a <code>Configuration</code> for a particular provider - * implementation. Optionally overrides the provider resolution strategy used - * to determine the provider. - * <p/> - * Used by applications targeting a specific provider programmatically. - * <p/> - * - * <pre> - * ACMEConfiguration configuration = - * Validation.byProvider(ACMEProvider.class) - * .providerResolver( new MyResolverStrategy() ) - * .configure(); - * </pre> - * , where <code>ACMEConfiguration</code> is the <code>Configuration</code> - * sub interface uniquely identifying the ACME Bean Validation provider. and - * <code>ACMEProvider</code> is the <code>ValidationProvider</code> - * implementation of the ACME provider. - * - * @param providerType the <code>ValidationProvider</code> implementation type - * - * @return instance building a provider specific <code>Configuration</code> - * sub interface implementation. - */ - public static <T extends Configuration<T>,U extends ValidationProvider<T>> - ProviderSpecificBootstrap<T> byProvider(Class<U> providerType) { - return new ProviderSpecificBootstrapImpl<T, U>(providerType); - } -}
diff --git a/user/src/com/google/gwt/validation/client/ValidationMessageResolver.java b/user/src/com/google/gwt/validation/client/ValidationMessageResolver.java deleted file mode 100644 index 5b96dd9..0000000 --- a/user/src/com/google/gwt/validation/client/ValidationMessageResolver.java +++ /dev/null
@@ -1,30 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -/** - * Users and Validation providers implement this to resolve ValidationMessages - */ -public interface ValidationMessageResolver { - - /** - * Lookup the value of the given key. - * - * @param key the key to find - * @return the value of the key or {@code null} if not found. - */ - String get(String key); -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMaxValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMaxValidator.java deleted file mode 100644 index 57fb0eb..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMaxValidator.java +++ /dev/null
@@ -1,50 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.DecimalMax; - -/** - * Abstract {@link DecimalMax} constraint validator implementation for a - * <code>T</code>. - * - * @param <T> the type of object to validate - */ -public abstract class AbstractDecimalMaxValidator<T> implements - ConstraintValidator<DecimalMax, T> { - - private BigDecimal max; - - public AbstractDecimalMaxValidator() { - super(); - } - - public final void initialize(DecimalMax constraintAnnotation) { - try { - max = new BigDecimal(constraintAnnotation.value()); - } catch (NumberFormatException e) { - throw new IllegalArgumentException(constraintAnnotation.value() - + " does not represent a valid BigDecimal format", e); - } - } - - protected final boolean isValid(BigDecimal bigValue) { - return max.compareTo(bigValue) >= 0; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMinValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMinValidator.java deleted file mode 100644 index c0c6748..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMinValidator.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.DecimalMin; - -/** - * Abstract {@link DecimalMin} constraint validator implementation for a - * <code>T</code>. - * - * @param <T> the type of object to validate - */ -public abstract class AbstractDecimalMinValidator<T> implements - ConstraintValidator<DecimalMin, T> { - - private BigDecimal min; - - public final void initialize(DecimalMin constraintAnnotation) { - try { - min = new BigDecimal(constraintAnnotation.value()); - } catch (NumberFormatException e) { - throw new IllegalArgumentException(constraintAnnotation.value() - + " does not represent a valid BigDecimal format", e); - } - } - - protected final boolean isValid(BigDecimal bigValue) { - return min.compareTo(bigValue) <= 0; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractDigitsValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractDigitsValidator.java deleted file mode 100644 index 3b21514..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractDigitsValidator.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Digits; - -/** - * Abstract {@link Digits} constraint validator implementation for a - * <code>T</code>. - * - * @param <T> the type of object to validate - */ -public abstract class AbstractDigitsValidator<T> implements - ConstraintValidator<Digits, T> { - - private int fraction; - private int integer; - - public final void initialize(Digits constraintAnnotation) { - if (!(constraintAnnotation.fraction() >= 0)) { - throw new IllegalArgumentException( - "@Digits.fraction must be a nonnegative nubmer"); - } - if (!(constraintAnnotation.integer() >= 0)) { - throw new IllegalArgumentException( - "@Digits.integer must be a nonnegative nubmer"); - } - fraction = constraintAnnotation.fraction(); - integer = constraintAnnotation.integer(); - } - - protected final boolean isValid(BigDecimal bigValue) { - int integerLength = bigValue.precision() - bigValue.scale(); - if (integerLength > integer) { - return false; - } - int fractionalLength = bigValue.scale() < 0 ? 0 : bigValue.scale(); - return fractionalLength <= fraction; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractMaxValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractMaxValidator.java deleted file mode 100644 index 5465269..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractMaxValidator.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Max; - -/** - * - * @param <T> the type of object to validate - */ -public abstract class AbstractMaxValidator<T> implements - ConstraintValidator<Max, T> { - - private long max; - - public final void initialize(Max constraintAnnotation) { - max = constraintAnnotation.value(); - } - - protected final boolean isValid(Number value) { - if (value instanceof BigDecimal) { - return ((BigDecimal) value).compareTo(BigDecimal.valueOf(max)) <= 0; - } else if (value instanceof BigInteger) { - return ((BigInteger) value).compareTo(BigInteger.valueOf(max)) <= 0; - } else { - return value.longValue() <= max; - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractMinValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractMinValidator.java deleted file mode 100644 index 0fab154..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractMinValidator.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Min; - -/** - * Abstract {@link Min} constraint validator implementation for a <code>T</code> - * . - * - * @param <T> the type of object to validate - */ -public abstract class AbstractMinValidator<T> implements - ConstraintValidator<Min, T> { - - private long min; - - public final void initialize(Min constraintAnnotation) { - min = constraintAnnotation.value(); - } - - protected final boolean isValid(Number value) { - if (value instanceof BigDecimal) { - return ((BigDecimal) value).compareTo(BigDecimal.valueOf(min)) >= 0; - } else if (value instanceof BigInteger) { - return ((BigInteger) value).compareTo(BigInteger.valueOf(min)) >= 0; - } else { - return value.longValue() >= min; - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractSizeValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractSizeValidator.java deleted file mode 100644 index 43d38b5..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractSizeValidator.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Size; - -/** - * Abstract {@link Size} constraint validator implementation. - * - * @param <T> - */ -public abstract class AbstractSizeValidator<T> implements - ConstraintValidator<Size, T> { - - private int min; - private int max; - - public AbstractSizeValidator() { - super(); - } - - public final void initialize(Size annotation) { - if (!(annotation.min() >= 0)) { - throw new IllegalArgumentException( - "@Size.min must be a nonnegative nubmer"); - } - if (!(annotation.max() >= 0)) { - throw new IllegalArgumentException( - "@Size.max must be a nonnegative nubmer"); - } - if (!(annotation.min() <= annotation.max())) { - throw new IllegalArgumentException( - "@Size.min must be less than or equal to @Size.max"); - } - min = annotation.min(); - max = annotation.max(); - } - - protected final boolean isLengthValid(int length) { - return min <= length && length <= max; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AssertFalseValidator.java b/user/src/com/google/gwt/validation/client/constraints/AssertFalseValidator.java deleted file mode 100644 index ee44197..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AssertFalseValidator.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.AssertFalse; - -/** - * {@link AssertFalse} constraint validator implementation. - */ -public class AssertFalseValidator implements - ConstraintValidator<AssertFalse, Boolean> { - - public void initialize(AssertFalse constraintAnnotation) { - } - - public boolean isValid(Boolean value, ConstraintValidatorContext context) { - return value == null || !value.booleanValue(); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/AssertTrueValidator.java b/user/src/com/google/gwt/validation/client/constraints/AssertTrueValidator.java deleted file mode 100644 index dfd5827..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AssertTrueValidator.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.AssertTrue; - -/** - * {@link AssertTrue} constraint validator implementation. - */ -public class AssertTrueValidator implements - ConstraintValidator<AssertTrue, Boolean> { - - public void initialize(AssertTrue constraintAnnotation) { - } - - public boolean isValid(Boolean value, ConstraintValidatorContext context) { - return value == null || value.booleanValue(); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumber.java deleted file mode 100644 index 668b3d5..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumber.java +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMax} constraint validator - * implementation for a {@link Number}. - */ -public class DecimalMaxValidatorForNumber extends - AbstractDecimalMaxValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - if (value instanceof BigDecimal) { - return isValid((BigDecimal) value); - } - if (value instanceof BigInteger) { - return isValid(new BigDecimal((BigInteger) value)); - } - return isValid(BigDecimal.valueOf(value.doubleValue())); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForString.java deleted file mode 100644 index 16e378f..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMax} constraint validator - * implementation for a {@link String}. - */ -public class DecimalMaxValidatorForString extends - AbstractDecimalMaxValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumber.java deleted file mode 100644 index eaf5169..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumber.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMin} constraint validator - * implementation for a {@link Number}. - */ -public class DecimalMinValidatorForNumber extends - AbstractDecimalMinValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } else if (value instanceof BigDecimal) { - BigDecimal bigValue = (BigDecimal) value; - return isValid(bigValue); - } else if (value instanceof BigInteger) { - return isValid(new BigDecimal((BigInteger) value)); - } else { - return isValid(BigDecimal.valueOf(value.doubleValue())); - } - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForString.java deleted file mode 100644 index eca67de..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMax} constraint validator - * implementation for a {@link String}. - */ -public class DecimalMinValidatorForString extends - AbstractDecimalMinValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForNumber.java deleted file mode 100644 index 8e10b66..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForNumber.java +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Digits} constraint validator - * implementation for a {@link Number}. - */ -public class DigitsValidatorForNumber extends AbstractDigitsValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } else if (value instanceof BigDecimal) { - BigDecimal bigValue = (BigDecimal) value; - return isValid(bigValue); - } else if (value instanceof BigInteger) { - return isValid(new BigDecimal((BigInteger) value)); - } else { - return isValid(BigDecimal.valueOf(value.doubleValue())); - } - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForString.java deleted file mode 100644 index 227453d..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Digits} constraint validator - * implementation for a {@link String}. - */ -public class DigitsValidatorForString extends AbstractDigitsValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/FutureValidatorForDate.java b/user/src/com/google/gwt/validation/client/constraints/FutureValidatorForDate.java deleted file mode 100644 index f007213..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/FutureValidatorForDate.java +++ /dev/null
@@ -1,40 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Future; - -/** - * {@link Future} constraint validator implementation for a - * {@link java.util.Date}. - */ -public class FutureValidatorForDate implements - ConstraintValidator<Future, Date> { - - public void initialize(Future constraintAnnotation) { - } - - public boolean isValid(Date value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return value.after(new Date()); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForNumber.java deleted file mode 100644 index e5adf31..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForNumber.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Max} constraint validator implementation - * for a {@link Number}. - */ -public class MaxValidatorForNumber extends AbstractMaxValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isValid(value); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForString.java deleted file mode 100644 index e3fc8c0..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Max} constraint validator implementation - * for a {@link String}. - */ -public class MaxValidatorForString extends AbstractMaxValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/MinValidatorForNumber.java deleted file mode 100644 index 16865dd..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForNumber.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Min} constraint validator implementation - * for a {@link Number}. - */ -public class MinValidatorForNumber extends AbstractMinValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isValid(value); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/MinValidatorForString.java deleted file mode 100644 index 7c713af..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForString.java +++ /dev/null
@@ -1,40 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Min} constraint validator implementation - * for a {@link String}. - */ -public class MinValidatorForString extends AbstractMinValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); // TODO(nchalko) deal with i18n - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/NotGwtCompatibleValidator.java b/user/src/com/google/gwt/validation/client/constraints/NotGwtCompatibleValidator.java deleted file mode 100644 index c1a2949..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/NotGwtCompatibleValidator.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.lang.annotation.Annotation; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -/** - * Masks a {@link ConstraintValidator} that is not GWT compatible. This - * validator always fails. - * <p> - * Extend this class and implement it as GWT super class. Use validation groups - * to keep this constraint from being validated on the client. - * - * <p> - * In a super source directory override your validator like this: - * - * <pre> - * public class MyValidator extends - * NotGwtCompatibleValidator <MyConstraint, MyType>{ - * } - * </pre> - * - * @param <A> the constraint to validate - * @param <T> the type to validate - */ -public abstract class NotGwtCompatibleValidator<A extends Annotation, T> - implements ConstraintValidator<A, T> { - - public final void initialize(A constraintAnnotation) { - } - - /** - * Always fails. - */ - public final boolean isValid(T value, ConstraintValidatorContext context) { - // TODO (nchalko) add a custom message - return false; - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/NotNullValidator.java b/user/src/com/google/gwt/validation/client/constraints/NotNullValidator.java deleted file mode 100644 index 95aec12..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/NotNullValidator.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.NotNull; - -/** - * {@link NotNull} constraint validator implementation. - */ -public class NotNullValidator implements ConstraintValidator<NotNull, Object> { - - public void initialize(NotNull constraintAnnotation) { - } - - public boolean isValid(Object value, ConstraintValidatorContext context) { - return value != null; - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/NullValidator.java b/user/src/com/google/gwt/validation/client/constraints/NullValidator.java deleted file mode 100644 index ed46cd6..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/NullValidator.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Null; - -/** - * {@link Null} constraint validator implementation. - */ -public class NullValidator implements ConstraintValidator<Null, Object> { - - public void initialize(Null constraintAnnotation) { - } - - public boolean isValid(Object value, ConstraintValidatorContext context) { - return value == null; - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/PastValidatorForDate.java b/user/src/com/google/gwt/validation/client/constraints/PastValidatorForDate.java deleted file mode 100644 index 4a7f0c8..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/PastValidatorForDate.java +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Past; - -/** - * {@link Past} constraint validator implementation for a {@link java.util.Date}. - */ -public class PastValidatorForDate implements ConstraintValidator<Past, Date> { - - public void initialize(Past constraintAnnotation) { - } - - public boolean isValid(Date value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return value.before(new Date()); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java b/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java deleted file mode 100644 index 59ec77a..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import com.google.gwt.regexp.shared.RegExp; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Pattern.Flag; - -/** - * {@link Pattern} constraint validator implementation. - * <p> - * Note this implementation uses {@link RegExp} which differs from - * {@link java.util.regex.Pattern}. - */ -public class PatternValidator implements ConstraintValidator<Pattern, String> { - private RegExp pattern; - - public void initialize(Pattern annotation) { - Pattern.Flag flags[] = annotation.flags(); - String flagString = ""; - for (Pattern.Flag flag : flags) { - flagString += toString(flag); - } - pattern = RegExp.compile(annotation.regexp(), flagString); - } - - public boolean isValid(String value, ConstraintValidatorContext context) { - return value == null || pattern.exec(value) != null; - } - - private String toString(Flag flag) { - String value; - switch (flag) { - case CASE_INSENSITIVE: - case UNICODE_CASE: - value = "i"; - break; - case MULTILINE: - value = "m"; - break; - default: - throw new IllegalArgumentException(flag - + " is not a suppoted gwt Pattern (RegExp) flag"); - } - return value; - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBoolean.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBoolean.java deleted file mode 100644 index 3c3b79d..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBoolean.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code boolean}s. - */ -public class SizeValidatorForArrayOfBoolean extends - AbstractSizeValidator<boolean[]> { - - public boolean isValid(boolean[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByte.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByte.java deleted file mode 100644 index 6312aee..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByte.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code byte}s. - */ -public class SizeValidatorForArrayOfByte extends AbstractSizeValidator<byte[]> { - - public boolean isValid(byte[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfChar.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfChar.java deleted file mode 100644 index 407e36a..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfChar.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code char}s. - */ -public class SizeValidatorForArrayOfChar extends AbstractSizeValidator<char[]> { - - public boolean isValid(char[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDouble.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDouble.java deleted file mode 100644 index d3b1feb..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDouble.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code double}s. - */ -public class SizeValidatorForArrayOfDouble extends - AbstractSizeValidator<double[]> { - - public boolean isValid(double[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloat.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloat.java deleted file mode 100644 index 1202a90..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloat.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code float}s. - */ -public class SizeValidatorForArrayOfFloat extends - AbstractSizeValidator<float[]> { - - public boolean isValid(float[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfInt.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfInt.java deleted file mode 100644 index 160f286..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfInt.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code int}s. - */ -public class SizeValidatorForArrayOfInt extends AbstractSizeValidator<int[]> { - - public boolean isValid(int[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLong.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLong.java deleted file mode 100644 index 552fcfd..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLong.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code long}s. - */ -public class SizeValidatorForArrayOfLong extends AbstractSizeValidator<long[]> { - - public boolean isValid(long[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObject.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObject.java deleted file mode 100644 index 3264f43..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObject.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link Object}s. - */ -public class SizeValidatorForArrayOfObject extends - AbstractSizeValidator<Object[]> { - - public boolean isValid(Object[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShort.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShort.java deleted file mode 100644 index 683fb3a..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShort.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@code short}s. - */ -public class SizeValidatorForArrayOfShort extends - AbstractSizeValidator<short[]> { - - public boolean isValid(short[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForCollection.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForCollection.java deleted file mode 100644 index 7f5b4ef..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForCollection.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Collection; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a {@link Collection}. - */ -public class SizeValidatorForCollection extends - AbstractSizeValidator<Collection<?>> { - - public boolean isValid(Collection<?> value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.size()); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForMap.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForMap.java deleted file mode 100644 index d820181..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForMap.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Map; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a {@link Map}. - */ -public class SizeValidatorForMap extends AbstractSizeValidator<Map<?, ?>> { - - public boolean isValid(Map<?, ?> value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.size()); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForString.java deleted file mode 100644 index c25fcac..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForString.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a {@link String}. - */ -public class SizeValidatorForString extends AbstractSizeValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length()); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java b/user/src/com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java deleted file mode 100644 index 62b482d..0000000 --- a/user/src/com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java +++ /dev/null
@@ -1,147 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import com.google.gwt.validation.client.BaseMessageInterpolator.ContextImpl; - -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintViolation; -import javax.validation.MessageInterpolator; -import javax.validation.groups.Default; - -/** - * Base methods for implementing a {@link GwtSpecificValidator}. - * <p> - * All methods that do not need to be generated go here. - * - * @param <G> the type object to validate - */ -public abstract class AbstractGwtSpecificValidator<G> implements - GwtSpecificValidator<G> { - - /** - * Builds attributes one at a time. - * <p> - * Used to create a attribute map for annotations. - */ - public static final class AttributeBuilder { - private final HashMap<String, Object> tempMap = new HashMap<String, Object>(); - - private AttributeBuilder() { - } - - public Map<String, Object> build() { - return Collections.unmodifiableMap(tempMap); - } - - public AttributeBuilder put(String key, Object value) { - tempMap.put(key, value); - return this; - } - } - - public static AttributeBuilder attributeBuilder() { - return new AttributeBuilder(); - } - - protected <A extends Annotation, T, V> void validate( - GwtValidationContext<T> context, Set<ConstraintViolation<T>> violations, - G object, V value, ConstraintValidator<A, ? super V> validator, - ConstraintDescriptorImpl<A> constraintDescriptor, Class<?>[] groups) { - validator.initialize(constraintDescriptor.getAnnotation()); - ConstraintValidatorContextImpl<A, V> constraintValidatorContext = - context.createConstraintValidatorContext(constraintDescriptor); - - // TODO(nchalko) set empties to Default earlier. - Set<Class<?>> constraintGroup = constraintDescriptor.getGroups(); - if (groups.length == 0) { - groups = new Class<?>[]{Default.class}; - } - if (constraintGroup.isEmpty()) { - constraintGroup = new HashSet<Class<?>>(); - constraintGroup.add(Default.class); - } - - // check group - if (!containsAny(groups, constraintGroup)) { - return; - } - - if (!validator.isValid(value, constraintValidatorContext)) { - addViolations(// - context, // - violations, // - object, // - value, // - constraintDescriptor, // - constraintValidatorContext); - } - } - - private <V, T, A extends Annotation> void addViolations( - GwtValidationContext<T> context, Set<ConstraintViolation<T>> violations, - G object, V value, ConstraintDescriptorImpl<A> constraintDescriptor, - ConstraintValidatorContextImpl<A, V> constraintValidatorContext) { - Set<MessageAndPath> mps = constraintValidatorContext.getMessageAndPaths(); - for (MessageAndPath messageAndPath : mps) { - ConstraintViolation<T> violation = createConstraintViolation(// - context, // - object, // - value, // - constraintDescriptor, // - messageAndPath); - violations.add(violation); - } - } - - private <T> boolean containsAny(T[] left, Collection<T> right) { - for (T t : left) { - if (right.contains(t)) { - return true; - } - } - return false; - } - - private <T, V, A extends Annotation> ConstraintViolation<T> createConstraintViolation( - GwtValidationContext<T> context, G object, V value, - ConstraintDescriptorImpl<A> constraintDescriptor, - MessageAndPath messageAndPath) { - MessageInterpolator messageInterpolator = context.getMessageInterpolator(); - ContextImpl messageContext = new ContextImpl(constraintDescriptor, value); - String message = messageInterpolator.interpolate( - messageAndPath.getMessage(), messageContext); - ConstraintViolation<T> violation = ConstraintViolationImpl.<T> builder() // - .setConstraintDescriptor(constraintDescriptor) // - .setInvalidValue(value) // - .setLeafBean(object) // - .setMessage(message) // - .setMessageTemplate(messageAndPath.getMessage()) // - .setPropertyPath(messageAndPath.getPath()) // - .setRootBean(context.getRootBean()) // - .setRootBeanClass(context.getRootBeanClass()) // - .build(); - return violation; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/AbstractGwtValidator.java b/user/src/com/google/gwt/validation/client/impl/AbstractGwtValidator.java deleted file mode 100644 index 17da692..0000000 --- a/user/src/com/google/gwt/validation/client/impl/AbstractGwtValidator.java +++ /dev/null
@@ -1,88 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; -import javax.validation.ValidationException; -import javax.validation.Validator; - -/** - * Base methods for implementing {@link Validator} in GWT. - * <p> - * All methods that do not need to be generated go here. - */ -public abstract class AbstractGwtValidator implements Validator { - - private final Set<Class<?>> validGroups; - private ConstraintValidatorFactory factory; - private MessageInterpolator messageInterpolator; - private TraversableResolver traversableResolver; - - /** - * - * @param groups list of valid groups. An empty list defaults to just the - * {@link javax.validation.groups.Default} group. - */ - public AbstractGwtValidator(Class<?>... groups) { - validGroups = new HashSet<Class<?>>(Arrays.asList(groups)); - } - - public void init(ConstraintValidatorFactory factory, - MessageInterpolator messageInterpolator, - TraversableResolver traversableResolver) { - this.factory = factory; - this.messageInterpolator = messageInterpolator; - this.traversableResolver = traversableResolver; - } - - public <T> T unwrap(Class<T> type) { - throw new ValidationException(); - } - - protected void checkGroups(Class<?>... groups) { - // an empty list of valid groups means all groups are valid. - if (!validGroups.isEmpty() - && !validGroups.containsAll(Arrays.asList(groups))) { - throw new IllegalArgumentException(this.getClass() - + " only processes the following groups " + validGroups); - } - } - - protected void checkNotNull(Object object, String name) - throws IllegalArgumentException { - if (object == null) { - throw new IllegalArgumentException(name + " can not be null."); - } - } - - protected ConstraintValidatorFactory getFactory() { - return factory; - } - - protected MessageInterpolator getMessageInterpolator() { - return messageInterpolator; - } - - protected TraversableResolver getTraversableResolver() { - return traversableResolver; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java deleted file mode 100644 index 14150b2..0000000 --- a/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java +++ /dev/null
@@ -1,186 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.validation.ConstraintValidator; -import javax.validation.Payload; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * A immutable GWT implementation of {@link ConstraintDescriptor}. - * - * @param <T> the constraint annotation to describe. - */ -public class ConstraintDescriptorImpl<T extends Annotation> implements - ConstraintDescriptor<T> { - - /** - * Builder for {@link ConstraintDescriptorImpl}. - * - * @param <T> the constraint annotation to describe. - */ - public static class Builder<T extends Annotation> { - private T annotation; - private Set<Class<?>> groups; - private Set<Class<? extends Payload>> payload; - private List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses; - private Map<String, Object> attributes; - private Set<ConstraintDescriptor<?>> composingConstraints; - private boolean reportAsSingleViolation; - - public ConstraintDescriptorImpl<T> build() { - return new ConstraintDescriptorImpl<T>(// - annotation, // - groups, // - payload, // - constraintValidatorClasses, // - attributes, // - composingConstraints, // - reportAsSingleViolation); - } - - public Builder<T> setAnnotation(T annotation) { - this.annotation = annotation; - return this; - } - - public Builder<T> setAttributes(Map<String, Object> attributes) { - this.attributes = attributes; - return this; - } - - public Builder<T> setComposingConstraints( - Set<ConstraintDescriptor<?>> composingConstraints) { - this.composingConstraints = composingConstraints; - return this; - } - - public Builder<T> setConstraintValidatorClasses( - List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses) { - this.constraintValidatorClasses = constraintValidatorClasses; - return this; - } - - /** - * @param classes - * @return - */ - public Builder<T> setConstraintValidatorClasses( - Class<? extends ConstraintValidator<T, ?>>[] constraintValidatorClasses) { - List<Class<? extends ConstraintValidator<T, ?>>> list = Arrays.asList(constraintValidatorClasses); - setConstraintValidatorClasses(list); - return this; - } - - public Builder<T> setGroups(Set<Class<?>> groups) { - this.groups = groups; - return this; - } - - public Builder<T> setGroups(Class<?>[] classes) { - setGroups(new HashSet<Class<?>>(Arrays.asList(classes))); - return this; - } - - public Builder<T> setPayload(Set<Class<? extends Payload>> payload) { - this.payload = payload; - return this; - } - - public Builder<T> setPayload(Class<? extends Payload>[] classes) { - setPayload(new HashSet<Class<? extends Payload>>(Arrays.asList(classes))); - return this; - } - - public Builder<T> setReportAsSingleViolation(boolean reportAsSingleViolation) { - this.reportAsSingleViolation = reportAsSingleViolation; - return this; - } - } - - public static <T extends Annotation> Builder<T> builder() { - return new Builder<T>(); - } - - private final T annotation; - private final Set<Class<?>> groups; - private final Set<Class<? extends Payload>> payload; - private final List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses; - private final Map<String, Object> attributes; - private final Set<ConstraintDescriptor<?>> composingConstraints; - private final boolean reportAsSingleViolation; - - private ConstraintDescriptorImpl( - T annotation, - Set<Class<?>> groups, - Set<Class<? extends Payload>> payload, - List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses, - Map<String, Object> attributes, - Set<ConstraintDescriptor<?>> composingConstraints, - boolean reportAsSingleViolation) { - super(); - this.annotation = annotation; - this.groups = groups; - this.payload = payload; - this.constraintValidatorClasses = constraintValidatorClasses; - this.attributes = attributes; - this.composingConstraints = composingConstraints; - this.reportAsSingleViolation = reportAsSingleViolation; - } - - public T getAnnotation() { - return annotation; - } - - public Map<String, Object> getAttributes() { - return attributes; - } - - public Set<ConstraintDescriptor<?>> getComposingConstraints() { - return composingConstraints; - } - - public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() { - return constraintValidatorClasses; - } - - public Set<Class<?>> getGroups() { - return groups; - } - - public Set<Class<? extends Payload>> getPayload() { - return payload; - } - - public boolean isReportAsSingleViolation() { - return reportAsSingleViolation; - } - - /** - * For debugging only. Do not rely on the format. It can change at any time. - */ - @Override - public String toString() { - return annotation + " " + attributes; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintValidatorContextImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintValidatorContextImpl.java deleted file mode 100644 index 1705c4a..0000000 --- a/user/src/com/google/gwt/validation/client/impl/ConstraintValidatorContextImpl.java +++ /dev/null
@@ -1,218 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; -import java.util.HashSet; -import java.util.Set; - -import javax.validation.ConstraintValidatorContext; -import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext; -import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext; -import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder; -import javax.validation.ConstraintViolation; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * GWT safe immutable implementation of {@link ConstraintValidatorContext} - * <p> - * These objects are very short lived. - * - * @param <A> the constraint being validated - * @param <T> the type of object being validated - */ -public class ConstraintValidatorContextImpl<A extends Annotation, T> implements - ConstraintValidatorContext { - - /** - * Builder for {@link ConstraintValidatorContextImpl}. - */ - public final class ConstraintViolationBuilderImpl implements - ConstraintViolationBuilder { - - private ConstraintValidatorContextImpl<A, T> context; - private String messageTemplate; - - /** - * @param constraintValidatorContextImpl - * @param messageTemplate - */ - public ConstraintViolationBuilderImpl( - ConstraintValidatorContextImpl<A, T> constraintValidatorContextImpl, - String messageTemplate) { - this.context = constraintValidatorContextImpl; - this.messageTemplate = messageTemplate; - } - - public ConstraintValidatorContext addConstraintViolation() { - return context; - } - - public NodeBuilderDefinedContext addNode(String name) { - return new NodeBuilderDefinedContextImpl(this, messageTemplate, - basePath.append(name)); - } - } - - /** - * Immutable GWT safe {@link NodeBuilderCustomizableContext}. - */ - public final class NodeBuilderCustomizableContextImpl implements - NodeBuilderCustomizableContext { - private final String messageTemplate; - private final ConstraintViolationBuilderImpl parent; - private final PathImpl path; - - /** - * @param parent - * @param messageTemplate - * @param append - */ - public NodeBuilderCustomizableContextImpl( - ConstraintViolationBuilderImpl parent, String messageTemplate, - PathImpl path) { - this.parent = parent; - this.messageTemplate = messageTemplate; - this.path = path; - } - - public ConstraintValidatorContext addConstraintViolation() { - return null; - } - - public NodeBuilderCustomizableContext addNode(String name) { - return this; - } - - public NodeContextBuilder inIterable() { - return new NodeContextBuilderImpl(path, messageTemplate, parent); - } - } - - /** - * Immutable GWT safe {@link NodeBuilderDefinedContext}. - */ - public final class NodeBuilderDefinedContextImpl implements - NodeBuilderDefinedContext { - - private final String messageTemplate; - private final ConstraintViolationBuilderImpl parent; - private final PathImpl path; - - /** - * @param constraintViolationBuilderImpl - * @param messageTemplate - * @param append - */ - public NodeBuilderDefinedContextImpl(ConstraintViolationBuilderImpl parent, - String messageTemplate, PathImpl path) { - this.parent = parent; - this.messageTemplate = messageTemplate; - this.path = path; - } - - public ConstraintValidatorContext addConstraintViolation() { - ConstraintViolation<T> violation = ConstraintViolationImpl.<T> builder().setPropertyPath( - path).setMessageTemplate(messageTemplate).build(); - - parent.context.violations.add(violation); - return parent.context; - } - - public NodeBuilderCustomizableContext addNode(String name) { - return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, - path.append(name)); - } - } - - /** - * Immutable GWT safe {@link NodeContextBuilder}. - */ - public final class NodeContextBuilderImpl implements NodeContextBuilder { - - private final String messageTemplate; - - private final ConstraintViolationBuilderImpl parent; - private final PathImpl path; - - public NodeContextBuilderImpl(PathImpl path, String messageTemplate, - ConstraintViolationBuilderImpl parent) { - super(); - this.path = path; - this.messageTemplate = messageTemplate; - this.parent = parent; - } - - public ConstraintValidatorContext addConstraintViolation() { - return null; - } - - public NodeBuilderCustomizableContext addNode(String name) { - return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, - path.append(name)); - } - - public NodeBuilderDefinedContext atIndex(Integer index) { - return new NodeBuilderDefinedContextImpl(parent, messageTemplate, - path.appendIndex(null, index.intValue())); - } - - public NodeBuilderDefinedContext atKey(Object key) { - return new NodeBuilderDefinedContextImpl(parent, messageTemplate, - path.appendKey(null, key)); - } - } - - private final PathImpl basePath; - private final ConstraintDescriptor<A> descriptor; - - private boolean disableDefault; - private Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>(); - - public ConstraintValidatorContextImpl(PathImpl path, - ConstraintDescriptor<A> descriptor) { - super(); - this.basePath = path; - this.descriptor = descriptor; - } - - public ConstraintViolationBuilder buildConstraintViolationWithTemplate( - String messageTemplate) { - ConstraintViolationBuilderImpl builder = new ConstraintViolationBuilderImpl( - this, messageTemplate); - return builder; - } - - public void disableDefaultConstraintViolation() { - disableDefault = true; - } - - public String getDefaultConstraintMessageTemplate() { - return (String) descriptor.getAttributes().get("message"); - } - - public Set<MessageAndPath> getMessageAndPaths() { - // TODO handle custom. - HashSet<MessageAndPath> messages = new HashSet<MessageAndPath>(); - messages.add(new MessageAndPath(this.basePath, - this.getDefaultConstraintMessageTemplate())); - return messages; - } - - public Set<ConstraintViolation<T>> getViolations() { - return violations; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java deleted file mode 100644 index 2aa2cd9..0000000 --- a/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java +++ /dev/null
@@ -1,176 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.io.Serializable; - -import javax.validation.ConstraintViolation; -import javax.validation.Path; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * An implementation of {@link ConstraintViolation}. - * - * @param <T> the type of bean validated. - */ -public class ConstraintViolationImpl<T> implements ConstraintViolation<T>, - Serializable { - - /** - * Builder for ConstraintViolations. - * - * @param <T> the type of bean validated. - */ - public static class Builder<T> { - private String message; - private String messageTemplate; - private T rootBean; - private Class<T> rootBeanClass; - private Object leafBean; - private Path propertyPath; - private Object invalidValue; - private ConstraintDescriptor<?> constraintDescriptor; - - public ConstraintViolationImpl<T> build() { - return new ConstraintViolationImpl<T>(message, messageTemplate, rootBean, - rootBeanClass, leafBean, propertyPath, invalidValue, - constraintDescriptor); - } - - public Builder<T> setConstraintDescriptor( - ConstraintDescriptor<?> constraintDescriptor) { - this.constraintDescriptor = constraintDescriptor; - return this; - } - - public Builder<T> setInvalidValue(Object invalidValue) { - this.invalidValue = invalidValue; - return this; - } - - public Builder<T> setLeafBean(Object leafBean) { - this.leafBean = leafBean; - return this; - } - - public Builder<T> setMessage(String message) { - this.message = message; - return this; - } - - public Builder<T> setMessageTemplate(String messageTemplate) { - this.messageTemplate = messageTemplate; - return this; - } - - public Builder<T> setPropertyPath(Path propertyPath) { - this.propertyPath = propertyPath; - return this; - } - - public Builder<T> setRootBean(T rootBean) { - this.rootBean = rootBean; - return this; - } - - public Builder<T> setRootBeanClass(Class<T> rootBeanClass) { - this.rootBeanClass = rootBeanClass; - return this; - } - } - - private static final long serialVersionUID = 1L; - - public static <T> Builder<T> builder() { - return new Builder<T>(); - } - - private final String message; - private final String messageTemplate; - private final T rootBean; - private final Class<T> rootBeanClass; - private final Object leafBean; - private final Path propertyPath; - private final Object invalidValue; - private final ConstraintDescriptor<?> constraintDescriptor; - - /** - * @param message - * @param messageTemplate - * @param rootBean - * @param rootBeanClass - * @param leafBean - * @param propertyPath - * @param invalidValue - * @param constraintDescriptor - */ - private ConstraintViolationImpl(String message, String messageTemplate, - T rootBean, Class<T> rootBeanClass, Object leafBean, Path propertyPath, - Object invalidValue, ConstraintDescriptor<?> constraintDescriptor) { - super(); - this.message = message; - this.messageTemplate = messageTemplate; - this.rootBean = rootBean; - this.rootBeanClass = rootBeanClass; - this.leafBean = leafBean; - this.propertyPath = propertyPath; - this.invalidValue = invalidValue; - this.constraintDescriptor = constraintDescriptor; - } - - public ConstraintDescriptor<?> getConstraintDescriptor() { - return constraintDescriptor; - } - - public Object getInvalidValue() { - return invalidValue; - } - - public Object getLeafBean() { - return leafBean; - } - - public String getMessage() { - return message; - } - - public String getMessageTemplate() { - return messageTemplate; - } - - public Path getPropertyPath() { - return propertyPath; - } - - public T getRootBean() { - return rootBean; - } - - public Class<T> getRootBeanClass() { - return rootBeanClass; - } - - /** - * For debugging only. Do not rely on the format. It can change at any time. - */ - @Override - public String toString() { - return "message= " + message // - + ", path= " + propertyPath // - + ", invalidValue=" + invalidValue // - + " , desc=" + constraintDescriptor; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptor.java b/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptor.java deleted file mode 100644 index 700cf7a..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptor.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import javax.validation.metadata.BeanDescriptor; - -/** - * Marker interface used by GWT to generate a {@link BeanDescriptor} for a - * specific class T. - * - * @param <T> - */ -public interface GwtBeanDescriptor<T> extends BeanDescriptor { -}
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptorImpl.java b/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptorImpl.java deleted file mode 100644 index 591a1b1..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptorImpl.java +++ /dev/null
@@ -1,123 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.validation.metadata.ConstraintDescriptor; -import javax.validation.metadata.PropertyDescriptor; - -/** - * Abstract BeanDescriptor for use by generated {@link GwtBeanDescriptor}. - * <p> - * Subclasses are expected to call setDescriptorMap from the constructor. - * - * @param <T> the bean Type - */ -public final class GwtBeanDescriptorImpl<T> implements GwtBeanDescriptor<T> { - - /** - * Builder for {@link GwtBeanDescriptors}. - * - * @param <T> the bean Type - */ - public static final class Builder<T> { - - private final Class<T> clazz; - private final Map<String, PropertyDescriptor> descriptorMap = new HashMap<String, PropertyDescriptor>(); - private boolean isConstrained; - - private Builder(Class<T> clazz) { - this.clazz = clazz; - } - - public GwtBeanDescriptorImpl<T> build() { - return new GwtBeanDescriptorImpl<T>(clazz, isConstrained, descriptorMap); - } - - public Builder<T> put(String key, PropertyDescriptor value) { - descriptorMap.put(key, value); - return this; - } - - public Builder<T> setConstrained(boolean isConstrained) { - this.isConstrained = isConstrained; - return this; - } - } - - public static <T> Builder<T> builder(Class<T> clazz) { - return new Builder<T>(clazz); - } - - private final Class<T> clazz; - private final Set<ConstraintDescriptor<?>> constraints = new HashSet<ConstraintDescriptor<?>>(); - - private final Map<String, PropertyDescriptor> descriptorMap = new HashMap<String, PropertyDescriptor>(); - private final boolean isBeanConstrained; - - private GwtBeanDescriptorImpl(Class<T> clazz, boolean isConstrained, - Map<String, PropertyDescriptor> descriptorMap) { - super(); - this.clazz = clazz; - this.isBeanConstrained = isConstrained; - this.descriptorMap.putAll(descriptorMap); - } - - public ConstraintFinder findConstraints() { - // TODO(nchalko) implement - return null; - } - - public Set<PropertyDescriptor> getConstrainedProperties() { - return new HashSet<PropertyDescriptor>(descriptorMap.values()); - } - - public Set<ConstraintDescriptor<?>> getConstraintDescriptors() { - // Copy for safety - return new HashSet<ConstraintDescriptor<?>>(constraints); - } - - public PropertyDescriptor getConstraintsForProperty(String propertyName) { - return descriptorMap.get(propertyName); - } - - public Class<?> getElementClass() { - return clazz; - } - - public boolean hasConstraints() { - return !constraints.isEmpty(); - } - - public boolean isBeanConstrained() { - return isBeanConstrained; - } - - protected void setDescriptorMap(Map<String, PropertyDescriptor> map) { - descriptorMap.clear(); - descriptorMap.putAll(map); - constraints.clear(); - for (PropertyDescriptor p : descriptorMap.values()) { - if (p.hasConstraints()) { - constraints.addAll(p.getConstraintDescriptors()); - } - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtSpecificValidator.java b/user/src/com/google/gwt/validation/client/impl/GwtSpecificValidator.java deleted file mode 100644 index 2391c8f..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtSpecificValidator.java +++ /dev/null
@@ -1,115 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.ValidationException; - -/** - * Defines GWT version of {@link javax.validation.Validator}. This used by - * generate a specific Validator for a given class G. - * - * @param <G> the type of bean for this validator - */ -public interface GwtSpecificValidator<G> { - - /** - * Return the descriptor object describing bean constraints. The returned - * object (and associated objects including - * <code>ConstraintDescriptor<code>s) are immutable. - * - * - * @return the bean descriptor for the class associated with this validator. - * - * @throws IllegalArgumentException if clazz is null - * @throws ValidationException if a non recoverable error happens during the - * metadata discovery or if some constraints are invalid. - */ - GwtBeanDescriptor<G> getConstraints() throws ValidationException; - - /** - * Validates all constraints on <code>object</code>. - * - * @param<T> the type of the RootBean for this validation context - * @param context The gwt validation context - * @param object object to validate - * @param groups group or list of groups targeted for validation (default to - * {@link javax.validation.groups.Default}) - * - * @return constraint violations or an empty Set if none - * - * @throws IllegalArgumentException if object is null or if null is passed to - * the varargs groups - * @throws ValidationException if a non recoverable error happens during the - * validation process - */ - <T> Set<ConstraintViolation<T>> validate(GwtValidationContext<T> context, - G object, Class<?>... groups) throws ValidationException; - - /** - * Validates all constraints placed on the property of <code>object</code> - * named <code>propertyName</code>. - * - * @param<T> the type of the RootBean for this validation context - * @param context The gwt validation context - * @param object object to validate - * @param propertyName property to validate (ie field and getter constraints) - * @param groups group or list of groups targeted for validation (default to - * {@link javax.validation.groups.Default}) - * - * @return constraint violations or an empty Set if none - * - * @throws IllegalArgumentException if <code>object</code> is null, if - * <code>propertyName</code> null, empty or not a valid object - * property or if null is passed to the varargs groups - * @throws ValidationException if a non recoverable error happens during the - * validation process - */ - <T> Set<ConstraintViolation<T>> validateProperty( - GwtValidationContext<T> context, G object, String propertyName, - Class<?>... groups) throws ValidationException; - - /** - * Validates all constraints placed on the property named - * <code>propertyName</code> of the class <code>beanType</code> where the - * property value is <code>value</code>. - * <p/> - * <code>ConstraintViolation</code> objects return null for - * {@link ConstraintViolation#getRootBean()} and - * {@link ConstraintViolation#getLeafBean()} - * - * @param<T> the type of the RootBean for this validation context - * @param context The gwt validation context - * @param beanType the bean type - * @param propertyName property to validate - * @param value property value to validate - * @param groups group or list of groups targeted for validation (default to - * {@link javax.validation.groups.Default}) - * - * @return constraint violations or an empty Set if none - * - * @throws IllegalArgumentException if <code>beanType</code> is null, if - * <code>propertyName</code> null, empty or not a valid object - * property or if null is passed to the varargs groups - * @throws ValidationException if a non recoverable error happens during the - * validation process - */ - <T> Set<ConstraintViolation<T>> validateValue( - GwtValidationContext<T> context, Class<G> beanType, String propertyName, - Object value, Class<?>... groups) throws ValidationException; -}
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java b/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java deleted file mode 100644 index 38d6ccd..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java +++ /dev/null
@@ -1,76 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; - -import javax.validation.MessageInterpolator; -import javax.validation.metadata.BeanDescriptor; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * Context for a {@link com.google.gwt.validation.client.GwtValidation}. - * - * @param <T> the type of the root bean. - */ -public class GwtValidationContext<T> { - - private final BeanDescriptor beanDescriptor; - private PathImpl path = new PathImpl(); - private final T rootBean; - private final MessageInterpolator messageInterpolator; - - /** - * - */ - public GwtValidationContext(T rootBean, BeanDescriptor beanDescriptor, - MessageInterpolator messageInterpolator) { - this.rootBean = rootBean; - this.beanDescriptor = beanDescriptor; - this.messageInterpolator = messageInterpolator; - } - - /** - * Append a node named name to the path.. - * - * @param name - * @return the new GwtValidationContext. - */ - public GwtValidationContext<T> append(String name) { - GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean, - beanDescriptor, messageInterpolator); - temp.path = temp.path.append(name); - return temp; - } - - public <A extends Annotation, V> ConstraintValidatorContextImpl<A, V> createConstraintValidatorContext( - ConstraintDescriptor<A> descriptor) { - return new ConstraintValidatorContextImpl<A, V>(path, descriptor); - } - - public MessageInterpolator getMessageInterpolator() { - return messageInterpolator; - } - - public T getRootBean() { - return rootBean; - } - - @SuppressWarnings("unchecked") - public Class<T> getRootBeanClass() { - return (Class<T>) rootBean.getClass(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/MessageAndPath.java b/user/src/com/google/gwt/validation/client/impl/MessageAndPath.java deleted file mode 100644 index f40cc15..0000000 --- a/user/src/com/google/gwt/validation/client/impl/MessageAndPath.java +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import javax.validation.Path; - -/** - * Holds as Message and a Path. - * <p> - * Used to build a {@link javax.validation.ConstraintViolation} - */ -public class MessageAndPath { - - private final String message; - private final Path path; - - public MessageAndPath(Path path, String message) { - super(); - this.path = path; - this.message = message; - } - - public String getMessage() { - return message; - } - - public Path getPath() { - return path; - } - - /** - * For debugging use only. - */ - @Override - public String toString() { - return path + "=" + message; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/NodeImpl.java b/user/src/com/google/gwt/validation/client/impl/NodeImpl.java deleted file mode 100644 index 0482ee0..0000000 --- a/user/src/com/google/gwt/validation/client/impl/NodeImpl.java +++ /dev/null
@@ -1,132 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.io.Serializable; - -import javax.validation.Path.Node; - -/** - * An immutable GWT safe implementation of {@link Node}. - */ -class NodeImpl implements Node, Serializable { - - private static final long serialVersionUID = 1L; - public static final Node ROOT_NODE = new NodeImpl(null); - - private final String name; - private final Integer index; - private final Object key; - - /** - * Create a non iterable node. - * - * @param name the possibly <code>null</code> name. - */ - public NodeImpl(String name) { - this.name = name; - this.index = null; - this.key = null; - } - - /** - * Create an iterable node with an index. - * - * @param name the possibly <code>null</code> name. - * @param index the zero based index. - */ - public NodeImpl(String name, int index) { - if (index < 0) { - throw new IllegalArgumentException("Index can not be negative."); - } - this.name = name; - this.index = Integer.valueOf(index); - this.key = null; - } - - /** - * Create an iterable node with a key. - * - * @param name the possibly <code>null</code> name. - * @param key the lookup key for this node. - */ - public NodeImpl(String name, Object key) { - if (key == null) { - throw new NullPointerException(); - } - this.name = name; - this.index = null; - this.key = key; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof NodeImpl)) { - return false; - } - NodeImpl that = (NodeImpl) obj; - return (this.name == null ? that.name == null : this.name == that.name) - && (this.index == null ? that.index == null : this.index == that.index) - && (this.key == null ? that.key == null : this.key == that.key); - } - - public Integer getIndex() { - return index; - } - - public Object getKey() { - return key; - } - - public String getName() { - return name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((index == null) ? 0 : index.hashCode()); - result = prime * result + ((key == null) ? 0 : key.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - public boolean isInIterable() { - return index != null || key != null; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - if (name != null) { - sb.append(name); - } - if (isInIterable()) { - sb.append('['); - if (key != null) { - sb.append(key); - } else { - sb.append(index); - } - sb.append(']'); - } - return sb.toString(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/PathImpl.java b/user/src/com/google/gwt/validation/client/impl/PathImpl.java deleted file mode 100644 index 8591073..0000000 --- a/user/src/com/google/gwt/validation/client/impl/PathImpl.java +++ /dev/null
@@ -1,114 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.validation.Path; - -/** - * An immutable GWT safe implementation of {@link Path}. - */ -public class PathImpl implements Path, Serializable { - - private static final long serialVersionUID = 1L; - - private final List<Node> nodes = new ArrayList<Node>(); - - /** - * Creates a new path containing only the root (<code>null</code>) - * {@link Node}. - */ - public PathImpl() { - nodes.add(NodeImpl.ROOT_NODE); - } - - private PathImpl(PathImpl originalPath, Node node) { - nodes.addAll(originalPath.nodes); - nodes.add(node); - } - - /** - * Create a new path with a node named <code>name</code> appended to the - * existing path. - * - * @param name - * @return The new path with appended node. - */ - public PathImpl append(String name) { - return new PathImpl(this, new NodeImpl(name)); - } - - /** - * Create a new path with a indexed node named <code>name</code> appended to - * the existing path. - * - * @param name - * @param key - * @return The new path with appended node. - */ - public PathImpl appendIndex(String name, int index) { - return new PathImpl(this, new NodeImpl(name, index)); - } - - /** - * Create a new path with a keyed node named <code>name</code> appended to the - * existing path. - * - * @param name - * @param key - * @return The new path with appended node. - */ - public PathImpl appendKey(String name, Object key) { - return new PathImpl(this, new NodeImpl(name, key)); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof PathImpl)) { - return false; - } - PathImpl that = (PathImpl) obj; - return this.nodes.equals(that.nodes); - } - - @Override - public int hashCode() { - return nodes.hashCode(); - } - - public Iterator<Node> iterator() { - return nodes.iterator(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (Node n : nodes) { - if (sb.length() > 0) { - sb.append('.'); - } - sb.append(n); - } - return sb.toString(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/PropertyDescriptorImpl.java b/user/src/com/google/gwt/validation/client/impl/PropertyDescriptorImpl.java deleted file mode 100644 index 67c95b4..0000000 --- a/user/src/com/google/gwt/validation/client/impl/PropertyDescriptorImpl.java +++ /dev/null
@@ -1,76 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.validation.metadata.ConstraintDescriptor; -import javax.validation.metadata.PropertyDescriptor; - -/** - * - */ -public class PropertyDescriptorImpl implements PropertyDescriptor { - - private boolean cascaded; - private Set<ConstraintDescriptor<?>> descriptors = new HashSet<ConstraintDescriptor<?>>(); - private Class<?> elementClass; - private String name; - - /** - * @param name - * @param elementClass - * @param cascaded - * @param descriptors - */ - public PropertyDescriptorImpl(String name, Class<?> elementClass, - boolean cascaded, ConstraintDescriptor<?>... descriptors) { - super(); - - this.elementClass = elementClass; - this.cascaded = cascaded; - this.name = name; - this.descriptors = new HashSet<ConstraintDescriptor<?>>( - Arrays.asList(descriptors)); - } - - public ConstraintFinder findConstraints() { - return null; - } - - public Set<ConstraintDescriptor<?>> getConstraintDescriptors() { - return Collections.unmodifiableSet(descriptors); - } - - public Class<?> getElementClass() { - return elementClass; - } - - public String getPropertyName() { - return name; - } - - public boolean hasConstraints() { - return !descriptors.isEmpty(); - } - - public boolean isCascaded() { - return cascaded; - } -}
diff --git a/user/src/com/google/gwt/validation/client/spi/BaseConfigurationState.java b/user/src/com/google/gwt/validation/client/spi/BaseConfigurationState.java deleted file mode 100644 index 732cf1d..0000000 --- a/user/src/com/google/gwt/validation/client/spi/BaseConfigurationState.java +++ /dev/null
@@ -1,55 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.spi; - -import java.util.Map; - -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; -import javax.validation.spi.ConfigurationState; - -/** - * Base GWT implementation of {@link ConfigurationState}. - */ -public abstract class BaseConfigurationState implements ConfigurationState { - - public ConstraintValidatorFactory getConstraintValidatorFactory() { - // TODO(nchalko) implement. - return null; - } - - public MessageInterpolator getMessageInterpolator() { - // TODO(nchalko) implement. - return null; - } - - public Map<String, String> getProperties() { - // TODO(nchalko) implement. - return null; - } - - public TraversableResolver getTraversableResolver() { - // TODO(nchalko) implement. - return null; - } - - public boolean isIgnoreXmlConfiguration() { - // Always ignore XML - return false; - } - -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/spi/GwtBootStrapState.java b/user/src/com/google/gwt/validation/client/spi/GwtBootStrapState.java deleted file mode 100644 index 859251f..0000000 --- a/user/src/com/google/gwt/validation/client/spi/GwtBootStrapState.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.spi; - -import com.google.gwt.core.client.GWT; - -import javax.validation.ValidationProviderResolver; -import javax.validation.spi.BootstrapState; - -/** - * GWT {@link BootstrapState}. - */ -public class GwtBootStrapState implements BootstrapState { - - public ValidationProviderResolver getDefaultValidationProviderResolver() { - return GWT.create(ValidationProviderResolver.class); - } - - public ValidationProviderResolver getValidationProviderResolver() { - return null; - } -}
diff --git a/user/src/com/google/gwt/validation/client/spi/GwtConfigurationState.java b/user/src/com/google/gwt/validation/client/spi/GwtConfigurationState.java deleted file mode 100644 index 69ce2a0..0000000 --- a/user/src/com/google/gwt/validation/client/spi/GwtConfigurationState.java +++ /dev/null
@@ -1,31 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.spi; - -import java.io.InputStream; -import java.util.Set; - -/** - * Only the GWT incompatible parts. - */ -public class GwtConfigurationState extends BaseConfigurationState { - - public Set<InputStream> getMappingStreams() { - throw new UnsupportedOperationException( - "GWT Validation does not support getMappingStreams"); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/spi/GwtValidationProvider.java b/user/src/com/google/gwt/validation/client/spi/GwtValidationProvider.java deleted file mode 100644 index 52cab9d..0000000 --- a/user/src/com/google/gwt/validation/client/spi/GwtValidationProvider.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.spi; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.BaseGwtConfiguration; -import com.google.gwt.validation.client.GwtConfiguration; - -import javax.validation.Configuration; -import javax.validation.ValidatorFactory; -import javax.validation.spi.BootstrapState; -import javax.validation.spi.ConfigurationState; -import javax.validation.spi.ValidationProvider; - -/** - * GWT {@link ValidationProvider}. - */ -public class GwtValidationProvider implements - ValidationProvider<BaseGwtConfiguration> { - - public ValidatorFactory buildValidatorFactory( - ConfigurationState configurationState) { - return GWT.create(ValidatorFactory.class); - } - - public Configuration<?> createGenericConfiguration(BootstrapState state) { - return new GwtConfiguration(this, state); - } - - public GwtConfiguration createSpecializedConfiguration(BootstrapState state) { - return new GwtConfiguration(this, state); - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/AbstractCreator.java b/user/src/com/google/gwt/validation/rebind/AbstractCreator.java deleted file mode 100644 index 1fb9e02..0000000 --- a/user/src/com/google/gwt/validation/rebind/AbstractCreator.java +++ /dev/null
@@ -1,121 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JPackage; -import com.google.gwt.user.rebind.AbstractSourceCreator; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; - -import java.io.PrintWriter; - -/** - * Abstract Class for Creating source files. - * <p> - * This class is not thread safe. - */ -public abstract class AbstractCreator extends AbstractSourceCreator { - - protected final GeneratorContext context; - - protected final TreeLogger logger; - - protected final JClassType validatorType; - - public AbstractCreator(GeneratorContext context, TreeLogger logger, - JClassType validatorType) { - super(); - this.context = context; - this.logger = branch(logger, "Creating " + validatorType); - this.validatorType = validatorType; - } - - public final String create() throws UnableToCompleteException { - SourceWriter sourceWriter = getSourceWriter(logger, context); - if (sourceWriter != null) { - writeClassBody(sourceWriter); - sourceWriter.commit(logger); - } - return getQualifiedName(); - } - - protected void addImports(ClassSourceFileComposerFactory composerFactory, Class<?>... imports) { - for (Class<?> imp : imports) { - composerFactory.addImport(imp.getCanonicalName()); - } - } - - protected abstract void compose(ClassSourceFileComposerFactory composerFactory); - - protected BeanHelper createBeanHelper(Class<?> clazz) { - return BeanHelper.createBeanHelper(clazz, logger, context); - } - - protected final String getPackage() { - JPackage serviceIntfPkg = validatorType.getPackage(); - String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName(); - return packageName; - } - - protected abstract void writeClassBody(SourceWriter sourceWriter) - throws UnableToCompleteException; - - protected void writeValidatorInstance(SourceWriter sw, BeanHelper bean) { - BeanHelper.writeInterface(context, logger, bean); - // private final MyBeanValidator myBeanValidator = - sw.print("private final " + bean.getFullyQualifiedValidatorName() + " "); - sw.print(bean.getValidatorInstanceName()); - sw.println(" = "); - sw.indent(); - sw.indent(); - - // GWT.create(MyBeanValidator.class); - sw.println("GWT.create(" + bean.getFullyQualifiedValidatorName() - + ".class);"); - sw.outdent(); - sw.outdent(); - } - - private String getQualifiedName() { - String packageName = getPackage(); - return (packageName == "" ? "" : packageName + ".") + getSimpleName(); - } - - private String getSimpleName() { - return validatorType.getSimpleSourceName() + "Impl"; - } - - private SourceWriter getSourceWriter(TreeLogger logger, - GeneratorContext ctx) { - String packageName = getPackage(); - String simpleName = getSimpleName(); - PrintWriter printWriter = ctx.tryCreate(logger, packageName, simpleName); - if (printWriter == null) { - return null; - } - - ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory( - packageName, simpleName); - compose(composerFactory); - SourceWriter sourceWriter = composerFactory.createSourceWriter(ctx, - printWriter); - return sourceWriter; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/rebind/BeanHelper.java b/user/src/com/google/gwt/validation/rebind/BeanHelper.java deleted file mode 100644 index e3c6d84..0000000 --- a/user/src/com/google/gwt/validation/rebind/BeanHelper.java +++ /dev/null
@@ -1,168 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.google.gwt.validation.client.impl.GwtSpecificValidator; - -import java.io.PrintWriter; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.metadata.BeanDescriptor; - -/** - * A simple struct for the various values associated with a Bean that can be - * validated. - */ -final class BeanHelper { - - private static final Validator serverSideValidor = Validation.buildDefaultValidatorFactory().getValidator(); - - // stash the map in a ThreadLocal, since each GWT module lives in its own - // thread in DevMode - private static final ThreadLocal<Map<JClassType, BeanHelper>> threadLocalHelperMap = - new ThreadLocal<Map<JClassType, BeanHelper>>() { - @Override - protected synchronized Map<JClassType, BeanHelper> initialValue() { - return new HashMap<JClassType, BeanHelper>(); - } - }; - - protected static BeanHelper createBeanHelper(Class<?> clazz, - TreeLogger logger, GeneratorContext context) { - JClassType beanType = context.getTypeOracle().findType( - clazz.getCanonicalName()); - BeanHelper helper = getBeanHelper(beanType); - if (helper == null) { - helper = new BeanHelper(beanType, clazz, - serverSideValidor.getConstraintsForClass(clazz)); - addBeanHelper(helper); - writeInterface(context, logger, helper); - } - return helper; - } - - protected static boolean isClassConstrained(Class<?> clazz) { - return serverSideValidor.getConstraintsForClass(clazz).isBeanConstrained(); - } - - static BeanHelper getBeanHelper(JClassType beanType) { - return getBeanHelpers().get(beanType); - } - - /** - * Write an Empty Interface implementing {@link GwtSpecificValidator} with - * Generic parameter of the bean type. - */ - static void writeInterface(GeneratorContext context, TreeLogger logger, - BeanHelper bean) { - PrintWriter pw = context.tryCreate(logger, bean.getPackage(), - bean.getValidatorName()); - if (pw != null) { - TreeLogger interfaceLogger = logger.branch(TreeLogger.TRACE, - "Creating the interface for " + bean.getFullyQualifiedValidatorName()); - - ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory( - bean.getPackage(), bean.getValidatorName()); - factory.addImplementedInterface(GwtSpecificValidator.class.getCanonicalName() - + " <" + bean.getTypeCanonicalName() + ">"); - factory.makeInterface(); - SourceWriter sw = factory.createSourceWriter(context, pw); - sw.commit(interfaceLogger); - pw.close(); - } - } - - private static synchronized void addBeanHelper(BeanHelper helper) { - threadLocalHelperMap.get().put(helper.getJClass(), helper); - } - - private static Map<JClassType, BeanHelper> getBeanHelpers() { - return Collections.unmodifiableMap(threadLocalHelperMap.get()); - } - - private final BeanDescriptor beanDescriptor; - - private final JClassType jClass; - - private Class<?> clazz; - - private BeanHelper(JClassType jClass, Class<?> clazz, - BeanDescriptor beanDescriptor) { - super(); - this.beanDescriptor = beanDescriptor; - this.jClass = jClass; - this.clazz = clazz; - } - - public BeanDescriptor getBeanDescriptor() { - return beanDescriptor; - } - - /* - * The server side validator needs an actual class. - */ - public Class<?> getClazz() { - return clazz; - } - - public String getDescriptorName() { - - return jClass.getName() + "Descriptor"; - } - - public String getFullyQualifiedValidatorName() { - return getPackage() + "." + getValidatorName(); - } - - public JClassType getJClass() { - return jClass; - } - - public String getPackage() { - return jClass.getPackage().getName(); - } - - public String getTypeCanonicalName() { - return jClass.getQualifiedSourceName(); - } - - public String getValidatorInstanceName() { - return makeJavaSafe(jClass.getName().toLowerCase() + "Validator"); - } - - public String getValidatorName() { - return makeJavaSafe("_" + jClass.getName() + "Validator"); - } - - @Override - public String toString() { - return getTypeCanonicalName(); - } - - private String makeJavaSafe(String in) { - return in.replaceAll("\\.", "_"); - } - -}
diff --git a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java deleted file mode 100644 index 6e2c00c..0000000 --- a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java +++ /dev/null
@@ -1,1219 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.UnsafeNativeLong; -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.TreeLogger.Type; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JField; -import com.google.gwt.core.ext.typeinfo.JMethod; -import com.google.gwt.core.ext.typeinfo.JPrimitiveType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.dev.jjs.ast.JProgram; -import com.google.gwt.thirdparty.guava.common.base.Predicate; -import com.google.gwt.thirdparty.guava.common.collect.Iterables; -import com.google.gwt.thirdparty.guava.common.collect.Maps; -import com.google.gwt.thirdparty.guava.common.collect.Sets; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.google.gwt.validation.client.impl.AbstractGwtSpecificValidator; -import com.google.gwt.validation.client.impl.ConstraintDescriptorImpl; -import com.google.gwt.validation.client.impl.GwtBeanDescriptor; -import com.google.gwt.validation.client.impl.GwtBeanDescriptorImpl; -import com.google.gwt.validation.client.impl.GwtValidationContext; -import com.google.gwt.validation.client.impl.PropertyDescriptorImpl; - -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintViolation; -import javax.validation.Payload; -import javax.validation.ValidationException; -import javax.validation.metadata.BeanDescriptor; -import javax.validation.metadata.ConstraintDescriptor; -import javax.validation.metadata.PropertyDescriptor; - -/** - * Creates a {@link com.google.gwt.validation.client.GwtSpecificValidator}. - * <p> - * This class is not thread safe. - */ -public class GwtSpecificValidatorCreator extends AbstractCreator { - - private static enum Stage { - OBJECT, PROPERTY, VALUE - } - - private static final JType[] NO_ARGS = new JType[]{}; - - /** - * Returns the literal value of an object that is suitable for inclusion in - * Java Source code. - * - * <p> - * Supports all types that {@link Annotation) value can have. - * - * - * @throws IllegalArgumentException if the type of the object does not have a java literal form. - */ - public static String asLiteral(Object value) throws IllegalArgumentException { - Class<?> clazz = value.getClass(); - JProgram jProgram = new JProgram(); - - if (clazz.isArray()) { - StringBuilder sb = new StringBuilder(); - Object[] array = (Object[]) value; - - sb.append("new " + clazz.getComponentType().getCanonicalName() + "[] "); - sb.append("{"); - boolean first = true; - for (Object object : array) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(asLiteral(object)); - } - sb.append("}"); - return sb.toString(); - } - - if (value instanceof Class) { - return ((Class<?>) ((Class<?>) value)).getCanonicalName() + ".class"; - } - if (value instanceof Double) { - return jProgram.getLiteralDouble(((Double) value).doubleValue()).toSource(); - } - if (value instanceof Integer) { - return jProgram.getLiteralInt(((Integer) value).intValue()).toSource(); - } - if (value instanceof Long) { - return jProgram.getLiteralLong(((Long) value).intValue()).toSource(); - } - if (value instanceof String) { - return '"' + Generator.escape((String) value) + '"'; - } - // TODO(nchalko) handle the rest of the literal types - throw new IllegalArgumentException(value.getClass() - + " is can not be represented as a Java Literal."); - } - - static <T extends Annotation> Class<?> getTypeOfConstraintValidator( - Class<? extends ConstraintValidator<T, ?>> constraintClass) { - - for (Method method : constraintClass.getMethods()) { - if (method.getName().equals("isValid") - && method.getParameterTypes().length == 2 - && method.getReturnType().isAssignableFrom(Boolean.TYPE)) { - return method.getParameterTypes()[0]; - } - } - throw new IllegalStateException( - "ConstraintValidators must have a isValid method"); - } - - // Visible for testing - static <A extends Annotation> Class<? extends ConstraintValidator<A, ?>> getValidatorForType( - Class<?> type, - List<Class<? extends ConstraintValidator<A, ?>>> constraintValidatorClasses) { - Map<Class<?>, Class<? extends ConstraintValidator<A, ?>>> map = Maps.newHashMap(); - for (Class<? extends ConstraintValidator<A, ?>> constraintClass : constraintValidatorClasses) { - Class<?> aType = getTypeOfConstraintValidator(constraintClass); - if (aType.isAssignableFrom(type)) { - map.put(aType, constraintClass); - } - } - Class<?> best = null; - for (Class<?> c : map.keySet()) { - if (best == null) { - best = c; - } else { - if (c.equals(type)) { - best = c; - break; // Exact match we can stop - } - // TODO(nchalko) implement per spec - // is the new one better than the last. - } - } - return map.get(best); - } - - private static <A extends Annotation> Class<? extends ConstraintValidator<A, ?>> getValidatorForType( - ConstraintDescriptor<A> constraint, Class<?> clazz) { - List<Class<? extends ConstraintValidator<A, ?>>> constraintValidatorClasses - = constraint.getConstraintValidatorClasses(); - if (constraintValidatorClasses.isEmpty()) { - return null; - } - return getValidatorForType(clazz, constraintValidatorClasses); - } - - private BeanHelper beanHelper; - private Set<BeanHelper> beansToValidate = Sets.newHashSet(); - private final JClassType beanType; - - private final Set<JField> fieldsToWrap = Sets.newHashSet(); - - private Set<JMethod> gettersToWrap = Sets.newHashSet(); - - - - private final TypeOracle oracle; - - public GwtSpecificValidatorCreator(JClassType validatorType, - JClassType beanType, BeanHelper beanHelper, TreeLogger logger, - GeneratorContext context) { - super(context, logger, validatorType); - this.oracle = context.getTypeOracle(); - this.beanType = beanType; - this.beanHelper = beanHelper; - } - - public JType getElementType(PropertyDescriptor p, boolean useField) { - if (useField) { - return beanType.findField(p.getPropertyName()).getType(); - } else { - return beanType.findMethod(this.asGetter(p), NO_ARGS).getReturnType(); - } - } - - @Override - protected void compose(ClassSourceFileComposerFactory composerFactory) { - addImports(composerFactory, GWT.class, GwtBeanDescriptor.class, - GwtValidationContext.class, Set.class, HashSet.class, - ConstraintViolation.class, Annotation.class); - composerFactory.setSuperclass(AbstractGwtSpecificValidator.class.getCanonicalName() - + "<" + beanType.getQualifiedSourceName() + ">"); - composerFactory.addImplementedInterface(validatorType.getName()); - } - - @Override - protected void writeClassBody(SourceWriter sw) - throws UnableToCompleteException { - writeFields(sw); - sw.println(); - writeValidate(sw); - sw.println(); - writeValidateProperty(sw); - sw.println(); - writeValidateValue(sw); - sw.println(); - writeGetDescriptor(sw); - sw.println(); - writePropertyValidators(sw); - sw.println(); - - // Write these after we know what is needed - writeWrappers(sw); - sw.println(); - - // Write the Validator instance variables after we have collected the - // ones we need in beansToValidate - writeValidatorInstances(sw); - } - - protected void writeUnsafeNativeLongIfNeeded(SourceWriter sw, JType jType) { - if (JPrimitiveType.LONG.equals(jType)) { - // @com.google.gwt.core.client.UnsafeNativeLong - sw.print("@"); - sw.println(UnsafeNativeLong.class.getCanonicalName()); - } - } - - private <T> T[] asArray(Collection<?> collection, T[] array) { - if (collection == null) { - return null; - } - return collection.toArray(array); - } - - private String asGetter(PropertyDescriptor p) { - return "get" + capitalizeFirstLetter(p.getPropertyName()); - } - - private String capitalizeFirstLetter(String propertyName) { - if (propertyName == null) { - return null; - } - if (propertyName.length() == 0) { - return ""; - } - String cap = propertyName.substring(0, 1).toUpperCase(); - if (propertyName.length() > 1) { - cap += propertyName.substring(1); - } - return cap; - } - - private String constraintDescriptorVar(String name, int count) { - String s = name + "_c" + count; - return s; - } - - private Annotation getAnnotation(PropertyDescriptor p, boolean useField, - ConstraintDescriptor<?> constraint) { - Class<? extends Annotation> expectedAnnotaionClass = - ((Annotation) constraint.getAnnotation()).annotationType(); - Annotation annotation = null; - if (useField) { - JField field = beanType.findField(p.getPropertyName()); - if (field.getEnclosingType().equals(beanType)) { - annotation = field.getAnnotation(expectedAnnotaionClass); - } - } else { - JMethod method = beanType.findMethod(asGetter(p), NO_ARGS); - if (method.getEnclosingType().equals(beanType)) { - annotation = method.getAnnotation(expectedAnnotaionClass); - } - } - return annotation; - } - - /** - * @param elementType - * @return - */ - private String getQualifiedSourceNonPrimitiveType(JType elementType) { - JPrimitiveType primitive = elementType.isPrimitive(); - return primitive == null ? elementType.getQualifiedSourceName() - : primitive.getQualifiedBoxedSourceName(); - } - - private boolean hasField(PropertyDescriptor p) { - JField field = beanType.findField(p.getPropertyName()); - return field != null; - } - - /** - * @param beanHelper2 - * @param p - * @return - */ - private boolean hasGetter(PropertyDescriptor p) { - JType[] paramTypes = new JType[]{}; - try { - beanType.getMethod(asGetter(p), paramTypes); - return true; - } catch (NotFoundException e) { - return false; - } - } - - private boolean isIterableOrMap(Class<?> elementClass) { - // TODO(nchalko) handle iterables everywhere this is called. - return elementClass.isArray() - || Iterable.class.isAssignableFrom(elementClass) - || Map.class.isAssignableFrom(elementClass); - } - - private boolean isPropertyConstrained(BeanHelper helper, PropertyDescriptor p) { - Set<PropertyDescriptor> propertyDescriptors = - helper.getBeanDescriptor().getConstrainedProperties(); - Predicate<PropertyDescriptor> nameMatches = newPropertyNameMatches(p); - return Iterables.any(propertyDescriptors, nameMatches); - } - - private Predicate<PropertyDescriptor> newPropertyNameMatches( - final PropertyDescriptor p) { - return new Predicate<PropertyDescriptor>() { - public boolean apply(PropertyDescriptor input) { - return input.getPropertyName().equals(p.getPropertyName()); - } - }; - } - - private String toWrapperName(JField field) { - return "_" + field.getName(); - } - - /** - * @param method - * @return - */ - private String toWrapperName(JMethod method) { - return "_" + method.getName(); - } - - private String validateMethodFieldName(PropertyDescriptor p) { - return "validateProperty_" + p.getPropertyName(); - } - - private String validateMethodGetterName(PropertyDescriptor p) { - return "validateProperty_get" + p.getPropertyName(); - } - - private void writeBeanDescriptor(SourceWriter sw) { - BeanDescriptor beanDescriptor = beanHelper.getBeanDescriptor(); - - // GwtBeanDescriptor <MyBean> beanDescriptor = - sw.print(GwtBeanDescriptor.class.getCanonicalName()); - sw.print("<" + beanHelper.getTypeCanonicalName() + ">"); - sw.println(" beanDescriptor = "); - sw.indent(); - sw.indent(); - - // GwtBeanDescriptorImpl.builder(Order.class) - sw.print(GwtBeanDescriptorImpl.class.getCanonicalName()); - sw.println(".builder(" + beanHelper.getTypeCanonicalName() + ".class)"); - sw.indent(); - sw.indent(); - - // .setConstrained(true) - sw.println(".setConstrained(" + beanDescriptor.isBeanConstrained() + ")"); - - // .put("myProperty", myProperty_pd) - for (PropertyDescriptor p : beanDescriptor.getConstrainedProperties()) { - sw.print(".put(\""); - sw.print(p.getPropertyName()); - sw.print("\", "); - sw.print(p.getPropertyName()); - sw.println("_pd)"); - } - - // .build(); - sw.println(".build();"); - sw.outdent(); - sw.outdent(); - sw.outdent(); - sw.outdent(); - } - - private void writeConstraintDescriptor(SourceWriter sw, - ConstraintDescriptor<? extends Annotation> constraint, - String constraintDescripotorVar) throws UnableToCompleteException { - Class<? extends Annotation> annotationType = - constraint.getAnnotation().annotationType(); - - // First list all composing constraints - int count = 0; - for (ConstraintDescriptor<?> composingConstraint : - constraint.getComposingConstraints()) { - writeConstraintDescriptor(sw, composingConstraint, - constraintDescripotorVar + "_" + count++); - } - - // ConstraintDescriptorImpl<MyAnnotation> constraintDescriptor = ; - sw.print(ConstraintDescriptorImpl.class.getCanonicalName()); - sw.print("<"); - - sw.print(annotationType.getCanonicalName()); - sw.print(">"); - - sw.println(" " + constraintDescripotorVar + " = "); - sw.indent(); - sw.indent(); - - // ConstraintDescriptorImpl.<MyConstraint> builder() - sw.print(ConstraintDescriptorImpl.class.getCanonicalName()); - sw.print(".<"); - - sw.print(annotationType.getCanonicalName()); - sw.println("> builder()"); - sw.indent(); - sw.indent(); - - // .setAnnotation(new MyAnnotation ) - sw.println(".setAnnotation( "); - sw.indent(); - sw.indent(); - writeNewAnnotation(sw, constraint); - sw.println(")"); - sw.outdent(); - sw.outdent(); - - // .setAttributes(builder() - sw.println(".setAttributes(attributeBuilder()"); - sw.indent(); - - for (Map.Entry<String, Object> entry : - constraint.getAttributes().entrySet()) { - // .put(key, value) - sw.print(".put("); - sw.print(asLiteral(entry.getKey())); - sw.print(", "); - sw.print(asLiteral(entry.getValue())); - sw.println(")"); - } - - // .build()) - sw.println(".build())"); - sw.outdent(); - - // .setConstraintValidatorClasses(classes ) - sw.print(".setConstraintValidatorClasses("); - sw.print(asLiteral(asArray(constraint.getConstraintValidatorClasses(), - new Class[0]))); - sw.println(")"); - - // .getGroups(groups) - sw.print(".setGroups("); - Set<Class<?>> groups = constraint.getGroups(); - sw.print(asLiteral(asArray(groups, new Class<?>[0]))); - sw.println(")"); - - // .setPayload(payload) - sw.print(".setPayload("); - Set<Class<? extends Payload>> payload = constraint.getPayload(); - sw.print(asLiteral(asArray(payload, new Class[0]))); - sw.println(")"); - - // .setsetReportAsSingleViolation(boolean ) - sw.print(".setReportAsSingleViolation("); - sw.print(Boolean.valueOf(constraint.isReportAsSingleViolation()) - .toString()); - sw.println(")"); - - // .build(); - sw.println(".build();"); - sw.outdent(); - sw.outdent(); - - sw.outdent(); - sw.outdent(); - sw.println(); - } - - private void writeFields(SourceWriter sw) throws UnableToCompleteException { - - // Create a variable for each constraint of each property - for (PropertyDescriptor p : - beanHelper.getBeanDescriptor().getConstrainedProperties()) { - int count = 0; - for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) { - writeConstraintDescriptor(sw, constraint, - constraintDescriptorVar(p.getPropertyName(), count)); - count++; // index starts at zero. - } - writePropertyDescriptor(sw, p); - if (p.isCascaded() && !isIterableOrMap(p.getElementClass())) { - beansToValidate.add(createBeanHelper(p.getElementClass())); - } - } - - // Now write the BeanDescriptor after we already have the PropertyDescriptor - writeBeanDescriptor(sw); - sw.println(); - - // Create a variable for each constraint of this class. - int count = 0; - for (ConstraintDescriptor<?> constraint : - beanHelper.getBeanDescriptor().getConstraintDescriptors()) { - - writeConstraintDescriptor(sw, constraint, - constraintDescriptorVar("this", count)); - count++; // index starts at zero. - } - } - - private void writeFieldWrapperMethod(SourceWriter sw, JField field) { - writeUnsafeNativeLongIfNeeded(sw, field.getType()); - - // private native fieldType _fieldName(Bean object) /*-{ - sw.print("private native "); - - sw.print(field.getType().getQualifiedSourceName()); - sw.print(" "); - sw.print(toWrapperName(field)); - sw.print("("); - sw.print(beanType.getName()); - sw.println(" object) /*-{"); - sw.indent(); - - // return object.@com.examples.Bean::myMethod(); - sw.print("return object.@"); - sw.print(field.getEnclosingType().getQualifiedSourceName()); - sw.print("::" + field.getName()); - sw.println(";"); - - // }-*/; - sw.outdent(); - sw.println("}-*/;"); - } - - private void writeGetDescriptor(SourceWriter sw) { - // public GwtBeanDescriptor<beanType> getConstraints() { - sw.print("public "); - sw.print("GwtBeanDescriptor<" + beanHelper.getTypeCanonicalName() + "> "); - sw.println("getConstraints() {"); - sw.indent(); - - // return beanDescriptor; - sw.println("return beanDescriptor;"); - - sw.outdent(); - sw.println("}"); - } - - private void writeGetterWrapperMethod(SourceWriter sw, JMethod method) { - writeUnsafeNativeLongIfNeeded(sw, method.getReturnType()); - - // private native fieldType _getter(Bean object) /*={ - sw.print("private native "); - sw.print(method.getReturnType().getQualifiedSourceName()); - sw.print(" "); - sw.print(toWrapperName(method)); - sw.print("("); - sw.print(beanType.getName()); - sw.println(" object) /*-{"); - sw.indent(); - - // return object.@com.examples.Bean::myMethod()(); - sw.print("return object."); - sw.print(method.getJsniSignature()); - sw.println("();"); - - // }-*/; - sw.outdent(); - sw.println("}-*/;"); - } - - private void writeNewAnnotation(SourceWriter sw, - ConstraintDescriptor<? extends Annotation> constraint) - throws UnableToCompleteException { - Annotation annotation = constraint.getAnnotation(); - Class<? extends Annotation> annotationType = annotation.annotationType(); - - // new MyAnnotation () { - sw.print("new "); - sw.print(annotationType.getCanonicalName()); - sw.println("(){"); - sw.indent(); - sw.indent(); - - // public Class<? extends Annotation> annotationType() { return - // MyAnnotation.class; } - sw.print("public Class<? extends Annotation> annotationType() { return "); - sw.print(annotationType.getCanonicalName()); - sw.println(".class; }"); - - for (Method method : annotationType.getMethods()) { - // method.isAbstract would be better - if (method.getDeclaringClass().equals(annotation.annotationType())) { - // public returnType method() { return value ;} - sw.print("public "); - sw.print(method.getReturnType().getCanonicalName()); // TODO handle - // generics - sw.print(" "); - sw.print(method.getName()); - sw.print("() { return "); - - try { - Object value = method.invoke(annotation); - sw.print(asLiteral(value)); - } catch (IllegalArgumentException e) { - throw error(logger, e); - } catch (IllegalAccessException e) { - throw error(logger, e); - } catch (InvocationTargetException e) { - throw error(logger, e); - } - sw.println(";}"); - } - } - - sw.outdent(); - sw.outdent(); - sw.println("}"); - } - - private void writeNewViolations(SourceWriter sw) { - // Set<ConstraintViolation<T>> violations = - // new HashSet<ConstraintViolation<T>>(); - sw.println("Set<ConstraintViolation<T>> violations = "); - sw.indent(); - sw.indent(); - - sw.println("new HashSet<ConstraintViolation<T>>();"); - sw.outdent(); - sw.outdent(); - } - - /** - * @param sw - * @param p - */ - private void writePropertyDescriptor(SourceWriter sw, PropertyDescriptor p) { - // PropertyDescriptor myProperty_pd = - sw.print(PropertyDescriptor.class.getCanonicalName()); - sw.print(" "); - sw.print(p.getPropertyName()); - sw.println("_pd ="); - sw.indent(); - sw.indent(); - - // new PropertyDescriptorImpl( - sw.println("new " + PropertyDescriptorImpl.class.getCanonicalName() + "("); - sw.indent(); - sw.indent(); - - // "myProperty", - sw.println("\"" + p.getPropertyName() + "\","); - - // MyType.class, - sw.println(p.getElementClass().getCanonicalName() + ".class,"); - - // isCascaded, - sw.print(Boolean.toString(p.isCascaded())); - - // myProperty_c0, - // myProperty_c1 ); - int size = p.getConstraintDescriptors().size(); - for (int i = 0; i < size; i++) { - sw.println(","); // Print the , for the previous line - sw.print(constraintDescriptorVar(p.getPropertyName(), i)); - } - sw.println(");"); - - sw.outdent(); - sw.outdent(); - sw.outdent(); - sw.outdent(); - } - - private void writePropertyValidators(SourceWriter sw) { - for (PropertyDescriptor p : - beanHelper.getBeanDescriptor().getConstrainedProperties()) { - if (hasField(p)) { - writeValidatePropertyMethod(sw, p, true); - sw.println(); - } - if (hasGetter(p)) { - writeValidatePropertyMethod(sw, p, false); - sw.println(); - } - } - } - - private void writeValidate(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate( - sw.println("public <T> Set<ConstraintViolation<T>> validate("); - - // GwtValidationContext<T> context, BeanType object, Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println(beanHelper.getTypeCanonicalName() + " object,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - writeNewViolations(sw); - - if (beanHelper.getBeanDescriptor().isBeanConstrained()) { - - // /// For each group - - // TODO(nchalko) handle the sequence in the AbstractValidator - - // See JSR 303 section 3.5 - // all reachable fields - // all reachable getters (both) at once - - Set<PropertyDescriptor> properties = beanHelper.getBeanDescriptor().getConstrainedProperties(); - - for (PropertyDescriptor p : properties) { - writeValidatePropertyCall(sw, p, false); - } - - // all class level constraints - // including super classes - // including super interfaces - - int count = 0; - Class<?> clazz = beanHelper.getClazz(); - for (ConstraintDescriptor<?> constraint : beanHelper.getBeanDescriptor().findConstraints().getConstraintDescriptors()) { - - Class<? extends ConstraintValidator<? extends Annotation, ?>> validatorClass = getValidatorForType( - constraint, clazz); - if (validatorClass != null) { - // TODO(nchalko) handle constraint.isReportAsSingleViolation() and - // hasComposingConstraints - - // validate(context, violations, object, value, validator, - // constraintDescriptor, groups); - sw.print("validate(context, violations, null, object, "); - // new MyValidtor(); - sw.print("new "); - sw.print(validatorClass.getCanonicalName()); - sw.print("(), "); // new one each time because validators are not thread - // safe - sw.print(constraintDescriptorVar("this", count)); - sw.println(", groups);"); - } else { - // TODO(nchalko) What does the spec say to do here. - logger.log(Type.WARN, "No ConstraintValidator of " + constraint - + " for type " + clazz); - } - count++; // index starts at 0 - } - - // validate all super classes and interfaces - writeValidateInheritance(sw, clazz, Stage.OBJECT, null); - - // all reachable and cascadable associations - - beanType.getFields(); - } - // return violations; - sw.println("return violations;"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidateConstraint(SourceWriter sw, PropertyDescriptor p, - Class<?> elementClass, ConstraintDescriptor<?> constraint, - String constraintDescriptorVar) { - Class<? extends ConstraintValidator<? extends Annotation, ?>> validatorClass = - getValidatorForType(constraint, elementClass); - if (validatorClass == null) { - // TODO(nchalko) What does the spec say to do here. - logger.log(Type.WARN, "No ConstraintValidator of " + constraint + " for " - + p.getPropertyName() + " of type " + elementClass); - - } else { - // TODO(nchalko) handle constraint.isReportAsSingleViolation() - // validate(context, violations, object, value, new MyValidator(), - // constraintDescriptor, groups); - sw.print("validate(context, violations, object, value, "); - sw.print("new "); // new one each time because validators are not - // thread safe - // TODO(nchalko) use ConstraintValidatorFactory - sw.print(validatorClass.getCanonicalName()); - sw.print("(), "); - sw.print(constraintDescriptorVar); - sw.println(", groups);"); - } - int count = 0; - for (ConstraintDescriptor<?> compositeConstraint : constraint.getComposingConstraints()) { - String compositeVar = constraintDescriptorVar + "_" + count++; - writeValidateConstraint(sw, p, elementClass, compositeConstraint, - compositeVar); - } - } - - private void writeValidateFieldCall(SourceWriter sw, PropertyDescriptor p, - boolean useValue) { - String propertyName = p.getPropertyName(); - - // validateProperty_<<field>>(context, - sw.print(validateMethodFieldName(p)); - sw.print("(context, "); - sw.print("violations, "); - - // null, (MyType) value, - // or - // object, object.getLastName(), - if (useValue) { - sw.print("null, "); - sw.print("("); - sw.print(getQualifiedSourceNonPrimitiveType(getElementType(p, true))); - sw.print(") value"); - } else { - sw.print("object, "); - JField field = beanType.getField(propertyName); - if (field.isPublic()) { - sw.print("object."); - sw.print(propertyName); - } else { - fieldsToWrap.add(field); - sw.print(toWrapperName(field) + "(object)"); - } - } - sw.print(", "); - - // groups)); - sw.println("groups);"); - } - - private void writeValidateGetterCall(SourceWriter sw, PropertyDescriptor p, - boolean useValue) { - // validateProperty_get<<field>>(context, violations, - sw.print(validateMethodGetterName(p)); - sw.print("(context, "); - sw.print("violations, "); - - // object, object.getMyProp(), - // or - // null, (MyType) value, - if (useValue) { - sw.print("null, "); - sw.print("("); - sw.print(getQualifiedSourceNonPrimitiveType(getElementType(p, false))); - sw.print(") value"); - } else { - sw.print("object, "); - JMethod method = beanType.findMethod(asGetter(p), NO_ARGS); - if (method.isPublic()) { - sw.print("object."); - sw.print(asGetter(p)); - sw.print("()"); - } else { - gettersToWrap.add(method); - sw.print(toWrapperName(method) + "(object)"); - } - } - sw.print(", "); - - // groups); - sw.println("groups);"); - } - - private void writeValidateInheritance(SourceWriter sw, Class<?> clazz, - Stage stage, PropertyDescriptor property) { - writeValidateInterfaces(sw, clazz, stage, property); - Class<?> superClass = clazz.getSuperclass(); - if (superClass != null) { - writeValidatorCall(sw, superClass, stage, property); - } - } - - private void writeValidateInterfaces(SourceWriter sw, Class<?> clazz, - Stage stage, PropertyDescriptor p) { - for (Class<?> type : clazz.getInterfaces()) { - writeValidatorCall(sw, type, stage, p); - writeValidateInterfaces(sw, type, stage, p); - } - } - - private void writeValidateProperty(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate( - sw.println("public <T> Set<ConstraintViolation<T>> validateProperty("); - - // GwtValidationContext<T> context, BeanType object, String propertyName, - // Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println(beanHelper.getTypeCanonicalName() + " object,"); - sw.println("String propertyName,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - writeNewViolations(sw); - - // TODO(nchalko) check if it is a valid propertyName - - for (PropertyDescriptor property : beanHelper.getBeanDescriptor().getConstrainedProperties()) { - // if (propertyName.equals(myPropety)) { - sw.print("if (propertyName.equals(\""); - sw.print(property.getPropertyName()); - sw.println("\")) {"); - sw.indent(); - - writeValidatePropertyCall(sw, property, false); - - // validate all super classes and interfaces - writeValidateInheritance(sw, beanHelper.getClazz(), Stage.PROPERTY, - property); - - // } - sw.outdent(); - sw.print("} else "); - } - - // { - sw.println("{"); - sw.indent(); - - // throw new IllegalArgumentException(propertyName - // +"is not a valid property of myClass"); - sw.print("throw new "); - sw.print(IllegalArgumentException.class.getCanonicalName()); - sw.print("( propertyName +\" is not a valid property of "); - sw.print(beanType.getQualifiedSourceName()); - sw.println("\");"); - - // } - sw.outdent(); - sw.println("}"); - - if (!beanHelper.getBeanDescriptor().getConstrainedProperties().isEmpty()) { - - // return violations; - sw.println("return violations;"); - } - - sw.outdent(); - sw.println("}"); - } - - private void writeValidatePropertyCall(SourceWriter sw, - PropertyDescriptor property, boolean useValue) { - if (hasGetter(property)) { - if (useValue) { - // if ( value == null || value instanceof propertyType) { - sw.print("if ( value == null || value instanceof "); - sw.print(getQualifiedSourceNonPrimitiveType(getElementType(property, - false))); - sw.println(") {"); - sw.indent(); - } - // validate_getMyProperty - writeValidateGetterCall(sw, property, useValue); - if (useValue) { - // } else - sw.outdent(); - sw.print("} else "); - } - } - - - if (hasField(property)) { - if (useValue) { - // if ( value == null || value instanceof propertyType) { - sw.print("if ( value == null || value instanceof "); - sw.print(getQualifiedSourceNonPrimitiveType(getElementType(property, - true))); - sw.println(") {"); - sw.indent(); - } - // validate_myProperty - writeValidateFieldCall(sw, property, useValue); - if (useValue) { - // } else - sw.outdent(); - sw.print("} else "); - } - } - - if (useValue & (hasGetter(property) || hasField(property))) { - // { - sw.println(" {"); - sw.indent(); - - // throw new ValidationException(value.getClass + - // " is not a valid type for " + propertyName); - sw.print("throw new "); - sw.print(ValidationException.class.getCanonicalName()); - sw.println("(value.getClass() +\" is not a valid type for \"+ propertyName);"); - - // } - sw.outdent(); - sw.println("}"); - } - } - - private void writeValidatePropertyMethod(SourceWriter sw, - PropertyDescriptor p, boolean useField) { - Class<?> elementClass = p.getElementClass(); - JType elementType = getElementType(p, useField); - - // private final <T> void validateProperty_{get}<p>( - sw.print("private final <T> void "); - if (useField) { - sw.print(validateMethodFieldName(p)); - } else { - sw.print(validateMethodGetterName(p)); - } - sw.println("("); - // GwtValidationContext<T> context, Set<ConstraintViolation<T>> violations, - // BeanType object, <Type> value, Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println("Set<ConstraintViolation<T>> violations,"); - sw.println(beanHelper.getTypeCanonicalName() + " object,"); - sw.print(elementType.getQualifiedSourceName()); - sw.println(" value,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - // TODO(nchalko) handle the other path types. - // context = context.append("myProperty"); - sw.print("context = context.append(\""); - sw.print(p.getPropertyName()); - sw.println("\");"); - - // TODO(nchalko) move this out of here to the Validate method - if (p.isCascaded() && !isIterableOrMap(elementClass)) { - - BeanHelper helper = createBeanHelper(elementClass); - - // if(value != null) { - sw.println("if(value != null) {"); - sw.indent(); - - // violations.addAll(myGwtValidator.validate(context, value, groups)); - sw.print("violations.addAll("); - sw.print(helper.getValidatorInstanceName()); - sw.println(".validate(context, value, groups));"); - - // } - sw.outdent(); - sw.println("}"); - } - - int count = 0; - for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) { - Annotation annotation = getAnnotation(p, useField, constraint); - if (annotation != null) { - // TODO(nchalko) check for annotation equality - - String constraintDescriptorVar = constraintDescriptorVar( - p.getPropertyName(), count); - - writeValidateConstraint(sw, p, elementClass, constraint, - constraintDescriptorVar); - } - count++; // index starts at zero - } - sw.outdent(); - sw.println("}"); - } - - private void writeValidateValue(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate( - sw.println("public <T> Set<ConstraintViolation<T>> validateValue("); - - // GwtValidationContext<T> context, Class<Author> beanType, - // String propertyName, Object value, Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println("Class<" + beanHelper.getTypeCanonicalName() + "> beanType,"); - sw.println("String propertyName,"); - sw.println("Object value,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - writeNewViolations(sw); - - // TODO(nchalko) check if it is a valid propertyName - - for (PropertyDescriptor property : - beanHelper.getBeanDescriptor().getConstrainedProperties()) { - // if (propertyName.equals(myPropety)) { - sw.print("if (propertyName.equals(\""); - sw.print(property.getPropertyName()); - sw.println("\")) {"); - sw.indent(); - - if (!isIterableOrMap(property.getElementClass())) { - writeValidatePropertyCall(sw, property, true); - } - - // validate all super classes and interfaces - writeValidateInheritance(sw, beanHelper.getClazz(), - Stage.VALUE, property); - - // } - sw.outdent(); - sw.print("} else "); - } - - // { - sw.println("{"); - sw.indent(); - - // throw new IllegalArgumentException(propertyName - // +"is not a valid property of myClass"); - sw.print("throw new "); - sw.print(IllegalArgumentException.class.getCanonicalName()); - sw.print("( propertyName +\" is not a valid property of "); - sw.print(beanType.getQualifiedSourceName()); - sw.println("\");"); - - // } - sw.outdent(); - sw.println("}"); - - if (!beanHelper.getBeanDescriptor() - .getConstrainedProperties().isEmpty()) { - // return violations; - sw.println("return violations;"); - } - - sw.outdent(); - sw.println("}"); - } - - private void writeValidatorCall(SourceWriter sw, Class<?> type, Stage stage, - PropertyDescriptor p) { - if (BeanHelper.isClassConstrained(type) && !isIterableOrMap(type)) { - BeanHelper helper = createBeanHelper(type); - beansToValidate.add(helper); - switch (stage) { - case OBJECT: - // voilations.addAll(myValidator.validate(context,object,groups)); - sw.print("violations.addAll("); - sw.print(helper.getValidatorInstanceName()); - sw.println(".validate(context, object, groups));"); - break; - case PROPERTY: - if (isPropertyConstrained(helper, p)) { - // voilations.addAll(myValidator.validateProperty(context,object - // ,propertyName, groups)); - sw.print("violations.addAll("); - sw.print(helper.getValidatorInstanceName()); - sw.print(".validateProperty(context, object,"); - sw.println(" propertyName, groups));"); - } - break; - case VALUE: - if (isPropertyConstrained(helper, p)) { - // voilations.addAll(myValidator.validateProperty(context,beanType - // ,propertyName, value, groups)); - sw.print("violations.addAll("); - sw.print(helper.getValidatorInstanceName()); - sw.print(".validateValue(context, "); - // TODO(nchalko) this seems like an unneeded param - sw.print(helper.getTypeCanonicalName()); - sw.println(".class, propertyName, value, groups));"); - } - break; - default: - throw new IllegalStateException(); - } - } - } - - private void writeValidatorInstances(SourceWriter sw) { - sw.println("// The validator instance variables are written last "); - sw.println("// after we have identified all the ones we need."); - for (BeanHelper helper : beansToValidate) { - writeValidatorInstance(sw, helper); - } - } - - private void writeWrappers(SourceWriter sw) { - sw.println("// Write the wrappers after we know which are needed"); - for (JField field : fieldsToWrap) { - writeFieldWrapperMethod(sw, field); - sw.println(); - } - - for (JMethod method : gettersToWrap) { - writeGetterWrapperMethod(sw, method); - sw.println(); - } - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorGenerator.java b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorGenerator.java deleted file mode 100644 index 11ec398..0000000 --- a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorGenerator.java +++ /dev/null
@@ -1,92 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JParameterizedType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.validation.client.impl.GwtSpecificValidator; - -/** - * Generates a {@link com.google.gwt.validation.client.GwtSpecificValidator}. - * <p> - * This class is thread safe. - */ -public class GwtSpecificValidatorGenerator extends Generator { - - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - JClassType validatorType = context.getTypeOracle().findType(typeName); - TypeOracle typeOracle = context.getTypeOracle(); - assert (typeOracle != null); - - JClassType validator = typeOracle.findType(typeName); - if (validator == null) { - logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" - + typeName + "'", null); - throw new UnableToCompleteException(); - } - - JClassType gwtSpecificInterface = getGwtSpecificValidator(logger, validator); - JClassType beanType = getBeanType(logger, validator, gwtSpecificInterface); - - BeanHelper beanHelper = BeanHelper.getBeanHelper(beanType); - - if (beanHelper == null) { - logger.log(TreeLogger.ERROR, "Unable to find BeanHelper for " + beanType - + " " + GwtSpecificValidator.class.getSimpleName() - + " should only be referenced from a class created by " - + ValidatorGenerator.class.getCanonicalName(), null); - throw new UnableToCompleteException(); - } - - AbstractCreator creator = new GwtSpecificValidatorCreator(validatorType, - beanType, beanHelper, logger, context); - return creator.create(); - } - - private JClassType getBeanType(TreeLogger logger, JClassType validator, - JClassType gwtSpecificInterface) throws UnableToCompleteException { - if (gwtSpecificInterface instanceof JParameterizedType) { - JParameterizedType paramType = (JParameterizedType) gwtSpecificInterface; - return paramType.getTypeArgs()[0]; - } - logger.log(TreeLogger.ERROR, validator.getQualifiedSourceName() - + " must implement " + GwtSpecificValidator.class.getCanonicalName() - + " with a one generic parameter.", null); - throw new UnableToCompleteException(); - } - - private JClassType getGwtSpecificValidator(TreeLogger logger, - JClassType validator) throws UnableToCompleteException { - for (JClassType interfaceType : validator.getImplementedInterfaces()) { - if (interfaceType.getQualifiedSourceName().endsWith( - GwtSpecificValidator.class.getCanonicalName())) { - return interfaceType; - } - } - logger.log(TreeLogger.ERROR, validator.getQualifiedSourceName() - + " must implement " + GwtSpecificValidator.class.getCanonicalName(), - null); - throw new UnableToCompleteException(); - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java b/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java deleted file mode 100644 index 7d4772f..0000000 --- a/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java +++ /dev/null
@@ -1,295 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; -import com.google.gwt.validation.client.impl.GwtBeanDescriptor; -import com.google.gwt.validation.client.impl.GwtSpecificValidator; -import com.google.gwt.validation.client.impl.GwtValidationContext; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.metadata.BeanDescriptor; - -/** - * Class that creates the validator for the given input class. - */ -public class ValidatorCreator extends AbstractCreator { - - private final Map<JClassType, BeanHelper> beansToValidate = new HashMap<JClassType, BeanHelper>(); - private final GwtValidation gwtValidation; - - - public ValidatorCreator(JClassType validatorType, // - GwtValidation gwtValidation, // - TreeLogger logger, // - GeneratorContext context) { - super(context, logger, validatorType); - this.gwtValidation = gwtValidation; - - for (Class<?> clazz : gwtValidation.value()) { - BeanHelper helper = createBeanHelper(clazz); - beansToValidate.put(helper.getJClass(), helper); - } - } - - @Override - protected void compose(ClassSourceFileComposerFactory composerFactory) { - addImports(composerFactory, - GWT.class, - GwtBeanDescriptor.class, - GwtSpecificValidator.class, - GwtValidationContext.class, - Set.class, - ConstraintViolation.class, - BeanDescriptor.class); - composerFactory.setSuperclass(AbstractGwtValidator.class.getCanonicalName()); - composerFactory.addImplementedInterface(this.validatorType.getQualifiedSourceName()); - } - - @Override - protected void writeClassBody(SourceWriter sourceWriter) { - writeTypeSupport(sourceWriter); - sourceWriter.println(); - writeConstructor(sourceWriter); - sourceWriter.println(); - writeValidate(sourceWriter); - sourceWriter.println(); - writeValidateProperty(sourceWriter); - sourceWriter.println(); - writeValidateValue(sourceWriter); - sourceWriter.println(); - writeGetConstraintsForClass(sourceWriter); - } - - private String getSimpleName() { - return validatorType.getSimpleSourceName() + "Impl"; - } - - private void writeConstructor(SourceWriter sw) { - // public MyValidator() { - sw.println("public " + getSimpleName() + "() {"); - sw.indent(); - - // super( <<groups>>); - sw.print("super("); - boolean first = true; - for (Class<?> group : gwtValidation.groups()) { - if (!first) { - sw.print(", "); - } else { - first = false; - } - sw.print(group.getCanonicalName() + ".class"); - } - sw.println(");"); - - sw.outdent(); - sw.println("}"); - } - - - private void writeContext(SourceWriter sw, BeanHelper bean, String objectName) { - // GwtValidationContext<T> context = - // new GwtValidationContext<T>(object,myBeanValidator.getConstraints(), - // getMessageInterpolator()); - sw.print(GwtValidationContext.class.getSimpleName()); - sw.print("<T> context ="); - sw.print(" new " + GwtValidationContext.class.getSimpleName()); - sw.print("<T>(" + objectName + ", "); - sw.print(bean.getValidatorInstanceName()); - sw.print(".getConstraints(), "); - sw.print("getMessageInterpolator()"); - sw.println(");"); - } - - private void writeGetConstraintsForClass(SourceWriter sw) { - // public BeanDescriptor getConstraintsForClass(Class<?> clazz { - sw.println("public BeanDescriptor getConstraintsForClass(Class<?> clazz) {"); - sw.indent(); - - // checkNotNull(clazz, "clazz"); - sw.println("checkNotNull(clazz, \"clazz\");"); - - for (BeanHelper bean : beansToValidate.values()) { - writeGetConstraintsForClass(sw, bean); - } - - writeThrowIllegalArgumnet(sw, "clazz.getName()"); - - // } - sw.outdent(); - sw.println("}"); - } - - private void writeGetConstraintsForClass(SourceWriter sw, - BeanHelper bean) { - // if (clazz.eqals(MyBean.class)) { - sw.println("if (clazz.equals(" + bean.getTypeCanonicalName() + ".class)) {"); - sw.indent(); - - // return myBeanValidator.getConstraints(); - sw.print("return "); - sw.print(bean.getValidatorInstanceName() + ".getConstraints();"); - - // } - sw.outdent(); - sw.println("}"); - } - - private void writeIfInstanceofBeanType(SourceWriter sourceWriter, BeanHelper bean) { - // if (object instanceof MyBean) { - sourceWriter.print("if (object instanceof "); - sourceWriter.print(bean.getTypeCanonicalName()); - sourceWriter.println(") {"); - } - - private void writeThrowIllegalArgumnet(SourceWriter sourceWriter, - String getClassName) { - // throw new IllegalArgumentException("MyValidator can not validate ", - sourceWriter.print("throw new IllegalArgumentException(\""); - sourceWriter.print(this.validatorType.getName() + " can not validate \""); - sourceWriter.indent(); - sourceWriter.indent(); - - // + object.getClass().getName() +". " - sourceWriter.print("+ "); - sourceWriter.print(getClassName); - sourceWriter.println("+ \". \""); - - // + "Valid values are {Foo.clas, Bar.class} - sourceWriter.print("+ \"Valid types are "); - sourceWriter.print(beansToValidate.values().toString()); - sourceWriter.println("\");"); - sourceWriter.outdent(); - sourceWriter.outdent(); - } - - private void writeTypeSupport(SourceWriter sw) { - for (BeanHelper bean : beansToValidate.values()) { - writeValidatorInstance(sw, bean); - } - } - - private void writeValidate(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... - // groups) { - sw.println("public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups) {"); - sw.indent(); - - sw.println("checkNotNull(object, \"object\");"); - sw.println("checkNotNull(groups, \"groups\");"); - sw.println("checkGroups(groups);"); - - for (BeanHelper bean : beansToValidate.values()) { - writeValidate(sw, bean); - } - - writeThrowIllegalArgumnet(sw, "object.getClass().getName()"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidate(SourceWriter sw, BeanHelper bean) { - writeIfInstanceofBeanType(sw, bean); - sw.indent(); - - writeContext(sw, bean, "object"); - - // return personValidator.validate(context, (<<MyBean>>) object, groups); - sw.print("return "); - sw.print(bean.getValidatorInstanceName() + ".validate("); - sw.print("context, "); - sw.print("(" + bean.getTypeCanonicalName() + ") object, "); - sw.println("groups);"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidateProperty(SourceWriter sw) { - sw.println("public <T> Set<ConstraintViolation<T>> validateProperty(T object,String propertyName, Class<?>... groups) {"); - sw.indent(); - - sw.println("checkNotNull(object, \"object\");"); - sw.println("checkNotNull(propertyName, \"propertyName\");"); - sw.println("checkNotNull(groups, \"groups\");"); - sw.println("checkGroups(groups);"); - - for (BeanHelper bean : beansToValidate.values()) { - writeValidateProperty(sw, bean); - } - - writeThrowIllegalArgumnet(sw, "object.getClass().getName()"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidateProperty(SourceWriter sw, BeanHelper bean) { - writeIfInstanceofBeanType(sw, bean); - sw.indent(); - writeContext(sw, bean, "object"); - sw.print("return " + bean.getValidatorInstanceName() - + ".validateProperty(context, (" + bean.getTypeCanonicalName() - + ") object, propertyName, "); - sw.println("groups);"); - sw.outdent(); // if - sw.println("}"); - } - - private void writeValidateValue(SourceWriter sw) { - sw.println("public <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups) {"); - sw.indent(); - - sw.println("checkNotNull(beanType, \"beanType\");"); - sw.println("checkNotNull(propertyName, \"propertyName\");"); - sw.println("checkNotNull(groups, \"groups\");"); - sw.println("checkGroups(groups);"); - - for (BeanHelper bean : beansToValidate.values()) { - writeValidateValue(sw, bean); - } - - writeThrowIllegalArgumnet(sw, "beanType.getName()"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidateValue(SourceWriter sw, BeanHelper bean) { - sw.println("if (beanType.equals(" + bean.getTypeCanonicalName() - + ".class)) {"); - sw.indent(); - writeContext(sw, bean, "null"); - sw.println("return " + bean.getValidatorInstanceName() - + ".validateValue(context, (Class<" + bean.getTypeCanonicalName() - + ">)beanType, propertyName, value, groups);"); - sw.outdent(); // if - sw.println("}"); - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java b/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java deleted file mode 100644 index c1dc0f1..0000000 --- a/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java +++ /dev/null
@@ -1,72 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.validation.client.GwtValidation; - -/** - * Generates the generic {@link javax.validation.Validator}. The generic - * validator only handles the classes listed in the - * {@link com.google.gwt.validation.client.GwtValidation} annotation. See - * {@link com.google.gwt.validation.client.GwtValidation} for usage. - */ -public class ValidatorGenerator extends Generator { - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - JClassType validatorType = context.getTypeOracle().findType(typeName); - TypeOracle typeOracle = context.getTypeOracle(); - assert (typeOracle != null); - - JClassType validator = typeOracle.findType(typeName); - if (validator == null) { - logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" - + typeName + "'", null); - throw new UnableToCompleteException(); - } - - GwtValidation gwtValidation = validatorType.findAnnotationInTypeHierarchy(GwtValidation.class); - - if (gwtValidation == null) { - logger.log(TreeLogger.ERROR, typeName + " must be anntotated with " - + GwtValidation.class.getCanonicalName(), null); - throw new UnableToCompleteException(); - } - - if (gwtValidation.value().length == 0) { - logger.log(TreeLogger.ERROR, - "The @" + GwtValidation.class.getSimpleName() + " of " + typeName - + "must specify at least one bean type to validate.", null); - throw new UnableToCompleteException(); - } - - TreeLogger validatorLogger = logger.branch(TreeLogger.DEBUG, - "Generating Validator for '" + validator.getQualifiedSourceName() - + "'", null); - AbstractCreator creator = new ValidatorCreator(validatorType, - gwtValidation, - validatorLogger, - context); - return creator.create(); - } -}
diff --git a/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/GwtConfiguration.java b/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/GwtConfiguration.java deleted file mode 100644 index c70d11b..0000000 --- a/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/GwtConfiguration.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.validation.client.spi.GwtValidationProvider; - -import javax.validation.spi.BootstrapState; - -/** - * Extends {@link BaseGwtConfiguration} with just the parts that are not GWT - * compatible. - */ -public class GwtConfiguration extends BaseGwtConfiguration { - - public GwtConfiguration(GwtValidationProvider gwtValidationProvider, - BootstrapState state) { - super(gwtValidationProvider, state); - } - - public BaseGwtConfiguration addMapping(String stream) { - throw new UnsupportedOperationException("GWT does not support InputStreams"); - } -}
diff --git a/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/GwtMessageInterpolator.java b/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/GwtMessageInterpolator.java deleted file mode 100644 index f180b17..0000000 --- a/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/GwtMessageInterpolator.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.i18n.shared.GwtLocale; - -import javax.validation.MessageInterpolator.Context; - -/** - * Simple GWT {@link javax.validation.MessageInterpolator}. - */ -public class GwtMessageInterpolator extends BaseMessageInterpolator { - // This class only has the parts the need to overridden for GWT - - public String interpolate(String messageTemplate, Context context, - GwtLocale locale) { - return gwtInterpolate(messageTemplate,context,locale); - } -}
diff --git a/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/spi/GwtConfigurationState.java b/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/spi/GwtConfigurationState.java deleted file mode 100644 index 6cabb78..0000000 --- a/user/src/com/google/gwt/validation/super/com/google/gwt/validation/client/spi/GwtConfigurationState.java +++ /dev/null
@@ -1,30 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.spi; - -import java.util.Set; - -/** - * Only the GWT incompatible parts. - */ -public class GwtConfigurationState extends BaseConfigurationState { - - public Set<String> getMappingStreams() { - throw new UnsupportedOperationException( - "GWT Validation does not support getMappingStreams"); - } - -}
diff --git a/user/src/javax/validation/ConstraintViolationException_CustomFieldSerializer.java b/user/src/javax/validation/ConstraintViolationException_CustomFieldSerializer.java deleted file mode 100644 index c73aef0..0000000 --- a/user/src/javax/validation/ConstraintViolationException_CustomFieldSerializer.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package javax.validation; - -import com.google.gwt.user.client.rpc.SerializationException; -import com.google.gwt.user.client.rpc.SerializationStreamReader; -import com.google.gwt.user.client.rpc.SerializationStreamWriter; - -import java.util.Set; - -/** - * Custom Serializer for {@link ConstraintViolationException}. - */ -public class ConstraintViolationException_CustomFieldSerializer { - - public static void deserialize(SerializationStreamReader streamReader, - ConstraintViolationException instance) throws SerializationException { - // no fields - } - - public static ConstraintViolationException instantiate( - SerializationStreamReader streamReader) - throws SerializationException { - String message = streamReader.readString(); - @SuppressWarnings("unchecked") - Set<ConstraintViolation<?>> set = (Set<ConstraintViolation<?>>) streamReader.readObject(); - return new ConstraintViolationException(message, set); - } - - public static void serialize(SerializationStreamWriter streamWriter, - ConstraintViolationException instance) throws SerializationException { - streamWriter.writeString(instance.getMessage()); - streamWriter.writeObject(instance.getConstraintViolations()); - } -}
diff --git a/user/src/javax/validation/Validation.gwt.xml b/user/src/javax/validation/Validation.gwt.xml deleted file mode 100644 index 9eec257..0000000 --- a/user/src/javax/validation/Validation.gwt.xml +++ /dev/null
@@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<!-- Includes the javax.validation classes from the source jar --> -<module> - <source path=""> - <exclude name="super/"/> - </source> - <super-source path="super"/> -</module> \ No newline at end of file
diff --git a/user/src/javax/validation/super/javax/validation/Configuration.java b/user/src/javax/validation/super/javax/validation/Configuration.java deleted file mode 100644 index 7a792a4..0000000 --- a/user/src/javax/validation/super/javax/validation/Configuration.java +++ /dev/null
@@ -1,203 +0,0 @@ -// $Id: Configuration.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -// Changed by Google -package javax.validation; - - -/** - * Receives configuration information, selects the appropriate - * Bean Validation provider and builds the appropriate <code>ValidatorFactory</code>. - * <p/> - * Usage: - * <pre> - * {@code - * Configuration<?> configuration = //provided by one of the Validation bootstrap methods - * ValidatorFactory = configuration - * .messageInterpolator( new CustomMessageInterpolator() ) - * .buildValidatorFactory();} - * </pre> - * <p/> - * By default, the configuration information is retrieved from - * <i>META-INF/validation.xml</i>. - * It is possible to override the configuration retrieved from the XML file - * by using one or more of the <code>Configuration</code> methods. - * <p/> - * The {@link ValidationProviderResolver} is specified at configuration time - * (see {@link javax.validation.spi.ValidationProvider}). - * If none is explicitly requested, the default <code>ValidationProviderResolver</code> is used. - * <p/> - * The provider is selected in the following way: - * <ul> - * <li>if a specific provider is requested programmatically using - * <code>Validation.byProvider(Class)</code>, find the first provider implementing - * the provider class requested and use it</li> - * <li>if a specific provider is requested in <i>META-INF/validation.xml</i>, - * find the first provider implementing the provider class requested and use it</li> - * <li>otherwise, use the first provider returned by the <code>ValidationProviderResolver<code></li> - * </ul> - * <p/> - * Implementations are not meant to be thread-safe. - * - * @author Emmanuel Bernard - */ -public interface Configuration<T extends Configuration<T>> { - - /** - * Ignore data from the <i>META-INF/validation.xml</i> file if this - * method is called. - * This method is typically useful for containers that parse - * <i>META-INF/validation.xml</i> themselves and pass the information - * via the <code>Configuration</code> methods. - * - * @return <code>this</code> following the chaining method pattern. - */ - T ignoreXmlConfiguration(); - - /** - * Defines the message interpolator used. Has priority over the configuration - * based message interpolator. - * If <code>null</code> is passed, the default message interpolator is used - * (defined in XML or the specification default). - * - * @param interpolator message interpolator implementation. - * - * @return <code>this</code> following the chaining method pattern. - */ - T messageInterpolator(MessageInterpolator interpolator); - - /** - * Defines the traversable resolver used. Has priority over the configuration - * based traversable resolver. - * If <code>null</code> is passed, the default traversable resolver is used - * (defined in XML or the specification default). - * - * @param resolver traversable resolver implementation. - * - * @return <code>this</code> following the chaining method pattern. - */ - T traversableResolver(TraversableResolver resolver); - - /** - * Defines the constraint validator factory. Has priority over the configuration - * based constraint factory. - * If null is passed, the default constraint validator factory is used - * (defined in XML or the specification default). - * - * @param constraintValidatorFactory constraint factory inmplementation. - * - * @return <code>this</code> following the chaining method pattern. - */ - T constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory); - - /** - * Add a stream describing constraint mapping in the Bean Validation - * XML format. - * <p/> - * The stream should be closed by the client API after the - * <code>ValidatorFactory</code> has been built. The Bean Validation provider - * must not close the stream. - * - * @param stream XML mapping stream. - * - * @return <code>this</code> following the chaining method pattern. - * @throws IllegalArgumentException if <code>stream</code> is null - */ - T addMapping(String stream); - - /** - * Add a provider specific property. This property is equivalent to - * XML configuration properties. - * If the underlying provider does not know how to handle the property, - * it must silently ignore it. - * <p/> - * Note: Using this non type-safe method is generally not recommended. - * <p/> - * It is more appropriate to use, if available, the type-safe equivalent provided - * by a specific provider via its <code>Configuration<code> subclass. - * <code>ValidatorFactory factory = Validation.byProvider(ACMEPrivoder.class) - * .configure() - * .providerSpecificProperty(ACMEState.FAST) - * .buildValidatorFactory(); - * </code> - * This method is typically used by containers parsing <i>META-INF/validation.xml</i> - * themselves and injecting the state to the Configuration object. - * <p/> - * If a property with a given name is defined both via this method and in the - * XML configuration, the value set programmatically has priority. - * - * If null is passed as a value, the value defined in XML is used. If no value - * is defined in XML, the property is considered unset. - * - * @param name property name. - * @param value property value. - * @return <code>this</code> following the chaining method pattern. - * - * @throws IllegalArgumentException if <code>name</code> is null - */ - T addProperty(String name, String value); - - /** - * Return an implementation of the <code>MessageInterpolator</code> interface - * following the default <code>MessageInterpolator</code> defined in the - * specification: - * <ul> - * <li>use the ValidationMessages resource bundle to load keys</li> - * <li>use Locale.getDefault()</li> - * </ul> - * - * @return default MessageInterpolator implementation compliant with the specification - */ - MessageInterpolator getDefaultMessageInterpolator(); - - /** - * Return an implementation of the <code>TraversableResolver</code> interface - * following the default <code>TraversableResolver</code> defined in the - * specification: - * <ul> - * <li>if Java Persistence is available in the runtime environment, - * a property is considered reachable if Java Persistence considers - * the property as loaded</li> - * <li>if Java Persistence is not available in the runtime environment, - * all properties are considered reachable</li> - * <li>all properties are considered cascadable.</li> - * </ul> - * - * @return default TraversableResolver implementation compliant with the specification - */ - TraversableResolver getDefaultTraversableResolver(); - - /** - * Return an implementation of the <code>ConstraintValidatorFactory</code> interface - * following the default <code>ConstraintValidatorFactory</code> defined in the - * specification: - * <ul> - * <li>uses the public no-arg constructor of the <code>ConstraintValidator</code></li> - * </ul> - * - * @return default ConstraintValidatorFactory implementation compliant with the specification - */ - ConstraintValidatorFactory getDefaultConstraintValidatorFactory(); - - /** - * Build a <code>ValidatorFactory</code> implementation. - * - * @return ValidatorFactory - * @throws ValidationException if the ValidatorFactory cannot be built - */ - ValidatorFactory buildValidatorFactory(); -}
diff --git a/user/src/javax/validation/super/javax/validation/MessageInterpolator.java b/user/src/javax/validation/super/javax/validation/MessageInterpolator.java deleted file mode 100644 index 7507ad5..0000000 --- a/user/src/javax/validation/super/javax/validation/MessageInterpolator.java +++ /dev/null
@@ -1,73 +0,0 @@ -// $Id: MessageInterpolator.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//Changed by Google -package javax.validation; - -import javax.validation.metadata.ConstraintDescriptor; - -import com.google.gwt.i18n.shared.GwtLocale; - -/** - * Interpolate a given constraint violation message. - * Implementations should be as tolerant as possible on syntax errors. - *<p> - * Modified to use {@link GwtLocale} instead of {@link java.util.Locale}. - * - * @author Emmanuel Bernard - * @author Hardy Ferentschik - */ -public interface MessageInterpolator { - /** - * Interpolate the message template based on the contraint validation context. - * The locale is defaulted according to the <code>MessageInterpolator</code> - * implementation. See the implementation documentation for more detail. - * - * @param messageTemplate The message to interpolate. - * @param context contextual information related to the interpolation - * - * @return Interpolated error message. - */ - String interpolate(String messageTemplate, Context context); - - /** - * Interpolate the message template based on the contraint validation context. - * The <code>Locale</code> used is provided as a parameter. - * - * @param messageTemplate The message to interpolate. - * @param context contextual information related to the interpolation - * @param locale the locale targeted for the message - * - * @return Interpolated error message. - */ - String interpolate(String messageTemplate, Context context, GwtLocale locale); - - /** - * Information related to the interpolation context - */ - interface Context { - /** - * @return ConstraintDescriptor corresponding to the constraint being validated - */ - ConstraintDescriptor<?> getConstraintDescriptor(); - - /** - * @return value being validated - */ - Object getValidatedValue(); - } -}
diff --git a/user/src/javax/validation/super/javax/validation/Validation.java b/user/src/javax/validation/super/javax/validation/Validation.java deleted file mode 100644 index 45a4540..0000000 --- a/user/src/javax/validation/super/javax/validation/Validation.java +++ /dev/null
@@ -1,22 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package javax.validation; - -/** - * Pass through to GWT version {@link com.google.gwt.validation.client.Validation}. - */ -public class Validation extends com.google.gwt.validation.client.Validation { -}
diff --git a/user/src/javax/validation/super/javax/validation/constraints/Pattern.java b/user/src/javax/validation/super/javax/validation/constraints/Pattern.java deleted file mode 100644 index 017edfe..0000000 --- a/user/src/javax/validation/super/javax/validation/constraints/Pattern.java +++ /dev/null
@@ -1,159 +0,0 @@ -// $Id: Pattern.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* - * JBoss, Home of Professional Open Source Copyright 2009, Red Hat, Inc. and/or - * its affiliates, and individual contributors by the @authors tag. See the - * copyright.txt in the distribution for a full listing of individual - * contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by - * applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS - * OF ANY KIND, either express or implied. See the License for the specific - * language governing permissions and limitations under the License. - */ -// Modified by Google. -package javax.validation.constraints; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.Payload; - -/** - * The annotated String must match the following regular expression. The regular - * expression follows the Java regular expression conventions see - * {@link java.util.regex.Pattern}. - * - * <p> - * Accepts String. <code>null</code> elements are considered valid. - * - * <p> - * GWT Modification: Reference to java.util.regex.Pattern are inlined - * - * @author Emmanuel Bernard - */ -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) -@Retention(RUNTIME) -@Documented -@Constraint(validatedBy = {}) -public @interface Pattern { - /** - * @return The regular expression to match. - */ - String regexp(); - - /** - * @return Array of <code>Flag</code>s considered when resolving the regular - * expression. - */ - Flag[] flags() default {}; - - /** - * @return The error message template. - */ - String message() default "{javax.validation.constraints.Pattern.message}"; - - /** - * @return The groups the constraint belongs to. - */ - Class<?>[] groups() default {}; - - /** - * @return The payload associated to the constraint - */ - Class<? extends Payload>[] payload() default {}; - - /** - * Possible Regexp flags - */ - public static enum Flag { - - /** - * Enables Unix lines mode - * - * @see java.util.regex.Pattern#UNIX_LINES - */ - UNIX_LINES(1), - - /** - * Enables case-insensitive matching - * - * @see java.util.regex.Pattern#CASE_INSENSITIVE - */ - CASE_INSENSITIVE(2), - - /** - * Permits whitespace and comments in pattern - * - * @see java.util.regex.Pattern#COMMENTS - */ - COMMENTS(4), - - /** - * Enables multiline mode - * - * @see java.util.regex.Pattern#MULTILINE - */ - MULTILINE(8), - - /** - * Enables dotall mode - * - * @see java.util.regex.Pattern#DOTALL - */ - DOTALL(32), - - /** - * Enables Unicode-aware case folding - * - * @see java.util.regex.Pattern#UNICODE_CASE - */ - UNICODE_CASE(64), - - /** - * Enables canonical equivalence - * - * @see java.util.regex.Pattern#CANON_EQ - */ - CANON_EQ(128); - - // JDK flag value - private final int value; - - private Flag(int value) { - this.value = value; - } - - /** - * @return flag value as defined in {@link java.util.regex.Pattern} - */ - public int getValue() { - return value; - } - } - - /** - * Defines several <code>@Pattern</code> annotations on the same element - * - * @see Pattern - * - * @author Emmanuel Bernard - */ - @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) - @Retention(RUNTIME) - @Documented - @interface List { - Pattern[] value(); - } -}
diff --git a/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java b/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java deleted file mode 100644 index 3037ddb..0000000 --- a/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java +++ /dev/null
@@ -1,123 +0,0 @@ -// $Id: ConfigurationState.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package javax.validation.spi; - -import java.util.Map; -import java.util.Set; -import javax.validation.ConstraintValidatorFactory; -import javax.validation.MessageInterpolator; -import javax.validation.TraversableResolver; - -/** - * Contract between a <code>Configuration</code> and a - * </code>ValidatorProvider</code> to create a <code>ValidatorFactory</code>. - * The configuration artifacts defined in the XML configuration and provided to the - * <code>Configuration</code> are merged and passed along via - * <code>ConfigurationState</code>. - * - * @author Emmanuel Bernard - * @author Hardy Ferentschik - */ -public interface ConfigurationState { - - /** - * Returns true if Configuration.ignoreXMLConfiguration() has been called - * In this case, the ValidatorFactory must ignore META-INF/validation.xml - * - * @return {@code true} if META-INF/validation.xml should be ignored - */ - boolean isIgnoreXmlConfiguration(); - - /** - * Returns the message interpolator of this configuration. - * Message interpolator is defined in the following decreasing priority: - * <ul> - * <li>set via the <code>Configuration</code> programmatic API</li> - * <li>defined in META-INF/validation.xml provided that ignoreXmlConfiguration - * is false. In this case the instance is created via its no-arg constructor.</li> - * <li>{@code null} if undefined.</li> - * </ul> - * - * @return message provider instance or null if not defined - */ - MessageInterpolator getMessageInterpolator(); - - /** - * Returns a set of configuration streams. - * The streams are defined by: - * <ul> - * <li>mapping XML streams passed programmatically in <code>Configuration</code></li> - * <li>mapping XML stream located in the resources defined in</li> - * META-INF/validation.xml (constraint-mapping element) - * </ul> - * Streams represented in the XML configuration and opened by the - * <code>Configuration</code> implementation must be closed by the - * <code>Configuration</code> implementation after the <code>ValidatorFactory</code> - * creation (or if an exception occurs). - * - * <p/> - * GWT change: Rerturn a set of Strings intest of a InputStream. - * - * @return set of Strings (was input stream) - */ - Set<String> getMappingStreams(); - - /** - * Returns the constraint validator factory of this configuration. - * The {@code ConstraintValidatorFactory} implementation is defined in the following - * decreasing priority: - * <ul> - * <li>set via the <code>Configuration</code> programmatic API</li> - * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration - * is false. In this case the instance is created via its no-arg constructor.</li> - * <li>{@code null} if undefined.</li> - * </ul> - * - * @return factory instance or {@code null} if not defined - */ - ConstraintValidatorFactory getConstraintValidatorFactory(); - - /** - * Returns the traversable resolver for this configuration. - * <code>TraversableResolver</code> is defined in the following decreasing priority: - * <ul> - * <li>set via the <code>Configuration</code> programmatic API</li> - * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration - * is false. In this case the instance is created via its no-arg constructor.</li> - * <li>{@code null} if undefined.</li> - * </ul> - * - * @return traversable provider instance or {@code null} if not defined - */ - TraversableResolver getTraversableResolver(); - - /** - * Returns a map of non type-safe custom properties. - * Properties defined via: - * <ul> - * <li>Configuration.addProperty(String, String)</li> - * <li>META-INF/validation.xml provided that ignoredXmlConfiguration</li> - * is false. - * </ul> - * If a property is defined both programmatically and in XML, - * the value defined programmatically has priority - * - * @return Map whose key is the property key and the value the property value - */ - Map<String, String> getProperties(); -}
diff --git a/user/src/org/hibernate/validator/HibernateValidationMessageResolver.java b/user/src/org/hibernate/validator/HibernateValidationMessageResolver.java deleted file mode 100644 index 824c017..0000000 --- a/user/src/org/hibernate/validator/HibernateValidationMessageResolver.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.client.ConstantsWithLookup; -import com.google.gwt.validation.client.AbstractValidationMessageResolver; -import com.google.gwt.validation.client.ProviderValidationMessageResolver; - -/** - * Hibernate default {@link ProviderValidationMessageResolver}. - */ -public class HibernateValidationMessageResolver extends - AbstractValidationMessageResolver implements - ProviderValidationMessageResolver { - - private final ValidationMessages messages = GWT.create(ValidationMessages.class); - - public HibernateValidationMessageResolver() { - super((ConstantsWithLookup) GWT.create(ValidationMessages.class)); - } -}
diff --git a/user/src/org/hibernate/validator/HibernateValidator.gwt.xml b/user/src/org/hibernate/validator/HibernateValidator.gwt.xml deleted file mode 100644 index 8100d63..0000000 --- a/user/src/org/hibernate/validator/HibernateValidator.gwt.xml +++ /dev/null
@@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module> -<!-- -Import this module to use Hibernate Validator during the compilation of validation classes for -gwt clients. - --> - <inherits name='com.google.gwt.validation.Validation' /> - <source path="constraints"> - <exclude name="impl/scriptassert/" /> - <exclude name="super/" /> - </source> - <source path="engine"> - <include name="ConstraintViolationImpl.java"/> - <include name="NodeImpl.java"/> - <include name="PathImpl.java"/> - </source> - <source path=""> - <include name="ValidationMessages.java"/> - <include name="HibernateValidationMessageResolver.java"/> - </source> - <super-source path="super" /> - <replace-with - class="org.hibernate.validator.HibernateValidationMessageResolver"> - <when-type-is class="com.google.gwt.validation.client.ProviderValidationMessageResolver" /> - </replace-with> -</module>
diff --git a/user/src/org/hibernate/validator/README.txt b/user/src/org/hibernate/validator/README.txt deleted file mode 100644 index 008bc33..0000000 --- a/user/src/org/hibernate/validator/README.txt +++ /dev/null
@@ -1,13 +0,0 @@ -The Hibernate Validator module is used to: - -1) generate client side validators. -2) super source hibernate specific constraints -3) super source hibernate classes needed to return ConstraintViolations from the server to the client. - - -Maintenance Notes. -Test using samples/validation and samples/validationtck - - -NOTE -(nchalko) all of should be pushed back to hibernate. \ No newline at end of file
diff --git a/user/src/org/hibernate/validator/ValidationMessages.java b/user/src/org/hibernate/validator/ValidationMessages.java deleted file mode 100644 index a1fbaec..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages.java +++ /dev/null
@@ -1,197 +0,0 @@ -package org.hibernate.validator; - -/** - * Interface to represent the constants contained in resource bundle: - * 'validation/ValidationMessages.properties'. - */ -public interface ValidationMessages extends com.google.gwt.i18n.client.ConstantsWithLookup { - - /** - * Translated "must be false". - * - * @return translated "must be false" - */ - @DefaultStringValue("must be false") - @Key("javax.validation.constraints.AssertFalse.message") - String javax_validation_constraints_AssertFalse_message(); - - /** - * Translated "must be true". - * - * @return translated "must be true" - */ - @DefaultStringValue("must be true") - @Key("javax.validation.constraints.AssertTrue.message") - String javax_validation_constraints_AssertTrue_message(); - - /** - * Translated "must be less than or equal to {value}". - * - * @return translated "must be less than or equal to {value}" - */ - @DefaultStringValue("must be less than or equal to {value}") - @Key("javax.validation.constraints.DecimalMax.message") - String javax_validation_constraints_DecimalMax_message(); - - /** - * Translated "must be greater than or equal to {value}". - * - * @return translated "must be greater than or equal to {value}" - */ - @DefaultStringValue("must be greater than or equal to {value}") - @Key("javax.validation.constraints.DecimalMin.message") - String javax_validation_constraints_DecimalMin_message(); - - /** - * Translated "numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)". - * - * @return translated "numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)" - */ - @DefaultStringValue("numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)") - @Key("javax.validation.constraints.Digits.message") - String javax_validation_constraints_Digits_message(); - - /** - * Translated "must be in the future". - * - * @return translated "must be in the future" - */ - @DefaultStringValue("must be in the future") - @Key("javax.validation.constraints.Future.message") - String javax_validation_constraints_Future_message(); - - /** - * Translated "must be less than or equal to {value}". - * - * @return translated "must be less than or equal to {value}" - */ - @DefaultStringValue("must be less than or equal to {value}") - @Key("javax.validation.constraints.Max.message") - String javax_validation_constraints_Max_message(); - - /** - * Translated "must be greater than or equal to {value}". - * - * @return translated "must be greater than or equal to {value}" - */ - @DefaultStringValue("must be greater than or equal to {value}") - @Key("javax.validation.constraints.Min.message") - String javax_validation_constraints_Min_message(); - - /** - * Translated "may not be null". - * - * @return translated "may not be null" - */ - @DefaultStringValue("may not be null") - @Key("javax.validation.constraints.NotNull.message") - String javax_validation_constraints_NotNull_message(); - - /** - * Translated "must be null". - * - * @return translated "must be null" - */ - @DefaultStringValue("must be null") - @Key("javax.validation.constraints.Null.message") - String javax_validation_constraints_Null_message(); - - /** - * Translated "must be in the past". - * - * @return translated "must be in the past" - */ - @DefaultStringValue("must be in the past") - @Key("javax.validation.constraints.Past.message") - String javax_validation_constraints_Past_message(); - - /** - * Translated "must match \"{regexp}\"". - * - * @return translated "must match \"{regexp}\"" - */ - @DefaultStringValue("must match \"{regexp}\"") - @Key("javax.validation.constraints.Pattern.message") - String javax_validation_constraints_Pattern_message(); - - /** - * Translated "size must be between {min} and {max}". - * - * @return translated "size must be between {min} and {max}" - */ - @DefaultStringValue("size must be between {min} and {max}") - @Key("javax.validation.constraints.Size.message") - String javax_validation_constraints_Size_message(); - - /** - * Translated "invalid credit card number". - * - * @return translated "invalid credit card number" - */ - @DefaultStringValue("invalid credit card number") - @Key("org.hibernate.validator.constraints.CreditCardNumber.message") - String org_hibernate_validator_constraints_CreditCardNumber_message(); - - /** - * Translated "not a well-formed email address". - * - * @return translated "not a well-formed email address" - */ - @DefaultStringValue("not a well-formed email address") - @Key("org.hibernate.validator.constraints.Email.message") - String org_hibernate_validator_constraints_Email_message(); - - /** - * Translated "length must be between {min} and {max}". - * - * @return translated "length must be between {min} and {max}" - */ - @DefaultStringValue("length must be between {min} and {max}") - @Key("org.hibernate.validator.constraints.Length.message") - String org_hibernate_validator_constraints_Length_message(); - - /** - * Translated "may not be empty". - * - * @return translated "may not be empty" - */ - @DefaultStringValue("may not be empty") - @Key("org.hibernate.validator.constraints.NotBlank.message") - String org_hibernate_validator_constraints_NotBlank_message(); - - /** - * Translated "may not be empty". - * - * @return translated "may not be empty" - */ - @DefaultStringValue("may not be empty") - @Key("org.hibernate.validator.constraints.NotEmpty.message") - String org_hibernate_validator_constraints_NotEmpty_message(); - - /** - * Translated "must be between {min} and {max}". - * - * @return translated "must be between {min} and {max}" - */ - @DefaultStringValue("must be between {min} and {max}") - @Key("org.hibernate.validator.constraints.Range.message") - String org_hibernate_validator_constraints_Range_message(); - - /** - * Translated "script expression \"{script}\" didn't evaluate to true". - * - * @return translated "script expression \"{script}\" didn't evaluate to true" - */ - @DefaultStringValue("script expression \"{script}\" didn't evaluate to true") - @Key("org.hibernate.validator.constraints.ScriptAssert.message") - String org_hibernate_validator_constraints_ScriptAssert_message(); - - /** - * Translated "must be a valid URL". - * - * @return translated "must be a valid URL" - */ - @DefaultStringValue("must be a valid URL") - @Key("org.hibernate.validator.constraints.URL.message") - String org_hibernate_validator_constraints_URL_message(); -}
diff --git a/user/src/org/hibernate/validator/ValidationMessages.properties b/user/src/org/hibernate/validator/ValidationMessages.properties deleted file mode 100644 index 0e92c8f..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages.properties +++ /dev/null
@@ -1,23 +0,0 @@ - -# $Id: ValidationMessages.properties 19251 2010-04-20 15:28:18Z hardy.ferentschik $ -javax.validation.constraints.AssertFalse.message=must be false -javax.validation.constraints.AssertTrue.message=must be true -javax.validation.constraints.DecimalMax.message=must be less than or equal to {value} -javax.validation.constraints.DecimalMin.message=must be greater than or equal to {value} -javax.validation.constraints.Digits.message=numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected) -javax.validation.constraints.Future.message=must be in the future -javax.validation.constraints.Max.message=must be less than or equal to {value} -javax.validation.constraints.Min.message=must be greater than or equal to {value} -javax.validation.constraints.NotNull.message=may not be null -javax.validation.constraints.Null.message=must be null -javax.validation.constraints.Past.message=must be in the past -javax.validation.constraints.Pattern.message=must match "{regexp}" -javax.validation.constraints.Size.message=size must be between {min} and {max} -org.hibernate.validator.constraints.Email.message=not a well-formed email address -org.hibernate.validator.constraints.Length.message=length must be between {min} and {max} -org.hibernate.validator.constraints.NotBlank.message=may not be empty -org.hibernate.validator.constraints.NotEmpty.message=may not be empty -org.hibernate.validator.constraints.Range.message=must be between {min} and {max} -org.hibernate.validator.constraints.URL.message=must be a valid URL -org.hibernate.validator.constraints.CreditCardNumber.message=invalid credit card number -org.hibernate.validator.constraints.ScriptAssert.message=script expression "{script}" didn't evaluate to true
diff --git a/user/src/org/hibernate/validator/ValidationMessages_de.properties b/user/src/org/hibernate/validator/ValidationMessages_de.properties deleted file mode 100644 index 194b15d..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages_de.properties +++ /dev/null
@@ -1,22 +0,0 @@ -# $Id: ValidationMessages_de.properties 19251 2010-04-20 15:28:18Z hardy.ferentschik $ -javax.validation.constraints.NotNull.message=kann nicht null sein -javax.validation.constraints.Size.message=muss zwischen {min} und {max} liegen -javax.validation.constraints.Pattern.message=muss auf Ausdruck "{regexp}" passen -javax.validation.constraints.Min.message=muss gr\u00F6ssergleich {value} sein -javax.validation.constraints.Max.message=muss kleinergleich {value} sein -javax.validation.constraints.Null.message=muss null sein -javax.validation.constraints.Past.message=muss in der Vergangenheit liegen -javax.validation.constraints.Future.message=muss in der Zukunft liegen -javax.validation.constraints.AssertTrue.message=muss wahr sein -javax.validation.constraints.AssertFalse.message=muss falsch sein -javax.validation.constraints.Digits.message=numerischer Wert au\u00DFerhalb erlaubten Wertebereichs (<{integer} Ziffern>.<{fraction} Ziffern> erwartet) -javax.validation.constraints.DecimalMin.message=muss gr\u00F6ssergleich {value} sein -javax.validation.constraints.DecimalMax.message=muss kleinergleich {value} sein -org.hibernate.validator.constraints.Email.message=keine g\u00FCltige E-Mail-Adresse -org.hibernate.validator.constraints.Length.message=muss zwischen {min} und {max} liegen -org.hibernate.validator.constraints.NotBlank.message=kann nicht leer sein -org.hibernate.validator.constraints.NotEmpty.message=kann nicht leer sein -org.hibernate.validator.constraints.Range.message=muss zwischen {min} und {max} liegen -org.hibernate.validator.constraints.URL.message=muss eine g\u00FCltige URL sein -org.hibernate.validator.constraints.CreditCardNumber.message=ung\u00FCltige Kreditkartennummer -org.hibernate.validator.constraints.ScriptAssert.message=Skriptausdruck "{script}" muss true zur\u00FCckliefern
diff --git a/user/src/org/hibernate/validator/ValidationMessages_en.properties b/user/src/org/hibernate/validator/ValidationMessages_en.properties deleted file mode 100644 index cea61f0..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages_en.properties +++ /dev/null
@@ -1,9 +0,0 @@ -# $Id: ValidationMessages_en.properties 19090 2010-03-23 15:22:59Z hardy.ferentschik $ -# This file is intentionally left empty. All calls to this bundle will -# be delegated to the parent bundle ValidationMessages (which contains -# English messages). -# -# Not providing this bundle would cause the bundle for the default -# locale to take precedence over the base bundle. If the default locale -# is not English but one, for which a resource bundle exists (e.g. German), -# the English texts would never be returned.
diff --git a/user/src/org/hibernate/validator/ValidationMessages_fr.properties b/user/src/org/hibernate/validator/ValidationMessages_fr.properties deleted file mode 100644 index 44713b5..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages_fr.properties +++ /dev/null
@@ -1,21 +0,0 @@ -# $Id: ValidationMessages_fr.properties 19252 2010-04-20 15:29:43Z hardy.ferentschik $ -javax.validation.constraints.NotNull.message=ne peut pas \u00EAtre nul -javax.validation.constraints.Size.message=la taille doit \u00EAtre entre {min} et {max} -javax.validation.constraints.Pattern.message=doit suivre "{regexp}" -javax.validation.constraints.Min.message=doit \u00EAtre plus grand que {value} -javax.validation.constraints.Max.message=doit \u00EAtre plus petit que {value} -javax.validation.constraints.Null.message=doit \u00EAtre nul -javax.validation.constraints.Past.message=doit \u00EAtre dans le pass\u00E9 -javax.validation.constraints.Future.message=doit \u00EAtre dans le futur -javax.validation.constraints.AssertTrue.message=doit \u00EAtre vrai -javax.validation.constraints.AssertFalse.message=doit \u00EAtre faux -javax.validation.constraints.Digits.message=Valeur num\u00E9rique hors limite (<{integer} chiffres>.<{fraction} chiffres> attendus) -javax.validation.constraints.DecimalMin.message=doit \u00EAtre plus grand que {value} -javax.validation.constraints.DecimalMax.message=doit \u00EAtre plus petit que {value} -org.hibernate.validator.constraints.Email.message=Addresse email mal form\u00E9e -org.hibernate.validator.constraints.Length.message=la taille doit \u00EAtre entre {min} et {max} -org.hibernate.validator.constraints.NotBlank.message=ne peut pas \u00EAtre vide -org.hibernate.validator.constraints.NotEmpty.message=ne peut pas \u00EAtre vide -org.hibernate.validator.constraints.Range.message=doit \u00EAtre entre {min} et {max} -org.hibernate.validator.constraints.URL.message=URL mal form\u00E9e -org.hibernate.validator.constraints.CreditCardNumber.message=Num\u00E9ro de carte de cr\u00E9dit invalide \ No newline at end of file
diff --git a/user/src/org/hibernate/validator/ValidationMessages_mn_MN.properties b/user/src/org/hibernate/validator/ValidationMessages_mn_MN.properties deleted file mode 100644 index f11da6f..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages_mn_MN.properties +++ /dev/null
@@ -1,18 +0,0 @@ -javax.validation.constraints.AssertFalse.message=\u0425\u0443\u0434\u0430\u043B \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.AssertTrue.message=\u04AE\u043D\u044D\u043D \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.DecimalMax.message={value}-\u0430\u0430\u0441 \u0431\u0430\u0433\u0430 \u0431\u0443\u044E\u0443 \u0442\u044D\u043D\u0446\u04AF\u04AF \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.DecimalMin.message={value}-\u0430\u0430\u0441 \u0438\u0445 \u0431\u0443\u044E\u0443 \u0442\u044D\u043D\u0446\u04AF\u04AF \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.Digits.message=\u0422\u043E\u043E\u043D \u0445\u044F\u0437\u0433\u0430\u0430\u0440\u0430\u0430\u0441 \u0445\u044D\u0442\u044D\u0440\u0441\u044D\u043D \u0431\u0430\u0439\u043D\u0430 (<{integerDigits} digits>.<{fractionalDigits} digits> \u0445\u043E\u043E\u0440\u043E\u043D\u0434 \u0431\u0430\u0439\u043D\u0430) -javax.validation.constraints.Future.message=\u0418\u0440\u044D\u044D\u0434\u04AF\u0439\u0434 \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.Max.message={value}-\u0430\u0430\u0441 \u0431\u0430\u0433\u0430 \u0431\u0443\u044E\u0443 \u0442\u044D\u043D\u0446\u04AF\u04AF \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.Min.message={value}-\u0430\u0430\u0441 \u0438\u0445 \u0431\u0443\u044E\u0443 \u0442\u044D\u043D\u0446\u04AF\u04AF \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.NotNull.message=null \u0431\u0430\u0439\u0436 \u0431\u043E\u043B\u043E\u0445\u0433\u04AF\u0439 -javax.validation.constraints.Null.message=null \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.Past.message=\u04E8\u043D\u0433\u04E9\u0440\u0441\u04E9\u043D\u0434 \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.Pattern.message=\"{regexp}\"-\u0434 \u0442\u0430\u0430\u0440\u0430\u0445 \u0451\u0441\u0442\u043E\u0439 -javax.validation.constraints.Size.message=\u0425\u044D\u043C\u0436\u044D\u044D {min}-\u0441 {max} \u0445\u043E\u043E\u0440\u043E\u043D\u0434 \u0431\u0430\u0439\u043D\u0430 -org.hibernate.validator.constraints.Email.message=\u0411\u0443\u0440\u0443\u0443 \u0438-\u043C\u044D\u0439\u043B \u0445\u0430\u044F\u0433 \u0431\u0430\u0439\u043D\u0430 -org.hibernate.validator.constraints.Length.message=\u0422\u044D\u043C\u0434\u044D\u0433\u0442\u0438\u0439\u043D \u0443\u0440\u0442 {min}-\u0441 {max} \u0445\u043E\u043E\u0440\u043E\u043D\u0434 \u0431\u0430\u0439\u043D\u0430 -org.hibernate.validator.constraints.NotBlank.message=\u0425\u043E\u043E\u0441\u043E\u043D \u0431\u0430\u0439\u0436 \u0431\u043E\u043B\u043E\u0445\u0433\u04AF\u0439 -org.hibernate.validator.constraints.NotEmpty.message=\u0425\u043E\u043E\u0441\u043E\u043D \u0431\u0430\u0439\u0436 \u0431\u043E\u043B\u043E\u0445\u0433\u04AF\u0439 -org.hibernate.validator.constraints.Range.message=\u0423\u0442\u0433\u0430 {min}-\u0441 {max} \u0445\u043E\u043E\u0440\u043E\u043D\u0434 \u0431\u0430\u0439\u043D\u0430 \ No newline at end of file
diff --git a/user/src/org/hibernate/validator/ValidationMessages_tr.properties b/user/src/org/hibernate/validator/ValidationMessages_tr.properties deleted file mode 100644 index 01acd7f..0000000 --- a/user/src/org/hibernate/validator/ValidationMessages_tr.properties +++ /dev/null
@@ -1,18 +0,0 @@ -javax.validation.constraints.AssertFalse.message=teyit ba\u015far\u0131s\u0131z -javax.validation.constraints.AssertTrue.message=teyit ba\u015far\u0131s\u0131z -javax.validation.constraints.DecimalMax.message='{value}' de\u011ferinden k\u00fc\u00e7\u00fck yada e\u015fit olmal\u0131 -javax.validation.constraints.DecimalMin.message='{value}' de\u011ferinden b\u00fcy\u00fck yada e\u015fit olmal\u0131 -javax.validation.constraints.Digits.message=s\u0131n\u0131rlar\u0131n d\u0131\u015f\u0131nda say\u0131sal de\u011fer (beklenen <{integerDigits} basamak>.<{fractionalDigits} basamak>) -javax.validation.constraints.Future.message=ileri bir tarih olmal\u0131 -javax.validation.constraints.Max.message='{value}' de\u011ferinden k\u00fc\u00e7\u00fck yada e\u015fit olmal\u0131 -javax.validation.constraints.Min.message='{value}' de\u011ferinden b\u00fcy\u00fck yada e\u015fit olmal\u0131 -javax.validation.constraints.NotNull.message=bo\u015f de\u011fer olamaz -javax.validation.constraints.Null.message=bo\u015f de\u011fer olmal\u0131 -javax.validation.constraints.Past.message=ge\u00e7mi\u015f bir tarih olmal\u0131 -javax.validation.constraints.Pattern.message='{regexp}' ile e\u015fle\u015fmeli -javax.validation.constraints.Size.message=boyut '{min}' ile '{max}' aras\u0131nda olmal\u0131 -org.hibernate.validator.constraints.Length.message=uzunluk '{min}' ile '{max}' aras\u0131nda olmal\u0131 -org.hibernate.validator.constraints.NotBlank.message=bo\u015f de\u011fer olamaz -org.hibernate.validator.constraints.NotEmpty.message=bo\u015f de\u011fer olamaz -org.hibernate.validator.constraints.Email.message=d\u00fczg\u00fcn bi\u00e7imli bir e-posta adresi de\u011fil! -org.hibernate.validator.constraints.Range.message={min} ve {max} aras\u0131nda olmal\u0131d\u0131r!
diff --git a/user/src/org/hibernate/validator/engine/ConstraintViolationImpl_CustomFieldSerializer.java b/user/src/org/hibernate/validator/engine/ConstraintViolationImpl_CustomFieldSerializer.java deleted file mode 100644 index 97883fa..0000000 --- a/user/src/org/hibernate/validator/engine/ConstraintViolationImpl_CustomFieldSerializer.java +++ /dev/null
@@ -1,81 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.engine; - -import com.google.gwt.user.client.rpc.SerializationException; -import com.google.gwt.user.client.rpc.SerializationStreamReader; -import com.google.gwt.user.client.rpc.SerializationStreamWriter; - -import java.lang.annotation.ElementType; - -import javax.validation.Path; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * Custom Serializer for {@link ConstraintViolationImpl}. - */ -public class ConstraintViolationImpl_CustomFieldSerializer { - - public static void deserialize(SerializationStreamReader streamReader, - ConstraintViolationImpl instance) throws SerializationException { - // no fields - } - - public static ConstraintViolationImpl<Object> instantiate( - SerializationStreamReader streamReader) throws SerializationException { - - String messageTemplate = null; - String interpolatedMessage = streamReader.readString(); - Class<Object> rootBeanClass = null; - Object rootBean = null; - Object leafBeanInstance = null; - Object value = null; - Path propertyPath = (Path) streamReader.readObject(); - ConstraintDescriptor<?> constraintDescriptor = null; - ElementType elementType = null; - return new ConstraintViolationImpl<Object>(messageTemplate, - interpolatedMessage, rootBeanClass, rootBean, leafBeanInstance, value, - propertyPath, constraintDescriptor, elementType); - } - - /** - * Only a subset of fields are actually serialized. - * <p/> - * There is no guarantee that the root bean is GWT-serializable or that it's - * appropriate for it to be exposed on the client. Even if the root bean could - * be sent back, the lack of reflection on the client makes it troublesome to - * interpret the path as a sequence of property accesses. - * <p/> - * The current implementation is the simplest-to-implement properties. - * <ol> - * <li>Message</li> - * <li>Property Path</li> - * </ol> - */ - public static void serialize(SerializationStreamWriter streamWriter, - ConstraintViolationImpl instance) throws SerializationException { - - // streamWriter.writeString(instance.getMessageTemplate()); - streamWriter.writeString(instance.getMessage()); - // streamWriter.writeObject(instance.getRootBeanClass()); - // streamWriter.writeObject(instance.getRootBean()); - // streamWriter.writeObject(instance.getLeafBean()); - // streamWriter.writeObject(instance.getInvalidValue()); - streamWriter.writeObject(instance.getPropertyPath()); - // streamWriter.writeObject(instance.getConstraintDescriptor()); - // ElementType - } -}
diff --git a/user/src/org/hibernate/validator/engine/PathImpl_CustomFieldSerializer.java b/user/src/org/hibernate/validator/engine/PathImpl_CustomFieldSerializer.java deleted file mode 100644 index 67c6c59..0000000 --- a/user/src/org/hibernate/validator/engine/PathImpl_CustomFieldSerializer.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.engine; - -import com.google.gwt.user.client.rpc.SerializationException; -import com.google.gwt.user.client.rpc.SerializationStreamReader; -import com.google.gwt.user.client.rpc.SerializationStreamWriter; - -/** - * Custom Serializer for {@link PathImpl}. - */ -public class PathImpl_CustomFieldSerializer { - - public static void deserialize(SerializationStreamReader streamReader, - PathImpl instance) throws SerializationException { - // no fields - } - - public static PathImpl instantiate(SerializationStreamReader streamReader) - throws SerializationException { - String propertyPath = streamReader.readString(); - - return PathImpl.createPathFromString(propertyPath); - } - - public static void serialize(SerializationStreamWriter streamWriter, - PathImpl instance) throws SerializationException { - streamWriter.writeString(instance.toString()); - } -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/ScriptAssert.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/ScriptAssert.java deleted file mode 100644 index 260a80e..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/ScriptAssert.java +++ /dev/null
@@ -1,136 +0,0 @@ -// $Id: ScriptAssert.java 19327 2010-04-30 08:11:15Z hardy.ferentschik $ -/* - * JBoss, Home of Professional Open Source Copyright 2010, Red Hat, Inc. and/or - * its affiliates, and individual contributors by the @authors tag. See the - * copyright.txt in the distribution for a full listing of individual - * contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by - * applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS - * OF ANY KIND, either express or implied. See the License for the specific - * language governing permissions and limitations under the License. - */ -// MODIFIED BY GOOGLE -package org.hibernate.validator.constraints; - -import org.hibernate.validator.constraints.impl.ScriptAssertValidator; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.ConstraintDeclarationException; -import javax.validation.Payload; - -/** - * <p> - * A class-level constraint, that evaluates a script expression against the - * annotated element. This constraint can be used to implement validation - * routines, that depend on multiple attributes of the annotated element. - * </p> - * <p> - * For evaluation of expressions the Java Scripting API as defined by <a - * href="http://jcp.org/en/jsr/detail?id=223">JSR 223</a> - * ("Scripting for the Java<sup>TM</sup> Platform") is used. Therefore an - * implementation of that API must part of the class path. This is automatically - * the case when running on Java 6. For older Java versions, the JSR 223 RI can - * be added manually to the class path. - * </p> - * The expressions to be evaluated can be written in any scripting or expression - * language, for which a JSR 223 compatible engine can be found in the class - * path. The following listing shows an example using the JavaScript engine, - * which comes with Java 6: </p> - * <p/> - * - * <pre> - * @ScriptAssert(lang = "javascript", script = "_this.startDate.before(_this.endDate)") - * public class CalendarEvent { - * <p/> - * private Date startDate; - * <p/> - * private Date endDate; - * <p/> - * //... - * <p/> - * } - * </pre> - * <p> - * Using a real expression language in conjunction with a shorter object alias - * allows for very compact expressions: - * </p> - * - * <pre> - * @ScriptAssert(lang = "jexl", script = "_.startDate < _.endDate", alias = "_") - * public class CalendarEvent { - * <p/> - * private Date startDate; - * <p/> - * private Date endDate; - * <p/> - * //... - * <p/> - * } - * </pre> - * <p> - * Accepts any type. - * </p> - * - * @author Gunnar Morling - */ -@Target({TYPE}) -@Retention(RUNTIME) -@Constraint(validatedBy = ScriptAssertValidator.class) -@Documented -public @interface ScriptAssert { - - String message() default "{org.hibernate.validator.constraints.ScriptAssert.message}"; - - Class<?>[] groups() default {}; - - Class<? extends Payload>[] payload() default {}; - - /** - * @return The name of the script language used by this constraint as expected - * by the JSR 223 {@link javax.script.ScriptEngineManager}. A - * {@link ConstraintDeclarationException} will be thrown upon script - * evaluation, if no engine for the given language could be found. - */ - String lang(); - - /** - * @return The script to be executed. The script must return - * <code>Boolean.TRUE</code>, if the annotated element could - * successfully be validated, otherwise <code>Boolean.FALSE</code>. - * Returning null or any type other than Boolean will cause a - * {@link ConstraintDeclarationException} upon validation. Any - * exception occurring during script evaluation will be wrapped into a - * ConstraintDeclarationException, too. Within the script, the - * validated object can be accessed from the - * {@link javax.script.ScriptContext script context} using the name - * specified in the <code>alias</code> attribute. - */ - String script(); - - /** - * @return The name, under which the annotated element shall be registered - * within the script context. Defaults to "_this". - */ - String alias() default "_this"; - - /** - * Defines several {@code @ScriptAssert} annotations on the same element. - */ - @Target({TYPE}) - @Retention(RUNTIME) - @Documented - public @interface List { - ScriptAssert[] value(); - } -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/EmailValidator.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/EmailValidator.java deleted file mode 100644 index 46ed562..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/EmailValidator.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -import com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator; - -import org.hibernate.validator.constraints.Email; - -/** - * This Validator is not GWT complatible. - */ -public class EmailValidator extends NotGwtCompatibleValidator<Email, String> { - // TODO(nchalko) make compatible -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/FutureValidatorForCalendar.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/FutureValidatorForCalendar.java deleted file mode 100644 index 7cbf05e..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/FutureValidatorForCalendar.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -import com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator; - -import javax.validation.constraints.Future; - -/** - * This Validator is not GWT complatible. - */ -public class FutureValidatorForCalendar extends - NotGwtCompatibleValidator<Future, Object> { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/PastValidatorForCalendar.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/PastValidatorForCalendar.java deleted file mode 100644 index 1dba9e2..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/PastValidatorForCalendar.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -import com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator; - -import javax.validation.constraints.Past; - -/** - * This Validator is not GWT complatible. - */ -public class PastValidatorForCalendar extends - NotGwtCompatibleValidator<Past, Object> { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/PatternValidator.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/PatternValidator.java deleted file mode 100644 index aaf3e92..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/PatternValidator.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class PatternValidator extends - com.google.gwt.validation.client.constraints.PatternValidator { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/ScriptAssertValidator.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/ScriptAssertValidator.java deleted file mode 100644 index 48bdc3a..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/ScriptAssertValidator.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -import com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator; - -import org.hibernate.validator.constraints.Email; - -/** - * This Validator is not GWT complatible. - */ -public class ScriptAssertValidator extends - NotGwtCompatibleValidator<Email, String> { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArray.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArray.java deleted file mode 100644 index 5ed12e4..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArray.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArray extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfObject { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfBoolean.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfBoolean.java deleted file mode 100644 index a26c805..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfBoolean.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfBoolean extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfBoolean { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfByte.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfByte.java deleted file mode 100644 index 228fdd9..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfByte.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfByte extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfByte { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfChar.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfChar.java deleted file mode 100644 index 8a1f3c2..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfChar.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfChar extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfChar { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfDouble.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfDouble.java deleted file mode 100644 index 4e4beb8..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfDouble.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfDouble extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfDouble { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfFloat.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfFloat.java deleted file mode 100644 index 8d87589..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfFloat.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfFloat extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfFloat { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfInt.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfInt.java deleted file mode 100644 index d875240..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfInt.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfInt extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfInt { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfLong.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfLong.java deleted file mode 100644 index 55bf45d..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfLong.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfLong extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfLong { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfShort.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfShort.java deleted file mode 100644 index bd50c7d..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/SizeValidatorForArraysOfShort.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -/** - * Override the Hibernate implementation with the GWT version. - */ -public class SizeValidatorForArraysOfShort extends - com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfShort { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/URLValidator.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/URLValidator.java deleted file mode 100644 index bf01353..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/URLValidator.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.hibernate.validator.constraints.impl; - -import com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator; - -import org.hibernate.validator.constraints.URL; - -/** - * This Validator is not GWT complatible. - */ -public class URLValidator extends - NotGwtCompatibleValidator<URL, Object> { -}
diff --git a/user/src/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java b/user/src/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java deleted file mode 100644 index 91bd2c3..0000000 --- a/user/src/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java +++ /dev/null
@@ -1,225 +0,0 @@ -// $Id: PathImpl.java 17744 2009-10-14 14:38:57Z hardy.ferentschik $ -/* -* JBoss, Home of Professional Open Source -* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -// Modified by Google: Replace java.util.Pattern with gwt RegExp -package org.hibernate.validator.engine; - -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.validation.Path; - -/** - * @author Hardy Ferentschik - */ -public class PathImpl implements Path, Serializable { - - private static final long serialVersionUID = 7564511574909882392L; - - /** - * Regular expression used to split a string path into its elements. - * - * @see <a href="http://www.regexplanet.com/simple/index.jsp">Regular expression tester</a> - */ - private static final RegExp pathPattern = RegExp.compile("(\\w+)(\\[(\\w*)\\])?(\\.(.*))*"); - - private static final String PROPERTY_PATH_SEPERATOR = "."; - - private final List<Node> nodeList; - - /** - * Returns a {@code Path} instance representing the path described by the given string. To create a root node the empty string should be passed. - * - * @param propertyPath the path as string representation. - * - * @return a {@code Path} instance representing the path described by the given string. - * - * @throws IllegalArgumentException in case {@code property == null} or {@code property} cannot be parsed. - */ - public static PathImpl createPathFromString(String propertyPath) { - if ( propertyPath == null ) { - throw new IllegalArgumentException( "null is not allowed as property path." ); - } - - if ( propertyPath.length() == 0 ) { - return createNewPath( null ); - } - - return parseProperty( propertyPath ); - } - - public static PathImpl createNewPath(String name) { - PathImpl path = new PathImpl(); - NodeImpl node = new NodeImpl( name ); - path.addNode( node ); - return path; - } - - public static PathImpl createShallowCopy(Path path) { - return path == null ? null : new PathImpl( path ); - } - - private PathImpl(Path path) { - this.nodeList = new ArrayList<Node>(); - for ( Object aPath : path ) { - nodeList.add( new NodeImpl( ( Node ) aPath ) ); - } - } - - private PathImpl() { - nodeList = new ArrayList<Node>(); - } - - private PathImpl(List<Node> nodeList) { - this.nodeList = new ArrayList<Node>(); - for ( Node node : nodeList ) { - this.nodeList.add( new NodeImpl( node ) ); - } - } - - public boolean isRootPath() { - return nodeList.size() == 1 && nodeList.get( 0 ).getName() == null; - } - - public PathImpl getPathWithoutLeafNode() { - List<Node> nodes = new ArrayList<Node>( nodeList ); - PathImpl path = null; - if ( nodes.size() > 1 ) { - nodes.remove( nodes.size() - 1 ); - path = new PathImpl( nodes ); - } - return path; - } - - public void addNode(Node node) { - nodeList.add( node ); - } - - public Node removeLeafNode() { - if ( nodeList.size() == 0 ) { - throw new IllegalStateException( "No nodes in path!" ); - } - if ( nodeList.size() == 1 ) { - throw new IllegalStateException( "Root node cannot be removed!" ); - } - return nodeList.remove( nodeList.size() - 1 ); - } - - public NodeImpl getLeafNode() { - if ( nodeList.size() == 0 ) { - throw new IllegalStateException( "No nodes in path!" ); - } - return ( NodeImpl ) nodeList.get( nodeList.size() - 1 ); - } - - public Iterator<Path.Node> iterator() { - return nodeList.iterator(); - } - - public boolean isSubPathOf(Path path) { - Iterator<Node> pathIter = path.iterator(); - Iterator<Node> thisIter = iterator(); - while ( pathIter.hasNext() ) { - Node pathNode = pathIter.next(); - if ( !thisIter.hasNext() ) { - return false; - } - Node thisNode = thisIter.next(); - if ( !thisNode.equals( pathNode ) ) { - return false; - } - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - Iterator<Path.Node> iter = iterator(); - while ( iter.hasNext() ) { - Node node = iter.next(); - builder.append( node.toString() ); - if ( iter.hasNext() ) { - builder.append( PROPERTY_PATH_SEPERATOR ); - } - } - return builder.toString(); - } - - @Override - public boolean equals(Object o) { - if ( this == o ) { - return true; - } - if ( o == null || getClass() != o.getClass() ) { - return false; - } - - PathImpl path = ( PathImpl ) o; - if ( nodeList != null && !nodeList.equals( path.nodeList ) ) { - return false; - } - if ( nodeList == null && path.nodeList != null ) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - return nodeList != null ? nodeList.hashCode() : 0; - } - - private static PathImpl parseProperty(String property) { - PathImpl path = new PathImpl(); - String tmp = property; - do { - MatchResult matcher = pathPattern.exec(tmp); - if (matcher != null) { - String value = matcher.getGroup(1); - String indexed = matcher.getGroup(2); - String index = matcher.getGroup(3); - NodeImpl node = new NodeImpl( value ); - if ( indexed != null ) { - node.setInIterable( true ); - } - if ( index != null && index.length() > 0 ) { - try { - Integer i = Integer.parseInt( index ); - node.setIndex( i ); - } - catch ( NumberFormatException e ) { - node.setKey( index ); - } - } - path.addNode( node ); - tmp = matcher.getGroup(5); - } - else { - throw new IllegalArgumentException( "Unable to parse property path " + property ); - } - } while ( tmp != null ); - return path; - } - -}
diff --git a/user/test/com/google/gwt/validation/ConstraintsGwtSuite.java b/user/test/com/google/gwt/validation/ConstraintsGwtSuite.java deleted file mode 100644 index 2930f06..0000000 --- a/user/test/com/google/gwt/validation/ConstraintsGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation; - -import com.google.gwt.junit.tools.GWTTestSuite; -import com.google.gwt.validation.client.constraints.GwtCompileTest; - -import junit.framework.Test; - -/** - * All Constraints tests that GWTTestCase. - */ -public class ConstraintsGwtSuite { - public static Test suite() { - GWTTestSuite suite = new GWTTestSuite( - "Validation Constraint tests that require GWT"); - suite.addTestSuite(GwtCompileTest.class); - return suite; - } - -}
diff --git a/user/test/com/google/gwt/validation/ConstraintsJreSuite.java b/user/test/com/google/gwt/validation/ConstraintsJreSuite.java deleted file mode 100644 index 218e53f..0000000 --- a/user/test/com/google/gwt/validation/ConstraintsJreSuite.java +++ /dev/null
@@ -1,91 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation; - -import com.google.gwt.validation.client.constraints.AssertFalseValidatorTest; -import com.google.gwt.validation.client.constraints.AssertTrueValidatorTest; -import com.google.gwt.validation.client.constraints.DecimalMaxValidatorForNumberTest; -import com.google.gwt.validation.client.constraints.DecimalMaxValidatorForStringTest; -import com.google.gwt.validation.client.constraints.DecimalMinValidatorForNumberTest; -import com.google.gwt.validation.client.constraints.DecimalMinValidatorForStringTest; -import com.google.gwt.validation.client.constraints.DigitsValidatorForNumberTest; -import com.google.gwt.validation.client.constraints.DigitsValidatorForStringTest; -import com.google.gwt.validation.client.constraints.FutureValidatorForDateTest; -import com.google.gwt.validation.client.constraints.MaxValidatorForNumberTest; -import com.google.gwt.validation.client.constraints.MaxValidatorForStringTest; -import com.google.gwt.validation.client.constraints.MinValidatorForNumberTest; -import com.google.gwt.validation.client.constraints.MinValidatorForStringTest; -import com.google.gwt.validation.client.constraints.NotNullValidatorTest; -import com.google.gwt.validation.client.constraints.NullValidatorTest; -import com.google.gwt.validation.client.constraints.PastValidatorForDateTest; -import com.google.gwt.validation.client.constraints.PatternValidatorTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfBooleanTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfByteTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfCharTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfDoubleTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfFloatTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfIntTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfLongTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfObjectTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForArrayOfShortTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForCollectionTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForMapTest; -import com.google.gwt.validation.client.constraints.SizeValidatorForStringTest; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * All Constraints tests that don't need GWTTestCase. - */ -public class ConstraintsJreSuite { - public static Test suite() { - TestSuite suite = new TestSuite( - "Validation Constraint tests that require the JRE"); - suite.addTestSuite(AssertFalseValidatorTest.class); - suite.addTestSuite(AssertTrueValidatorTest.class); - suite.addTestSuite(DecimalMaxValidatorForNumberTest.class); - suite.addTestSuite(DecimalMaxValidatorForStringTest.class); - suite.addTestSuite(DecimalMinValidatorForNumberTest.class); - suite.addTestSuite(DecimalMinValidatorForStringTest.class); - suite.addTestSuite(DigitsValidatorForNumberTest.class); - suite.addTestSuite(DigitsValidatorForStringTest.class); - suite.addTestSuite(FutureValidatorForDateTest.class); - suite.addTestSuite(MaxValidatorForNumberTest.class); - suite.addTestSuite(MaxValidatorForStringTest.class); - suite.addTestSuite(MinValidatorForNumberTest.class); - suite.addTestSuite(MinValidatorForStringTest.class); - suite.addTestSuite(NotNullValidatorTest.class); - suite.addTestSuite(NullValidatorTest.class); - suite.addTestSuite(PastValidatorForDateTest.class); - suite.addTestSuite(PatternValidatorTest.class); - suite.addTestSuite(SizeValidatorForArrayOfBooleanTest.class); - suite.addTestSuite(SizeValidatorForArrayOfByteTest.class); - suite.addTestSuite(SizeValidatorForArrayOfCharTest.class); - suite.addTestSuite(SizeValidatorForArrayOfDoubleTest.class); - suite.addTestSuite(SizeValidatorForArrayOfFloatTest.class); - suite.addTestSuite(SizeValidatorForArrayOfIntTest.class); - suite.addTestSuite(SizeValidatorForArrayOfLongTest.class); - suite.addTestSuite(SizeValidatorForArrayOfObjectTest.class); - suite.addTestSuite(SizeValidatorForArrayOfShortTest.class); - suite.addTestSuite(SizeValidatorForCollectionTest.class); - suite.addTestSuite(SizeValidatorForMapTest.class); - suite.addTestSuite(SizeValidatorForCollectionTest.class); - suite.addTestSuite(SizeValidatorForMapTest.class); - suite.addTestSuite(SizeValidatorForStringTest.class); - return suite; - } -}
diff --git a/user/test/com/google/gwt/validation/ValidationClientGwtSuite.java b/user/test/com/google/gwt/validation/ValidationClientGwtSuite.java deleted file mode 100644 index a40bd79..0000000 --- a/user/test/com/google/gwt/validation/ValidationClientGwtSuite.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation; - -import com.google.gwt.junit.tools.GWTTestSuite; -import com.google.gwt.validation.client.BaseMessageInterpolatorTest; -import com.google.gwt.validation.client.SimpleSampleTest; - -import junit.framework.Test; - -/** - * All validation client GWT tests. - */ -public class ValidationClientGwtSuite { - - public static Test suite() { - GWTTestSuite suite = new GWTTestSuite( - "Test suite for all validation code."); - suite.addTestSuite(BaseMessageInterpolatorTest.class); - suite.addTestSuite(SimpleSampleTest.class); - return suite; - } -}
diff --git a/user/test/com/google/gwt/validation/ValidationClientJreSuite.java b/user/test/com/google/gwt/validation/ValidationClientJreSuite.java deleted file mode 100644 index bc794e7..0000000 --- a/user/test/com/google/gwt/validation/ValidationClientJreSuite.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation; - -import com.google.gwt.validation.client.impl.NodeImplTest; -import com.google.gwt.validation.client.impl.PathImplTest; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * All validation client non GWT tests. - */ -public class ValidationClientJreSuite { - - public static Test suite() { - TestSuite suite = new TestSuite( - "Test suite for validation client code that does not require GWT."); - suite.addTestSuite(PathImplTest.class); - suite.addTestSuite(NodeImplTest.class); - return suite; - } -}
diff --git a/user/test/com/google/gwt/validation/ValidationTest.gwt.xml b/user/test/com/google/gwt/validation/ValidationTest.gwt.xml deleted file mode 100644 index d088c8f..0000000 --- a/user/test/com/google/gwt/validation/ValidationTest.gwt.xml +++ /dev/null
@@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <inherits name="org.hibernate.validator.HibernateValidator" /> - <source path="client"> - </source> -</module> \ No newline at end of file
diff --git a/user/test/com/google/gwt/validation/client/BaseMessageInterpolatorTest.java b/user/test/com/google/gwt/validation/client/BaseMessageInterpolatorTest.java deleted file mode 100644 index 5b8a2f3..0000000 --- a/user/test/com/google/gwt/validation/client/BaseMessageInterpolatorTest.java +++ /dev/null
@@ -1,59 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import java.util.HashMap; -import java.util.Map; - -/** - * Test for {@link BaseMessageInterpolator}. Full tests are in the TCK. - */ -public class BaseMessageInterpolatorTest extends ValidationClientGwtTestCase { - BaseMessageInterpolator interpolator; - Map<String, Object> defaultMap = new HashMap<String, Object>(); - - public void testReplace_foo() { - assertAttributesReplaced("bar", "{foo}", defaultMap); - } - - public void testReplace_fooFoo() { - assertAttributesReplaced("bar and bar", "{foo} and {foo}", defaultMap); - } - - public void testReplace_integer() { - assertAttributesReplaced("integer=1", "integer={integer}", defaultMap); - } - - public void testReplace_none() { - assertAttributesReplaced("none", "none", defaultMap); - } - - protected void assertAttributesReplaced(String expected, String message, - Map<String, Object> map) { - String result = interpolator.replaceParameters(message, - BaseMessageInterpolator.createAnnotationReplacer(map)); - assertEquals(expected, result); - } - - @Override - protected void gwtSetUp() throws Exception { - super.gwtSetUp(); - interpolator = new GwtMessageInterpolator(); - defaultMap.clear(); - defaultMap.put("foo", "bar"); - defaultMap.put("integer", Integer.valueOf(1)); - } -}
diff --git a/user/test/com/google/gwt/validation/client/SimpleSample.java b/user/test/com/google/gwt/validation/client/SimpleSample.java deleted file mode 100644 index 86083d8..0000000 --- a/user/test/com/google/gwt/validation/client/SimpleSample.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import javax.validation.constraints.NotNull; - -/** - * A simple sample class to test javax.validation. - */ -public class SimpleSample { - @NotNull - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -}
diff --git a/user/test/com/google/gwt/validation/client/SimpleSampleTest.java b/user/test/com/google/gwt/validation/client/SimpleSampleTest.java deleted file mode 100644 index 72c6860..0000000 --- a/user/test/com/google/gwt/validation/client/SimpleSampleTest.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.validation.client.impl.ConstraintViolationImpl; - -import javax.validation.ConstraintViolation; -import javax.validation.constraints.NotNull; - -/** - * Tests for {@link SimpleSample}. - */ -public class SimpleSampleTest extends ValidationClientGwtTestCase { - SimpleSample sample; - - public void testAnnotatedClassCompiles() throws Exception { - // Only tests that validation annotated class compile - assertEquals(null, sample.getName()); - } - - public void testConstraintViolation_compiles() throws Exception { - // Only tests that Violation Compiles which will also compile Path, Node - // and ConstraintDescriptor - ConstraintViolation<NotNull> violation = ConstraintViolationImpl.<NotNull> builder(). - setLeafBean(sample). - build(); - assertEquals(sample, violation.getLeafBean()); - } - - @Override - protected void gwtSetUp() { - sample = new SimpleSample(); - } -}
diff --git a/user/test/com/google/gwt/validation/client/ValidationClientGwtTestCase.java b/user/test/com/google/gwt/validation/client/ValidationClientGwtTestCase.java deleted file mode 100644 index eb2d781..0000000 --- a/user/test/com/google/gwt/validation/client/ValidationClientGwtTestCase.java +++ /dev/null
@@ -1,29 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client; - -import com.google.gwt.junit.client.GWTTestCase; - -/** - * Base {@link GWTTestCase} for Validation Client tests. - */ -public abstract class ValidationClientGwtTestCase extends GWTTestCase { - - @Override - public final String getModuleName() { - return "com.google.gwt.validation.ValidationTest"; - } -} \ No newline at end of file
diff --git a/user/test/com/google/gwt/validation/client/constraints/AssertFalseValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/AssertFalseValidatorTest.java deleted file mode 100644 index 771247a..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/AssertFalseValidatorTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.AssertFalse; - -/** - * Tests for {@link AssertFalseValidator}. - */ -public class AssertFalseValidatorTest extends - ConstraintValidatorTestCase<AssertFalse, Boolean> { - - @SuppressWarnings("unused") - @AssertFalse - private Boolean defaultField; - - protected AssertFalseValidator createValidator() { - return new AssertFalseValidator(); - } - - public void testIsValid_false() { - Boolean value = Boolean.FALSE; - boolean expected = true; - assertConstraintValidator(value, expected); - } - - public void testIsValid_true() { - assertConstraintValidator(Boolean.TRUE, false); - } - - @Override - protected Class<AssertFalse> getAnnotationClass() { - return AssertFalse.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/AssertTrueValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/AssertTrueValidatorTest.java deleted file mode 100644 index 5ff0379..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/AssertTrueValidatorTest.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.AssertTrue; - -/** - * Tests for {@link AssertFalseValidator}. - */ -public class AssertTrueValidatorTest extends - ConstraintValidatorTestCase<AssertTrue, Boolean> { - - @SuppressWarnings("unused") - @AssertTrue - private Boolean defaultField; - - @Override - protected AssertTrueValidator createValidator() { - return new AssertTrueValidator(); - } - - public void testIsValid_false() { - assertConstraintValidator(Boolean.FALSE, false); - } - - public void testIsValid_true() { - assertConstraintValidator(Boolean.TRUE, true); - } - - @Override - protected Class<AssertTrue> getAnnotationClass() { - return AssertTrue.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/ConstraintValidatorTestCase.java b/user/test/com/google/gwt/validation/client/constraints/ConstraintValidatorTestCase.java deleted file mode 100644 index d267949..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/ConstraintValidatorTestCase.java +++ /dev/null
@@ -1,137 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import junit.framework.TestCase; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -/** - * TestCase for {@link javax.validation.ConstraintValidator}s. - * <p> - * Subclasses must : - * <ul> - * <li>implement {@link #getAnnotationClass()}</li> - * <li>implement {@link #createValidator()}.</li> - * <li>define a field called <code>defaultField</code> and annotate it with the - * constraint Annotation under test</li> - * </ul> - * - * <p> - * If additional instances of the annotation need to be tested you can get there - * value with {@link #getAnnotation(Class, Class, String)} - * - * @param <A> The constraint Annotation of the ConstraintValidator under test - * @param <T> The bean type of the ConstraintValidator under test - */ -public abstract class ConstraintValidatorTestCase<A extends Annotation, T> - extends TestCase { - - public final static String DEFAULT_ANNOTATED_FIELD_NAME = "defaultField"; - - // Validators are reusable but not thread safe - protected final ConstraintValidator<A, T> validator = createValidator(); - - // private ConstraintValidatorContext context; - - public ConstraintValidatorTestCase() { - super(); - } - - /** - * All constraints except {@link NotNull} should return true for a null value. - */ - public final void testIsValid_null() { - ConstraintValidatorTestCase.assertConstraintValidator(validator, - getDefaultAnnotation(), null, null, isNullValid()); - } - - /** - * Override this if a null value should not be valid. This is called by - * {@link #testIsValid_null()} - */ - protected boolean isNullValid() { - return true; - } - - /** - * Get the annotation of type {@link #getAnnotationClass()} on the field named - * <code>defaultField</code>. - */ - protected final A getDefaultAnnotation() { - return getAnnotation(getAnnotationClass(), this.getClass(), - DEFAULT_ANNOTATED_FIELD_NAME); - } - - protected abstract Class<A> getAnnotationClass(); - - protected A getAnnotation(Class<A> annotationClass, Class<?> objectClass, - String fieldName) { - - for (Field field : objectClass.getDeclaredFields()) { - if (field.getName().equals(fieldName)) { - A annotation = field.getAnnotation(annotationClass); - if (annotation == null) { - throw new IllegalArgumentException(objectClass + "." + fieldName - + " is not annotated with " + annotationClass); - } - return annotation; - } - } - throw new IllegalArgumentException(objectClass - + " does not have a field called " + fieldName); - } - - protected abstract ConstraintValidator<A, T> createValidator(); - - /** - * Assert result of validating <code>value</code> with <code>validator</code> - * initialized with the annotation of the <code>defaultField</code>. - * - * @param value the Value to validate - * @param expected the expected result of a calling <code>isValid</code> - */ - protected void assertConstraintValidator(T value, boolean expected) { - assertConstraintValidator(validator, getDefaultAnnotation(), null, value, - expected); - } - - /** - * Asserts the validity of a value using the given validator, annotation, and - * context. - * - * @param <T> object type - * @param <A> the constraint annotation type - * @param validator the {@link ConstraintValidator} to test - * @param annotation the constraint annotation to initialize the validator. - * @param context The context for the validator - * @param value the value to validate. - * @param expected the expected result - */ - public static <T, A extends Annotation> void assertConstraintValidator( - ConstraintValidator<A, T> validator, A annotation, - ConstraintValidatorContext context, T value, boolean expected) { - validator.initialize(annotation); - String message = validator.getClass().getName() + "(" + annotation - + ").isValid(" + value + ", " + context + ")"; - assertEquals(message, expected, validator.isValid(value, context)); - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumberTest.java deleted file mode 100644 index c91bb52..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumberTest.java +++ /dev/null
@@ -1,53 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMax; - -/** - * Tests for {@link DecimalMaxValidatorForNumber}. - */ -public class DecimalMaxValidatorForNumberTest extends - ConstraintValidatorTestCase<DecimalMax, Number> { - private static Double BELOW = Double.valueOf(922392239223.08); - private static Double SAME = Double.valueOf(922392239223.09); - private static Double ABOVE = Double.valueOf(922392239223.10); - - @SuppressWarnings("unused") - @DecimalMax("922392239223.09") - private double defaultField; - - protected DecimalMaxValidatorForNumber createValidator() { - return new DecimalMaxValidatorForNumber(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, true); - } - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, false); - } - - @Override - protected Class<DecimalMax> getAnnotationClass() { - return DecimalMax.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForStringTest.java deleted file mode 100644 index cc73112..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForStringTest.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMax; - -/** - * Tests for {@link DecimalMaxValidatorForString}. - */ -public class DecimalMaxValidatorForStringTest extends - ConstraintValidatorTestCase<DecimalMax, String> { - private static String BELOW = "922392239223.08"; - private static String SAME = "922392239223.09"; - private static String ABOVE = "922392239223.10"; - - @SuppressWarnings("unused") - @DecimalMax("922392239223.09") - private String defaultField; - - protected DecimalMaxValidatorForString createValidator() { - return new DecimalMaxValidatorForString(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, true); - } - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, false); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected Class<DecimalMax> getAnnotationClass() { - return DecimalMax.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumberTest.java deleted file mode 100644 index 8b72c9f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumberTest.java +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMin; - -/** - * Tests for {@link DecimalMinValidatorForNumber}. - */ -public class DecimalMinValidatorForNumberTest extends - ConstraintValidatorTestCase<DecimalMin, Number> { - private static Double BELOW = Double.valueOf(922392239223.08); - private static Double ABOVE = Double.valueOf(922392239223.10); - - @SuppressWarnings("unused") - @DecimalMin("922392239223.09") - private double defaultField; - - protected DecimalMinValidatorForNumber createValidator() { - return new DecimalMinValidatorForNumber(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, false); - } - - // Because of rounding error we can't actually test for the exact vale - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, true); - } - - @Override - protected Class<DecimalMin> getAnnotationClass() { - return DecimalMin.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForStringTest.java deleted file mode 100644 index 1fa77bd..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForStringTest.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMin; - -/** - * Tests for {@link DecimalMinValidatorForString}. - */ -public class DecimalMinValidatorForStringTest extends - ConstraintValidatorTestCase<DecimalMin, String> { - private static String BELOW = "922392239223.08"; - private static String SAME = "922392239223.09"; - private static String ABOVE = "922392239223.10"; - - @SuppressWarnings("unused") - @DecimalMin("922392239223.09") - private double defaultField; - - protected DecimalMinValidatorForString createValidator() { - return new DecimalMinValidatorForString(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, false); - } - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, true); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected Class<DecimalMin> getAnnotationClass() { - return DecimalMin.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForNumberTest.java deleted file mode 100644 index 8131a06..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForNumberTest.java +++ /dev/null
@@ -1,66 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.constraints.Digits; - -/** - * Tests for {@link DigitsValidatorForNumber}. - */ -public class DigitsValidatorForNumberTest extends - ConstraintValidatorTestCase<Digits, Number> { - - private static BigDecimal GOOD = new BigDecimal("1234.12"); - private static BigDecimal INT_TO_BIG = new BigDecimal("12345.12"); - private static BigDecimal INT_SMALL = new BigDecimal("123.12"); - private static BigDecimal DECIMAL_TO_BIG = new BigDecimal("1234.123"); - private static BigDecimal DECIMAL_SMALL = new BigDecimal("1234.1"); - - @SuppressWarnings("unused") - @Digits(integer = 4, fraction = 2) - private double defaultField; - - protected DigitsValidatorForNumber createValidator() { - return new DigitsValidatorForNumber(); - } - - public void testIsValid_decimalToBig() { - assertConstraintValidator(DECIMAL_SMALL, true); - } - - public void testIsValid_decimalToSmall() { - assertConstraintValidator(DECIMAL_TO_BIG, false); - } - - public void testIsValid_good() { - assertConstraintValidator(GOOD, true); - } - - public void testIsValid_intToBig() { - assertConstraintValidator(INT_TO_BIG, false); - } - - public void testIsValid_intToSmall() { - assertConstraintValidator(INT_SMALL, true); - } - - @Override - protected Class<Digits> getAnnotationClass() { - return Digits.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForStringTest.java deleted file mode 100644 index 9b60d6d..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForStringTest.java +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Digits; - -/** - * Tests for {@link DigitsValidatorForString}. - */ -public class DigitsValidatorForStringTest extends - ConstraintValidatorTestCase<Digits, String> { - - private static String GOOD = "1234.12"; - private static String INT_TO_BIG = "12345.12"; - private static String INT_SMALL = "123.12"; - private static String DECIMAL_TO_BIG = "1234.123"; - private static String DECIMAL_SMALL = "1234.1"; - - @SuppressWarnings("unused") - @Digits(integer = 4, fraction = 2) - private double defaultField; - - protected DigitsValidatorForString createValidator() { - return new DigitsValidatorForString(); - } - - public void testIsValid_decimalToBig() { - assertConstraintValidator(DECIMAL_SMALL, true); - } - - public void testIsValid_decimalToSmall() { - assertConstraintValidator(DECIMAL_TO_BIG, false); - } - - public void testIsValid_good() { - assertConstraintValidator(GOOD, true); - } - - public void testIsValid_intToBig() { - assertConstraintValidator(INT_TO_BIG, false); - } - - public void testIsValid_intToSmall() { - assertConstraintValidator(INT_SMALL, true); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected Class<Digits> getAnnotationClass() { - return Digits.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/FutureValidatorForDateTest.java b/user/test/com/google/gwt/validation/client/constraints/FutureValidatorForDateTest.java deleted file mode 100644 index bc3a609..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/FutureValidatorForDateTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Future; - -/** - * Tests for {@link FutureValidatorForDate}. - */ -public class FutureValidatorForDateTest extends - ConstraintValidatorTestCase<Future, Date> { - - @SuppressWarnings("unused") - @Future - private Date defaultField; - - protected FutureValidatorForDate createValidator() { - return new FutureValidatorForDate(); - } - - public void testAssertIsValid_nowMinus1000() { - assertConstraintValidator(new Date(new Date().getTime() - 1000), false); - } - - public void testAssertIsValid_nowPlus1000() { - assertConstraintValidator(new Date(new Date().getTime() + 1000), true); - } - - @Override - protected Class<Future> getAnnotationClass() { - return Future.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/GwtCompileTest.java b/user/test/com/google/gwt/validation/client/constraints/GwtCompileTest.java deleted file mode 100644 index 29d193e..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/GwtCompileTest.java +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import com.google.gwt.validation.client.ValidationClientGwtTestCase; - -import java.util.ArrayList; -import java.util.List; - -/** - * A GWT test to force the compilation of all default standard - * {@link javax.validation.ConstraintValidator}s. - */ -public class GwtCompileTest extends ValidationClientGwtTestCase { - - public void testDefaultConstraints() { - List<Class<?>> temp = new ArrayList<Class<?>>(); - temp.add(AssertFalseValidator.class); - temp.add(AssertTrueValidator.class); - temp.add(DecimalMaxValidatorForNumber.class); - temp.add(DecimalMaxValidatorForString.class); - temp.add(DecimalMinValidatorForNumber.class); - temp.add(DecimalMinValidatorForString.class); - temp.add(DigitsValidatorForNumber.class); - temp.add(DigitsValidatorForString.class); - // FutureValidatorForCalendar GWT does not support java.util.Calendar - temp.add(FutureValidatorForDate.class); - temp.add(MaxValidatorForNumber.class); - temp.add(MaxValidatorForString.class); - temp.add(MinValidatorForNumber.class); - temp.add(MinValidatorForString.class); - temp.add(NotNullValidator.class); - temp.add(NullValidator.class); - // PastValidatorForCalendar GWT does not support java.util.Calendar - temp.add(PastValidatorForDate.class); - temp.add(PatternValidator.class); - temp.add(SizeValidatorForArrayOfBoolean.class); - temp.add(SizeValidatorForArrayOfByte.class); - temp.add(SizeValidatorForArrayOfChar.class); - temp.add(SizeValidatorForArrayOfDouble.class); - temp.add(SizeValidatorForArrayOfFloat.class); - temp.add(SizeValidatorForArrayOfInt.class); - temp.add(SizeValidatorForArrayOfLong.class); - temp.add(SizeValidatorForArrayOfObject.class); - temp.add(SizeValidatorForArrayOfShort.class); - temp.add(SizeValidatorForCollection.class); - temp.add(SizeValidatorForMap.class); - temp.add(SizeValidatorForString.class); - - assertEquals(29, temp.size()); - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForNumberTest.java deleted file mode 100644 index f18b5df..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForNumberTest.java +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Max; - -/** - * Tests for {@link MaxValidatorForNumber}. - */ -public class MaxValidatorForNumberTest extends - ConstraintValidatorTestCase<Max, Number> { - private static long SAME = 123456789L; - private static long SMALLER = SAME - 1L; - private static long BIGGER = SAME + 1L; - - @Max(123456789L) - public long defaultField; - - public void testIsValid_same() { - assertConstraintValidator(Long.valueOf(SAME), true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(Long.valueOf(SMALLER), true); - } - - public void testIsValid_bigger() { - assertConstraintValidator(Long.valueOf(BIGGER), false); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE), true); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE), false); - } - - @Override - protected MaxValidatorForNumber createValidator() { - return new MaxValidatorForNumber(); - } - - @Override - protected Class<Max> getAnnotationClass() { - return Max.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForStringTest.java deleted file mode 100644 index b5cb1b7..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForStringTest.java +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Max; - -/** - * Tests for {@link MinValidatorForString}. - */ -public class MaxValidatorForStringTest extends - ConstraintValidatorTestCase<Max, String> { - private static String SAME = "123456789"; - private static String SMALLER = "123456788"; - private static String BIGGER = "123456790"; - - @Max(123456789) - public String defaultField; - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(SMALLER, true); - } - - public void testIsValid_bigger() { - assertConstraintValidator(BIGGER, false); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE).toString(), true); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE).toString(), false); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected MaxValidatorForString createValidator() { - return new MaxValidatorForString(); - } - - @Override - protected Class<Max> getAnnotationClass() { - return Max.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/MinValidatorForNumberTest.java deleted file mode 100644 index bbb8a44..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForNumberTest.java +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Min; - -/** - * Tests for {@link MinValidatorForNumber}. - */ -public class MinValidatorForNumberTest extends - ConstraintValidatorTestCase<Min, Number> { - private static long SAME = 123456789L; - private static long SMALLER = SAME - 1L; - private static long BIGGER = SAME + 1L; - - @Min(123456789L) - public long defaultField; - - public void testIsValid_same() { - assertConstraintValidator(Long.valueOf(SAME), true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(Long.valueOf(SMALLER), false); - } - - public void testIsValid_bigger() { - assertConstraintValidator(Long.valueOf(BIGGER), true); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE), false); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE), true); - } - - @Override - protected MinValidatorForNumber createValidator() { - return new MinValidatorForNumber(); - } - - @Override - protected Class<Min> getAnnotationClass() { - return Min.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/MinValidatorForStringTest.java deleted file mode 100644 index 5c1d526..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForStringTest.java +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Max; - -/** - * Tests for {@link MinValidatorForString}. - */ -public class MinValidatorForStringTest extends - ConstraintValidatorTestCase<Max, String> { - private static String SAME = "123456789"; - private static String SMALLER = "123456788"; - private static String BIGGER = "123456790"; - - @Max(123456789) - public String defaultField; - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(SMALLER, true); - } - - public void testIsValid_bigger() { - assertConstraintValidator(BIGGER, false); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE).toString(), true); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE).toString(), false); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected MaxValidatorForString createValidator() { - return new MaxValidatorForString(); - } - - @Override - protected Class<Max> getAnnotationClass() { - return Max.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/NotNullValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/NotNullValidatorTest.java deleted file mode 100644 index bf4dc31..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/NotNullValidatorTest.java +++ /dev/null
@@ -1,50 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.NotNull; - -/** - * Tests for {@link NotNullValidator}. - */ -public class NotNullValidatorTest extends - ConstraintValidatorTestCase<NotNull, Object> { - - @SuppressWarnings("unused") - @NotNull - private String defaultField; - - public void testIsValid_notNull() { - ConstraintValidatorTestCase.assertConstraintValidator(validator, - getDefaultAnnotation(), null, new Object(), true); - } - - @Override - protected boolean isNullValid() { - return false; - } - - @Override - protected Class<NotNull> getAnnotationClass() { - return NotNull.class; - } - - @Override - protected ConstraintValidator<NotNull, Object> createValidator() { - return new NotNullValidator(); - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/NullValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/NullValidatorTest.java deleted file mode 100644 index 7197064..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/NullValidatorTest.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Null; - -/** - * Tests for {@link NullValidator}. - */ -public class NullValidatorTest extends - ConstraintValidatorTestCase<Null, Object> { - - @SuppressWarnings("unused") - @Null - private Object defaultField; - - protected NullValidator createValidator() { - return new NullValidator(); - } - - public void testIsValid_notNull() { - assertConstraintValidator("this is not null", false); - } - - @Override - protected Class<Null> getAnnotationClass() { - return Null.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/PastValidatorForDateTest.java b/user/test/com/google/gwt/validation/client/constraints/PastValidatorForDateTest.java deleted file mode 100644 index 7c3d37a..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/PastValidatorForDateTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Past; - -/** - * Tests for {@link PastValidatorForDate}. - */ -public class PastValidatorForDateTest extends - ConstraintValidatorTestCase<Past, Date> { - - @SuppressWarnings("unused") - @Past - private Date defaultField; - - protected PastValidatorForDate createValidator() { - return new PastValidatorForDate(); - } - - public void testAssertIsValid_nowMinus1000() { - assertConstraintValidator(new Date(new Date().getTime() - 1000), true); - } - - public void testAssertIsValid_nowPlus1000() { - assertConstraintValidator(new Date(new Date().getTime() + 1000), false); - } - - @Override - protected Class<Past> getAnnotationClass() { - return Past.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/PatternValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/PatternValidatorTest.java deleted file mode 100644 index 60f3fea..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/PatternValidatorTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Pattern; - -/** - * Tests for {@link PastValidatorForDate}. - */ -public class PatternValidatorTest extends - ConstraintValidatorTestCase<Pattern, String> { - - @SuppressWarnings("unused") - @Pattern(regexp = "good") - private Date defaultField; - - protected PatternValidator createValidator() { - return new PatternValidator(); - } - - public void testAssertIsValid_good() { - assertConstraintValidator("this is good", true); - } - - public void testAssertIsValid_bad() { - assertConstraintValidator("this is bad", false); - } - - @Override - protected Class<Pattern> getAnnotationClass() { - return Pattern.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBooleanTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBooleanTest.java deleted file mode 100644 index 3c70fbd..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBooleanTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfBoolean}. - */ -public class SizeValidatorForArrayOfBooleanTest extends - ConstraintValidatorTestCase<Size, boolean[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfBoolean createValidator() { - return new SizeValidatorForArrayOfBoolean(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private boolean[] createArray(int size) { - boolean[] array = new boolean[size]; - for (int i = 0; i < size; i++) { - array[i] = (i % 2 == 0); - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByteTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByteTest.java deleted file mode 100644 index 4efd56f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByteTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfByte}. - */ -public class SizeValidatorForArrayOfByteTest extends - ConstraintValidatorTestCase<Size, byte[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfByte createValidator() { - return new SizeValidatorForArrayOfByte(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private byte[] createArray(int size) { - byte[] array = new byte[size]; - for (int i = 0; i < size; i++) { - array[i] = (byte) i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfCharTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfCharTest.java deleted file mode 100644 index c831e8f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfCharTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfChar}. - */ -public class SizeValidatorForArrayOfCharTest extends - ConstraintValidatorTestCase<Size, char[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfChar createValidator() { - return new SizeValidatorForArrayOfChar(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private char[] createArray(int size) { - char[] array = new char[size]; - for (int i = 0; i < size; i++) { - array[i] = (char) i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDoubleTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDoubleTest.java deleted file mode 100644 index 7be25ae..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDoubleTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfDouble}. - */ -public class SizeValidatorForArrayOfDoubleTest extends - ConstraintValidatorTestCase<Size, double[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfDouble createValidator() { - return new SizeValidatorForArrayOfDouble(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private double[] createArray(int size) { - double[] array = new double[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloatTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloatTest.java deleted file mode 100644 index f265b45..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloatTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfFloat}. - */ -public class SizeValidatorForArrayOfFloatTest extends - ConstraintValidatorTestCase<Size, float[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfFloat createValidator() { - return new SizeValidatorForArrayOfFloat(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private float[] createArray(int size) { - float[] array = new float[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfIntTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfIntTest.java deleted file mode 100644 index 0e37693..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfIntTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfInt}. - */ -public class SizeValidatorForArrayOfIntTest extends - ConstraintValidatorTestCase<Size, int[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfInt createValidator() { - return new SizeValidatorForArrayOfInt(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private int[] createArray(int size) { - int[] array = new int[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLongTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLongTest.java deleted file mode 100644 index c8b3b41..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLongTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfLong}. - */ -public class SizeValidatorForArrayOfLongTest extends - ConstraintValidatorTestCase<Size, long[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfLong createValidator() { - return new SizeValidatorForArrayOfLong(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private long[] createArray(int size) { - long[] array = new long[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObjectTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObjectTest.java deleted file mode 100644 index 34da630..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObjectTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfObject}. - */ -public class SizeValidatorForArrayOfObjectTest extends - ConstraintValidatorTestCase<Size, Object[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfObject createValidator() { - return new SizeValidatorForArrayOfObject(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private Object[] createArray(int size) { - Object[] array = new Object[size]; - for (int i = 0; i < size; i++) { - array[i] = Integer.valueOf(i); - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShortTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShortTest.java deleted file mode 100644 index bfab23f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShortTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfShort}. - */ -public class SizeValidatorForArrayOfShortTest extends - ConstraintValidatorTestCase<Size, short[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfShort createValidator() { - return new SizeValidatorForArrayOfShort(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private short[] createArray(int size) { - short[] array = new short[size]; - for (int i = 0; i < size; i++) { - array[i] = (short) i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForCollectionTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForCollectionTest.java deleted file mode 100644 index 6a44d53..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForCollectionTest.java +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForCollection}. - */ -public class SizeValidatorForCollectionTest extends - ConstraintValidatorTestCase<Size, Collection<?>> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForCollection createValidator() { - return new SizeValidatorForCollection(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createList(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createList(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createList(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createList(6), false); - } - - private Collection<Integer> createList(int size) { - List<Integer> list = new ArrayList<Integer>(size); - for (int i = 1; i <= size; i++) { - Integer key = Integer.valueOf(i); - list.add(key); - } - return list; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForMapTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForMapTest.java deleted file mode 100644 index 67eb163..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForMapTest.java +++ /dev/null
@@ -1,67 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForMap}. - */ -public class SizeValidatorForMapTest extends - ConstraintValidatorTestCase<Size, Map<?, ?>> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForMap createValidator() { - return new SizeValidatorForMap(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createMap(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createMap(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createMap(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createMap(6), false); - } - - private Map<Integer, String> createMap(int size) { - Map<Integer, String> map = new HashMap<Integer, String>(size); - for (int i = 1; i <= size; i++) { - Integer key = Integer.valueOf(i); - map.put(key, key.toString()); - } - return map; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForStringTest.java deleted file mode 100644 index 26c0198..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForStringTest.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForString}. - */ -public class SizeValidatorForStringTest extends - ConstraintValidatorTestCase<Size, String> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForString createValidator() { - return new SizeValidatorForString(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator("1", false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator("12", true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator("12345", true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator("123456", false); - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java b/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java deleted file mode 100644 index ca9b74c..0000000 --- a/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import junit.framework.TestCase; - -import javax.validation.Path.Node; - -/** - * Tests for {@link NodeImpl}. - */ -public class NodeImplTest extends TestCase { - - public void testRoot() throws Exception { - assertNode(NodeImpl.ROOT_NODE, null, false, null, null); - } - - public void testFoo() throws Exception { - assertNode(new NodeImpl("foo"), "foo", false, null, null); - } - - public void testFoo1() throws Exception { - assertNode(new NodeImpl("foo", 1), "foo", true, null, - Integer.valueOf(1)); - } - - public void testFooBar() throws Exception { - assertNode(new NodeImpl("foo", "bar"), "foo", true, "bar", null); - } - - protected void assertNode(Node node, String expectedName, - boolean expectedInIterator, Object expectedKey, Integer expectedIndex) { - assertEquals(node + " name", expectedName, node.getName()); - assertEquals(node + " isInIterator", expectedInIterator, - node.isInIterable()); - assertEquals(node + " key", expectedKey, node.getKey()); - assertEquals(node + " index", expectedIndex, node.getIndex()); - } -}
diff --git a/user/test/com/google/gwt/validation/client/impl/PathImplTest.java b/user/test/com/google/gwt/validation/client/impl/PathImplTest.java deleted file mode 100644 index e8a1fd7..0000000 --- a/user/test/com/google/gwt/validation/client/impl/PathImplTest.java +++ /dev/null
@@ -1,77 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.client.impl; - -import junit.framework.TestCase; - -/** - * Tests for {@link PathImpl}. - */ -public class PathImplTest extends TestCase { - - public void testEquals_root() { - PathImpl root = new PathImpl(); - PathImpl rootCopy = new PathImpl(); - assertEqualsAndHash(root, rootCopy); - } - - public void testEquals_foo() { - PathImpl foo = new PathImpl().append("foo"); - PathImpl fooCopy = new PathImpl().append("foo"); - assertEqualsAndHash(foo, fooCopy); - } - - public void testEqual_fooBarKey() { - PathImpl fooBarKey = new PathImpl().append("foo").appendKey("bar", "key"); - PathImpl fooBarKeyCopy = new PathImpl().append("foo").appendKey("bar", - "key"); - assertEqualsAndHash(fooBarKey, fooBarKeyCopy); - } - - public void testEquals_fooBar1() { - PathImpl fooBar1 = new PathImpl().append("foo").appendIndex("bar", 1); - PathImpl fooBar1Copy = new PathImpl().append("foo").appendIndex("bar", 1); - assertEqualsAndHash(fooBar1, fooBar1Copy); - } - - public void testEquals_not() { - PathImpl root = new PathImpl(); - PathImpl foo = new PathImpl().append("foo"); - assertNotEqual(root, foo); - - PathImpl fooBarKey = new PathImpl().append("foo").appendKey("bar", "key"); - PathImpl fooBarNote = new PathImpl().append("foo").appendKey("bar", "note"); - assertNotEqual(root, fooBarKey); - assertNotEqual(foo, fooBarKey); - assertNotEqual(fooBarNote, fooBarKey); - - PathImpl fooBar1 = new PathImpl().append("foo").appendIndex("bar", 1); - PathImpl fooBar2 = new PathImpl().append("foo").appendIndex("bar", 2); - assertNotEqual(root, fooBar1); - assertNotEqual(foo, fooBar1); - assertNotEqual(fooBarKey, fooBar1); - assertNotEqual(fooBar2, fooBar1); - } - - protected void assertNotEqual(Object lhs, Object rhs) { - assertFalse(lhs + "should not equal " + rhs, lhs.equals(rhs)); - } - - protected void assertEqualsAndHash(Object lhs, Object rhs) { - assertEquals(lhs, rhs); - assertEquals("hashCode", lhs.hashCode(), rhs.hashCode()); - } -}
diff --git a/user/test/com/google/gwt/validation/example/ExampleValidationClientGwtSuite.java b/user/test/com/google/gwt/validation/example/ExampleValidationClientGwtSuite.java deleted file mode 100644 index c13ee78..0000000 --- a/user/test/com/google/gwt/validation/example/ExampleValidationClientGwtSuite.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example; - -import com.google.gwt.junit.tools.GWTTestSuite; -import com.google.gwt.validation.example.client.AuthorTest; - -import junit.framework.Test; - -/** - * All Constraints tests that GWTTestCase. - */ -public class ExampleValidationClientGwtSuite { - public static Test suite() { - GWTTestSuite suite = new GWTTestSuite( - "Validation Example tests that require GWT"); - suite.addTestSuite(AuthorTest.class); - return suite; - } - -}
diff --git a/user/test/com/google/gwt/validation/example/ValidationExample.gwt.xml b/user/test/com/google/gwt/validation/example/ValidationExample.gwt.xml deleted file mode 100644 index a719210..0000000 --- a/user/test/com/google/gwt/validation/example/ValidationExample.gwt.xml +++ /dev/null
@@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not - use this file except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations under - the License. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <inherits name="org.hibernate.validator.HibernateValidator" /> - <source path="client"> - </source> - <replace-with - class="com.google.gwt.validation.example.client.ExampleValidatorFactory"> - <when-type-is class="javax.validation.ValidatorFactory" /> -</replace-with> -</module> \ No newline at end of file
diff --git a/user/test/com/google/gwt/validation/example/client/Author.java b/user/test/com/google/gwt/validation/example/client/Author.java deleted file mode 100644 index fc84f893f..0000000 --- a/user/test/com/google/gwt/validation/example/client/Author.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example.client; - -import javax.validation.constraints.Size; - -/** - * From the jsr spec. - */ -public class Author { - - private String firstName; - - @NotEmpty(message = "lastname must not be null") - private String lastName; - - @Size(max = 30) - private String company; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public String getCompany() { - return company; - } - - public void setCompany(String company) { - this.company = company; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/AuthorTest.java b/user/test/com/google/gwt/validation/example/client/AuthorTest.java deleted file mode 100644 index 374399d..0000000 --- a/user/test/com/google/gwt/validation/example/client/AuthorTest.java +++ /dev/null
@@ -1,152 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example.client; - -import com.google.gwt.junit.client.GWTTestCase; -import com.google.gwt.validation.example.client.ExampleValidatorFactory.ClientGroup; -import com.google.gwt.validation.example.client.ExampleValidatorFactory.ServerGroup; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.groups.Default; - -/** - * Tests for {@link Author}. - */ -public class AuthorTest extends GWTTestCase { - - private Author author; - - private Validator validator; - - @Override - public String getModuleName() { - return "com.google.gwt.validation.example.ValidationExample"; - } - - public void testGroup_clientGroup() throws Exception { - initValidAuthor(); - Set<ConstraintViolation<Author>> violations = validator.validate(author, - ClientGroup.class); - assertContentsAnyOrder("valid author", violations); - } - - public void testGroup_default() throws Exception { - initValidAuthor(); - Set<ConstraintViolation<Author>> violations = validator.validate(author, - Default.class); - assertContentsAnyOrder("valid author", violations); - } - - public void testGroup_empty() throws Exception { - initValidAuthor(); - Set<ConstraintViolation<Author>> violations = validator.validate(author); - assertContentsAnyOrder("valid author", violations); - } - - public void testGroup_serverGroup() throws Exception { - initValidAuthor(); - try { - validator.validate(author, ServerGroup.class); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - // expected - } - } - - public void testValidate_companySize31() { - initValidAuthor(); - author.setCompany("1234567890123456789012345678901"); - Set<ConstraintViolation<Author>> violations = validator.validate(author); - assertContentsAnyOrder("company size 31", toMessage(violations), - "size must be between 0 and 30" - ); - } - - public void testValidate_string() { - try { - validator.validate("some string"); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException expected) { - } - } - - public void testValidate_valid() { - initValidAuthor(); - Set<ConstraintViolation<Author>> violations = validator.validate(author); - assertContentsAnyOrder("valid author", violations); - } - - public void testValidateProperty_object() { - try { - validator.validateProperty(new Object(), "foo"); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException expected) { - } - } - - public void testValidateValue_string() { - try { - validator.validateValue(String.class, "notValid", "value"); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException expected) { - } - } - - @Override - protected final void gwtSetUp() throws Exception { - super.gwtSetUp(); - author = new Author(); - validator = Validation.buildDefaultValidatorFactory().getValidator(); - } - - protected void initValidAuthor() { - author.setFirstName("John"); - author.setLastName("Smith"); - author.setCompany("Google"); - } - - private <T> void assertContentsAnyOrder(String message, - Iterable<T> actual, T... expected) { - - List<T> expectedList = new ArrayList<T>(Arrays.asList(expected)); - message += "Expected to find " + expectedList + " but found " + actual; - for (T a : actual) { - if (expectedList.contains(a)) { - expectedList.remove(a); - } else { - fail(message); - } - } - if (!expectedList.isEmpty()) { - fail(message); - } - } - - private <T> List<String> toMessage(Set<ConstraintViolation<T>> violations) { - List<String> messages = new ArrayList<String>(); - for (ConstraintViolation<T> violation : violations) { - messages.add(violation.getMessage()); - } - return messages; - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/Book.java b/user/test/com/google/gwt/validation/example/client/Book.java deleted file mode 100644 index 4267176..0000000 --- a/user/test/com/google/gwt/validation/example/client/Book.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example.client; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import javax.validation.groups.Default; - -/** - * From the JSR 303 spec. - */ -public class Book { - private String title; - private String description; - @Valid - @NotNull - private Author author; - - @NotEmpty(groups = {FirstLevelCheck.class, Default.class}) - @Size(max = 30) - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Author getAuthor() { - return author; - } - - public void setAuthor(Author author) { - this.author = author; - } - - public String getDescription() { - return description; - } - - public void setAuthor(String description) { - this.description = description; - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/ExampleValidatorFactory.java b/user/test/com/google/gwt/validation/example/client/ExampleValidatorFactory.java deleted file mode 100644 index 05f1a70..0000000 --- a/user/test/com/google/gwt/validation/example/client/ExampleValidatorFactory.java +++ /dev/null
@@ -1,59 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.AbstractGwtValidatorFactory; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; - -import javax.validation.Validator; -import javax.validation.groups.Default; - -/** - * Factory to create the Validator specified by {@link GwtValidator}. - * - * GWT.create instances of this class - */ -public class ExampleValidatorFactory extends AbstractGwtValidatorFactory { - - /** - * Marks constraints that should run on the client. - */ - public interface ClientGroup { - } - - /** - * Validator Interface annotated with the list of classes to validate on the - * client. - */ - @GwtValidation( - value = {Author.class}, - groups = {Default.class, ClientGroup.class}) - public interface GwtValidator extends Validator { - } - - /** - * Marks constraints that should run on the server. - */ - public interface ServerGroup { - } - - @Override - public AbstractGwtValidator createValidator() { - return GWT.create(GwtValidator.class); - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/FirstLevelCheck.java b/user/test/com/google/gwt/validation/example/client/FirstLevelCheck.java deleted file mode 100644 index e560fee..0000000 --- a/user/test/com/google/gwt/validation/example/client/FirstLevelCheck.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example.client; - -/** - * A example group for validation. - */ -public interface FirstLevelCheck { - -}
diff --git a/user/test/com/google/gwt/validation/example/client/NotEmpty.java b/user/test/com/google/gwt/validation/example/client/NotEmpty.java deleted file mode 100644 index e21489c..0000000 --- a/user/test/com/google/gwt/validation/example/client/NotEmpty.java +++ /dev/null
@@ -1,75 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.example.client; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.Payload; -import javax.validation.ReportAsSingleViolation; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -/** - * The annotated element size must at least 1 and cannot be null. From the JSR - * 303 spec. - */ -@Documented -@NotNull -@Size(min = 1) -@ReportAsSingleViolation -@Constraint(validatedBy = NotEmpty.NotEmptyValidator.class) -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) -@Retention(RUNTIME) -public @interface NotEmpty { - String message() default "{com.google.gwt.validation.example.client.NotEmpty.message}"; - - Class<?>[] groups() default {}; - - Class<? extends Payload>[] payload() default {}; - - /** - * From the JSR 303 spec. - */ - @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) - @Retention(RUNTIME) - @Documented - @interface List { - NotEmpty[] value(); - } - /** - * Sample composite validator. - */ - class NotEmptyValidator implements ConstraintValidator<NotEmpty, String> { - public void initialize(NotEmpty constraintAnnotation) { - } - - public boolean isValid(String value, ConstraintValidatorContext context) { - return true; - } - } -}
diff --git a/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java b/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java deleted file mode 100644 index 06f5b14..0000000 --- a/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java +++ /dev/null
@@ -1,53 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.validation.rebind; - -import static com.google.gwt.validation.rebind.GwtSpecificValidatorCreator.getValidatorForType; - -import com.google.gwt.thirdparty.guava.common.collect.ImmutableList; -import com.google.gwt.validation.client.constraints.SizeValidatorForCollection; -import com.google.gwt.validation.client.constraints.SizeValidatorForString; - -import junit.framework.TestCase; - -import java.lang.annotation.Annotation; -import java.util.List; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Size; - -/** - * NonGWT tests for {@link GwtSpecificValidatorCreator}. - */ -public class GwtSpecificValidatorCreatorTest extends TestCase { - - ImmutableList<Class<? extends ConstraintValidator<Size, ?>>> sizeValidators = ImmutableList.<Class<? extends ConstraintValidator<Size, ?>>> of( - SizeValidatorForCollection.class, SizeValidatorForString.class); - - public void testGetValidatorForType_collection() throws Exception { - Class<? extends ConstraintValidator<? extends Annotation, ?>> expected = SizeValidatorForCollection.class; - Class<? extends ConstraintValidator<Size, ?>> actual = getValidatorForType( - List.class, sizeValidators); - assertEquals(expected, actual); - } - - public void testGetValidatorForType_string() throws Exception { - Class<String> target = String.class; - Class<? extends ConstraintValidator<Size, ?>> actual = getValidatorForType( - target, sizeValidators); - assertEquals(SizeValidatorForString.class, actual); - } -}