/*
 * Copyright (c) 2010-2013. Axon Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.axonframework.ext.hazelcast.test;

import com.google.common.collect.Lists;
import com.hazelcast.core.HazelcastInstance;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.domain.SimpleDomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.ext.hazelcast.store.HzEventStore;
import org.axonframework.ext.hazelcast.test.model.HzAxonEventMessage;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.List;
import java.util.UUID;

import static org.junit.Assert.assertEquals;

public class HzEventStoreTest extends HzTestBase {
    private HazelcastInstance m_instance = null;

    // *************************************************************************
    //
    // *************************************************************************

    @Before
    public void setUp() throws Exception {
        m_instance = createInstance();
    }

    @After
    public void tearDown() throws Exception {
        m_instance.shutdown();
    }

    // *************************************************************************
    //
    // *************************************************************************

    @Test
    public void testSaveStreamAndReadBack() {
        String     type  = "org.axonframework.ext.eventstore.chronicle.test";
        String     aid   = UUID.randomUUID().toString();
        EventStore store = new HzEventStore(m_instance);
        int        evts  = 10;

        List<DomainEventMessage<?>> demWrite = Lists.newArrayListWithCapacity(evts);
        for(int i=0;i<evts;i++) {
            demWrite.add(new HzAxonEventMessage(aid,i,"evt-" + i));
        }

        store.appendEvents(type,new SimpleDomainEventStream(demWrite));

        List<DomainEventMessage<?>> demRead = Lists.newArrayListWithCapacity(evts);
        DomainEventStream des = store.readEvents(type,aid);
        while (des.hasNext()) {
            demRead.add(des.next());
        }

        assertEquals(demWrite.size(),demRead.size());

        for(int i=0;i<evts;i++) {
            assertEquals(
                demWrite.get(i).getIdentifier(),
                demRead.get(i).getIdentifier());
        }
    }
}

@@ -1234,16 +1234,62 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertNotNull;
 %0A%0Apublic
@@ -1703,32 +1703,70 @@
 ows Exception %7B%0A
+        if(m_instance != null)  %7B%0A    
         m_instan
@@ -1776,24 +1776,34 @@
 shutdown();%0A
+        %7D%0A
     %7D%0A%0A    /
@@ -2019,24 +2019,88 @@
 eadBack() %7B%0A
+        assertNotNull(%22HazelcastInstance is null%22,m_instance);%0A%0A
         Stri

fix test