Use platform line separators in exception messages Otherwise the stacktraces include mixed line separators making writing assertions brittle.
POLYGENE-270 Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/42b3d335 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/42b3d335 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/42b3d335 Branch: refs/heads/master Commit: 42b3d335875ba6a0882fd41d008c1da8d6dc604f Parents: d0c1ff5 Author: Paul Merlin <[email protected]> Authored: Fri Jul 21 10:09:24 2017 +0200 Committer: Paul Merlin <[email protected]> Committed: Fri Jul 21 10:09:24 2017 +0200 ---------------------------------------------------------------------- .../polygene/api/composite/DecoratorMixin.java | 12 +++++----- .../composite/InvalidCompositeException.java | 23 ++++++++++---------- .../composite/NoSuchCompositeTypeException.java | 10 +++++---- .../ConstraintViolationException.java | 9 ++++---- .../api/object/NoSuchObjectTypeException.java | 5 +++-- .../ConcurrentEntityModificationException.java | 5 +++-- .../bootstrap/AssemblyReportException.java | 7 +++--- .../apache/polygene/bootstrap/Energy4Java.java | 3 ++- .../bootstrap/CompositeAssemblyImpl.java | 2 +- .../composite/CompositeMethodsModel.java | 11 ++++++---- .../runtime/composite/ConstructorModel.java | 8 ++++--- .../runtime/injection/InjectedFieldModel.java | 8 ++++--- .../polygene/bootstrap/ErrorReportingTest.java | 22 ++++++++++--------- ...currentEntityStateModificationException.java | 4 +++- 14 files changed, 75 insertions(+), 54 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/api/src/main/java/org/apache/polygene/api/composite/DecoratorMixin.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/DecoratorMixin.java b/core/api/src/main/java/org/apache/polygene/api/composite/DecoratorMixin.java index 1707f3e..7e24da5 100644 --- a/core/api/src/main/java/org/apache/polygene/api/composite/DecoratorMixin.java +++ b/core/api/src/main/java/org/apache/polygene/api/composite/DecoratorMixin.java @@ -37,6 +37,8 @@ import org.apache.polygene.api.injection.scope.Uses; public class DecoratorMixin implements InvocationHandler { + private static final String NL = System.getProperty( "line.separator" ); + private Object delegate; public DecoratorMixin( @Uses Object delegate ) @@ -78,15 +80,15 @@ public class DecoratorMixin private String constructMessage( Method method, Object[] args ) { StringBuilder builder = new StringBuilder(); - builder.append( "\nmethod: " ); + builder.append( NL ).append( "method: " ); builder.append( method.getDeclaringClass().getName() ); builder.append( "." ); builder.append( method.getName() ); - builder.append( "\ndelegate: " ); + builder.append( NL ).append( "delegate: " ); builder.append( delegate ); - builder.append( "\ndelegateType: " ); + builder.append( NL ).append( "delegateType: " ); builder.append( delegate == null ? "n/a" : delegate.getClass().getName() ); - builder.append( "\narguments: \n" ); + builder.append( NL ).append( "arguments:" ).append( NL ); for( Object arg : args ) { builder.append( " " ); @@ -99,7 +101,7 @@ public class DecoratorMixin { builder.append( argClass.getName() ); } - builder.append( '\n' ); + builder.append( NL ); } return builder.toString(); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/api/src/main/java/org/apache/polygene/api/composite/InvalidCompositeException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/InvalidCompositeException.java b/core/api/src/main/java/org/apache/polygene/api/composite/InvalidCompositeException.java index c7657b3..4d1ead2 100644 --- a/core/api/src/main/java/org/apache/polygene/api/composite/InvalidCompositeException.java +++ b/core/api/src/main/java/org/apache/polygene/api/composite/InvalidCompositeException.java @@ -34,6 +34,7 @@ import org.apache.polygene.api.structure.ModuleDescriptor; */ public class InvalidCompositeException extends RuntimeException { + private static final String NL = System.getProperty( "line.separator" ); private static boolean aggregateProblems = true; private static ThreadLocal<ArrayList<InvalidCompositeException>> report = ThreadLocal.withInitial( ArrayList::new ); private ModuleDescriptor module; @@ -73,13 +74,13 @@ public class InvalidCompositeException extends RuntimeException public String getMessage() { String typeNames = typesString(); - String primary = primaryType == null ? "" : " primary: " + primaryType.toGenericString() + "\n"; + String primary = primaryType == null ? "" : " primary: " + primaryType.toGenericString() + NL; String methodName = memberString(); - String message = super.getMessage() == null ? "" : " message: " + super.getMessage() + "\n"; - String fragment = fragmentClass == null ? "" : " fragmentClass: " + fragmentClass.getName() + "\n"; - String valueType = this.valueType == null ? "" : " valueType: " + this.valueType.getTypeName() + "\n"; - String module = this.module == null ? "" : " layer: " + this.module.layer().name() + "\n module: " - + this.module.name() + "\n"; + String message = super.getMessage() == null ? "" : " message: " + super.getMessage() + NL; + String fragment = fragmentClass == null ? "" : " fragmentClass: " + fragmentClass.getName() + NL; + String valueType = this.valueType == null ? "" : " valueType: " + this.valueType.getTypeName() + NL; + String module = this.module == null ? "" : " layer: " + this.module.layer().name() + NL + " module: " + + this.module.name() + NL; return message + module + primary + fragment + methodName + valueType + typeNames; } @@ -93,7 +94,7 @@ public class InvalidCompositeException extends RuntimeException + types.stream() .map( Class::getSimpleName ) .collect( Collectors.joining( ",", "[", "]" ) ) - + "\n"; + + NL; } private String memberString() @@ -108,12 +109,12 @@ public class InvalidCompositeException extends RuntimeException String parameters = Arrays.stream( method.getParameters() ) .map( p -> p.getType().getSimpleName() + " " + p.getName() ) .collect( Collectors.joining( ", ", "(", ")" ) ); - return " method: " + method.getReturnType().getSimpleName() + " " + method.getName() + parameters + "\n"; + return " method: " + method.getReturnType().getSimpleName() + " " + method.getName() + parameters + NL; } if( member instanceof Field ) { Field field = (Field) member; - return " field: " + field.getType().getSimpleName() + " " + field.getName() + "\n"; + return " field: " + field.getType().getSimpleName() + " " + field.getName() + NL; } return member.toString(); } @@ -122,10 +123,10 @@ public class InvalidCompositeException extends RuntimeException { if( report.get().size() > 0 ) { - String reportText = "\nComposition Problems Report:\n" + String reportText = NL + "Composition Problems Report:" + NL + report.get().stream() .map( Throwable::getMessage ) - .map( m -> m + "\n--\n" ) + .map( m -> m + NL + "--" + NL ) .collect( Collectors.joining() ); report.set( new ArrayList<>() ); return reportText; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java index 1d6f155..2fdaea3 100644 --- a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java +++ b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java @@ -32,6 +32,8 @@ import static java.util.stream.Collectors.joining; */ public abstract class NoSuchCompositeTypeException extends InvalidApplicationException { + private static final String NL = System.getProperty( "line.separator" ); + private final String compositeType; private final String moduleName; private final String visibleTypes; @@ -40,7 +42,7 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc protected NoSuchCompositeTypeException( String metaType, String compositeType, ModuleDescriptor module ) { - super( "\n\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + module.name() + "]." ); + super( NL + "\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + module.name() + "]." ); this.metaType = metaType; this.compositeType = compositeType; this.moduleName = module.name(); @@ -71,7 +73,7 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc @Override public String getMessage() { - return super.getMessage() + "\n" + candidateTypes + "\n" + visibleTypes; + return super.getMessage() + NL + candidateTypes + NL + visibleTypes; } private String formatVisibleTypes( TypeLookup typeLookup ) @@ -85,7 +87,7 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc } ) .sorted() .distinct() - .collect( joining( "\n", "\tVisible " + metaType + " types are:\n", "" ) ); + .collect( joining( NL, "\tVisible " + metaType + " types are:" + NL, "" ) ); } private String findCandidateTypes( ModuleDescriptor module ) @@ -102,7 +104,7 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc return "\t\t[ " + typeName + "] in [" + descriptor.module().name() + "] with visibility " + descriptor.visibility(); } ) .distinct() - .collect( joining( "\n", "\tInvisible " + metaType + " types are:\n", "" ) ); + .collect( joining( NL, "\tInvisible " + metaType + " types are:" + NL, "" ) ); } protected abstract Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java index 0eecf04..83f9a8c 100644 --- a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java +++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java @@ -47,11 +47,12 @@ import org.apache.polygene.api.util.Classes; */ public class ConstraintViolationException extends IllegalArgumentException { + private static final String NL = System.getProperty( "line.separator" ); private static final boolean longNames = Boolean.getBoolean( "polygene.constraints.longNames" ); - private static final String DEFAULT_PATTERN = "\n\tConstraint Violation(s) in {0} of types [{3}].\n"; - private static final String ENTITY_DEFAULT_PATTERN = "\n\tConstraint Violation(s) in entity {0} with id=[{2}].\n"; - private static final String SERVICE_DEFAULT_PATTERN = "\n\tConstraint Violation(s) in service {0} with id=[{2}].\n"; - private static final String MIXIN_DEFAULT_PATTERN = "\t\t@{2}({3}) on {0}.{1}(). Parameter [{4}] does not allow value [{5}].\n"; + private static final String DEFAULT_PATTERN = NL + "\tConstraint Violation(s) in {0} of types [{3}]." + NL; + private static final String ENTITY_DEFAULT_PATTERN = NL + "\tConstraint Violation(s) in entity {0} with id=[{2}]." + NL; + private static final String SERVICE_DEFAULT_PATTERN = NL + "\tConstraint Violation(s) in service {0} with id=[{2}]." + NL; + private static final String MIXIN_DEFAULT_PATTERN = "\t\t@{2}({3}) on {0}.{1}(). Parameter [{4}] does not allow value [{5}]." + NL; private String instanceToString; // arg {0} private Class<?> primaryType; // arg {1} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java b/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java index af1801f..dcbd4f3 100644 --- a/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java +++ b/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java @@ -30,6 +30,7 @@ public class NoSuchObjectTypeException extends InvalidApplicationException { private static final long serialVersionUID = -1121690536365682511L; + private static final String NL = System.getProperty( "line.separator" ); private final String objectType; private final String moduleName; @@ -38,8 +39,8 @@ public class NoSuchObjectTypeException { super( "Could not find any visible Object of type [" + type + "] in module [" + moduleName - + "]. The visible types are: \n" - + visible.map( Class::getName ).collect( Collectors.joining("\n") ) + + "]. The visible types are: " + NL + + visible.map( Class::getName ).collect( Collectors.joining( NL ) ) ); this.objectType = type; this.moduleName = moduleName; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/api/src/main/java/org/apache/polygene/api/unitofwork/ConcurrentEntityModificationException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/unitofwork/ConcurrentEntityModificationException.java b/core/api/src/main/java/org/apache/polygene/api/unitofwork/ConcurrentEntityModificationException.java index 7d439b0..d54b1ad 100644 --- a/core/api/src/main/java/org/apache/polygene/api/unitofwork/ConcurrentEntityModificationException.java +++ b/core/api/src/main/java/org/apache/polygene/api/unitofwork/ConcurrentEntityModificationException.java @@ -34,6 +34,7 @@ public class ConcurrentEntityModificationException extends UnitOfWorkCompletionException { private static final long serialVersionUID = 3872723845064767689L; + private static final String NL = System.getProperty( "line.separator" ); private final Map<EntityComposite, HasTypes> concurrentlyModifiedEntities; @@ -41,7 +42,7 @@ public class ConcurrentEntityModificationException Usecase usecase ) { - super( "Entities changed concurrently, and detected in usecase '" + usecase + "'\nModified entities : " + format( concurrentlyModifiedEntities ) ); + super( "Entities changed concurrently, and detected in usecase '" + usecase + "'" + NL + "Modified entities : " + format( concurrentlyModifiedEntities ) ); this.concurrentlyModifiedEntities = concurrentlyModifiedEntities; } @@ -54,7 +55,7 @@ public class ConcurrentEntityModificationException + entry.getValue().types().map( Class::getSimpleName ) .collect( Collectors.joining( "," ) ) ) - .collect( Collectors.joining( "\n" ) ); + .collect( Collectors.joining( NL ) ); } public Map<EntityComposite, HasTypes> concurrentlyModifiedEntities() http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java index 4a2211e..2ca57cf 100644 --- a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java @@ -21,7 +21,6 @@ package org.apache.polygene.bootstrap; import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -30,6 +29,8 @@ import java.util.stream.Collectors; */ public class AssemblyReportException extends AssemblyException { + private static final String NL = System.getProperty( "line.separator" ); + private Set<Throwable> problems; private String modelReport; @@ -44,7 +45,7 @@ public class AssemblyReportException extends AssemblyException String message; if( modelReport == null ) { - message = "\nComposition Problems Report:\n"; + message = NL+ "Composition Problems Report:" + NL; } else { @@ -52,7 +53,7 @@ public class AssemblyReportException extends AssemblyException } return message + problems.stream() .map( this::composeMessage ) - .map( m -> m + "\n--\n" ) + .map( m -> m + NL + "--" + NL ) .collect( Collectors.joining() ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Energy4Java.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Energy4Java.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Energy4Java.java index a4cf0c3..13941c1 100644 --- a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Energy4Java.java +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Energy4Java.java @@ -76,7 +76,8 @@ public final class Energy4Java String modelReport = InvalidCompositeException.modelReport(); if( modelReport != null ) { - throw new AssemblyException( "Composition problems\n\n" + modelReport ); + String nl = System.getProperty( "line.separator" ); + throw new AssemblyException( "Composition problems" + nl + nl + modelReport ); } return model; } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java index 7f69916..e25bfe7 100644 --- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java +++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java @@ -338,7 +338,7 @@ public abstract class CompositeAssemblyImpl { return implementMethodWithClass( method, mixinClass ); } - handleInvalidCompositeType( "No implementation found for method ", null, null, null, null, method, types ); + handleInvalidCompositeType( "No implementation found for method", null, null, null, null, method, types ); return null; } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodsModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodsModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodsModel.java index 2223091..dd2bfb6 100644 --- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodsModel.java +++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodsModel.java @@ -39,6 +39,8 @@ import org.apache.polygene.runtime.injection.DependencyModel; public final class CompositeMethodsModel implements VisitableHierarchy<Object, Object>, Dependencies { + private static final String NL = System.getProperty( "line.separator" ); + private final LinkedHashMap<Method, CompositeMethodModel> methods; private final MixinsModel mixinsModel; @@ -102,14 +104,15 @@ public final class CompositeMethodsModel // return method.invoke( proxy, args ); String message = "We have detected a default method on an interface that is not backed by a Composite. " + "Please report this to [email protected] together with the information below, " - + "that/those class(es) and the relevant assembly information. Thank you\nMethod:" + + "that/those class(es) and the relevant assembly information. Thank you" + + NL + "Method:" + method.toGenericString() - + "\nDeclaring Class:" + + NL + "Declaring Class:" + method.getDeclaringClass().toGenericString() - + "\nTypes:" + + NL + "Types:" + mixinsModel.mixinTypes() .map( Class::toGenericString ) - .collect( Collectors.joining( "\n" ) ); + .collect( Collectors.joining( NL ) ); throw new UnsupportedOperationException( message ); } throw new MissingMethodException( "Method '" + method + "' is not implemented" ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java index 026a4e1..a35227c 100644 --- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java +++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java @@ -41,6 +41,8 @@ import static org.apache.polygene.api.util.AccessibleObjects.accessible; public final class ConstructorModel implements ConstructorDescriptor, VisitableHierarchy<Object, Object> { + private static final String NL = System.getProperty( "line.separator" ); + private Constructor<?> constructor; private InjectedParametersModel parameters; @@ -103,9 +105,9 @@ public final class ConstructorModel private String createExceptionMessage( Object[] parametersInstance ) { - return "Could not instantiate \n " + constructor.getDeclaringClass() - + "\nusing constructor:\n " + constructor.toGenericString() - + "\nparameter types:\n " + Arrays.toString( parametersInstance ); + return "Could not instantiate " + NL + " " + constructor.getDeclaringClass() + + NL + "using constructor:" + NL + " " + constructor.toGenericString() + + NL + "parameter types:" + NL + " " + Arrays.toString( parametersInstance ); } @Override http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/runtime/src/main/java/org/apache/polygene/runtime/injection/InjectedFieldModel.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/injection/InjectedFieldModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/injection/InjectedFieldModel.java index 553f1ff..8ce5597 100644 --- a/core/runtime/src/main/java/org/apache/polygene/runtime/injection/InjectedFieldModel.java +++ b/core/runtime/src/main/java/org/apache/polygene/runtime/injection/InjectedFieldModel.java @@ -47,6 +47,8 @@ import static java.util.Collections.singleton; public final class InjectedFieldModel implements InjectedFieldDescriptor, Dependencies, VisitableHierarchy<InjectedFieldModel, DependencyModel> { + private static final String NL = System.getProperty( "line.separator" ); + private DependencyModel dependencyModel; private Field injectedField; @@ -124,11 +126,11 @@ public final class InjectedFieldModel annotBuilder.append( " " ); } String annots = annotBuilder.toString(); - String message = "Can not inject the field\n " + String message = "Can not inject the field" + NL + " " + injectedField.getDeclaringClass() - + "\n {\n " + annots + "\n " + + NL + " {" + NL + " " + annots + NL + " " + injectedField.getType().getSimpleName() + " " + injectedField.getName() - + "\n }\nwith value \n " + value + "\nof type\n " + + NL + " }" + NL + "with value " + NL + " " + value + NL + "of type" + NL + " " + valueClassName; throw new InjectionException( message, e ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/runtime/src/test/java/org/apache/polygene/bootstrap/ErrorReportingTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/bootstrap/ErrorReportingTest.java b/core/runtime/src/test/java/org/apache/polygene/bootstrap/ErrorReportingTest.java index 8feca04..0ddb5e6 100644 --- a/core/runtime/src/test/java/org/apache/polygene/bootstrap/ErrorReportingTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/bootstrap/ErrorReportingTest.java @@ -31,6 +31,8 @@ import static org.junit.Assert.assertThat; public class ErrorReportingTest extends AbstractPolygeneTest { + private static final String NL = System.getProperty( "line.separator" ); + @Override public void assemble( ModuleAssembly module ) { @@ -41,18 +43,18 @@ public class ErrorReportingTest extends AbstractPolygeneTest @Override protected void assemblyException( AssemblyException exception ) { - assertThat( exception.getMessage(), containsString( "Composition Problems Report:\n" ) ); - assertThat( exception.getMessage(), containsString( " message: No implementation found for method \n" - + " method: Map doAnotherThing(String name, int value)\n" - + " types: [Person,ValueComposite]\n" ) ); + assertThat( exception.getMessage(), containsString( "Composition Problems Report:" + NL ) ); + assertThat( exception.getMessage(), containsString( " message: No implementation found for method" + NL + + " method: Map doAnotherThing(String name, int value)" + NL + + " types: [Person,ValueComposite]" + NL ) ); - assertThat( exception.getMessage(), containsString( " message: No implementation found for method \n" - + " method: void doOneThing()\n" - + " types: [Person,ValueComposite]\n" ) ); + assertThat( exception.getMessage(), containsString( " message: No implementation found for method" + NL + + " method: void doOneThing()" + NL + + " types: [Person,ValueComposite]" + NL ) ); - assertThat( exception.getMessage(), containsString( " message: No implementation found for method \n" - + " method: void goForWalk(int minutes)\n" - + " types: [Pet,ValueComposite]\n" ) ); + assertThat( exception.getMessage(), containsString( " message: No implementation found for method" + NL + + " method: void goForWalk(int minutes)" + NL + + " types: [Pet,ValueComposite]" + NL ) ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/42b3d335/core/spi/src/main/java/org/apache/polygene/spi/entitystore/ConcurrentEntityStateModificationException.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/ConcurrentEntityStateModificationException.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/ConcurrentEntityStateModificationException.java index f6bbfe8..132edb2 100644 --- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/ConcurrentEntityStateModificationException.java +++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/ConcurrentEntityStateModificationException.java @@ -29,6 +29,8 @@ import org.apache.polygene.api.entity.EntityReference; public class ConcurrentEntityStateModificationException extends EntityStoreException { + private static final String NL = System.getProperty( "line.separator" ); + private Collection<EntityReference> modifiedEntities; public ConcurrentEntityStateModificationException( Collection<EntityReference> modifiedEntities ) @@ -45,6 +47,6 @@ public class ConcurrentEntityStateModificationException @Override public String getMessage() { - return "Entities changed concurrently.\nModified entities are;\n" + modifiedEntities; + return "Entities changed concurrently." + NL + "Modified entities are;" + NL + modifiedEntities; } } \ No newline at end of file
