You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by si...@apache.org on 2013/01/30 21:48:26 UTC
svn commit: r1440659 - in /incubator/onami/sandbox/validation/src:
main/java/org/apache/onami/validation/ test/java/org/apache/onami/validation/
Author: simonetripodi
Date: Wed Jan 30 20:48:25 2013
New Revision: 1440659
URL: http://svn.apache.org/viewvc?rev=1440659&view=rev
Log:
[ONAMI-72] #comment code format aligned to Onami conventions #resolve
Modified:
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ConfigurationStateProvider.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/GuiceAwareConstraintValidatorFactory.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/Validate.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidateMethodInterceptor.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidationModule.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorFactoryProvider.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorProvider.java
incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/package-info.java
incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Country.java
incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyCountryDao.java
incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyException.java
incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/GuiceAwareValidationTestCase.java
incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Insert.java
incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Update.java
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ConfigurationStateProvider.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ConfigurationStateProvider.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ConfigurationStateProvider.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ConfigurationStateProvider.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.inject.Inject;
import javax.inject.Provider;
@@ -29,12 +32,12 @@ import org.apache.bval.jsr303.Configurat
/**
* The {@code javax.validation.spi.ConfigurationState} provider implementation.
- *
- * @version $Id$
*/
-public final class ConfigurationStateProvider implements Provider<ConfigurationState> {
+public final class ConfigurationStateProvider
+ implements Provider<ConfigurationState>
+{
- @com.google.inject.Inject(optional = true)
+ @com.google.inject.Inject( optional = true )
private BootstrapState bootstrapState;
@Inject
@@ -49,34 +52,40 @@ public final class ConfigurationStatePro
@Inject
private ConstraintValidatorFactory constraintValidatorFactory;
- public void setBootstrapState(BootstrapState bootstrapState) {
+ public void setBootstrapState( BootstrapState bootstrapState )
+ {
this.bootstrapState = bootstrapState;
}
- public void setValidationProvider(ValidationProvider<?> validationProvider) {
+ public void setValidationProvider( ValidationProvider<?> validationProvider )
+ {
this.validationProvider = validationProvider;
}
- public void setTraversableResolver(TraversableResolver traversableResolver) {
+ public void setTraversableResolver( TraversableResolver traversableResolver )
+ {
this.traversableResolver = traversableResolver;
}
- public void setMessageInterpolator(MessageInterpolator messageInterpolator) {
+ public void setMessageInterpolator( MessageInterpolator messageInterpolator )
+ {
this.messageInterpolator = messageInterpolator;
}
- public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) {
+ public void setConstraintValidatorFactory( ConstraintValidatorFactory constraintValidatorFactory )
+ {
this.constraintValidatorFactory = constraintValidatorFactory;
}
/**
* {@inheritDoc}
*/
- public ConfigurationState get() {
- ConfigurationImpl configuration = new ConfigurationImpl(this.bootstrapState, this.validationProvider);
- configuration.traversableResolver(this.traversableResolver);
- configuration.messageInterpolator(this.messageInterpolator);
- configuration.constraintValidatorFactory(this.constraintValidatorFactory);
+ public ConfigurationState get()
+ {
+ ConfigurationImpl configuration = new ConfigurationImpl( this.bootstrapState, this.validationProvider );
+ configuration.traversableResolver( this.traversableResolver );
+ configuration.messageInterpolator( this.messageInterpolator );
+ configuration.constraintValidatorFactory( this.constraintValidatorFactory );
return configuration;
}
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/GuiceAwareConstraintValidatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/GuiceAwareConstraintValidatorFactory.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/GuiceAwareConstraintValidatorFactory.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/GuiceAwareConstraintValidatorFactory.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -24,26 +27,27 @@ import javax.validation.ConstraintValida
import com.google.inject.Injector;
/**
- * {@code javax.validation.ConstraintValidatorFactory} implementation that
- * relies on Google Guice.
- *
- * @version $Id$
+ * {@code javax.validation.ConstraintValidatorFactory} implementation that relies on Google Guice.
*/
@Singleton
-final class GuiceAwareConstraintValidatorFactory implements ConstraintValidatorFactory {
+final class GuiceAwareConstraintValidatorFactory
+ implements ConstraintValidatorFactory
+{
@Inject
private Injector injector;
- public void setInjector(Injector injector) {
+ public void setInjector( Injector injector )
+ {
this.injector = injector;
}
/**
* {@inheritDoc}
*/
- public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
- return this.injector.getInstance(key);
+ public <T extends ConstraintValidator<?, ?>> T getInstance( Class<T> key )
+ {
+ return this.injector.getInstance( key );
}
}
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/Validate.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/Validate.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/Validate.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/Validate.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -27,13 +30,12 @@ import com.google.inject.BindingAnnotati
/**
* Marker for methods which arguments have to be validated.
- *
- * @version $Id$
*/
@BindingAnnotation
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD })
-public @interface Validate {
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.METHOD } )
+public @interface Validate
+{
/**
* The groups have to be validated, empty by default.
@@ -43,8 +45,7 @@ public @interface Validate {
Class<?>[] groups() default {};
/**
- * Marks if the returned object by the intercepted method execution has to
- * be validated, false by default.
+ * Marks if the returned object by the intercepted method execution has to be validated, false by default.
*
* @return false by default.
*/
@@ -53,16 +54,13 @@ public @interface Validate {
/**
* The exception re-thrown when an error occurs during the validation.
*
- * @return the exception re-thrown when an error occurs during the
- * validation.
+ * @return the exception re-thrown when an error occurs during the validation.
*/
Class<? extends Throwable> rethrowExceptionsAs() default ConstraintViolationException.class;
/**
- * A custom error message when throwing the custom exception.
- *
- * It supports java.util.Formatter place holders, intercepted method
- * arguments will be used as message format arguments.
+ * A custom error message when throwing the custom exception. It supports java.util.Formatter place holders,
+ * intercepted method arguments will be used as message format arguments.
*
* @return a custom error message when throwing the custom exception.
* @see java.util.Formatter#format(String, Object...)
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidateMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidateMethodInterceptor.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidateMethodInterceptor.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidateMethodInterceptor.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
@@ -34,14 +37,14 @@ import org.apache.bval.jsr303.extensions
/**
* Method interceptor for {@link Validate} annotation.
- *
- * @version $Id$
*/
-public final class ValidateMethodInterceptor implements MethodInterceptor {
+public final class ValidateMethodInterceptor
+ implements MethodInterceptor
+{
- private static final Class<?>[] CAUSE_TYPES = new Class[]{ Throwable.class };
+ private static final Class<?>[] CAUSE_TYPES = new Class[] { Throwable.class };
- private static final Class<?>[] MESSAGE_CAUSE_TYPES = new Class[]{ String.class, Throwable.class };
+ private static final Class<?>[] MESSAGE_CAUSE_TYPES = new Class[] { String.class, Throwable.class };
/**
* The {@link ValidatorFactory} reference.
@@ -54,18 +57,21 @@ public final class ValidateMethodInterce
*
* @param validatorFactory the {@link ValidatorFactory} reference
*/
- public void setValidatorFactory(ValidatorFactory validatorFactory) {
+ public void setValidatorFactory( ValidatorFactory validatorFactory )
+ {
this.validatorFactory = validatorFactory;
}
/**
* {@inheritDoc}
*/
- public Object invoke(MethodInvocation invocation) throws Throwable {
- Validate validate = invocation.getMethod().getAnnotation(Validate.class);
+ public Object invoke( MethodInvocation invocation )
+ throws Throwable
+ {
+ Validate validate = invocation.getMethod().getAnnotation( Validate.class );
Validator validator = this.validatorFactory.getValidator();
- MethodValidator methodValidator = validator.unwrap(MethodValidator.class);
+ MethodValidator methodValidator = validator.unwrap( MethodValidator.class );
Set<ConstraintViolation<?>> constraintViolations = new HashSet<ConstraintViolation<?>>();
Class<?> clazz = invocation.getMethod().getDeclaringClass();
@@ -73,36 +79,31 @@ public final class ValidateMethodInterce
Object[] arguments = invocation.getArguments();
Class<?>[] groups = validate.groups();
- constraintViolations.addAll(methodValidator.validateParameters(clazz,
- method,
- arguments,
- groups));
-
- if (!constraintViolations.isEmpty()) {
- throw getException(new ConstraintViolationException(
- String.format("Validation error when calling method '%s' with arguments %s",
- method,
- Arrays.deepToString(arguments)),
- constraintViolations),
- validate.rethrowExceptionsAs(),
- validate.exceptionMessage(),
- arguments);
+ constraintViolations.addAll( methodValidator.validateParameters( clazz, method, arguments, groups ) );
+
+ if ( !constraintViolations.isEmpty() )
+ {
+ throw getException( new ConstraintViolationException(
+ String.format( "Validation error when calling method '%s' with arguments %s",
+ method,
+ Arrays.deepToString( arguments ) ),
+ constraintViolations ),
+ validate.rethrowExceptionsAs(), validate.exceptionMessage(), arguments );
}
Object returnedValue = invocation.proceed();
- if (validate.validateReturnedValue()) {
- constraintViolations.addAll(methodValidator.validateReturnedValue(clazz, method, returnedValue, groups));
-
- if (!constraintViolations.isEmpty()) {
- throw getException(new ConstraintViolationException(
- String.format("Method '%s' returned a not valid value %s",
- method,
- returnedValue),
- constraintViolations),
- validate.rethrowExceptionsAs(),
- validate.exceptionMessage(),
- arguments);
+ if ( validate.validateReturnedValue() )
+ {
+ constraintViolations.addAll( methodValidator.validateReturnedValue( clazz, method, returnedValue, groups ) );
+
+ if ( !constraintViolations.isEmpty() )
+ {
+ throw getException( new ConstraintViolationException(
+ String.format( "Method '%s' returned a not valid value %s",
+ method, returnedValue ),
+ constraintViolations ),
+ validate.rethrowExceptionsAs(), validate.exceptionMessage(), arguments );
}
}
@@ -110,19 +111,21 @@ public final class ValidateMethodInterce
}
/**
- * Define the {@link Throwable} has to be thrown when a validation error
- * occurs and the user defined the custom error wrapper.
+ * Define the {@link Throwable} has to be thrown when a validation error occurs and the user defined the custom
+ * error wrapper.
*
* @param exception the occurred validation error.
* @param exceptionWrapperClass the user defined custom error wrapper.
* @return the {@link Throwable} has o be thrown.
*/
- private static Throwable getException(ConstraintViolationException exception,
- Class<? extends Throwable> exceptionWrapperClass,
- String exceptionMessage,
- Object[] arguments) {
+ private static Throwable getException( ConstraintViolationException exception,
+ Class<? extends Throwable> exceptionWrapperClass,
+ String exceptionMessage,
+ Object[] arguments )
+ {
// check the thrown exception is of same re-throw type
- if (exceptionWrapperClass == ConstraintViolationException.class) {
+ if ( exceptionWrapperClass == ConstraintViolationException.class )
+ {
return exception;
}
@@ -133,43 +136,56 @@ public final class ValidateMethodInterce
Object[] initargs;
Class<?>[] initargsType;
- if (exceptionMessage.length() != 0) {
- errorMessage = String.format(exceptionMessage, arguments);
- initargs = new Object[]{ errorMessage, exception };
+ if ( exceptionMessage.length() != 0 )
+ {
+ errorMessage = String.format( exceptionMessage, arguments );
+ initargs = new Object[] { errorMessage, exception };
initargsType = MESSAGE_CAUSE_TYPES;
- } else {
- initargs = new Object[]{ exception };
+ }
+ else
+ {
+ initargs = new Object[] { exception };
initargsType = CAUSE_TYPES;
}
- Constructor<? extends Throwable> exceptionConstructor = getMatchingConstructor(exceptionWrapperClass, initargsType);
- if (exceptionConstructor != null) {
- try {
- rethrowEx = exceptionConstructor.newInstance(initargs);
- } catch (Exception e) {
- errorMessage = String.format("Impossible to re-throw '%s', it needs the constructor with %s argument(s).",
- exceptionWrapperClass.getName(),
- Arrays.toString(initargsType));
- rethrowEx = new RuntimeException(errorMessage, e);
+ Constructor<? extends Throwable> exceptionConstructor =
+ getMatchingConstructor( exceptionWrapperClass, initargsType );
+ if ( exceptionConstructor != null )
+ {
+ try
+ {
+ rethrowEx = exceptionConstructor.newInstance( initargs );
}
- } else {
- errorMessage = String.format("Impossible to re-throw '%s', it needs the constructor with %s or %s argument(s).",
- exceptionWrapperClass.getName(),
- Arrays.toString(CAUSE_TYPES),
- Arrays.toString(MESSAGE_CAUSE_TYPES));
- rethrowEx = new RuntimeException(errorMessage);
+ catch ( Exception e )
+ {
+ errorMessage =
+ String.format( "Impossible to re-throw '%s', it needs the constructor with %s argument(s).",
+ exceptionWrapperClass.getName(), Arrays.toString( initargsType ) );
+ rethrowEx = new RuntimeException( errorMessage, e );
+ }
+ }
+ else
+ {
+ errorMessage =
+ String.format( "Impossible to re-throw '%s', it needs the constructor with %s or %s argument(s).",
+ exceptionWrapperClass.getName(), Arrays.toString( CAUSE_TYPES ),
+ Arrays.toString( MESSAGE_CAUSE_TYPES ) );
+ rethrowEx = new RuntimeException( errorMessage );
}
return rethrowEx;
}
- @SuppressWarnings("unchecked")
- private static <E extends Throwable> Constructor<E> getMatchingConstructor(Class<E> type,
- Class<?>[] argumentsType) {
+ @SuppressWarnings( "unchecked" )
+ private static <E extends Throwable> Constructor<E> getMatchingConstructor( Class<E> type, Class<?>[] argumentsType )
+ {
Class<? super E> currentType = type;
- while (Object.class != currentType) {
- for (Constructor<?> constructor : currentType.getConstructors()) {
- if (Arrays.equals(argumentsType, constructor.getParameterTypes())) {
+ while ( Object.class != currentType )
+ {
+ for ( Constructor<?> constructor : currentType.getConstructors() )
+ {
+ if ( Arrays.equals( argumentsType, constructor.getParameterTypes() ) )
+ {
return (Constructor<E>) constructor;
}
}
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidationModule.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidationModule.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidationModule.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidationModule.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
@@ -35,30 +38,33 @@ import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matchers;
/**
- * The Google-Guice module for Apache BVal.
- *
- * @version $Id$
+ * The Google-Guice Validation module.
*/
-public final class ValidationModule extends AbstractModule {
+public final class ValidationModule
+ extends AbstractModule
+{
/**
* {@inheritDoc}
*/
@Override
- protected void configure() {
+ protected void configure()
+ {
// apache bval bootstrap
- this.bind(MessageInterpolator.class).to(DefaultMessageInterpolator.class).in(Scopes.SINGLETON);
- this.bind(TraversableResolver.class).to(DefaultTraversableResolver.class).in(Scopes.SINGLETON);
- this.bind(ConstraintValidatorFactory.class).to(GuiceAwareConstraintValidatorFactory.class);
- this.bind(new TypeLiteral<ValidationProvider<?>>() {}).to(ApacheValidationProvider.class).in(Scopes.SINGLETON);
- this.bind(ConfigurationState.class).toProvider(ConfigurationStateProvider.class).in(Scopes.SINGLETON);
- this.bind(ValidatorFactory.class).toProvider(ValidatorFactoryProvider.class).in(Scopes.SINGLETON);
- this.bind(Validator.class).toProvider(ValidatorProvider.class);
+ this.bind( MessageInterpolator.class ).to( DefaultMessageInterpolator.class ).in( Scopes.SINGLETON );
+ this.bind( TraversableResolver.class ).to( DefaultTraversableResolver.class ).in( Scopes.SINGLETON );
+ this.bind( ConstraintValidatorFactory.class ).to( GuiceAwareConstraintValidatorFactory.class );
+ this.bind( new TypeLiteral<ValidationProvider<?>>()
+ {
+ } ).to( ApacheValidationProvider.class ).in( Scopes.SINGLETON );
+ this.bind( ConfigurationState.class ).toProvider( ConfigurationStateProvider.class ).in( Scopes.SINGLETON );
+ this.bind( ValidatorFactory.class ).toProvider( ValidatorFactoryProvider.class ).in( Scopes.SINGLETON );
+ this.bind( Validator.class ).toProvider( ValidatorProvider.class );
// AOP stuff
MethodInterceptor validateMethodInterceptor = new ValidateMethodInterceptor();
- this.binder().requestInjection(validateMethodInterceptor);
- this.bindInterceptor(Matchers.any(), Matchers.annotatedWith(Validate.class), validateMethodInterceptor);
+ this.binder().requestInjection( validateMethodInterceptor );
+ this.bindInterceptor( Matchers.any(), Matchers.annotatedWith( Validate.class ), validateMethodInterceptor );
}
}
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorFactoryProvider.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorFactoryProvider.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorFactoryProvider.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.inject.Inject;
import javax.inject.Provider;
@@ -26,24 +29,26 @@ import org.apache.bval.jsr303.ApacheVali
/**
* Validator Factory guice provider implementation.
- *
- * @version $Id$
*/
@Singleton
-final class ValidatorFactoryProvider implements Provider<ValidatorFactory> {
+final class ValidatorFactoryProvider
+ implements Provider<ValidatorFactory>
+{
@Inject
private ConfigurationState configurationState;
- public void setConfigurationState(ConfigurationState configurationState) {
+ public void setConfigurationState( ConfigurationState configurationState )
+ {
this.configurationState = configurationState;
}
/**
* {@inheritDoc}
*/
- public ValidatorFactory get() {
- return new ApacheValidationProvider().buildValidatorFactory(this.configurationState);
+ public ValidatorFactory get()
+ {
+ return new ApacheValidationProvider().buildValidatorFactory( this.configurationState );
}
}
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorProvider.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorProvider.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorProvider.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/ValidatorProvider.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.inject.Inject;
import javax.inject.Provider;
@@ -24,11 +27,11 @@ import javax.validation.ValidatorFactory
/**
* Validator guice provider implementation.
- *
- * @version $Id$
*/
@Singleton
-final class ValidatorProvider implements Provider<Validator> {
+final class ValidatorProvider
+ implements Provider<Validator>
+{
/**
* The validator reference.
@@ -36,14 +39,16 @@ final class ValidatorProvider implements
@Inject
private ValidatorFactory validatorFactory;
- public void setValidatorFactory(ValidatorFactory validatorFactory) {
+ public void setValidatorFactory( ValidatorFactory validatorFactory )
+ {
this.validatorFactory = validatorFactory;
}
/**
* {@inheritDoc}
*/
- public Validator get() {
+ public Validator get()
+ {
return this.validatorFactory.getValidator();
}
Modified: incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/package-info.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/package-info.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/package-info.java (original)
+++ incubator/onami/sandbox/validation/src/main/java/org/apache/onami/validation/package-info.java Wed Jan 30 20:48:25 2013
@@ -1,23 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.
*/
/**
* Contains Apache BVal support for Google-Guice.
- *
- * @version $Id$
*/
package org.apache.onami.validation;
Modified: incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Country.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Country.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Country.java (original)
+++ incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Country.java Wed Jan 30 20:48:25 2013
@@ -1,3 +1,5 @@
+package org.apache.onami.validation;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -7,24 +9,20 @@
* "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
+ * 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.
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
- *
- *
- * @version $Id$
*/
public class Country {
Modified: incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyCountryDao.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyCountryDao.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyCountryDao.java (original)
+++ incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyCountryDao.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import javax.inject.Singleton;
import javax.validation.Valid;
@@ -24,33 +27,31 @@ import javax.validation.constraints.Size
import org.apache.onami.validation.Validate;
/**
- *
*
- * @version $Id$
*/
@Singleton
-public class DummyCountryDao {
+public class DummyCountryDao
+{
- @Validate(
- groups = { Insert.class },
- validateReturnedValue = true
- )
- public Country insertCountry(@NotNull(groups = { Insert.class }) String name,
- @NotNull(groups = { Insert.class }) @Size(max = 2, groups = { Insert.class, Update.class }) String iso2Code,
- @NotNull(groups = { Insert.class }) @Size(max = 3, groups = { Insert.class, Update.class }) String iso3Code) {
+ @Validate( groups = { Insert.class }, validateReturnedValue = true )
+ public Country insertCountry( @NotNull( groups = { Insert.class } )
+ String name, @NotNull( groups = { Insert.class } )
+ @Size( max = 2, groups = { Insert.class, Update.class } )
+ String iso2Code, @NotNull( groups = { Insert.class } )
+ @Size( max = 3, groups = { Insert.class, Update.class } )
+ String iso3Code )
+ {
Country country = new Country();
- country.setName(name);
- country.setIso2Code(iso2Code);
- country.setIso3Code(iso3Code);
+ country.setName( name );
+ country.setIso2Code( iso2Code );
+ country.setIso3Code( iso3Code );
return country;
}
- @Validate(
- groups = { Update.class },
- rethrowExceptionsAs = DummyException.class,
- exceptionMessage = "This is just a dummy message %s"
- )
- public int updateCountry(@Valid Country country) {
+ @Validate( groups = { Update.class }, rethrowExceptionsAs = DummyException.class, exceptionMessage = "This is just a dummy message %s" )
+ public int updateCountry( @Valid
+ Country country )
+ {
return 0;
}
Modified: incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyException.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyException.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyException.java (original)
+++ incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/DummyException.java Wed Jan 30 20:48:25 2013
@@ -1,36 +1,41 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
/**
- *
*
- * @version $Id$
*/
-public final class DummyException extends Exception {
+public final class DummyException
+ extends Exception
+{
private static final long serialVersionUID = 1L;
- public DummyException(Throwable cause) {
- super(cause);
+ public DummyException( Throwable cause )
+ {
+ super( cause );
}
- public DummyException(String message, Throwable cause) {
- super(message, cause);
+ public DummyException( String message, Throwable cause )
+ {
+ super( message, cause );
}
}
Modified: incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/GuiceAwareValidationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/GuiceAwareValidationTestCase.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/GuiceAwareValidationTestCase.java (original)
+++ incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/GuiceAwareValidationTestCase.java Wed Jan 30 20:48:25 2013
@@ -1,20 +1,23 @@
+package org.apache.onami.validation;
+
/*
- * 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
+ * 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
+ * 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.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-package org.apache.onami.validation;
import java.util.Set;
@@ -30,11 +33,11 @@ import junit.framework.TestCase;
import com.google.inject.Guice;
/**
- *
*
- * @version $Id$
*/
-public final class GuiceAwareValidationTestCase extends TestCase {
+public final class GuiceAwareValidationTestCase
+ extends TestCase
+{
@Inject
private Validator validator;
@@ -42,55 +45,71 @@ public final class GuiceAwareValidationT
@Inject
private DummyCountryDao dummyCountryDao;
- public void setValidator(Validator validator) {
+ public void setValidator( Validator validator )
+ {
this.validator = validator;
}
- public void setDummyCountryDao(DummyCountryDao dummyCountryDao) {
+ public void setDummyCountryDao( DummyCountryDao dummyCountryDao )
+ {
this.dummyCountryDao = dummyCountryDao;
}
@Override
- protected void setUp() throws Exception {
- Guice.createInjector(new ValidationModule()).injectMembers(this);
+ protected void setUp()
+ throws Exception
+ {
+ Guice.createInjector( new ValidationModule() ).injectMembers( this );
}
@Override
- protected void tearDown() throws Exception {
+ protected void tearDown()
+ throws Exception
+ {
this.validator = null;
this.dummyCountryDao = null;
}
- public void testInjectedValidation() {
+ public void testInjectedValidation()
+ {
Country country = new Country();
- country.setName("Italy");
- country.setIso2Code("it");
- country.setIso3Code("ita");
+ country.setName( "Italy" );
+ country.setIso2Code( "it" );
+ country.setIso3Code( "ita" );
- Set<ConstraintViolation<Country>> violations = this.validator.validate(country);
- assertTrue(violations.isEmpty());
+ Set<ConstraintViolation<Country>> violations = this.validator.validate( country );
+ assertTrue( violations.isEmpty() );
}
- public void testAOPInjectedValidation() {
- this.dummyCountryDao.insertCountry("Italy", "it", "ita");
+ public void testAOPInjectedValidation()
+ {
+ this.dummyCountryDao.insertCountry( "Italy", "it", "ita" );
}
- public void testAOPInjectedFailedValidation() {
- try {
- this.dummyCountryDao.insertCountry("Italy", "ita", "ita");
- fail("javax.validation.ConstraintViolationException expected");
- } catch (ConstraintViolationException cve) {
+ public void testAOPInjectedFailedValidation()
+ {
+ try
+ {
+ this.dummyCountryDao.insertCountry( "Italy", "ita", "ita" );
+ fail( "javax.validation.ConstraintViolationException expected" );
+ }
+ catch ( ConstraintViolationException cve )
+ {
// do nothing
}
}
- public void testRethrowWrappedException() {
- try {
- this.dummyCountryDao.updateCountry(new Country());
- fail("org.apache.bval.guice.DummyException expected");
- } catch (Exception e) {
- assertEquals(DummyException.class, e.getClass());
- assertTrue(e.getMessage().startsWith("This is just a dummy message "));
+ public void testRethrowWrappedException()
+ {
+ try
+ {
+ this.dummyCountryDao.updateCountry( new Country() );
+ fail( "org.apache.bval.guice.DummyException expected" );
+ }
+ catch ( Exception e )
+ {
+ assertEquals( DummyException.class, e.getClass() );
+ assertTrue( e.getMessage().startsWith( "This is just a dummy message " ) );
}
}
Modified: incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Insert.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Insert.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Insert.java (original)
+++ incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Insert.java Wed Jan 30 20:48:25 2013
@@ -1,3 +1,5 @@
+package org.apache.onami.validation;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -7,21 +9,18 @@
* "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
+ * 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.
+ * under the License.
*/
-package org.apache.onami.validation;
/**
- *
*
- * @version $Id$
*/
public interface Insert {
Modified: incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Update.java
URL: http://svn.apache.org/viewvc/incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Update.java?rev=1440659&r1=1440658&r2=1440659&view=diff
==============================================================================
--- incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Update.java (original)
+++ incubator/onami/sandbox/validation/src/test/java/org/apache/onami/validation/Update.java Wed Jan 30 20:48:25 2013
@@ -1,3 +1,5 @@
+package org.apache.onami.validation;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -7,21 +9,18 @@
* "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
+ * 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.
+ * under the License.
*/
-package org.apache.onami.validation;
/**
- *
*
- * @version $Id$
*/
public interface Update {