Skip to content

Commit

Permalink
Revert changes to AssertableLogProvider from 7b267c6d905 "IndexingSer…
Browse files Browse the repository at this point in the history
…vice log when deprecated IndexProviders are used"

And simply use Matchers.allOf instead where needed.
  • Loading branch information
burqen committed Oct 11, 2018
1 parent eb6b88d commit 7c1cfab
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
Expand Up @@ -188,7 +188,7 @@ private void nativeIndexMustLogCrashPointerCleanupDuringRecovery( GraphDatabaseS
matchers.add( indexRecoveryFinishedLogMatcher( subType ) ); matchers.add( indexRecoveryFinishedLogMatcher( subType ) );
matchers.add( indexRecoveryLogMatcher( "Schema index cleanup job closed", subType ) ); matchers.add( indexRecoveryLogMatcher( "Schema index cleanup job closed", subType ) );
} }
matchers.forEach( logProvider::assertContainsExactlyOneMessageMatchingInAnyOrder ); matchers.forEach( logProvider::assertContainsExactlyOneMessageMatching );
} }


private Matcher<String> indexRecoveryLogMatcher( String logMessage, String subIndexProviderKey ) private Matcher<String> indexRecoveryLogMatcher( String logMessage, String subIndexProviderKey )
Expand Down
Expand Up @@ -574,11 +574,13 @@ public void shouldLogDeprecatedIndexesOnInit() throws IOException
indexingService.init(); indexingService.init();


// then // then
userLogProvider.assertContainsExactlyOneMessageMatchingInAnyOrder( userLogProvider.assertContainsExactlyOneMessageMatching(
Matchers.containsString( "IndexingService.init: Deprecated index providers in use:" ), Matchers.allOf(
Matchers.containsString( lucene10Descriptor.name() + " (1 index)" ), Matchers.containsString( "IndexingService.init: Deprecated index providers in use:" ),
Matchers.containsString( native10Descriptor.name() + " (1 index)" ), Matchers.containsString( lucene10Descriptor.name() + " (1 index)" ),
Matchers.containsString( native20Descriptor.name() + " (2 indexes)" ) Matchers.containsString( native10Descriptor.name() + " (1 index)" ),
Matchers.containsString( native20Descriptor.name() + " (2 indexes)" )
)
); );
onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( nativeBtree10Descriptor.name() ) ); onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( nativeBtree10Descriptor.name() ) );
onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( fulltextDescriptor.name() ) ); onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( fulltextDescriptor.name() ) );
Expand Down Expand Up @@ -625,11 +627,13 @@ public void shouldLogDeprecatedIndexesOnStart() throws IOException
indexingService.start(); indexingService.start();


// then // then
userLogProvider.assertContainsExactlyOneMessageMatchingInAnyOrder( userLogProvider.assertContainsExactlyOneMessageMatching(
Matchers.containsString( "IndexingService.start: Deprecated index providers in use:" ), Matchers.allOf(
Matchers.containsString( lucene10Descriptor.name() + " (1 index)" ), Matchers.containsString( "IndexingService.start: Deprecated index providers in use:" ),
Matchers.containsString( native10Descriptor.name() + " (1 index)" ), Matchers.containsString( lucene10Descriptor.name() + " (1 index)" ),
Matchers.containsString( native20Descriptor.name() + " (2 indexes)" ) Matchers.containsString( native10Descriptor.name() + " (1 index)" ),
Matchers.containsString( native20Descriptor.name() + " (2 indexes)" )
)
); );
onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( nativeBtree10Descriptor.name() ) ); onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( nativeBtree10Descriptor.name() ) );
onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( fulltextDescriptor.name() ) ); onBothLogProviders( logProvider -> internalLogProvider.assertNoMessagesContaining( fulltextDescriptor.name() ) );
Expand Down
Expand Up @@ -764,24 +764,14 @@ public void assertContainsMessageMatching( Matcher<String> messageMatcher )
} }
} }


