X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Ftranslator%2FErrorTranslatorV10Test.java;h=5f5614e358c3288b354bc89792b3efa86325fa7f;hb=611180ac770b6038b526c54994701db16d1a8567;hp=8d8e9509489cda4cb5bb95cfd51c711e333c0a8c;hpb=d825f9754520e89ae9b4b516bc07c13ee80747d2;p=openflowplugin.git diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ErrorTranslatorV10Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ErrorTranslatorV10Test.java index 8d8e950948..5f5614e358 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ErrorTranslatorV10Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ErrorTranslatorV10Test.java @@ -1,6 +1,6 @@ /** - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -8,26 +8,29 @@ package org.opendaylight.openflowplugin.openflow.md.core.translator; import java.lang.reflect.Method; +import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * */ public class ErrorTranslatorV10Test { - + private ErrorV10Translator errorTranslator; private static Logger LOG = LoggerFactory .getLogger(ErrorTranslatorV10Test.class); - + /** * startup method */ @@ -37,11 +40,14 @@ public class ErrorTranslatorV10Test { } /** - * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.translator.ErrorTranslator#getGranularNodeErrors(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType)}. - * @throws Exception + * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.translator.ErrorTranslator#getGranularNodeErrors(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType, NodeRef)}. + * @throws Exception */ @Test public void testGetGranularNodeErrors() throws Exception { + BigInteger dpid = BigInteger.valueOf(0x1122334455L); + NodeRef node = new NodeRef( + InventoryDataServiceUtil.identifierFromDatapathId(dpid)); for (ErrorType eType : ErrorType.values()) { ErrorMessageBuilder builder = new ErrorMessageBuilder(); builder.setType(eType.getIntValue()); @@ -49,11 +55,14 @@ public class ErrorTranslatorV10Test { builder.setXid(42L); builder.setData(new byte[]{42}); - ErrorMessage errorMessage = errorTranslator.getGranularNodeErrors(builder.build(), eType); + ErrorMessage errorMessage = errorTranslator.getGranularNodeErrors(builder.build(), eType, node); LOG.debug("translating errorMessage of type {}", eType); Assert.assertNotNull("translated error is null", errorMessage); Assert.assertEquals(21, errorMessage.getCode().intValue()); Assert.assertEquals(eType, errorMessage.getType()); + Method getNode = errorMessage.getClass().getMethod("getNode"); + getNode.setAccessible(true); + Assert.assertEquals(node, getNode.invoke(errorMessage)); Method getXid = errorMessage.getClass().getMethod("getTransactionId", new Class[0]); getXid.setAccessible(true); TransactionId xid = (TransactionId) getXid.invoke(errorMessage, new Object[0]); @@ -79,11 +88,11 @@ public class ErrorTranslatorV10Test { break; case 5: expectedType = 9; - break; + break; default: expectedType = eType.getIntValue(); } - + Assert.assertEquals(expectedType, result.getIntValue()); } }