Deprecate ReadData/DataExists protobuff messages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / compat / PreBoronShardTest.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.compat;
9
10 import static org.junit.Assert.assertTrue;
11 import akka.actor.ActorRef;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.datastore.AbstractShardTest;
14 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
15 import org.opendaylight.controller.cluster.datastore.ShardTestKit;
16 import org.opendaylight.controller.cluster.datastore.TransactionType;
17 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
18 import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
19 import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
20 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
21 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
22
23 /**
24  * Shard unit tests for backwards compatibility with pre-Boron versions.
25  *
26  * @author Thomas Pantelis
27  */
28 public class PreBoronShardTest extends AbstractShardTest {
29
30     @Test
31     public void testCreateTransaction(){
32         new ShardTestKit(getSystem()) {{
33             final ActorRef shard = actorFactory.createActor(newShardProps(), "testCreateTransaction");
34
35             waitUntilLeader(shard);
36
37             shard.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
38
39             shard.tell(new CreateTransaction("txn-1", TransactionType.READ_ONLY.ordinal(), null,
40                     DataStoreVersions.LITHIUM_VERSION).toSerializable(), getRef());
41
42             ShardTransactionMessages.CreateTransactionReply reply =
43                     expectMsgClass(ShardTransactionMessages.CreateTransactionReply.class);
44
45             final String path = CreateTransactionReply.fromSerializable(reply).getTransactionPath().toString();
46             assertTrue("Unexpected transaction path " + path,
47                     path.contains("akka://test/user/testCreateTransaction/shard-txn-1"));
48         }};
49     }
50 }