@SafeVarargs public final void assertContainsExactlyOneMessageMatching( Matcher<String> messageMatcher )
public final void assertContainsExactlyOneMessageMatchingInAnyOrder( Matcher<? extends String>... messageMatchers )
{ {
boolean found = false; boolean found = false;
synchronized ( logCalls ) synchronized ( logCalls )
{ {
for ( LogCall logCall : logCalls ) for ( LogCall logCall : logCalls )
{ {
boolean match = true; if ( messageMatcher.matches( logCall.message ) )
for ( Matcher<? extends String> messageMatcher : messageMatchers )
{
if ( !messageMatcher.matches( logCall.message ) )
{
match = false;
break;
}
}
if ( match )
{ {
if ( !found ) if ( !found )
{ {
Expand All @@ -790,10 +780,7 @@ public final void assertContainsExactlyOneMessageMatchingInAnyOrder( Matcher<? e
else else
{ {
StringDescription description = new StringDescription(); StringDescription description = new StringDescription();
for ( Matcher<? extends String> messageMatcher : messageMatchers ) description.appendDescriptionOf( messageMatcher );
{
description.appendDescriptionOf( messageMatcher );
}
fail( format( "Expected exactly one log statement with message as %s, but multiple found. Actual log calls were:%n%s", fail( format( "Expected exactly one log statement with message as %s, but multiple found. Actual log calls were:%n%s",
description.toString(), serialize( logCalls.iterator() ) ) ); description.toString(), serialize( logCalls.iterator() ) ) );
} }
Expand All @@ -802,10 +789,7 @@ public final void assertContainsExactlyOneMessageMatchingInAnyOrder( Matcher<? e
if ( !found ) if ( !found )
{ {
StringDescription description = new StringDescription(); StringDescription description = new StringDescription();
for ( Matcher<? extends String> messageMatcher : messageMatchers ) description.appendDescriptionOf( messageMatcher );
{
description.appendDescriptionOf( messageMatcher );
}
fail( format( fail( format(
"Expected at least one log statement with message as %s, but none found. Actual log calls were:\n%s", "Expected at least one log statement with message as %s, but none found. Actual log calls were:\n%s",
description.toString(), serialize( logCalls.iterator() ) ) ); description.toString(), serialize( logCalls.iterator() ) ) );
Expand Down
Expand Up @@ -326,7 +326,7 @@ public AdvertisedSocketAddress secondary()
} }
catch ( StoreCopyFailedException e ) catch ( StoreCopyFailedException e )
{ {
assertableLogProvider.assertContainsExactlyOneMessageMatchingInAnyOrder( assertableLogProvider.assertContainsExactlyOneMessageMatching(
both( containsString( "Connection refused:" ) ).and( containsString( "localhost/127.0.0.1:" + port ) ) ); both( containsString( "Connection refused:" ) ).and( containsString( "localhost/127.0.0.1:" + port ) ) );
} }
} }
Expand Down Expand Up @@ -356,7 +356,7 @@ public AdvertisedSocketAddress secondary() throws CatchupAddressResolutionExcept
} }
catch ( StoreCopyFailedException e ) catch ( StoreCopyFailedException e )
{ {
assertableLogProvider.assertContainsExactlyOneMessageMatchingInAnyOrder( startsWith( "Unable to resolve address for" ) ); assertableLogProvider.assertContainsExactlyOneMessageMatching( startsWith( "Unable to resolve address for" ) );
assertableLogProvider.assertLogStringContains(catchupAddressResolutionException.getMessage() ); assertableLogProvider.assertLogStringContains(catchupAddressResolutionException.getMessage() );
} }
} }
Expand Down
Expand Up @@ -52,7 +52,7 @@ public void shouldNotDuplicateToAnyLog()
ClusterId clusterId = new ClusterId( UUID.randomUUID() ); ClusterId clusterId = new ClusterId( UUID.randomUUID() );
monitor.boundToCluster( clusterId ); monitor.boundToCluster( clusterId );


user.assertContainsExactlyOneMessageMatchingInAnyOrder( Matchers.equalToIgnoringCase( "Bound to cluster with id " + clusterId.uuid() ) ); user.assertContainsExactlyOneMessageMatching( Matchers.equalToIgnoringCase( "Bound to cluster with id " + clusterId.uuid() ) );
debug.assertContainsExactlyOneMessageMatchingInAnyOrder( Matchers.equalToIgnoringCase( "Bound to cluster with id " + clusterId.uuid() ) ); debug.assertContainsExactlyOneMessageMatching( Matchers.equalToIgnoringCase( "Bound to cluster with id " + clusterId.uuid() ) );
} }
} }

0 comments on commit 7c1cfab

Please sign in to comment.