/**
 * 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.
 */
package org.apache.camel.cdi.sample.metrics;

import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import com.codahale.metrics.annotation.Metric;
import io.astefanutti.metrics.cdi.MetricsExtension;
import org.apache.camel.CamelContext;
import org.apache.camel.cdi.CdiCamelExtension;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.inject.Inject;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

@RunWith(Arquillian.class)
public class MetricsSampleTest {

    @Deployment
    public static Archive<?> deployment() {
        return ShrinkWrap.create(JavaArchive.class)
            // Camel CDI
            .addPackage(CdiCamelExtension.class.getPackage())
            // Metrics CDI
            .addPackage(MetricsExtension.class.getPackage())
            // Test classes
            .addPackage(MetricsSampleTest.class.getPackage())
            // Bean archive deployment descriptor
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Inject
    Meter generated, attempt, success, redelivery, error;

    @Inject
    @Metric(name = "success-ratio")
    Gauge<Double> ratio;

    @Test
    public void test(CamelContext context) throws Exception {
        // Wait a while so that the timer can kick in
        Thread.sleep(10000);

        // And stop the Camel context so that inflight exchanges get completed
        context.stop();

        assertThat("Meter counts are not consistent!", attempt.getCount() - redelivery.getCount() - success.getCount() - error.getCount(), is(equalTo(0L)));

        assertThat("Success rate gauge value is incorrect!", ratio.getValue(), is(equalTo(success.getOneMinuteRate() / generated.getOneMinuteRate())));
    }
}

@@ -1089,32 +1089,78 @@
 CamelExtension;%0A
+import org.apache.camel.cdi.test.LogVerifier;%0A
 import org.jboss
@@ -1450,20 +1450,81 @@
 g.junit.
-Test
+ClassRule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.TestRule
 ;%0Aimport
@@ -1620,55 +1620,248 @@
 ers.
-equalTo;%0Aimport static org.hamcrest.Matchers.is
+anyOf;%0Aimport static org.hamcrest.Matchers.containsString;%0Aimport static org.hamcrest.Matchers.equalTo;%0Aimport static org.hamcrest.Matchers.hasItems;%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.hamcrest.Matchers.matchesPattern
 ;%0Aim
@@ -2467,16 +2467,715 @@
 %0A    %7D%0A%0A
+    @ClassRule%0A    public static TestRule verifier = new LogVerifier() %7B%0A        @Override%0A        protected void verify() throws Throwable %7B%0A            assertThat(%22Log messages not found!%22, getMessages(),%0A                hasItems(%0A                    containsString(%22(CamelContext: camel-cdi-metrics) is starting%22),%0A                    anyOf(%0A                        matchesPattern(%22Successfully processed event #%5C%5Cd+%22),%0A                        matchesPattern(%22Processed event #%5C%5Cd+ after %5C%5Cd+ retries%22),%0A                        matchesPattern(%22Failed processing event #%5C%5Cd+%22)),%0A                    containsString(%22(CamelContext: camel-cdi-metrics) is shutdown%22))%0A            );%0A        %7D%0A    %7D;%0A%0A
     @Inj

Add log assertions for the Metrics CDI sample test