--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.intent;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import com.google.common.base.Optional;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.nemo.intent.computation.PNComputationUnit;
+import org.opendaylight.nemo.intent.computation.PNResourcesTracker;
+import org.opendaylight.nemo.intent.computation.VNComputationUnit;
+import org.opendaylight.nemo.intent.computation.VNMappingUnit;
+import org.opendaylight.nemo.intent.condition.ConditionManager;
+import org.opendaylight.nemo.user.vnspacemanager.structurestyle.updateintent.UpdateIntent;
+import org.opendaylight.nemo.user.vnspacemanager.structurestyle.updateintent.UpdateNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNetwork;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalPaths;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.paths.PhysicalPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.paths.PhysicalPathKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.VirtualNetworks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.VirtualNetwork;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.VirtualNetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.VirtualNetworkKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.arps.VirtualArp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.links.VirtualLink;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.nodes.VirtualNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.paths.VirtualPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.routes.VirtualRoute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.IntentVnMappingResults;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.VnPnMappingResults;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.UserIntentVnMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.UserIntentVnMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.UserIntentVnMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.IntentVnMappingResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.vn.pn.mapping.results.UserVnPnMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.vn.pn.mapping.results.UserVnPnMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.vn.pn.mapping.results.UserVnPnMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.vn.pn.mapping.results.user.vn.pn.mapping.VnPnMappingResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.NodeType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalPathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.VirtualNetworkId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.Users;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Connection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import java.util.List;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.LinkedList;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import java.util.*;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalLinks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalNodes;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import com.google.common.util.concurrent.CheckedFuture;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Operations;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Results;
+import static org.junit.Assert.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.VirtualResourceInstance.VirtualResourceType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalResourceEntityId;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalNodeId;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.ObjectId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.PhysicalHosts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.hosts.PhysicalHost;
+import static org.mockito.Mockito.doNothing;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.node.instance.Property;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.property.instance.property.values.StringValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.property.instance.PropertyValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.PropertyName;
+/**
+ * Created by ldzd11 on 2015/12/24.
+ */
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(IntentResolverUtils.class)
+public class IntentResolverTest {
+ private IntentResolver intentResolver;
+ private DataBroker dataBroker;
+ private UserId userId;
+ private List<VnPnMappingResult> vnPnMappingResults;
+ private VnPnMappingResult vnPnMappingResult;
+ private VirtualResourceType virtualResourceType;
+ private PhysicalResourceEntityId physicalResourceEntityId;
+ private Objects objects;
+ private List<Node> nodeList;
+ private Node node;
+ private NodeType nodeType;
+ private List<Connection> connections;
+ private Connection connection;
+ private List<Flow> flows;
+ private Flow flow;
+ private Operations operations;
+ private List<Operation> operationList;
+ private Operation operation;
+ private ObjectId objectId;
+ private NodeId nodeId;
+ private List<PhysicalHost> physicalHostList;
+ private PhysicalHost physicalHost;
+ private Property property;
+ private List<Property> propertyList;
+ private PropertyValues propertyValues;
+ private StringValue stringValue;
+ private List<StringValue> stringValueList;
+
+
+ @Before
+ public void setUp() throws Exception {
+ dataBroker = mock(DataBroker.class);
+ userId = mock(UserId.class);
+
+ vnPnMappingResults = new ArrayList<VnPnMappingResult>();
+ vnPnMappingResult = mock(VnPnMappingResult.class);
+ vnPnMappingResults.add(vnPnMappingResult);
+
+ virtualResourceType = VnPnMappingResult.VirtualResourceType.Vlink;
+ physicalResourceEntityId =mock(PhysicalResourceEntityId.class);
+ objects = mock(Objects.class);
+ nodeList = new ArrayList<Node>();
+ node = mock(Node.class);
+ nodeList.add(node);
+ nodeType = mock(NodeType.class);
+ connections = new ArrayList<Connection>();
+ connection = mock(Connection.class);
+ connections.add(connection);
+ flows = new ArrayList<Flow>();
+ flow = mock(Flow.class);
+ flows.add(flow);
+ operations = mock(Operations.class);
+ operationList = new ArrayList<Operation>();
+ operation = mock(Operation.class);
+ operationList.add(operation);
+ objectId = mock(ObjectId.class);
+ nodeId = mock(NodeId.class);
+
+ physicalHostList = new ArrayList<PhysicalHost>();
+ physicalHost = mock(PhysicalHost.class);
+ physicalHostList.add(physicalHost);
+ property = mock(Property.class);
+ propertyList = new ArrayList<Property>();
+ propertyList.add(property);
+ propertyValues = mock(PropertyValues.class);
+ stringValueList = new ArrayList<StringValue>();
+ stringValue = mock(StringValue.class);
+ stringValueList.add(stringValue);
+
+
+
+
+ //into PNC to result
+ ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
+ when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
+
+ CheckedFuture physicalnodesFuture = mock(CheckedFuture.class);
+ CheckedFuture physicallinksFuture = mock(CheckedFuture.class);
+ when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(physicalnodesFuture).thenReturn(physicallinksFuture);
+
+ //////////////////first result/////////////////////
+ PhysicalNodes physicalNodes = mock(PhysicalNodes.class);
+ Optional<PhysicalNodes> result = Optional.of(physicalNodes);
+ Assert.assertTrue(result.isPresent());
+ when(physicalnodesFuture.get()).thenReturn(result);
+
+ ///////////////////Second result///////////////////////
+ PhysicalLinks physicalLinks = mock(PhysicalLinks.class);
+ Optional<PhysicalLinks> result1 = Optional.of(physicalLinks);
+ Assert.assertTrue(result1.isPresent());
+ when(physicallinksFuture.get()).thenReturn(result1);
+
+ intentResolver = new IntentResolver(dataBroker);
+ }
+
+ @Test
+ public void testResolveIntent() throws Exception {
+ PowerMockito.mockStatic(IntentResolverUtils.class);
+ PowerMockito.doNothing().when(IntentResolverUtils.class);
+ IntentResolverUtils.copyPhysicalNetworkConfigToOperational(dataBroker);
+
+ Class<IntentResolver> class1 = IntentResolver.class;
+
+ CheckedFuture userVnPnMappingIidFuture = mock(CheckedFuture.class);
+ CheckedFuture userFuture = mock(CheckedFuture.class);
+ CheckedFuture physicalHostsFuture = mock(CheckedFuture.class);
+
+ ReadWriteTransaction readWriteTransaction = mock(ReadWriteTransaction.class);
+ when(dataBroker.newReadWriteTransaction()).thenReturn(readWriteTransaction);
+ ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
+ when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
+
+ when(readWriteTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(userVnPnMappingIidFuture).thenReturn(userFuture);
+ when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(physicalHostsFuture);
+
+
+ when(userId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+ //////////////152 forvnComputationUnits.get(userId) into if null != vnComputationUnit
+ Map<UserId, VNComputationUnit> vnComputationUnits = new HashMap<UserId, VNComputationUnit>();
+ VNComputationUnit vnComputationUnit = mock(VNComputationUnit.class);
+ vnComputationUnits.put(userId, vnComputationUnit);
+
+ Field field1 = class1.getDeclaredField("vnComputationUnits");
+ field1.setAccessible(true);
+ field1.set(intentResolver, vnComputationUnits);//for 170
+ //into null!=vncomputionUnit
+
+ ////////////////////the result1////////////////////////
+ UserVnPnMapping userVnPnMapping = mock(UserVnPnMapping.class);
+ Optional<UserVnPnMapping> result1 = Optional.of(userVnPnMapping);
+ Assert.assertTrue(result1.isPresent());
+ when(userVnPnMappingIidFuture.get()).thenReturn(result1);
+
+ //187 into result1.is present
+ when(userVnPnMapping.getVnPnMappingResult()).thenReturn(vnPnMappingResults);
+ when(vnPnMappingResult.getVirtualResourceType()).thenReturn(virtualResourceType);
+ when(vnPnMappingResult.getPhysicalResourceEntityId()).thenReturn(physicalResourceEntityId);
+ when(vnPnMappingResult.getPhysicalResourceEntityId().getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+
+ //end of 212
+ //////////////////the result2////////////////////////////////
+ User user = mock(User.class);
+ Optional<User> result2 = Optional.of(user);
+ Assert.assertTrue(result2.isPresent());
+ when(userFuture.get()).thenReturn(result2);
+
+ ////////into null!-user.getObjects
+ when(user.getObjects()).thenReturn(objects);
+ when(user.getObjects().getNode()).thenReturn(nodeList);
+ ////////////////////1/////////////////////////////////
+ nodeType = new NodeType("host");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ NodeMapper nodeMapper = mock(NodeMapper.class);
+ Field field2 = class1.getDeclaredField("nodeMapper");
+ field2.setAccessible(true);
+ field2.set(intentResolver, nodeMapper);//for 170
+ doNothing().when(nodeMapper).resolveHost(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ ///////////////////2//////////////////////////////
+ nodeType = new NodeType("l2-group");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ doNothing().when(nodeMapper).resolveLayer2Group(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////3///////////////////////////////
+ nodeType = new NodeType("l3-group");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ doNothing().when(nodeMapper).resolveLayer3Group(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////4///////////////////////////////
+ nodeType = new NodeType("ext-group");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ when(node.getProperty()).thenReturn(propertyList);
+ PropertyName propertyName = new PropertyName("ac-info-network");
+ when(property.getPropertyName()).thenReturn(propertyName);
+ when(property.getPropertyValues()).thenReturn(propertyValues);
+ when(property.getPropertyValues().getStringValue()).thenReturn(stringValueList);
+ when(property.getPropertyValues().getStringValue().get(0).getValue()).thenReturn(new String("layer3"));
+ doNothing().when(nodeMapper).resolveExternalLayer3Group(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////5///////////////////////////////
+ nodeType = new NodeType("chain-group");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ doNothing().when(nodeMapper).resolveServiceChainGroup(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////6///////////////////////////////
+ nodeType = new NodeType("fw");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ doNothing().when(nodeMapper).resolveServiceFunction(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////6///////////////////////////////
+ nodeType = new NodeType("lb");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ doNothing().when(nodeMapper).resolveServiceFunction(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////6///////////////////////////////
+ nodeType = new NodeType("cache");
+ when(node.getNodeType()).thenReturn(nodeType);
+ ////////////////////into nodeMapper.resolverHosr for nodes
+ doNothing().when(nodeMapper).resolveServiceFunction(any(User.class), any(Node.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+
+ //////////////////////connection///////////////////////////
+ when(user.getObjects().getConnection()).thenReturn(connections);
+ ConnectionMapper connectionMapper = mock(ConnectionMapper.class);
+ Field field4 = class1.getDeclaredField("connectionMapper");
+ field4.setAccessible(true);
+ field4.set(intentResolver, connectionMapper);//for 170
+ doNothing().when(connectionMapper).resolveConnection(any(User.class), any(Connection.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //////////////////////flow///////////////////////////
+ when(user.getObjects().getFlow()).thenReturn(flows);
+ //////////////////////operation///////////////////////////
+ when(user.getOperations()).thenReturn(operations);
+ when(user.getOperations().getOperation()).thenReturn(operationList);
+
+
+ //into operationResolver.classifyOperations
+ OperationResolver operationResolver =mock(OperationResolver.class);
+ Field field3 = class1.getDeclaredField("operationResolver");
+ field3.setAccessible(true);
+ field3.set(intentResolver, operationResolver);
+ doNothing().when(operationResolver).classifyOperations(any(User.class), any(List.class), any(List.class), any(List.class), any(List.class));
+ doNothing().when(operationResolver).resolveOperation(any(User.class), any(Operation.class), any(VirtualNetwork.class), any(UserIntentVnMapping.class));
+
+ //392vnMappingUnit
+ VNMappingUnit vnMappingUnit = mock(VNMappingUnit.class);
+ Field field5 = class1.getDeclaredField("vnMappingUnit");
+ field5.setAccessible(true);
+ field5.set(intentResolver, vnMappingUnit);//for 170
+ doNothing().when(vnMappingUnit).virtualNetworkMapping(any(VirtualNetwork.class), any(UserVnPnMapping.class), any(List.class));
+
+ intentResolver.resolveIntent(userId);
+
+ }
+
+ @Test
+ public void testClose() throws Exception {
+ Class<IntentResolver> class1 = IntentResolver.class;
+ PNComputationUnit pnComputationUnit = mock(PNComputationUnit.class);
+
+ VNComputationUnit vnComputationUnit = mock(VNComputationUnit.class);
+ Map<UserId, VNComputationUnit> vnComputationUnits = new HashMap<UserId, VNComputationUnit>();
+ vnComputationUnits.put(userId,vnComputationUnit);
+
+ PNResourcesTracker pnResourcesTracker = mock(PNResourcesTracker.class);
+ VNMappingUnit vnMappingUnit = mock(VNMappingUnit.class);
+
+
+ Field field1 = class1.getDeclaredField("pnComputationUnit");
+ field1.setAccessible(true);
+ field1.set(intentResolver, pnComputationUnit);
+
+ Field field2 = class1.getDeclaredField("vnComputationUnits");
+ field2.setAccessible(true);
+ field2.set(intentResolver, vnComputationUnits);
+
+ Field field3 = class1.getDeclaredField("pnResourcesTracker");
+ field3.setAccessible(true);
+ field3.set(intentResolver, pnResourcesTracker);
+
+ Field field4 = class1.getDeclaredField("vnMappingUnit");
+ field4.setAccessible(true);
+ field4.set(intentResolver, vnMappingUnit);
+
+ intentResolver.close();
+
+ }
+}
\ No newline at end of file
/*\r
- * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
*\r
* This program and the accompanying materials are made available under the\r
* terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
import java.io.*;\r
//import java.util.*;\r
\r
+import org.junit.runner.RunWith;\r
import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
import org.opendaylight.nemo.intent.IntentResolutionException;\r
import org.opendaylight.nemo.intent.IntentResolverUtils;\r
+import org.opendaylight.nemo.intent.NodeMapper;\r
import org.opendaylight.nemo.intent.computation.VNComputationUnit;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.VirtualNetwork;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.links.VirtualLink;\r
\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
\r
import javax.lang.model.type.ArrayType;\r
//import java.sql.Connection;\r
import java.util.*;\r
import java.lang.*;\r
\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
\r
\r
/**\r
* Created by Thomas Liu on 2015/12/7.\r
*/\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ActionResolverUtils.class,IntentResolverUtils.class})\r
public class ActionResolverTest extends TestCase {\r
\r
private ActionResolver actionResolverTest;\r
private Flow flow;\r
private VirtualNetwork virtualNetwork;\r
private UserIntentVnMapping userIntentVnMapping;\r
+ private UserId userId ;\r
\r
List<Action> actions;\r
private Action action;\r
private VirtualLinks virtualLink;\r
private List<VirtualLink> virtualLinks;\r
private VirtualResourceEntityId virtualResourceEntityId;\r
+ private Class class1;\r
+ private Method method;\r
+ private Field field;\r
\r
\r
//deny\r
\r
@org.junit.Before\r
public void setUp() throws Exception {\r
+ userId = new UserId("11111111-1111-1111-1111-111111111111");\r
dataBroker = mock(DataBroker.class);\r
vnComputationUnits = new HashMap<UserId, VNComputationUnit>();\r
- vnComputationUnits.put(mock(UserId.class), mock(VNComputationUnit.class));\r
+ vnComputationUnits.put(userId, mock(VNComputationUnit.class));\r
actionResolverTest = new ActionResolver(dataBroker,vnComputationUnits);\r
\r
\r
userIntentVnMapping = mock(UserIntentVnMapping.class);\r
\r
\r
+\r
actions = new ArrayList<Action>();\r
actions.add(mock(Action.class));\r
parameterValues1 = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.action.instance.parameter.values.IntValue>(){{ add(mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.action.instance.parameter.values.IntValue.class)); }};\r
subNodes = new ArrayList<SubNode>(){{add(mock(SubNode.class));}};\r
virtualPorts1 = new ArrayList<VirtualPort>();\r
virtualPorts2 = new ArrayList<VirtualPort>();\r
+ class1 = ActionResolver.class;\r
\r
}\r
\r
@org.junit.Test\r
public void testResolveActions() throws Exception {\r
actionResolverTest.resolveActions(user,operation,node,virtualNetwork, userIntentVnMapping);\r
-\r
}\r
\r
@org.junit.Test\r
public void testResolveActions1() throws Exception {\r
when(operation.getAction()).thenReturn(actions);\r
- when(actions.get(0).getActionName()).thenReturn(new ActionName("qos-bandwidth"));\r
- action = actions.get(0);\r
- when(action.getParameterValues()).thenReturn(parametervalues);\r
+ Action qosBandwidthAction = mock(Action.class);\r
+ PowerMockito.mockStatic(ActionResolverUtils.class);\r
+ PowerMockito.when(ActionResolverUtils.getAction(any(List.class), any(ActionName.class))).thenReturn(qosBandwidthAction);\r
+ //test resolveQosBandwidthAction()\r
+ when(qosBandwidthAction.getParameterValues()).thenReturn(parametervalues);\r
when(parametervalues.getIntValue()).thenReturn(parameterValues1);\r
- intValue1 = parameterValues1.get(0);\r
- when(intValue1.getValue()).thenReturn(new Long(1));\r
+ IntValue parameterValue = parameterValues1.get(0);\r
+ when(parameterValue.getValue()).thenReturn(1L);\r
when(connection.getProperty()).thenReturn(properties);\r
- when(properties.get(0).getPropertyName()).thenReturn(new PropertyName("bandwidth"));\r
- property2 = properties.get(0);\r
- when(property2.getPropertyValues()).thenReturn(propertyValues);\r
+ Property property = mock(Property.class);\r
+ PowerMockito.mockStatic(IntentResolverUtils.class);\r
+ PowerMockito.when(IntentResolverUtils.getConnectionProperty(any(List.class), any(PropertyName.class))).thenReturn(property);\r
+ when(property.getPropertyValues()).thenReturn(propertyValues);\r
when(propertyValues.getIntValue()).thenReturn(parameterValues2);\r
intValue2 = parameterValues2.get(0);\r
- when(intValue2.getValue()).thenReturn(new Long(2));\r
+ when(intValue2.getValue()).thenReturn(2L);\r
when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResults);\r
+ IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class);\r
when(connection.getConnectionId()).thenReturn(connectionId);\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId(connectionId));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
+ PowerMockito.when(IntentResolverUtils.getIntentVnMappingResult(any(List.class), any(IntentId.class))).thenReturn(intentVnMappingResult);\r
+ when(intentVnMappingResult.getVirtualResource()).thenReturn(virtualResources);\r
when(virtualNetwork.getVirtualLinks()).thenReturn(virtualLink);\r
when(virtualLink.getVirtualLink()).thenReturn(virtualLinks);\r
when(virtualResources.get(0).getVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
when(virtualResourceEntityId.getValue()).thenReturn("11111111-1111-1111-1111-111111111111");\r
when(virtualLinks.get(0).getLinkId()).thenReturn(new VirtualLinkId("11111111-1111-1111-1111-111111111111"));\r
actionResolverTest.resolveActions(user,operation,connection,virtualNetwork, userIntentVnMapping);\r
-\r
}\r
\r
@org.junit.Test\r
public void testResolveActionsDeny() throws Exception {\r
-\r
//deny\r
when(operation.getAction()).thenReturn(actions);\r
- when(actions.get(0).getActionName()).thenReturn(new ActionName("deny"));\r
+ Action denyAction = mock(Action.class);\r
+ PowerMockito.mockStatic(ActionResolverUtils.class);\r
+ PowerMockito.when(ActionResolverUtils.getAction(any(List.class), any(ActionName.class))).thenReturn(denyAction);\r
when(user.getObjects()).thenReturn(objects);\r
when(objects.getNode()).thenReturn(nodes);\r
when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNode);\r
when(virtualNode.getVirtualNode()).thenReturn(virtualNodes);\r
when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResults);\r
- when(flow.getMatchItem()).thenReturn(matchItem);//matchItem\r
- when(matchItem.get(0).getMatchItemName()).thenReturn(new MatchItemName("src-ip"));\r
- when(matchItem.get(0).getMatchItemValue()).thenReturn(matchItemValue);//matchItemValue\r
- when(matchItemValue.getStringValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeType()).thenReturn(new NodeType("l2-group"));\r
- when(nodes.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("ip-prefix"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeId()).thenReturn(nodeId);\r
- when(nodeId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
- when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport);\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
-\r
- when(flow.getMatchItem()).thenReturn(matchItem);//matchItem\r
- when(matchItem.get(0).getMatchItemName()).thenReturn(new MatchItemName("src-ip"));\r
- when(matchItem.get(0).getMatchItemValue()).thenReturn(matchItemValue);//matchItemValue\r
- when(matchItemValue.getStringValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeType()).thenReturn(new NodeType("l2-group"));\r
- when(nodes.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("ip-prefix"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeId()).thenReturn(nodeId);\r
- when(nodeId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
- when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport);\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
-\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
+ VirtualNode sourceVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.when(ActionResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults)).thenReturn(sourceVirtualNode);\r
+ VirtualNode destinationVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.when(ActionResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults)).thenReturn(destinationVirtualNode);\r
+ when(user.getUserId()).thenReturn(userId);\r
+ VNComputationUnit vnComputationUnit = vnComputationUnits.get(userId);\r
+ //List<VirtualPath> virtualPath = new ArrayList<VirtualPath>(){{ add(mock(VirtualPath.class));}};\r
+ VirtualPath virtualPath = mock(VirtualPath.class);\r
+ VirtualNodeId vnodeIds = mock(VirtualNodeId.class);\r
+ VirtualNodeId vnodeIdd = mock(VirtualNodeId.class);\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(vnodeIds);\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(vnodeIdd);\r
+ when(vnComputationUnit.computePath(vnodeIds, vnodeIdd)).thenReturn(virtualPath);\r
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink>(){{add(mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink.class));}};\r
+ when(virtualPath.getVirtualLink()).thenReturn(virtualLinks);\r
+ VirtualPaths virtualPaths = mock(VirtualPaths.class);\r
+ List<VirtualPath> virtualPathList = new ArrayList<VirtualPath>();\r
+ when(virtualNetwork.getVirtualPaths()).thenReturn(virtualPaths);\r
+ when(virtualPaths.getVirtualPath()).thenReturn(virtualPathList);\r
+ when(virtualPath.getPathId()).thenReturn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.VirtualPathId("11111111-1111-1111-1111-111111111111"));\r
when(operation.getOperationId()).thenReturn(new OperationId("11111111-1111-1111-1111-111111111111"));\r
- //actionResolverTest.resolveActions(user,operation,flow,virtualNetwork, userIntentVnMapping);\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
+ actionResolverTest.resolveActions(user,operation,flow,virtualNetwork, userIntentVnMapping);\r
}\r
- /*@org.junit.Test\r
+ @org.junit.Test\r
public void testResolveActionsAllow() throws Exception\r
{\r
\r
//allow\r
when(operation.getAction()).thenReturn(actions);\r
- when(actions.get(0).getActionName()).thenReturn(new ActionName("allow"));\r
+ Action allowAction = mock(Action.class);\r
+ PowerMockito.mockStatic(ActionResolverUtils.class);\r
+ PowerMockito.when(ActionResolverUtils.getAction(any(List.class), any(ActionName.class))).thenReturn(null);\r
+ PowerMockito.when(ActionResolverUtils.getAction(any(List.class), any(ActionName.class))).thenReturn(allowAction);\r
+\r
when(user.getObjects()).thenReturn(objects);\r
when(objects.getNode()).thenReturn(nodes);\r
when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNode);\r
when(virtualNode.getVirtualNode()).thenReturn(virtualNodes);\r
when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResults);\r
-\r
-\r
-\r
- when(flow.getMatchItem()).thenReturn(matchItem);//matchItem\r
- when(matchItem.get(0).getMatchItemName()).thenReturn(new MatchItemName("src-ip"));\r
- when(matchItem.get(0).getMatchItemValue()).thenReturn(matchItemValue);//matchItemValue\r
- when(matchItemValue.getStringValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeType()).thenReturn(new NodeType("l2-group"));\r
- when(nodes.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("ip-prefix"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeId()).thenReturn(nodeId);\r
- when(nodeId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
- when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport);\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- System.out.println("1");\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- System.out.println("2");\r
- when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
- System.out.println("3");\r
- //when(flow.getFlowId()).thenReturn(new FlowId("11111111-1111-1111-1111-111111111111"));\r
-\r
-\r
-\r
- when(flow.getMatchItem()).thenReturn(matchItem);//matchItem\r
- when(matchItem.get(0).getMatchItemName()).thenReturn(new MatchItemName("dst-ip"));\r
- when(matchItem.get(0).getMatchItemValue()).thenReturn(matchItemValue);//matchItemValue\r
- when(matchItemValue.getStringValue()).thenReturn(new String("dst-ip"));\r
- when(nodes.get(0).getNodeType()).thenReturn(new NodeType("l2-group"));\r
- when(nodes.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("ip-prefix"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeId()).thenReturn(nodeId);\r
- when(nodeId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
- when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport);\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
+ VirtualNode sourceVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.when(ActionResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults)).thenReturn(sourceVirtualNode);\r
+ VirtualNode destinationVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.when(ActionResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults)).thenReturn(destinationVirtualNode);\r
+ when(user.getUserId()).thenReturn(userId);\r
+ VNComputationUnit vnComputationUnit = vnComputationUnits.get(userId);\r
+ //List<VirtualPath> virtualPath = new ArrayList<VirtualPath>(){{ add(mock(VirtualPath.class));}};\r
+ VirtualPath virtualPath = mock(VirtualPath.class);\r
+ VirtualNodeId vnodeIds = mock(VirtualNodeId.class);\r
+ VirtualNodeId vnodeIdd = mock(VirtualNodeId.class);\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(vnodeIds);\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(vnodeIdd);\r
+ when(vnComputationUnit.computePath(vnodeIds, vnodeIdd)).thenReturn(virtualPath);\r
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink>(){{add(mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink.class));}};\r
+ when(virtualPath.getVirtualLink()).thenReturn(virtualLinks);\r
+ VirtualPaths virtualPaths = mock(VirtualPaths.class);\r
+ List<VirtualPath> virtualPathList = new ArrayList<VirtualPath>();\r
+ when(virtualNetwork.getVirtualPaths()).thenReturn(virtualPaths);\r
+ when(virtualPaths.getVirtualPath()).thenReturn(virtualPathList);\r
+ when(virtualPath.getPathId()).thenReturn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.VirtualPathId("11111111-1111-1111-1111-111111111111"));\r
+ when(operation.getOperationId()).thenReturn(new OperationId("11111111-1111-1111-1111-111111111111"));\r
actionResolverTest.resolveActions(user,operation,flow,virtualNetwork, userIntentVnMapping);\r
-\r
-\r
- }*/\r
+ }\r
\r
@org.junit.Test\r
public void testResolveActionsGoChain() throws Exception {\r
- //ResolveActions()\r
- when(operation.getAction()).thenReturn(actions);\r
- when(actions.get(0).getActionName()).thenReturn(new ActionName("go-through"));\r
- when(actions.get(0).getParameterValues()).thenReturn(parametervalues);\r
- when(parametervalues.getStringValue()).thenReturn(stringValue2);\r
-\r
- //resolveGoThroughAction()\r
+ Node nodex = mock(Node.class);\r
+ Action goThroughAction = mock(Action.class);\r
+ method = class1.getDeclaredMethod("resolveGoThroughChainGroupAction",new Class[]{\r
+ User.class,\r
+ Operation.class,\r
+ Flow.class,\r
+ Action.class,\r
+ Node.class,\r
+ VirtualNetwork.class,\r
+ UserIntentVnMapping.class\r
+ });\r
+ method.setAccessible(true);\r
+ /*ParameterValues parameterValue = mock(ParameterValues.class);\r
+ List<StringValue> parameterValues = new ArrayList<StringValue>();\r
+ StringValue stringValue = mock(StringValue.class);\r
+ parameterValues.add(stringValue);\r
+ when(goThroughAction.getParameterValues()).thenReturn(parameterValue);\r
+ when(parameterValue.getStringValue()).thenReturn(parameterValues);\r
+ List<Node> nodes = new ArrayList<Node>();\r
+\r
+ nodes.add(nodex);\r
when(user.getObjects()).thenReturn(objects);\r
- when(objects.getNode()).thenReturn(nodes3);\r
- when(stringValue2.get(0).getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(nodes3.get(0).getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
+ when(objects.getNode()).thenReturn(nodes);\r
+ when(stringValue.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
+ //PowerMockito.mockStatic(IntentResolverUtils.class);\r
+ //PowerMockito.when(IntentResolverUtils.getNode(any(List.class), any(NodeId.class))).thenReturn(nodex);\r
+ when(nodex.getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
+ when(nodex.getNodeType()).thenReturn(new NodeType("chain-group"));*/\r
\r
- //chaingroup\r
- when(nodes3.get(0).getNodeType()).thenReturn(new NodeType("chain-group"));\r
- //resolveGoThroughChainGroupAction()\r
when(user.getObjects()).thenReturn(objects2);\r
when(objects2.getNode()).thenReturn(nodes3);\r
when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNode);\r
when(virtualPath.getVirtualPath()).thenReturn(virtualPaths);\r
when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResults);\r
\r
- //when(nodes3.get(0).getSubNode()).thenReturn(new ArrayList<SubNode>());\r
- when(nodes3.get(0).getSubNode()).thenReturn(subNodes);\r
- when(subNodes.get(0).getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
- when(nodes3.get(0).getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
- when(nodes3.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("operating-mode"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("layer1"));\r
- when(nodes3.get(0).getSubNode()).thenReturn(subNodes);\r
- when(subNodes.get(0).getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
- when(nodes3.get(0).getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
- when(nodes3.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("operating-mode"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("layer3"));\r
- when(nodes3.get(0).getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
-\r
- //getSourceVirtualRouterOfFlow()\r
- when(flow.getMatchItem()).thenReturn(matchItem);//matchItem\r
- when(matchItem.get(0).getMatchItemName()).thenReturn(new MatchItemName("src-ip"));\r
- when(matchItem.get(0).getMatchItemValue()).thenReturn(matchItemValue);//matchItemValue\r
- when(matchItemValue.getStringValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeType()).thenReturn(new NodeType("l2-group"));\r
- when(nodes.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("ip-prefix"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeId()).thenReturn(nodeId);\r
- when(nodeId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
- when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport);\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
-\r
- //getDestinationVirtualRouterOfFlow()\r
- when(flow.getMatchItem()).thenReturn(matchItem);//matchItem\r
- when(matchItem.get(0).getMatchItemName()).thenReturn(new MatchItemName("dst-ip"));\r
- when(matchItem.get(0).getMatchItemValue()).thenReturn(matchItemValue);//matchItemValue\r
- when(matchItemValue.getStringValue()).thenReturn(new String("dst-ip"));\r
- when(nodes.get(0).getNodeType()).thenReturn(new NodeType("l2-group"));\r
- when(nodes.get(0).getProperty()).thenReturn(properties2);\r
- when(properties2.get(0).getPropertyName()).thenReturn(new PropertyName("ip-prefix"));\r
- when(properties2.get(0).getPropertyValues()).thenReturn(propertyValues);\r
- when(propertyValues.getStringValue()).thenReturn(stringValue);\r
- when(stringValue.get(0).getValue()).thenReturn(new String("src-ip"));\r
- when(nodes.get(0).getNodeId()).thenReturn(nodeId);\r
- when(nodeId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getIntentId()).thenReturn(new IntentId("11111111-1111-1111-1111-111111111111"));\r
- when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
- when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport);\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
+ when(nodex.getSubNode()).thenReturn(new ArrayList<SubNode>());\r
+ PowerMockito.mockStatic(IntentResolverUtils.class);\r
+ PowerMockito.when(IntentResolverUtils.checkAllLayer2OperatingMode(any(List.class), any(List.class))).thenReturn(false);\r
+ when(nodex.getSubNode()).thenReturn(new ArrayList<SubNode>());\r
+ PowerMockito.when(IntentResolverUtils.checkAllLayer3OperatingMode(any(List.class), any(List.class))).thenReturn(true);\r
+ IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class);\r
+ when(nodex.getNodeId()).thenReturn(new NodeId("11111111-1111-1111-1111-111111111111"));\r
+ PowerMockito.when(IntentResolverUtils.getIntentVnMappingResult(any(List.class), any(IntentId.class))).thenReturn(intentVnMappingResult);\r
+ VirtualNode sourceVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.mockStatic(ActionResolverUtils.class);\r
+ PowerMockito.when(ActionResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes3, intentVnMappingResults)).thenReturn(sourceVirtualNode);\r
+ VirtualNode destinationVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.when(ActionResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes3, intentVnMappingResults)).thenReturn(destinationVirtualNode);\r
+ List<VirtualResource> virtualResources1 = new ArrayList<VirtualResource>(){{add(mock(VirtualResource.class));}};\r
+ when(intentVnMappingResult.getVirtualResource()).thenReturn(new ArrayList<VirtualResource>());\r
+ PowerMockito.when(ActionResolverUtils.sortVirtualResources(any(List.class))).thenReturn(virtualResources1);\r
+ when(virtualResources1.get(0).getParentVirtualResourceEntityId()).thenReturn(new VirtualResourceEntityId("11111111-1111-1111-1111-111111111111"));\r
+ VirtualNode virtualNode = mock(VirtualNode.class);\r
+ PowerMockito.mockStatic(IntentResolverUtils.class);\r
+ PowerMockito.when(IntentResolverUtils.getVirtualNode(any(List.class), any(VirtualNodeId.class))).thenReturn(virtualNode);\r
+ when(virtualResources1.get(0).getParentVirtualResourceEntityId()).thenReturn(new VirtualResourceEntityId("11111111-1111-1111-1111-111111111111"));\r
+ VirtualNode virtualNode1 = mock(VirtualNode.class);\r
+ PowerMockito.when(IntentResolverUtils.getVirtualNode(any(List.class), any(VirtualNodeId.class))).thenReturn(virtualNode1);\r
+ VirtualLink virtualLink = mock(VirtualLink.class);\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(virtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ PowerMockito.when(IntentResolverUtils.getVirtualLink(any(List.class), any(VirtualNodeId.class), any(VirtualNodeId.class))).thenReturn(virtualLink);\r
+ when(virtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(virtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(virtualLink.getLinkId()).thenReturn(mock(VirtualLinkId.class));\r
+ when(virtualNode1.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(virtualNode1.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(virtualNode1.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(mock(VirtualNodeId.class));\r
+ when(virtualLink.getLinkId()).thenReturn(mock(VirtualLinkId.class));\r
+ when(operation.getOperationId()).thenReturn(new OperationId("11111111-1111-1111-1111-111111111111"));\r
+ method.invoke(actionResolverTest,user,operation,flow,goThroughAction,nodex,virtualNetwork, userIntentVnMapping);\r
+ }\r
\r
\r
+ @org.junit.Test\r
+ public void testResolveActionsGoNormal() throws Exception {\r
+ //ResolveActions()\r
+ field = class1.getDeclaredField("vnComputationUnits");\r
+ Map<UserId, VNComputationUnit> vnComputationUnits = new HashMap<UserId, VNComputationUnit>();\r
+ VNComputationUnit vnComputationUnit = mock(VNComputationUnit.class);\r
+ vnComputationUnits.put(userId,vnComputationUnit);\r
+ field.setAccessible(true);\r
+ field.set(actionResolverTest,vnComputationUnits);\r
+ Node nodex = mock(Node.class);\r
+ Action goThroughAction = mock(Action.class);\r
+ method = class1.getDeclaredMethod("resolveGoThroughNormalGroupAction",new Class[]{\r
+ User.class,\r
+ Operation.class,\r
+ Flow.class,\r
+ Action.class,\r
+ VirtualNetwork.class,\r
+ UserIntentVnMapping.class\r
+ });\r
+ method.setAccessible(true);\r
+ IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class);\r
+ when(user.getObjects()).thenReturn(objects2);\r
+ when(objects2.getNode()).thenReturn(nodes3);\r
+ when(goThroughAction.getParameterValues()).thenReturn(parametervalues);\r
+ when(parametervalues.getStringValue()).thenReturn(stringValue2);\r
+ when(stringValue2.get(0).getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
+ PowerMockito.mockStatic(IntentResolverUtils.class);\r
+ PowerMockito.when(IntentResolverUtils.getNode(any(List.class), any(NodeId.class))).thenReturn(nodex);\r
+ when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNode);\r
+ when(virtualNode.getVirtualNode()).thenReturn(virtualNodes);\r
+ when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResults);\r
+ PowerMockito.mockStatic(ActionResolverUtils.class);\r
+ PowerMockito.when(ActionResolverUtils.sortParameterValues(any(List.class))).thenReturn(stringValue2);\r
+ when(stringValue2.get(0).getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
when(intentVnMappingResults.get(0).getVirtualResource()).thenReturn(virtualResources);\r
+ when(stringValue.get(0).getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
+ PowerMockito.mockStatic(IntentResolverUtils.class);\r
+ PowerMockito.when(IntentResolverUtils.getIntentVnMappingResult(any(List.class), any(IntentId.class))).thenReturn(intentVnMappingResult);\r
+ when(intentVnMappingResult.getVirtualResource()).thenReturn(virtualResources);\r
\r
+ when(virtualResources.get(0).getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vnode);\r
+ when(virtualResources.get(0).getVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
+ when(virtualResourceEntityId.getValue()).thenReturn("11111111-1111-1111-1111-111111111111");\r
\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
-\r
- when(virtualResources.get(0).getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);\r
- when(virtualResourceEntityId.getValue()).thenReturn(new String("11111111-1111-1111-1111-111111111112"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111112"));\r
-\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111112"));\r
- when(virtualLinks.get(0).getSrcNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111113111"));\r
- when(virtualLinks.get(0).getDestNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111131112"));\r
- when(virtualNodes.get(0).getVirtualPort()).thenReturn(virtualPorts1);\r
- when(virtualNodes.get(0).getVirtualPort()).thenReturn(virtualPorts2);\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111112"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111112"));\r
- when(virtualNodes.get(0).getNodeId()).thenReturn(new VirtualNodeId("11111111-1111-1111-1111-111111111111"));\r
+ PowerMockito.when(IntentResolverUtils.getVirtualNode(any(List.class), any(VirtualNodeId.class))).thenReturn(virtualNodes.get(0));\r
+ VirtualNode sourceVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.mockStatic(ActionResolverUtils.class);\r
+ PowerMockito.when(ActionResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes3, intentVnMappingResults)).thenReturn(sourceVirtualNode);\r
+ VirtualNode destinationVirtualNode = mock(VirtualNode.class);\r
+ PowerMockito.when(ActionResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes3, intentVnMappingResults)).thenReturn(destinationVirtualNode);\r
+ when(user.getUserId()).thenReturn(userId);\r
\r
+ VirtualPath virtualPath1 = mock(VirtualPath.class);\r
\r
- when(operation.getOperationId()).thenReturn(new OperationId("11111111-1111-1111-1111-111111131112"));\r
+ VirtualNodeId virtualNodeId1 = new VirtualNodeId("11111111-1111-1111-1111-111111111111");\r
+ VirtualNodeId virtualNodeId2 = new VirtualNodeId("11111111-1111-1111-1111-111111111112");\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(virtualNodeId1);\r
+ when(virtualNodes.get(0).getNodeId()).thenReturn(virtualNodeId2);\r
+ when(sourceVirtualNode.getNodeId()).thenReturn(virtualNodeId1);\r
+ when(virtualNodes.get(0).getNodeId()).thenReturn(virtualNodeId2);\r
+ when(vnComputationUnit.computePath(virtualNodeId1,virtualNodeId2)).thenReturn(virtualPath1);\r
\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(virtualNodeId1);\r
+ when(virtualNodes.get(0).getNodeId()).thenReturn(virtualNodeId2);\r
+ when(virtualNodes.get(0).getNodeId()).thenReturn(virtualNodeId2);\r
+ when(destinationVirtualNode.getNodeId()).thenReturn(virtualNodeId1);\r
+ when(vnComputationUnit.computePath(virtualNodeId2,virtualNodeId1)).thenReturn(virtualPath1);\r
+ VirtualPaths virtualPaths = mock(VirtualPaths.class);\r
+ List<VirtualPath> virtualPathList = new ArrayList<VirtualPath>();\r
+ when(virtualNetwork.getVirtualPaths()).thenReturn(virtualPaths);\r
+ when(virtualPaths.getVirtualPath()).thenReturn(virtualPathList);\r
\r
\r
\r
- actionResolverTest.resolveActions(user,operation,flow,virtualNetwork, userIntentVnMapping);\r
- }\r
\r
\r
- @org.junit.Test\r
- public void testResolveActionsGoNormal() throws Exception {\r
- //ResolveActions()\r
- when(operation.getAction()).thenReturn(actions);\r
+ //method.invoke(actionResolverTest,user,operation,flow,goThroughAction,virtualNetwork, userIntentVnMapping);\r
+ /*when(operation.getAction()).thenReturn(actions);\r
when(actions.get(0).getActionName()).thenReturn(new ActionName("go-through"));\r
when(actions.get(0).getParameterValues()).thenReturn(parametervalues);\r
when(parametervalues.getStringValue()).thenReturn(stringValue2);\r
when(virtualNodes.get(0).getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter);\r
\r
\r
- //actionResolverTest.resolveActions(user,operation,flow,virtualNetwork, userIntentVnMapping);\r
+ //actionResolverTest.resolveActions(user,operation,flow,virtualNetwork, userIntentVnMapping);*/\r
\r
\r
}\r
-/*\r
- * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-/* Generated By:JavaCC: Do not edit this line. NEMOparserTokenManager.java */\r
-package org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse;\r
-import junit.framework.TestCase;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.NEMOparser;\r
-import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.NEMOparserTokenManager;\r
-import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.SimpleCharStream;\r
-import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.Token;\r
-\r
-import java.io.IOException;\r
-import java.io.PrintStream;\r
-import java.io.Reader;\r
-import java.lang.reflect.Field;\r
-import java.lang.reflect.Member;\r
-import java.lang.reflect.Method;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.*;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.api.support.membermodification.MemberMatcher;\r
-import org.powermock.api.support.membermodification.MemberModifier;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-/**\r
- * Created by zhangmeng on 2015/12/17.\r
- */\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({NEMOparserTokenManager.class,SimpleCharStream.class})\r
-public class NEMOparserTokenManagerTest extends TestCase {\r
- private SimpleCharStream simpleCharStream;\r
- private int lexState;\r
- private NEMOparserTokenManager nemOparserTokenManager;\r
- private Class<NEMOparserTokenManager> class1;\r
- private Field field;\r
- @Before\r
- public void setUp() throws Exception {\r
- class1 = NEMOparserTokenManager.class;\r
- field = class1.getDeclaredField("input_stream");\r
- field.setAccessible(true);\r
- field.set(class1,null);\r
-\r
- simpleCharStream = mock(SimpleCharStream.class);\r
- lexState = 0;\r
- }\r
-\r
- @Test\r
- public void Init_ReInit() throws Exception{\r
- nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream);\r
- NEMOparserTokenManager.ReInit(null);\r
- nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream,lexState);//curLexstate = 0\r
- NEMOparserTokenManager.ReInit(null, lexState);\r
-\r
- Assert.assertTrue(field.get(class1) == null);\r
- }\r
-\r
- @Test\r
- public void testSetDebugStream() throws Exception {\r
- NEMOparserTokenManager.setDebugStream(null);\r
- Field field1 = class1.getField("debugStream");\r
- field1.setAccessible(true);\r
- Assert.assertTrue(field1.get(class1) == null);\r
- }\r
-\r
-\r
- @Test\r
- public void testJjFillToken() throws Exception {\r
- nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream);\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.GetImage()).thenReturn("test");\r
- Assert.assertTrue(NEMOparserTokenManager.jjFillToken() != null);\r
- }\r
-\r
- @Test\r
- public void testGetNextToken() throws Exception {\r
- char curChar = 40;\r
- nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream);\r
- Assert.assertTrue(field.get(nemOparserTokenManager) == simpleCharStream);\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.BeginToken()).thenReturn(curChar);\r
-// System.out.println("out :" + NEMOparserTokenManager.getNextToken());\r
- Assert.assertTrue(NEMOparserTokenManager.getNextToken() != null);\r
- }\r
-\r
- @Test\r
- public void testjjStartNfa_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjStartNfa_0",new Class[]{int.class,long.class});\r
- method.setAccessible(true);\r
- int pos = 1;\r
- long active0 = 1L;\r
-\r
- Assert.assertTrue((Integer) method.invoke(class1, pos, active0) == 3);\r
-// System.out.println("method.invoke(class1,pos,active0):" + method.invoke(class1,pos,active0));\r
- }\r
-\r
- @Test\r
- public void testjjStopStringLiteralDfa_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjStopStringLiteralDfa_0",new Class[]{\r
- int.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-// System.out.println("testjjStopStringLiteralDfa_0" + method.invoke(class1, 0, 0));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0, 0) == -1);\r
-// System.out.println("testjjStopStringLiteralDfa_0" + method.invoke(class1, 0, 0x74800000000000L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0, 0x74800000000000L) == 205);\r
-// System.out.println("testjjStopStringLiteralDfa_0" + method.invoke(class1, 0, 0x3000000000000L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0, 0x3000000000000L) == 81);\r
- //case1\r
- Assert.assertTrue((Integer) method.invoke(class1, 1, 0x77800000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1, 0) == -1);\r
- //case2\r
- Assert.assertTrue((Integer) method.invoke(class1, 2, 0x77800000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 2, 0) == -1);\r
- //case3\r
- Assert.assertTrue((Integer) method.invoke(class1, 3, 0x77800000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 3, 0) == -1);\r
- //case4\r
- Assert.assertTrue((Integer) method.invoke(class1, 4, 0x35000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 4, 0x42800000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 4, 0) == -1);\r
- //case5\r
- Assert.assertTrue((Integer) method.invoke(class1, 5, 0x25000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 5, 0x10000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 5, 0) == -1);\r
- //case6\r
- Assert.assertTrue((Integer) method.invoke(class1, 6, 0x5000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 6, 0x20000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 6, 0) == -1);\r
- //case7\r
- Assert.assertTrue((Integer) method.invoke(class1, 7, 0x5000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 7, 0) == -1);\r
- //case8\r
- Assert.assertTrue((Integer) method.invoke(class1, 8, 0x5000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 8, 0) == -1);\r
- //case9\r
- Assert.assertTrue((Integer) method.invoke(class1, 9, 0x4000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 9, 0x1000000000000L) == 205);\r
- Assert.assertTrue((Integer) method.invoke(class1, 9, 0) == -1);\r
- //case default\r
- Assert.assertTrue((Integer) method.invoke(class1, 10, 0) == -1);\r
-\r
- }\r
-\r
- @Test\r
- public void testjjStopAtPos() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjStopAtPos",new Class[]{\r
- int.class,\r
- int.class\r
- });\r
- method.setAccessible(true);\r
-\r
- Assert.assertTrue((Integer) method.invoke(class1,1,1) == 2);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa0_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa0_0");\r
- method.setAccessible(true);\r
- Field field = class1.getDeclaredField("curChar");\r
- field.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar()).thenReturn((char) 0);\r
-\r
- NEMOparserTokenManager.curChar = 33;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 38;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 40;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 41;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 42;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 43;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 44;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 58;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 59;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 60;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 61;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 65;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 66;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 67;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 68;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 69;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 70;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 73;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 77;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 78;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 79;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 80;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 81;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 84;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 85;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 91;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 93;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 99;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 102;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 105;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 110;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 111;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 114;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 115;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 124;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- NEMOparserTokenManager.curChar = 1;\r
-// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));\r
- Assert.assertTrue((Integer) method.invoke(class1) != 0);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa1_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa1_0",new Class[]{long.class});\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 38)\r
- .thenReturn((char) 61)\r
- .thenReturn((char) 61)\r
- .thenReturn((char) 61)\r
- .thenReturn((char) 69)\r
- .thenReturn((char) 77)\r
- .thenReturn((char) 80)\r
- .thenReturn((char) 82)\r
- .thenReturn((char) 97)\r
- .thenReturn((char) 99)\r
- .thenReturn((char) 101)\r
- .thenReturn((char) 108)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 112)\r
- .thenReturn((char) 114)\r
- .thenReturn((char) 116)\r
- .thenReturn((char) 117)\r
- .thenReturn((char) 121)\r
- .thenReturn((char) 124);\r
-\r
- //case default\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
- //case 38 and so on\r
-// System.out.println("0x8000L" + method.invoke(class1, 0x1000L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x1000L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 38);\r
-// System.out.println("0x8000L" + method.invoke(class1, 0x8000L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x8000L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 61);\r
-// System.out.println("0x8000L" + method.invoke(class1,0x40000L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x40000L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 61);\r
-// System.out.println("0x8000L" + method.invoke(class1,0x80000L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x80000L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 61);\r
-// System.out.println("0x8000L" + method.invoke(class1,0L));\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 69);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 77);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 80);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 82);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 97);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 99);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 108);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 112);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 114);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 117);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 121);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 124);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa2_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa2_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 68)\r
- .thenReturn((char) 69)\r
- .thenReturn((char) 76)\r
- .thenReturn((char) 80)\r
- .thenReturn((char) 97)\r
- .thenReturn((char) 100)\r
- .thenReturn((char) 101)\r
- .thenReturn((char) 103)\r
- .thenReturn((char) 105)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 112)\r
- .thenReturn((char) 114)\r
- .thenReturn((char) 116);\r
-\r
- //case default\r
-// System.out.println("0x8000L" + method.invoke(class1, 1L, 1L));\r
- Assert.assertTrue((Integer)method.invoke(class1,1L,1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 68);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 69);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 76);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 80);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 97);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 100);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 103);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 112);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 114);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
-\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa3_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa3_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 65)\r
- .thenReturn((char) 69)\r
- .thenReturn((char) 79)\r
- .thenReturn((char) 99)\r
- .thenReturn((char) 100)\r
- .thenReturn((char) 101)\r
- .thenReturn((char) 103)\r
- .thenReturn((char) 105)\r
- .thenReturn((char) 109)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 112)\r
- .thenReturn((char) 114)\r
- .thenReturn((char) 116)\r
- .thenReturn((char) 119);\r
-\r
- //case default\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 65);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 69);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 79);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 99);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 100);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 103);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 109);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 112);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 114);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 119);\r
-\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa4_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa4_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 77)\r
- .thenReturn((char) 82)\r
- .thenReturn((char) 84)\r
- .thenReturn((char) 97)\r
- .thenReturn((char) 101)\r
-// .thenReturn((char) 101)\r
- .thenReturn((char) 103)\r
- .thenReturn((char) 104)\r
-// .thenReturn((char) 104)\r
- .thenReturn((char) 105)\r
-// .thenReturn((char) 110)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 114)\r
-// .thenReturn((char) 115)\r
-// .thenReturn((char) 115)\r
- .thenReturn((char) 115)\r
- .thenReturn((char) 121);\r
-\r
- //case default:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 77);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 82);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 84);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 97);\r
-// Assert.assertTrue((Integer) method.invoke(class1, 0x40000000000000L, 0x40000000000000L) == 5);\r
-// System.out.println("0x40000000000000L" + method.invoke(class1, 0x40000000000000L, 0x40000000000000L));\r
-// Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 103);\r
-// System.out.println("0x40000000000000L" + method.invoke(class1, 0x1000000000L, 0x1000000000L));\r
-// Assert.assertTrue(NEMOparserTokenManager.curChar == 104);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 104);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
-// System.out.println("0x40000000000000L" + method.invoke(class1, 0x200000000000L, 0x200000000000L));\r
-// Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 114);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 115);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 121);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa5_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa5_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 69)\r
- .thenReturn((char) 69)\r
- .thenReturn((char) 69)\r
- .thenReturn((char) 84)\r
- .thenReturn((char) 97)\r
- .thenReturn((char) 99)\r
- .thenReturn((char) 100)\r
- .thenReturn((char) 101)\r
- .thenReturn((char) 103)\r
- .thenReturn((char) 105)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 114)\r
- .thenReturn((char) 116)\r
- .thenReturn((char) 116);\r
-\r
-\r
- //case default:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x2000000L, 0x2000000L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 69);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x10000000L, 0x10000000L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 69);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x8000000L, 0x8000000L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 69);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x4000000L, 0x4000000L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 84);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 97);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 99);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 100);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 103);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x10000000000L, 0x10000000000L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 114);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x4000000000L, 0x4000000000L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa6_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa6_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 99)\r
- .thenReturn((char) 100)\r
- .thenReturn((char) 101)\r
- .thenReturn((char) 105)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 114)\r
- .thenReturn((char) 116);\r
-\r
- //case default\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 99);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 100);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x80000000L, 0x80000000L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 114);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
-\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa7_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa7_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 101)\r
- .thenReturn((char) 105)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 115)\r
- .thenReturn((char) 116)\r
- .thenReturn((char) 121)\r
- .thenReturn((char) 121);\r
-\r
- //case default:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
-\r
- //case others:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 101);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x400000000L, 0x400000000L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 115);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 116);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x100000000L, 0x100000000L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 121);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x80000000000L, 0x80000000000L) == 8);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 121);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa8_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa8_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 105)\r
- .thenReturn((char) 108)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111);\r
-\r
- //case default:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
-\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 105);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x8000000000000L, 0x8000000000000L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 108);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x2000000000L, 0x2000000000L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x8000000000L, 0x8000000000L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa9_0() throws Exception{\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa9_0",new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 111)\r
- .thenReturn((char) 115);\r
-\r
- //case default:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
-\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x200000000L, 0x200000000L) == 10);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 111);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 115);\r
- }\r
-\r
- @Test\r
- public void testjjMoveStringLiteralDfa10_0() throws Exception {\r
- Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa10_0", new Class[]{\r
- long.class,\r
- long.class\r
- });\r
- method.setAccessible(true);\r
-\r
- PowerMockito.mockStatic(SimpleCharStream.class);\r
- PowerMockito.when(SimpleCharStream.readChar())\r
- .thenReturn((char) 0)\r
- .thenReturn((char) 110)\r
- .thenReturn((char) 115);\r
-\r
- //case default:\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 11);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 0);\r
-\r
- //case others\r
- Assert.assertTrue((Integer) method.invoke(class1, 0x100000000000L, 0x100000000000L) == 11);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 110);\r
- Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 11);\r
- Assert.assertTrue(NEMOparserTokenManager.curChar == 115);\r
- }\r
-\r
- @Test\r
- public void testjjStartNfaWithStates_0() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testjjMoveNfa_0() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testjjCheckNAdd() throws Exception {\r
- Field field = class1.getDeclaredField("jjrounds");\r
- field.setAccessible(true);\r
- Field field1 = class1.getDeclaredField("jjround");\r
- field1.setAccessible(true);\r
-\r
- int state = 1;\r
- int jjrounds[] = new int[205];\r
- jjrounds[0] = 1;\r
- int jjround = 1;\r
-\r
- }\r
+/*
+ * Copyright (c) 2016 Huawei, 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
+ */
+/* Generated By:JavaCC: Do not edit this line. NEMOparserTokenManager.java */
+package org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse;
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.NEMOparser;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.NEMOparserTokenManager;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.SimpleCharStream;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.Token;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+/**
+ * Created by zhangmeng on 2015/12/17.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(SimpleCharStream.class)
+public class NEMOparserTokenManagerTest extends TestCase {
+ private SimpleCharStream simpleCharStream;
+ private int lexState;
+ private NEMOparserTokenManager nemOparserTokenManager;
+ private Class<NEMOparserTokenManager> class1;
+ private Field field;
+ @Before
+ public void setUp() throws Exception {
+ class1 = NEMOparserTokenManager.class;
+ field = class1.getDeclaredField("input_stream");
+ field.setAccessible(true);
+ field.set(class1,null);
+
+ simpleCharStream = mock(SimpleCharStream.class);
+ lexState = 0;
+ }
+
+ @Test
+ public void Init_ReInit() throws Exception{
+ nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream);
+ NEMOparserTokenManager.ReInit(null);
+ nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream,lexState);//curLexstate = 0
+ NEMOparserTokenManager.ReInit(null, lexState);
+
+ Assert.assertTrue(field.get(class1) == null);
+ }
+
+ @Test
+ public void testSetDebugStream() throws Exception {
+ NEMOparserTokenManager.setDebugStream(null);
+ Field field1 = class1.getField("debugStream");
+ field1.setAccessible(true);
+ Assert.assertTrue(field1.get(class1) == null);
+ }
+
+
+ @Test
+ public void testJjFillToken() throws Exception {
+ nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream);
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.GetImage()).thenReturn("test");
+ Assert.assertTrue(NEMOparserTokenManager.jjFillToken() != null);
+ }
+
+ @Test
+ public void testGetNextToken() throws Exception {
+ char curChar = 40;
+ nemOparserTokenManager = new NEMOparserTokenManager(simpleCharStream);
+ Assert.assertTrue(field.get(nemOparserTokenManager) == simpleCharStream);
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.BeginToken()).thenReturn(curChar);
+// System.out.println("out :" + NEMOparserTokenManager.getNextToken());
+ Assert.assertTrue(NEMOparserTokenManager.getNextToken() != null);
+ }
+
+ @Test
+ public void testjjStartNfa_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjStartNfa_0",new Class[]{int.class,long.class});
+ method.setAccessible(true);
+ int pos = 1;
+ long active0 = 1L;
+
+ Assert.assertTrue((Integer) method.invoke(class1, pos, active0) == 3);
+// System.out.println("method.invoke(class1,pos,active0):" + method.invoke(class1,pos,active0));
+ }
+
+ @Test
+ public void testjjStopStringLiteralDfa_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjStopStringLiteralDfa_0",new Class[]{
+ int.class,
+ long.class
+ });
+ method.setAccessible(true);
+// System.out.println("testjjStopStringLiteralDfa_0" + method.invoke(class1, 0, 0));
+ Assert.assertTrue((Integer) method.invoke(class1, 0, 0) == -1);
+// System.out.println("testjjStopStringLiteralDfa_0" + method.invoke(class1, 0, 0x74800000000000L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0, 0x74800000000000L) == 205);
+// System.out.println("testjjStopStringLiteralDfa_0" + method.invoke(class1, 0, 0x3000000000000L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0, 0x3000000000000L) == 81);
+ //case1
+ Assert.assertTrue((Integer) method.invoke(class1, 1, 0x77800000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 1, 0) == -1);
+ //case2
+ Assert.assertTrue((Integer) method.invoke(class1, 2, 0x77800000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 2, 0) == -1);
+ //case3
+ Assert.assertTrue((Integer) method.invoke(class1, 3, 0x77800000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 3, 0) == -1);
+ //case4
+ Assert.assertTrue((Integer) method.invoke(class1, 4, 0x35000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 4, 0x42800000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 4, 0) == -1);
+ //case5
+ Assert.assertTrue((Integer) method.invoke(class1, 5, 0x25000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 5, 0x10000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 5, 0) == -1);
+ //case6
+ Assert.assertTrue((Integer) method.invoke(class1, 6, 0x5000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 6, 0x20000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 6, 0) == -1);
+ //case7
+ Assert.assertTrue((Integer) method.invoke(class1, 7, 0x5000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 7, 0) == -1);
+ //case8
+ Assert.assertTrue((Integer) method.invoke(class1, 8, 0x5000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 8, 0) == -1);
+ //case9
+ Assert.assertTrue((Integer) method.invoke(class1, 9, 0x4000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 9, 0x1000000000000L) == 205);
+ Assert.assertTrue((Integer) method.invoke(class1, 9, 0) == -1);
+ //case default
+ Assert.assertTrue((Integer) method.invoke(class1, 10, 0) == -1);
+
+ }
+
+ @Test
+ public void testjjStopAtPos() throws Exception{
+ Method method = class1.getDeclaredMethod("jjStopAtPos",new Class[]{
+ int.class,
+ int.class
+ });
+ method.setAccessible(true);
+
+ Assert.assertTrue((Integer) method.invoke(class1,1,1) == 2);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa0_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa0_0");
+ method.setAccessible(true);
+ Field field = class1.getDeclaredField("curChar");
+ field.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar()).thenReturn((char) 0);
+
+ NEMOparserTokenManager.curChar = 33;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 38;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 40;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 41;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 42;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 43;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 44;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 58;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 59;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 60;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 61;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 65;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 66;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 67;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 68;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 69;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 70;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 73;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 77;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 78;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 79;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 80;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 81;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 84;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 85;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 91;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 93;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 99;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 102;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 105;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 110;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 111;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 114;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 115;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 124;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ NEMOparserTokenManager.curChar = 1;
+// System.out.println("jjMoveStringLiteralDfa0_0" + method.invoke(class1));
+ Assert.assertTrue((Integer) method.invoke(class1) != 0);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa1_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa1_0",new Class[]{long.class});
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 38)
+ .thenReturn((char) 61)
+ .thenReturn((char) 61)
+ .thenReturn((char) 61)
+ .thenReturn((char) 69)
+ .thenReturn((char) 77)
+ .thenReturn((char) 80)
+ .thenReturn((char) 82)
+ .thenReturn((char) 97)
+ .thenReturn((char) 99)
+ .thenReturn((char) 101)
+ .thenReturn((char) 108)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111)
+ .thenReturn((char) 112)
+ .thenReturn((char) 114)
+ .thenReturn((char) 116)
+ .thenReturn((char) 117)
+ .thenReturn((char) 121)
+ .thenReturn((char) 124);
+
+ //case default
+ Assert.assertTrue((Integer) method.invoke(class1, 1L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+ //case 38 and so on
+// System.out.println("0x8000L" + method.invoke(class1, 0x1000L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0x1000L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 38);
+// System.out.println("0x8000L" + method.invoke(class1, 0x8000L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0x8000L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 61);
+// System.out.println("0x8000L" + method.invoke(class1,0x40000L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0x40000L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 61);
+// System.out.println("0x8000L" + method.invoke(class1,0x80000L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0x80000L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 61);
+// System.out.println("0x8000L" + method.invoke(class1,0L));
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 69);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 77);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 80);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 82);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 97);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 99);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 108);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 112);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 114);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 117);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 121);
+ Assert.assertTrue((Integer) method.invoke(class1, 0L) == 2);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 124);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa2_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa2_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 68)
+ .thenReturn((char) 69)
+ .thenReturn((char) 76)
+ .thenReturn((char) 80)
+ .thenReturn((char) 97)
+ .thenReturn((char) 100)
+ .thenReturn((char) 101)
+ .thenReturn((char) 103)
+ .thenReturn((char) 105)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111)
+ .thenReturn((char) 112)
+ .thenReturn((char) 114)
+ .thenReturn((char) 116);
+
+ //case default
+// System.out.println("0x8000L" + method.invoke(class1, 1L, 1L));
+ Assert.assertTrue((Integer)method.invoke(class1,1L,1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 68);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 69);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 76);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 80);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 97);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 100);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 103);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 112);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 114);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 3);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa3_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa3_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 65)
+ .thenReturn((char) 69)
+ .thenReturn((char) 79)
+ .thenReturn((char) 99)
+ .thenReturn((char) 100)
+ .thenReturn((char) 101)
+ .thenReturn((char) 103)
+ .thenReturn((char) 105)
+ .thenReturn((char) 109)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111)
+ .thenReturn((char) 112)
+ .thenReturn((char) 114)
+ .thenReturn((char) 116)
+ .thenReturn((char) 119);
+
+ //case default
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 65);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 69);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 79);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 99);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 100);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 103);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 109);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 112);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 114);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 4);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 119);
+
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa4_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa4_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 77)
+ .thenReturn((char) 82)
+ .thenReturn((char) 84)
+ .thenReturn((char) 97)
+ .thenReturn((char) 101)
+// .thenReturn((char) 101)
+ .thenReturn((char) 103)
+ .thenReturn((char) 104)
+// .thenReturn((char) 104)
+ .thenReturn((char) 105)
+// .thenReturn((char) 110)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111)
+ .thenReturn((char) 114)
+// .thenReturn((char) 115)
+// .thenReturn((char) 115)
+ .thenReturn((char) 115)
+ .thenReturn((char) 121);
+
+ //case default:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 77);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 82);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 84);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 97);
+// Assert.assertTrue((Integer) method.invoke(class1, 0x40000000000000L, 0x40000000000000L) == 5);
+// System.out.println("0x40000000000000L" + method.invoke(class1, 0x40000000000000L, 0x40000000000000L));
+// Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 103);
+// System.out.println("0x40000000000000L" + method.invoke(class1, 0x1000000000L, 0x1000000000L));
+// Assert.assertTrue(NEMOparserTokenManager.curChar == 104);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 104);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+// System.out.println("0x40000000000000L" + method.invoke(class1, 0x200000000000L, 0x200000000000L));
+// Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 114);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 115);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 5);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 121);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa5_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa5_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 69)
+ .thenReturn((char) 69)
+ .thenReturn((char) 69)
+ .thenReturn((char) 84)
+ .thenReturn((char) 97)
+ .thenReturn((char) 99)
+ .thenReturn((char) 100)
+ .thenReturn((char) 101)
+ .thenReturn((char) 103)
+ .thenReturn((char) 105)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111)
+ .thenReturn((char) 114)
+ .thenReturn((char) 116)
+ .thenReturn((char) 116);
+
+
+ //case default:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 0x2000000L, 0x2000000L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 69);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x10000000L, 0x10000000L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 69);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x8000000L, 0x8000000L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 69);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x4000000L, 0x4000000L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 84);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 97);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 99);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 100);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 103);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x10000000000L, 0x10000000000L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 114);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x4000000000L, 0x4000000000L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 6);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa6_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa6_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 99)
+ .thenReturn((char) 100)
+ .thenReturn((char) 101)
+ .thenReturn((char) 105)
+ .thenReturn((char) 110)
+ .thenReturn((char) 114)
+ .thenReturn((char) 116);
+
+ //case default
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 99);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 100);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x80000000L, 0x80000000L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 114);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 7);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa7_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa7_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 101)
+ .thenReturn((char) 105)
+ .thenReturn((char) 111)
+ .thenReturn((char) 115)
+ .thenReturn((char) 116)
+ .thenReturn((char) 121)
+ .thenReturn((char) 121);
+
+ //case default:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+
+ //case others:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 101);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x400000000L, 0x400000000L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 115);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 116);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x100000000L, 0x100000000L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 121);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x80000000000L, 0x80000000000L) == 8);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 121);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa8_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa8_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 105)
+ .thenReturn((char) 108)
+ .thenReturn((char) 110)
+ .thenReturn((char) 110)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111);
+
+ //case default:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 105);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x8000000000000L, 0x8000000000000L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 108);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x2000000000L, 0x2000000000L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 0x8000000000L, 0x8000000000L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 9);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa9_0() throws Exception{
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa9_0",new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 110)
+ .thenReturn((char) 110)
+ .thenReturn((char) 111)
+ .thenReturn((char) 115);
+
+ //case default:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 0x200000000L, 0x200000000L) == 10);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 111);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 10);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 115);
+ }
+
+ @Test
+ public void testjjMoveStringLiteralDfa10_0() throws Exception {
+ Method method = class1.getDeclaredMethod("jjMoveStringLiteralDfa10_0", new Class[]{
+ long.class,
+ long.class
+ });
+ method.setAccessible(true);
+
+ PowerMockito.mockStatic(SimpleCharStream.class);
+ PowerMockito.when(SimpleCharStream.readChar())
+ .thenReturn((char) 0)
+ .thenReturn((char) 110)
+ .thenReturn((char) 115);
+
+ //case default:
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 11);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 0);
+
+ //case others
+ Assert.assertTrue((Integer) method.invoke(class1, 0x100000000000L, 0x100000000000L) == 11);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 110);
+ Assert.assertTrue((Integer) method.invoke(class1, 1L, 1L) == 11);
+ Assert.assertTrue(NEMOparserTokenManager.curChar == 115);
+ }
+
+ @Test
+ public void testjjStartNfaWithStates_0() throws Exception {
+ }
+
+ @Test
+ public void testjjMoveNfa_0() throws Exception {
+ }
+
+ @Test
+ public void testjjCheckNAdd() throws Exception {
+ Field field = class1.getDeclaredField("jjrounds");
+ field.setAccessible(true);
+ Field field1 = class1.getDeclaredField("jjround");
+ field1.setAccessible(true);
+
+ int state = 1;
+ int jjrounds[] = new int[205];
+ jjrounds[0] = 1;
+ int jjround = 1;
+
+ }
}
\ No newline at end of file
/*
- * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
+ * Copyright (c) 2016 Huawei, 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.nemo.user.vnspacemanager.structurestyle.updateintent;
-import org.opendaylight.nemo.user.vnspacemanager.structurestyle.updateintent.UpdateOperation;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.*;
+import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.nemo.user.tenantmanager.TenantManage;
-//import org.opendaylight.nemo.user.vnspacemanager.instancecheck.OperationInstanceCheck;
-//import org.opendaylight.nemo.user.vnspacemanager.syntaxcheck.OperationDefinitionCheck;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOConstants;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.NEMOparserConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.RegisterUserInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.Users;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalHostId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalNodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.VirtualNodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Objects;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Connection;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Operations;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.TemplateDefinitions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.TemplateInstances;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.OperationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.OperationKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.template.definitions.TemplateDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.template.definitions.TemplateDefinitionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.template.instances.TemplateInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.template.instances.TemplateInstanceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserKey;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.hosts.PhysicalHost;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.links.VirtualLink;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.nodes.VirtualNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.IntentVnMappingResult;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.intent.vn.mapping.result.VirtualResource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.user.rev151010.UserRoles;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.condition.instance.ConditionSegment.ConditionParameterMatchPattern;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.user.rev151010.user.roles.UserRole;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.flow.instance.MatchItem;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.node.instance.Property;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.node.instance.SubNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.property.instance.property.values.StringValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.operation.instance.Action;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.ConditionParameterName;
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.concurrent.ExecutionException;
+import static org.junit.Assert.*;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.nemo.user.tenantmanager.TenantManage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.OperationName;
+import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.action.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.action.instance.ParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.condition.instance.ConditionSegment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.condition.instance.condition.segment.ConditionParameterTargetValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.condition.parameter.definitions.ConditionParameterDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.condition.parameter.definitions.condition.parameter.definition.ParameterMatchPatterns;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.operation.instance.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.ObjectId;
+import java.lang.reflect.Method;
+import java.util.Map;
+import static org.mockito.Mockito.*;
/**
- * Created by Zhongwei Zhao on 2015/12/23.
+ * Created by zhangmeng on 2016/1/13.
*/
-public class UpdateOperationTest {
-
- private UpdateOperation updateOperation;
-
+public class UpdateOperationTest extends TestCase {
private DataBroker dataBroker;
private TenantManage tenantManage;
- private UserId userId;
- private User user;
- private Operation operation;
- private Objects objects;
-
- @org.junit.Before
+ private UpdateOperation updateOperation;
+ private Class<UpdateOperation> class1;
+ private Field field_getDefinitions;
+ private Field field_valueCheck;
+ @Before
public void setUp() throws Exception {
+ class1 = UpdateOperation.class;
+ field_getDefinitions = class1.getDeclaredField("getDefinitions");
+ field_getDefinitions.setAccessible(true);
+ field_valueCheck = class1.getDeclaredField("valueCheck");
+ field_valueCheck.setAccessible(true);
+
dataBroker = mock(DataBroker.class);
tenantManage = mock(TenantManage.class);
- userId = mock(UserId.class);
- user = mock(User.class);
- operation = mock(Operation.class);
-
- updateOperation = new UpdateOperation(dataBroker, tenantManage);
- objects = mock(Objects.class);
+ updateOperation = new UpdateOperation(dataBroker,tenantManage);
}
-
- @org.junit.Test
+
+ @Test
public void testOperationHandling() throws Exception {
-
- CheckedFuture operationdefinitionFuture = mock(CheckedFuture.class);
- ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
-
- when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
- when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(operationdefinitionFuture);
- //The action type has not been defined.
- Assert.assertEquals(updateOperation.OperationHandling(userId,operation),"The action type has not been defined.");
-
-
- when(operation.getAction()).thenReturn(null);
- when(operation.getConditionSegment()).thenReturn(null);
-
- ObjectId objectId = mock(ObjectId.class);
- when(operation.getTargetObject()).thenReturn(objectId);
- //The target object is not exist.
- Assert.assertEquals(updateOperation.OperationHandling(userId,operation),"The target null is not exist.");
-
-
- when(operation.getTargetObject()).thenReturn(null);
- //The target should not be empty.
- Assert.assertEquals(updateOperation.OperationHandling(userId,operation),"The target should not be empty.");
-
-
- when(operation.getTargetObject()).thenReturn(objectId);
- when(tenantManage.getUser()).thenReturn(user);
- when(user.getObjects()).thenReturn(objects);
-
- Node node = mock(Node.class);
- List<Node> nodeList = new ArrayList<Node>(1);
- nodeList.add(node);
- when(objects.getNode()).thenReturn(nodeList);
-
- NodeId nodeId = mock(NodeId.class);
- when(node.getNodeId()).thenReturn(nodeId);
- when(nodeId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
- when(objectId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
-
- WriteTransaction writeTransaction = mock(WriteTransaction.class);
- when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
-
- OperationId operationId = mock(OperationId.class);
- when(operation.getOperationId()).thenReturn(operationId);
- CheckedFuture<Void, TransactionCommitFailedException> f;
- f=mock(CheckedFuture.class);
- when(writeTransaction.submit()).thenReturn(f);
- //null
- Assert.assertEquals(updateOperation.OperationHandling(userId,operation),"The target 00001111-0000-0000-0000-000011112222 is not exist.");
-
+ UserId userId = mock(UserId.class);
+ Operation operation = mock(Operation.class);
+ GetDefinitions getDefinitions = mock(GetDefinitions.class);
+
+
+ field_getDefinitions.set(updateOperation, getDefinitions);
+
+ //get into method "checkDefinition" arg(operation)
+ ////get into method "checkAction" arg(operation)
+ when(operation.getAction())
+ .thenReturn(mock(List.class))
+ .thenReturn(null);
+ when(getDefinitions.getActionDefinition()).thenReturn(null);
+ ////get into method "checkCondition" arg(operation)
+ when(operation.getConditionSegment())
+ .thenReturn(mock(List.class))
+ .thenReturn(null);
+ when(getDefinitions.getConditionParameterDefinition()).thenReturn(null);
+
+ //get into method "checkInstance" arg(userId,operation)
+ when(operation.getPriority()).thenReturn(null);
+ Assert.assertTrue(updateOperation.OperationHandling(userId, operation).equals("The priority should not be empty."));
+ }
+
+ @Test
+ public void testCheckInstance() throws Exception {
+ Method method = class1.getDeclaredMethod("checkInstance", new Class[]{
+ UserId.class,
+ Operation.class
+ });
+ method.setAccessible(true);
+
+ UserId userId = mock(UserId.class);
+ ObjectId objectId = mock(ObjectId.class);
+ Operation operation = mock(Operation.class);
+ Operation operation1 = mock(Operation.class);
+ Map<NodeId, Node> nodeMap = mock(Map.class);
+ Map<FlowId,Flow> flowMap = mock(Map.class);
+ Map<ConnectionId, Connection> connectionMap = mock(Map.class);
+ Map<OperationId, Operation> operationMap = mock(Map.class);
+
+ when(operation.getPriority())
+ .thenReturn(null)
+ .thenReturn(1L);
+ Assert.assertTrue(method.invoke(updateOperation, userId, operation).equals("The priority should not be empty."));
+ verify(operation).getPriority();
+ when(operation.getTargetObject())
+ .thenReturn(null)
+ .thenReturn(objectId);
+ Assert.assertTrue(method.invoke(updateOperation, userId, operation).equals("The target should not be empty."));
+ verify(operation).getTargetObject();
+
+ when(tenantManage.getOperation(userId))
+ .thenReturn(operationMap)
+ .thenReturn(operationMap)
+ .thenReturn(operationMap)
+ .thenReturn(null);
+ when(operation.getOperationId()).thenReturn(mock(OperationId.class));
+ when(operationMap.containsKey(operation.getOperationId())).thenReturn(true);
+ when(operationMap.get(operation.getOperationId())).thenReturn(operation1);
+ when(operation.getOperationName()).thenReturn(mock(OperationName.class));
+ when(operation1.getOperationName()).thenReturn(mock(OperationName.class));
+ Assert.assertTrue(method.invoke(updateOperation, userId, operation).equals("The operation name should not be changed."));
+
+ when(tenantManage.getOperationDataStore(userId))
+ .thenReturn(operationMap)
+ .thenReturn(operationMap)
+ .thenReturn(operationMap)
+ .thenReturn(null);
+ Assert.assertTrue(method.invoke(updateOperation, userId, operation).equals("The operation name should not be changed."));
+ verify(operation1,times(2)).getOperationName();
+ Assert.assertTrue(method.invoke(updateOperation, userId, operation).equals("The target " + operation.getTargetObject().getValue() + " is not exist."));
+
+ when(tenantManage.getNode(userId)).thenReturn(nodeMap);
+ when(tenantManage.getConnection(userId)).thenReturn(connectionMap);
+ when(tenantManage.getFlow(userId)).thenReturn(flowMap);
+ when(tenantManage.getNodeDataStore(userId)).thenReturn(nodeMap);
+ when(tenantManage.getConnectionDataStore(userId)).thenReturn(connectionMap);
+ when(tenantManage.getFlowDataStore(userId)).thenReturn(flowMap);
+ when(nodeMap.containsKey(new NodeId(operation.getTargetObject()))).thenReturn(true);
+ when(connectionMap.containsKey(new ConnectionId(operation.getTargetObject()))).thenReturn(true);
+ when(flowMap.containsKey(new FlowId(operation.getTargetObject()))).thenReturn(true);
+ Assert.assertTrue(method.invoke(updateOperation, userId, operation) == null);
+ verify(nodeMap,times(2)).containsKey(new NodeId(operation.getTargetObject()));
+ verify(connectionMap,times(2)).containsKey(new ConnectionId(operation.getTargetObject()));
+ verify(flowMap,times(2)).containsKey(new FlowId(operation.getTargetObject()));
+ }
+
+ @Test
+ public void testCheckAction() throws Exception {
+ Method method = class1.getDeclaredMethod("checkAction", new Class[]{Operation.class});
+ method.setAccessible(true);
+
+ Action action = mock(Action.class);
+ ActionName actionName = mock(ActionName.class);
+ Operation operation = mock(Operation.class);
+ ParameterValues parameterValues = mock(ParameterValues.class);
+ GetDefinitions getDefinitions = mock(GetDefinitions.class);
+ ActionDefinition.ParameterValueType parameterValueType = ActionDefinition.ParameterValueType.Int;
+ List<Action> actionList = new ArrayList<Action>();
+ Map<ActionName, ActionDefinition> actionDefinitionMap = mock(Map.class);
+
+ field_getDefinitions.set(updateOperation, getDefinitions);
+ actionList.add(action);
+
+ when(getDefinitions.getActionDefinition()).thenReturn(actionDefinitionMap);
+ when(operation.getAction())
+ .thenReturn(null)
+ .thenReturn(actionList);
+ //test null
+ Assert.assertTrue(method.invoke(updateOperation, operation) == null);
+ verify(getDefinitions).getActionDefinition();
+
+ //test empty
+ when(actionDefinitionMap.isEmpty())
+ .thenReturn(true)
+ .thenReturn(false);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The action type has not been defined."));
+ verify(getDefinitions, times(2)).getActionDefinition();
+ //test not empty
+ when(action.getActionName()).thenReturn(actionName);
+ when(actionDefinitionMap.containsKey(action.getActionName()))
+ .thenReturn(false)
+ .thenReturn(true);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The action type has not been defined."));
+ verify(actionDefinitionMap).containsKey(action.getActionName());
+
+ when(action.getParameterValues()).thenReturn(parameterValues);
+ when(actionDefinitionMap.get(action.getActionName())).thenReturn(mock(ActionDefinition.class));
+ when(actionDefinitionMap.get(action.getActionName()).getParameterValueType())
+ .thenReturn(ActionDefinition.ParameterValueType.String)
+ .thenReturn(parameterValueType)
+ .thenReturn(ActionDefinition.ParameterValueType.Range);
+ when(parameterValues.getIntValue()).thenReturn(null);
+ when(parameterValues.getStringValue()).thenReturn(null);
+ when(parameterValues.getRangeValue()).thenReturn(null);
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.action.instance.parameter.values.IntValue
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The value type of" + action.getActionName().toString() + "should be string."));
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The value type of" + action.getActionName().toString() + "should be integer."));
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The value type of" + action.getActionName().toString() + "should be range."));
+
+ }
+
+ @Test
+ public void testCheckCondition() throws Exception {
+ Method method = class1.getDeclaredMethod("checkCondition", new Class[]{Operation.class});
+ method.setAccessible(true);
+
+ ValueCheck valueCheck = mock(ValueCheck.class);
+ Operation operation = mock(Operation.class);
+ ConditionSegment conditionSegment = mock(ConditionSegment.class);
+ ConditionParameterName conditionParameterName = mock(ConditionParameterName.class);
+ GetDefinitions getDefinitions = mock(GetDefinitions.class);
+ ConditionParameterTargetValue conditionParameterTargetValue = mock(ConditionParameterTargetValue.class);
+ ParameterMatchPatterns parameterMatchPatterns = mock(ParameterMatchPatterns.class);
+ ConditionParameterMatchPattern conditionParameterMatchPattern = ConditionParameterMatchPattern.Equal;
+ ConditionParameterDefinition conditionParameterDefinition = mock(ConditionParameterDefinition.class);
+ List<ParameterMatchPatterns.ParameterMatchPattern> conditionParameterMatchPatterns = new ArrayList<ParameterMatchPatterns.ParameterMatchPattern>();
+ List<ConditionSegment> conditionSegmentList = new ArrayList<ConditionSegment>();
+ Map<ParameterName, ConditionParameterDefinition> conditionParameterDefinitionMap = mock(Map.class);
+
+ field_getDefinitions.set(updateOperation, getDefinitions);
+ field_valueCheck.set(updateOperation, valueCheck);
+ conditionSegmentList.add(conditionSegment);
+ conditionParameterMatchPatterns.add(ParameterMatchPatterns.ParameterMatchPattern.NotEqual);
+
+ when(getDefinitions.getConditionParameterDefinition()).thenReturn(conditionParameterDefinitionMap);
+ when(operation.getConditionSegment())
+ .thenReturn(null)
+ .thenReturn(conditionSegmentList);
+ Assert.assertTrue(method.invoke(updateOperation, operation) == null);
+
+ when(conditionParameterDefinitionMap.isEmpty())
+ .thenReturn(true)
+ .thenReturn(false);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("This condition has not been defined in data store."));
+
+ when(conditionSegment.getConditionParameterName()).thenReturn(conditionParameterName);
+ when(conditionParameterName.getValue()).thenReturn(NEMOConstants.time);
+ when(conditionParameterDefinitionMap.containsKey(new ParameterName(conditionSegment.getConditionParameterName().getValue())))
+ .thenReturn(false)
+ .thenReturn(true);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("This condition has not been defined in data store."));
+
+ when(conditionParameterDefinitionMap.get(new ParameterName(conditionSegment.getConditionParameterName().getValue())))
+ .thenReturn(conditionParameterDefinition);
+ when(conditionSegment.getConditionParameterMatchPattern()).thenReturn(conditionParameterMatchPattern);
+ when(conditionParameterDefinition.getParameterMatchPatterns())
+ .thenReturn(null)
+ .thenReturn(parameterMatchPatterns);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("No match patterns have been defined in data store."));
+
+ when(conditionParameterDefinition.getParameterMatchPatterns().getParameterMatchPattern())
+ .thenReturn(null)
+ .thenReturn(conditionParameterMatchPatterns);
+ when(conditionSegment.getConditionParameterTargetValue()).thenReturn(conditionParameterTargetValue);
+ when(conditionSegment.getConditionParameterTargetValue().getStringValue()).thenReturn("test");
+ when(valueCheck.checkTime(conditionSegment.getConditionParameterTargetValue().getStringValue())).thenReturn(false);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("There are no match pattern in match pattrn list."));
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The " + NEMOConstants.time + " is not legal."));
+
+ conditionParameterMatchPatterns.clear();
+ conditionParameterMatchPatterns.add(ParameterMatchPatterns.ParameterMatchPattern.Equal);
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The " + NEMOConstants.time + " is not legal."));
+
+ when(conditionParameterDefinition.getParameterValueType())
+ .thenReturn(ConditionParameterDefinition.ParameterValueType.String)
+ .thenReturn(ConditionParameterDefinition.ParameterValueType.String)
+ .thenReturn(ConditionParameterDefinition.ParameterValueType.Int)
+ .thenReturn(ConditionParameterDefinition.ParameterValueType.Int)
+ .thenReturn(ConditionParameterDefinition.ParameterValueType.Range)
+ .thenReturn(ConditionParameterDefinition.ParameterValueType.Range);
+ when(conditionParameterTargetValue.getIntValue()).thenReturn(null);
+ when(conditionParameterTargetValue.getStringValue()).thenReturn(null);
+ when(conditionParameterTargetValue.getRangeValue()).thenReturn(null);
+// System.out.println(method.invoke(updateOperation, operation));
+// System.out.println(method.invoke(updateOperation, operation));
+// System.out.println(method.invoke(updateOperation, operation));
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The value type of " + conditionSegment.getConditionParameterName().getValue() + " should be string."));
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The value type of " + conditionSegment.getConditionParameterName().getValue() + " should be integer."));
+ Assert.assertTrue(method.invoke(updateOperation, operation).equals("The value type of " + conditionSegment.getConditionParameterName().getValue() + " should be range."));
+
}
}
\ No newline at end of file
<cliche.version>1.0-SNAPSHOT</cliche.version>
<ssh.version>262</ssh.version>
<json.version>20090211</json.version>
+ <powermock.version>1.5.2</powermock.version>
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import asg.cliche.Command;
+import asg.cliche.Shell;
+import asg.cliche.ShellDependent;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class CliTest extends TestCase {
+ private Cli cli;
+ @Before
+ public void setUp() throws Exception {
+ cli = new Cli();
+ }
+
+ @Test
+ public void testCliSetShell() throws Exception {
+ Shell shell = mock(Shell.class);
+ cli.cliSetShell(shell);
+ }
+
+ @Test
+ public void testInstall() throws Exception {
+ cli.install();
+ }
+
+ @Test
+ public void testUninstall() throws Exception {
+ cli.uninstall();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.color.CMMException;
+
+import static org.junit.Assert.*;
+import ch.ethz.ssh2.Connection;
+import ch.ethz.ssh2.Session;
+import ch.ethz.ssh2.StreamGobbler;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.tool.sandbox.utils.Config;
+import org.opendaylight.nemo.tool.sandbox.utils.FileUtils;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(ch.ethz.ssh2.Connection.class)
+public class CmdExecutorTest extends TestCase {
+ private CmdExecutor cmdExecutor;
+ private Class<CmdExecutor> class1;
+ private Field field_sshConnection;
+ @Before
+ public void setUp() throws Exception {
+ class1 = CmdExecutor.class;
+ field_sshConnection = class1.getDeclaredField("sshConnection");
+ field_sshConnection.setAccessible(true);
+
+ cmdExecutor = new CmdExecutor();
+ }
+
+ @Test
+ public void testOpen() throws Exception {
+ String command = "cd ~";
+ Session session = mock(Session.class);
+ Connection sshConnection = mock(Connection.class);
+
+ Assert.assertTrue(CmdExecutor.open() == false);
+ PowerMockito.whenNew(Connection.class).withArguments(any(String.class)).thenReturn(sshConnection);
+ when(sshConnection.authenticateWithPassword(any(String.class), any(String.class))).thenReturn(true);
+ Assert.assertTrue(CmdExecutor.open() == false);
+// Assert.assertTrue(field_sshConnection.get(class1) == sshConnection);
+// verify(sshConnection).authenticateWithPassword(any(String.class), any(String.class));
+
+ field_sshConnection.set(class1, sshConnection);
+ when(sshConnection.openSession()).thenReturn(session);
+ doNothing().when(session).execCommand(command);
+ when(session.getStdout()).thenReturn(mock(InputStream.class));
+ Assert.assertTrue(CmdExecutor.sshExecute(command) != null);
+ verify(session).getStdout();
+ CmdExecutor.queryInterfaceMac("eth0");
+ CmdExecutor.queryInterfaceMac("1","eth0");
+
+ CmdExecutor.close();
+ }
+
+ @Test
+ public void testgetMacFromResult() throws Exception {
+ Method method = class1.getDeclaredMethod("getMacFromResult",new Class[]{
+ String.class
+ });
+ method.setAccessible(true);
+ Assert.assertTrue(method.invoke(class1,"HWaddr") != null);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import asg.cliche.Shell;
+import asg.cliche.ShellFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class EasyCliTest extends TestCase {
+ private EasyCli easyCli;
+ @Before
+ public void setUp() throws Exception {
+ easyCli = new EasyCli("1","2","3");
+ }
+
+ @Test
+ public void testAdd() throws Exception {
+ easyCli.add("4");
+ }
+
+ @Test
+ public void testRun() throws Exception {
+ Field field = EasyCli.class.getDeclaredField("shell");
+ field.setAccessible(true);
+
+ Shell shell = mock(Shell.class);
+
+ field.set(easyCli,shell);
+ doNothing().when(shell).commandLoop();
+ easyCli.run();
+ verify(shell).commandLoop();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import org.json.JSONObject;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.tool.sandbox.models.*;
+import org.opendaylight.nemo.tool.sandbox.utils.PropertyLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(CmdExecutor.class)
+public class SandBoxManagerTest extends TestCase {
+ private SandBoxManager sandBoxManager;
+ private Method method;
+ @Before
+ public void setUp() throws Exception {
+ sandBoxManager = SandBoxManager.getInstance();
+ }
+
+ @Test
+ public void testGetInstance() throws Exception {
+ sandBoxManager = SandBoxManager.getInstance();
+ }
+
+ @Test
+ public void testGets() throws Exception {
+ Field field = SandBoxManager.class.getDeclaredField("network");
+ field.setAccessible(true);
+
+ Network network = mock(Network.class);
+ JSONObject jsonObject = mock(JSONObject.class);
+
+ //no powermock and network=null
+ field.set(sandBoxManager, null);
+ org.junit.Assert.assertTrue(!sandBoxManager.createNetwork(null));
+ org.junit.Assert.assertTrue(!sandBoxManager.createNetwork());
+ org.junit.Assert.assertTrue(sandBoxManager.getHosts() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.getExternals() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.getSwitches() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.getLinks() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.destroyNetwork());
+
+ field.set(sandBoxManager, network);
+ PowerMockito.mockStatic(CmdExecutor.class);
+ PowerMockito.when(CmdExecutor.open()).thenReturn(true);
+ when(network.hostJsonNode()).thenReturn(jsonObject);
+ when(network.externalJsonNode()).thenReturn(jsonObject);
+ when(network.nodeJsonNode()).thenReturn(jsonObject);
+ when(network.innerLinkJsonNode()).thenReturn(jsonObject);
+ when(network.execute(any(String.class), any(String.class))).thenReturn("test");
+ org.junit.Assert.assertTrue(sandBoxManager.execute("1","1").equals("test"));
+ org.junit.Assert.assertTrue(sandBoxManager.getHosts() != null);
+ org.junit.Assert.assertTrue(sandBoxManager.getExternals() != null);
+ org.junit.Assert.assertTrue(sandBoxManager.getSwitches() != null);
+ org.junit.Assert.assertTrue(sandBoxManager.getLinks() != null);
+
+ org.junit.Assert.assertTrue(sandBoxManager.createNetwork(PropertyLoader.readLines("/Network", "Network file does not exist.")));
+ org.junit.Assert.assertTrue(sandBoxManager.createNetwork());
+ org.junit.Assert.assertTrue(sandBoxManager.destroyNetwork());
+ }
+ @Test
+ public void testGetNodeType() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("getNodeType",new Class[]{String.class});
+ method.setAccessible(true);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Switch") == NodeType.SWITCH);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Router") == NodeType.ROUTER);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Cache") == NodeType.CACHE);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Firewall") == NodeType.FIREWALL);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Vm") == NodeType.VM);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,"1") == NodeType.UNKNOWN);
+
+ }
+
+ @Test
+ public void testHandleLink() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleLink",new Class[]{String.class});
+ method.setAccessible(true);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "12") == null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,"1,2,3,4,5") != null);
+ }
+
+ @Test
+ public void testSaveConnector() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("saveConnector",new Class[]{
+ Connector.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ Connector connector = mock(Connector.class);
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ when(connector.getNodeName()).thenReturn("test");
+ when(connectorMap.containsKey(any(String.class)))
+ .thenReturn(true)
+ .thenReturn(false);
+ when(connectorMap.get(any(String.class))).thenReturn(mock(List.class));
+ method.invoke(sandBoxManager, connector, connectorMap);
+ method.invoke(sandBoxManager, connector, connectorMap);
+ verify(connectorMap,times(2)).containsKey(any(String.class));
+ }
+
+ @Test
+ public void testParserHost() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("parserHost",new Class[]{
+ String[].class,
+ Map.class,
+ Host.class
+ });
+ method.setAccessible(true);
+
+ String[] args = {"1","2","3","1:2"};
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+ Host host = mock(Host.class);
+ Connector connector = mock(Connector.class);
+ List<Connector> connectors = new ArrayList<Connector>();
+
+ connectors.add(connector);
+
+ when(host.getName()).thenReturn("test");
+ when(connectorMap.get(host.getName())).thenReturn(connectors);
+
+ method.invoke(sandBoxManager, args, connectorMap, host);
+ verify(host,times(2)).getName();
+ }
+
+ @Test
+ public void testHandleFirewall() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleFirewall",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) == null);
+ line = "1,2,3,1:2";
+ when(connectorMap.get(any(String.class))).thenReturn(null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) != null);
+ }
+
+ @Test
+ public void testHandleCache() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleCache",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) == null);
+ line = "1,2,3,1:2";
+ when(connectorMap.get(any(String.class))).thenReturn(null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) != null);
+
+ }
+
+ @Test
+ public void testHandleVirtualMachine() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleVirtualMachine",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) == null);
+ line = "1,2,3,1:2";
+ when(connectorMap.get(any(String.class))).thenReturn(null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) != null);
+ }
+
+ @Test
+ public void testHandleSwitch() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleSwitch",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ List<Connector> connectorList = new ArrayList<Connector>();
+ Connector connector = mock(Connector.class);
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ connectorList.add(connector);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, line, connectorMap) == null);
+ line = "Router,2,3";
+ when(connectorMap.get(any(String.class))).thenReturn(connectorList);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, line, connectorMap) != null);
+
+ }
+
+ @Test
+ public void testGenerateNetwork() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("generateNetwork",new Class[]{List.class});
+ method.setAccessible(true);
+
+ List<String> list = new ArrayList<String>();
+ list.add("Switch");
+ method.invoke(sandBoxManager, list);
+ list.clear();
+ list.add("Vm");
+ method.invoke(sandBoxManager, list);
+ list.clear();
+ list.add("Cache");
+ method.invoke(sandBoxManager, list);
+ list.clear();
+ list.add("Firewall");
+ method.invoke(sandBoxManager, list);
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class CacheTest extends TestCase {\r
+ String name,uuId;\r
+ Cache cacheTest;\r
+ private Method method;\r
+ private Class class1;\r
+ private Connector connector;\r
+\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ uuId = new String("11111111-1111-1111-1111-111111111111");\r
+ cacheTest = new Cache(name,uuId);\r
+ class1 = Cache.class;\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = mock(org.opendaylight.nemo.tool.sandbox.models.Connector.class);\r
+ cacheTest.addConnectors(connector);\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(cacheTest));\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ cacheTest.uninstall();\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
+\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+public class ConnectorTest extends TestCase {\r
+ private int order;\r
+ private String nodeName;\r
+ private Connector connectorTest;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ order = 10;\r
+ nodeName = "connector";\r
+ connectorTest = new Connector(nodeName,order);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetConnectorName() throws Exception {\r
+ Assert.assertNotNull(connectorTest.getConnectorName());\r
+ }\r
+\r
+ @Test\r
+ public void testGetOrder() throws Exception {\r
+ Assert.assertNotNull(connectorTest.getOrder());\r
+ }\r
+\r
+ @Test\r
+ public void testGetNodeName() throws Exception {\r
+ Assert.assertNotNull(connectorTest.getNodeName());\r
+ }\r
+\r
+ @Test\r
+ public void testEquals() throws Exception {\r
+ Assert.assertNotNull(connectorTest.equals(this));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testHashCode() throws Exception {\r
+ Assert.assertNotNull(connectorTest.hashCode());\r
+ }\r
+\r
+ @Test\r
+ public void testToString() throws Exception {\r
+ Assert.assertNotNull(connectorTest.toString());\r
+ }\r
+\r
+ @Test\r
+ public void testCompareTo() throws Exception {\r
+ Assert.assertNotNull(connectorTest.compareTo(new Connector("connector2",5)));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.models.Firewall;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class FirewallTest extends TestCase {\r
+\r
+ String name,uuId;\r
+ Firewall firewallTest;\r
+ private Method method;\r
+ private Class class1;\r
+ private Connector connector;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ uuId = new String("11111111-1111-1111-1111-111111111111");\r
+ firewallTest = new Firewall(name,uuId);\r
+ class1 = Firewall.class;\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = mock(org.opendaylight.nemo.tool.sandbox.models.Connector.class);\r
+ firewallTest.addConnectors(connector);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(firewallTest));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ firewallTest.uninstall();\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class LinkTest extends TestCase {\r
+\r
+ private Connector srcInterface;\r
+ private Connector dstInterface;\r
+ private Link likeTest;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ srcInterface = new Connector("src",1);\r
+ dstInterface = new Connector("dst",2);\r
+ likeTest = new Link(srcInterface,dstInterface);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetSrcConnector() throws Exception {\r
+ Assert.assertNotNull(likeTest.getSrcConnector());\r
+ }\r
+\r
+ @Test\r
+ public void testGetDstConnector() throws Exception {\r
+ Assert.assertNotNull(likeTest.getDstConnector());\r
+ }\r
+\r
+ @Test\r
+ public void testInstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ likeTest.install();\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ likeTest.uninstall();\r
+ }\r
+\r
+ @Test\r
+ public void testEquals() throws Exception {\r
+ Assert.assertNotNull(likeTest.equals(this));\r
+ }\r
+\r
+ @Test\r
+ public void testHashCode() throws Exception {\r
+ Assert.assertNotNull(likeTest.hashCode());\r
+ }\r
+\r
+ @Test\r
+ public void testToString() throws Exception {\r
+ Assert.assertNotNull(likeTest.toString());\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+import org.opendaylight.nemo.tool.sandbox.models.Cache;\r
+import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
+import org.opendaylight.nemo.tool.sandbox.models.Network;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+\r
+import org.json.JSONArray;\r
+import org.json.JSONException;\r
+import org.json.JSONObject;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.utils.Config;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class NetworkTest extends TestCase {\r
+ private Network networkTest;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ networkTest = new Network();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testAddHost() throws Exception {\r
+ networkTest.addHost(new Cache("src1","1"));\r
+ networkTest.addHost(new Cache("dst2","1"));\r
+ }\r
+\r
+ @Test\r
+ public void testAddSwitch() throws Exception {\r
+ networkTest.addSwitch(new Switch("dst1", 1L));\r
+ networkTest.addSwitch(new Switch("src2", 1L));\r
+ networkTest.addSwitch(new Switch("src3", 1L));\r
+ networkTest.addSwitch(new Switch("dst3", 1L));\r
+ }\r
+\r
+ @Test\r
+ public void testAddLink() throws Exception {\r
+ networkTest.addLink(new Link(new Connector("src1", 1), new Connector("dst1", 2)));\r
+ networkTest.addLink(new Link(new Connector("src2", 1), new Connector("dst2", 2)));\r
+ networkTest.addLink(new Link(new Connector("src3", 1), new Connector("dst3", 2)));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.open()).thenReturn(true);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.doNothing().when(CmdExecutor.class);\r
+ CmdExecutor.close();\r
+ Assert.assertNotNull(networkTest.execute("cache", "command"));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testInstall() throws Exception {\r
+ //test traversal\r
+ networkTest.install();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+\r
+ networkTest.uninstall();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testEchoConfig() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+\r
+ networkTest.echoConfig();\r
+\r
+ //test hostJsonNode()\r
+\r
+\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testInnerLinkJsonNode() throws Exception {\r
+\r
+ Assert.assertNotNull(networkTest.innerLinkJsonNode());\r
+\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+public class RouterTest extends TestCase {\r
+ private String name;\r
+ private long dataPathId;\r
+ private Router routerTest;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ }\r
+\r
+ @Test\r
+ public void test1() throws Exception {\r
+ name = new String("name1");\r
+ dataPathId = 1L;\r
+ routerTest = new Router(name,dataPathId);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.opendaylight.nemo.tool.sandbox.utils.Config;\r
+import org.opendaylight.nemo.tool.sandbox.utils.HexString;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+public class SwitchTest extends TestCase {\r
+\r
+ private String name;\r
+ private long dataPathId;\r
+ private Switch switchTest;\r
+ private Class class1;\r
+ private Method method;\r
+\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ dataPathId = 1L;\r
+ switchTest = new Switch(name,dataPathId);\r
+ class1 = Switch.class;\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = new org.opendaylight.nemo.tool.sandbox.models.Connector("connectorname",1);\r
+ switchTest.addConnectors(connector);\r
+ }\r
+\r
+ @Test\r
+ public void testGetDataPathId() throws Exception {\r
+ Assert.assertNotNull(switchTest.getDataPathId());\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(switchTest));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testToString() throws Exception {\r
+ Assert.assertNotNull(switchTest.toString());\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.models.VirtualMachine;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class VirtualMachineTest extends TestCase {\r
+ String name,uuId;\r
+ Cache cacheTest;\r
+ private VirtualMachine virtualMachineTest;\r
+ private Connector connector;\r
+ private Class class1;\r
+ private Method method;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ uuId = new String("11111111-1111-1111-1111-111111111111");\r
+ virtualMachineTest = new VirtualMachine(name,uuId);\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = mock(org.opendaylight.nemo.tool.sandbox.models.Connector.class);\r
+ virtualMachineTest.addConnectors(connector);\r
+ class1 = VirtualMachine.class;\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(virtualMachineTest));\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ virtualMachineTest.uninstall();\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class CreateRequestTest extends TestCase {
+ private CreateRequest createRequest;
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @Test
+ public void testInit()throws Exception{
+ createRequest = new CreateRequest();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class ExecuteRequestTest extends TestCase {
+ private ExecuteRequest executeRequest;
+ @Before
+ public void setUp() throws Exception {
+ executeRequest = new ExecuteRequest();
+ }
+
+ @Test
+ public void testGet_Set() throws Exception {
+ Assert.assertTrue(executeRequest.getHostName() == null);
+ executeRequest.setHostName("test");
+ Assert.assertTrue(executeRequest.getHostName().equals("test"));
+
+ Assert.assertTrue(executeRequest.getCommand() == null);
+ executeRequest.setCommand("command");
+ Assert.assertTrue(executeRequest.getCommand().equals("command"));
+
+ //test to string
+ Assert.assertTrue(executeRequest.toString().equals("ExecuteRequest{" +
+ "hostName='" + "test" + '\'' +
+ ", command='" + "command" + '\'' +
+ '}'));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
+import org.glassfish.jersey.server.ResourceConfig;
+
+import java.io.Reader;
+import java.net.URI;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class RestServerTest extends TestCase {
+ private RestServer restServer;
+ @Before
+ public void setUp() throws Exception {
+ restServer = new RestServer();
+ }
+
+ @Test
+ public void testStart() throws Exception {
+// RestServer.start("s1");
+ }
+
+ @Test
+ public void testStop() throws Exception {
+ RestServer.stop();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, 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.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.codehaus.enunciate.jaxrs.TypeHint;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.tool.sandbox.SandBoxManager;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.List;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+
+public class SandboxNorthboundTest extends TestCase {
+ private SandboxNorthbound sandboxNorthbound;
+ @Before
+ public void setUp() throws Exception {
+ sandboxNorthbound = new SandboxNorthbound();
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ ExecuteRequest executeRequest = new ExecuteRequest();
+ Assert.assertTrue(sandboxNorthbound.create(null,"test") != null);
+ Assert.assertTrue(sandboxNorthbound.create(null,executeRequest) != null);
+ }
+
+ @Test
+ public void testDestroy() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.destroy(null) != null);
+ }
+
+ @Test
+ public void testGetXml() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getXml() != null);
+ }
+
+ @Test
+ public void testGetHosts() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getHosts() == null);
+ }
+
+ @Test
+ public void testGetSwitches() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getSwitches() != null);
+ }
+
+ @Test
+ public void testGetLinks() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getLinks() != null);
+ }
+
+ @Test
+ public void testGetExternals() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getExternals() == null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Huawei, 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.nemo.tool.sandbox.utils;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class ConfigTest extends TestCase {
+ private Config config;
+ @Before
+ public void setUp() throws Exception {
+ config = new Config();
+ }
+
+ @Test
+ public void testAll() throws Exception{
+ Assert.assertTrue(Config.getControllerSocket() != null);
+ Assert.assertTrue(Config.isPrintProcess() == false);
+ Assert.assertTrue(Config.getHostName() != null);
+ Assert.assertTrue(Config.getHostUser() != null);
+ Assert.assertTrue(Config.getHostPassword() != null);
+ Assert.assertTrue(Config.getConfigPath() != null);
+ Assert.assertTrue(Config.getConfigHostsFileName() != null);
+ Assert.assertTrue(Config.getConfigExternalsFileName() != null);
+ Assert.assertTrue(Config.getConfigLinksFileName() != null);
+ Assert.assertTrue(Config.getConfigNodesFileName() != null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.utils;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+/**\r
+ * Created by zhangmeng on 2016/1/14.\r
+ */\r
+public class FileUtilsTest extends TestCase {\r
+ private FileUtils fileUtils;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ fileUtils = new FileUtils();\r
+ }\r
+\r
+ @Test\r
+ public void testWrite() throws Exception {\r
+ FileUtils.write("home","test");\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Huawei, 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.nemo.tool.sandbox.utils;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class HexStringTest extends TestCase {
+ private HexString hexString;
+ @Test
+ public void testToHexString() throws Exception {
+ Assert.assertTrue(HexString.toHexString(1L,6) != null);
+ Assert.assertTrue(HexString.toHexString(1L) != null);
+ }
+
+ @Test
+ public void testFromHexString() throws Exception {
+ Assert.assertTrue(HexString.fromHexString("22:32") != null);
+ }
+
+ @Test
+ public void testToLong() throws Exception {
+// System.out.println(HexString.toLong("11:22"));
+ Assert.assertTrue(HexString.toLong("11:22") != 0);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.utils;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import static org.junit.Assert.*;\r
+import java.io.BufferedReader;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+/**\r
+ * Created by zhangmeng on 2016/1/14.\r
+ */\r
+public class PropertyLoaderTest extends TestCase {\r
+ private PropertyLoader propertyLoader;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ propertyLoader = new PropertyLoader();\r
+ }\r
+\r
+ @Test\r
+ public void testLoadProperties() throws Exception {\r
+ PropertyLoader.loadProperties("home","no file!");\r
+ }\r
+\r
+ @Test\r
+ public void testReadLines() throws Exception {\r
+ PropertyLoader.readLines("home","no file!");\r
+ }\r
+}
\ No newline at end of file