Fixed potential class pool override in integration tests.
[controller.git] / opendaylight / md-sal / sal-binding-dom-it / src / test / java / org / opendaylight / controller / sal / binding / test / bugfix / DOMCodecBug02Test.java
index 848fb6b1900eab43a3e3e2886d654c92c2135c24..bc6f567c2bd01fd3346cc0c8d9769fd20f9cfdc8 100644 (file)
@@ -1,5 +1,15 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.sal.binding.test.bugfix;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.Callable;
@@ -9,21 +19,21 @@ import java.util.concurrent.Future;
 
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
+import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import static org.junit.Assert.*;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 
 public class DOMCodecBug02Test extends AbstractDataServiceTest {
 
@@ -54,31 +64,47 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
     private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
 
     /**
-     * 
-     * 
+     * This test is ignored, till found out better way to test generation of
+     * classes without leaking of instances from previous run
+     *
      * @throws Exception
      */
+
+    @Override
+    public void setUp() {
+        ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
+        BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
+        factory.setExecutor(executor);
+        factory.setStartWithParsedSchema(getStartWithSchema());
+        testContext = factory.getTestContext();
+        testContext.start();
+
+        baDataService = testContext.getBindingDataBroker();
+        biDataService = testContext.getDomDataBroker();
+        dataStore = testContext.getDomDataStore();
+        mappingService = testContext.getBindingToDomMappingService();
+    };
+
     @Test
     public void testSchemaContextNotAvailable() throws Exception {
 
         ExecutorService testExecutor = Executors.newFixedThreadPool(1);
-        
-        Future<Future<RpcResult<TransactionStatus>>> future = testExecutor.submit(new Callable<Future<RpcResult<TransactionStatus>>>() {
-            @Override
-            public Future<RpcResult<TransactionStatus>> call() throws Exception {
-                NodesBuilder nodesBuilder = new NodesBuilder();
-                nodesBuilder.setNode(Collections.<Node> emptyList());
-                DataModificationTransaction transaction = baDataService.beginTransaction();
-                transaction.putOperationalData(NODES_INSTANCE_ID_BA, nodesBuilder.build());
-                return transaction.commit();
-            }
-        });
-        
         testContext.loadYangSchemaFromClasspath();
+        Future<Future<RpcResult<TransactionStatus>>> future = testExecutor
+                .submit(new Callable<Future<RpcResult<TransactionStatus>>>() {
+                    @Override
+                    public Future<RpcResult<TransactionStatus>> call() throws Exception {
+                        NodesBuilder nodesBuilder = new NodesBuilder();
+                        nodesBuilder.setNode(Collections.<Node> emptyList());
+                        DataModificationTransaction transaction = baDataService.beginTransaction();
+                        transaction.putOperationalData(NODES_INSTANCE_ID_BA, nodesBuilder.build());
+                        return transaction.commit();
+                    }
+                });
+
         RpcResult<TransactionStatus> result = future.get().get();
         assertEquals(TransactionStatus.COMMITED, result.getResult());
-        
-        
+
         Nodes nodes = checkForNodes();
         assertNotNull(nodes);
 
@@ -88,7 +114,7 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
         return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
 
     }
-    
+
     @Override
     protected boolean getStartWithSchema() {
         return false;