use of com.acgist.snail.pojo.bean.M3u8.Type in project jodd by oblac.
the class BigClassTest method testAllFeatures.
@Test
public void testAllFeatures() throws IOException, IllegalAccessException, InstantiationException {
StatCounter.counter = 0;
final MutableBoolean firstTime = new MutableBoolean(true);
ProxyAspect aspect = new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
public boolean apply(MethodInfo mi) {
if (firstTime.value) {
firstTime.value = false;
ClassInfo ci = mi.getClassInfo();
assertEquals("BigFatJoe", ci.getClassname());
assertEquals(BigFatJoe.class.getPackage().getName(), ci.getPackage());
assertEquals("jodd/proxetta/data/BigFatJoe", ci.getReference());
assertEquals("jodd/proxetta/data/SmallSkinnyZoe", ci.getSuperName());
AnnotationInfo[] anns = ci.getAnnotations();
assertNotNull(anns);
assertEquals(3, anns.length);
AnnotationInfo ai = anns[0];
assertSame(ai, getAnnotation(ci, MadvocAction.class));
assertEquals(MadvocAction.class.getName(), ai.getAnnotationClassname());
assertEquals("L" + MadvocAction.class.getName().replace('.', '/') + ";", ai.getAnnotationSignature());
assertEquals("madvocAction", ai.getElement("value"));
ai = anns[1];
assertSame(ai, getAnnotation(ci, PetiteBean.class));
assertEquals(PetiteBean.class.getName(), ai.getAnnotationClassname());
assertEquals("L" + PetiteBean.class.getName().replace('.', '/') + ";", ai.getAnnotationSignature());
ai = anns[2];
assertSame(ai, getAnnotation(ci, InterceptedBy.class));
assertEquals(InterceptedBy.class.getName(), ai.getAnnotationClassname());
assertEquals("L" + InterceptedBy.class.getName().replace('.', '/') + ";", ai.getAnnotationSignature());
assertTrue(ai.getElement("value") instanceof Object[]);
assertFalse(ai.getElement("value") instanceof String[]);
Object c1 = ((Object[]) ai.getElement("value"))[0];
assertEquals("Ljodd/proxetta/data/Str;", ((Type) c1).getDescriptor());
}
if (mi.getMethodName().equals("publicMethod")) {
AnnotationInfo[] anns = mi.getAnnotations();
assertNotNull(anns);
assertEquals(3, anns.length);
AnnotationInfo ai = anns[0];
assertSame(ai, getAnnotation(mi, Action.class));
assertEquals(Action.class.getName(), ai.getAnnotationClassname());
assertEquals("value", ai.getElement("value"));
assertEquals("alias", ai.getElement("alias"));
ai = anns[1];
assertSame(ai, getAnnotation(mi, PetiteInject.class));
assertEquals(PetiteInject.class.getName(), ai.getAnnotationClassname());
assertEquals(0, ai.getElementNames().size());
ai = anns[2];
assertSame(ai, getAnnotation(mi, Transaction.class));
assertEquals(Transaction.class.getName(), ai.getAnnotationClassname());
assertEquals(2, ai.getElementNames().size());
String s = (String) ai.getElement("propagation");
assertEquals("PROPAGATION_REQUIRES_NEW", s);
}
if (mi.getMethodName().equals("superPublicMethod")) {
AnnotationInfo[] anns = mi.getAnnotations();
assertNotNull(anns);
assertEquals(3, anns.length);
AnnotationInfo ai = anns[0];
assertSame(ai, getAnnotation(mi, Action.class));
assertEquals(Action.class.getName(), ai.getAnnotationClassname());
assertEquals(0, ai.getElementNames().size());
ai = anns[1];
assertSame(ai, getAnnotation(mi, PetiteInject.class));
assertEquals(PetiteInject.class.getName(), ai.getAnnotationClassname());
assertEquals(0, ai.getElementNames().size());
ai = anns[2];
assertSame(ai, getAnnotation(mi, Transaction.class));
assertEquals(Transaction.class.getName(), ai.getAnnotationClassname());
assertEquals(0, ai.getElementNames().size());
}
//System.out.println(!isRootMethod(mi) + " " + mi.getDeclaredClassName() + '#' + mi.getMethodName());
return !isRootMethod(mi);
}
});
byte[] classBytes = ProxyProxetta.withAspects(aspect).builder(BigFatJoe.class).create();
// URL resource = BigFatJoe.class.getResource("/" + BigFatJoe.class.getName().replace(".", "/") + ".class");
// jodd.io.FileUtil.copy(FileUtil.toFile(resource), new java.io.File(SystemUtil.getUserHome(), "jo.class"));
// jodd.io.FileUtil.writeBytes(new java.io.File(SystemUtil.getUserHome(), "joe.class"), classBytes);
Class clazz = ClassLoaderUtil.defineClass(null, classBytes);
BigFatJoe bigFatJoe = (BigFatJoe) clazz.newInstance();
assertEquals(BigFatJoe.class.getName() + "$$Proxetta", bigFatJoe.getClass().getName());
assertEquals(BigFatJoe.class, ProxettaUtil.getTargetClass(bigFatJoe.getClass()));
// test invocation
// 2 x static + 1 x instance
assertEquals(3, StatCounter.counter);
bigFatJoe.publicMethod();
assertEquals(4, StatCounter.counter);
bigFatJoe.callInnerMethods();
// private method is not overridden
assertEquals(7, StatCounter.counter);
bigFatJoe.superPublicMethod();
assertEquals(8, StatCounter.counter);
bigFatJoe.callInnerMethods2();
// only public super methods are overridden
assertEquals(9, StatCounter.counter);
// test class annotation
MadvocAction ma = (MadvocAction) clazz.getAnnotation(MadvocAction.class);
assertEquals("madvocAction", ma.value());
InterceptedBy ib = (InterceptedBy) clazz.getAnnotation(InterceptedBy.class);
assertNotNull(ib.value());
assertEquals(2, ib.value().length);
// test method annotation
ClassDescriptor cd = ClassIntrospector.lookup(clazz);
Method m = cd.getMethodDescriptor("publicMethod", false).getMethod();
assertNotNull(m);
Annotation[] aa = m.getAnnotations();
assertEquals(3, aa.length);
Action a = (Action) aa[0];
assertEquals("alias", a.alias());
assertEquals("extension", a.extension());
assertEquals("method", a.method());
assertEquals("value", a.value());
PetiteInject pi = (PetiteInject) aa[1];
assertEquals("", pi.value());
Transaction tx = (Transaction) aa[2];
assertTrue(tx.readOnly());
assertEquals(1000, tx.timeout());
assertEquals("PROPAGATION_REQUIRES_NEW", tx.propagation());
bigFatJoe.runInnerClass();
// proxy + call
assertEquals(11, StatCounter.counter);
}
use of com.acgist.snail.pojo.bean.M3u8.Type in project jodd by oblac.
the class MethodFinder method visitMethod.
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (paramExtractor != null) {
// method already found, skip all further methods
return null;
}
if (!name.equals(methodName)) {
// different method
return null;
}
Type[] argumentTypes = Type.getArgumentTypes(desc);
int dwordsCount = 0;
for (Type t : argumentTypes) {
if (t.getClassName().equals(TYPE_LONG) || t.getClassName().equals(TYPE_DOUBLE)) {
dwordsCount++;
}
}
int paramCount = argumentTypes.length;
if (paramCount != this.parameterTypes.length) {
// different number of params
return null;
}
for (int i = 0; i < argumentTypes.length; i++) {
if (!isEqualTypeName(argumentTypes[i], this.parameterTypes[i])) {
// wrong param types
return null;
}
}
this.paramExtractor = new ParamExtractor((Modifier.isStatic(access) ? 0 : 1), argumentTypes.length + dwordsCount);
return paramExtractor;
}
use of com.acgist.snail.pojo.bean.M3u8.Type in project openflowplugin by opendaylight.
the class SalToOfSetTpSrcActionCase method process.
@NonNull
@Override
public Optional<Action> process(@NonNull final SetTpSrcActionCase source, final ActionConvertorData data, final ConvertorExecutor convertorExecutor) {
IPProtocols protocol = null;
if (data.getIpProtocol() != null) {
protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
}
SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder().setOxmClass(OpenflowBasicClass.class).setHasMask(Boolean.FALSE);
final Uint16 port = settpsrcaction.getPort().getValue();
final Uint8 type = Uint8.valueOf(0xff & port.toJava());
if (protocol != null) {
switch(protocol) {
case ICMP:
matchBuilder.setOxmMatchField(Icmpv4Type.class);
matchBuilder.setMatchEntryValue(new Icmpv4TypeCaseBuilder().setIcmpv4Type(new Icmpv4TypeBuilder().setIcmpv4Type(type).build()).build());
break;
case ICMPV6:
matchBuilder.setOxmMatchField(Icmpv6Type.class);
matchBuilder.setMatchEntryValue(new Icmpv6TypeCaseBuilder().setIcmpv6Type(new Icmpv6TypeBuilder().setIcmpv6Type(type).build()).build());
break;
case TCP:
matchBuilder.setOxmMatchField(TcpSrc.class);
matchBuilder.setMatchEntryValue(new TcpSrcCaseBuilder().setTcpSrc(new TcpSrcBuilder().setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port)).build()).build());
break;
case UDP:
matchBuilder.setOxmMatchField(UdpSrc.class);
matchBuilder.setMatchEntryValue(new UdpSrcCaseBuilder().setUdpSrc(new UdpSrcBuilder().setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port)).build()).build());
break;
default:
LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
break;
}
} else {
LOG.warn("Null protocol with combination of SetSourcePort");
}
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of com.acgist.snail.pojo.bean.M3u8.Type in project openflowplugin by opendaylight.
the class OfToSalIcmpv4TypeCase method process.
@Override
public Optional<MatchBuilder> process(@NonNull final Icmpv4TypeCase source, final MatchResponseConvertorData data, final ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder();
Icmpv4Type icmpv4Type = source.getIcmpv4Type();
Uint8 type = icmpv4Type.getIcmpv4Type();
if (type != null) {
icmpv4MatchBuilder.setIcmpv4Type(type);
matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of com.acgist.snail.pojo.bean.M3u8.Type in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryNoMasks.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryNoMasks() {
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort.class);
entriesBuilder.setHasMask(false);
final InPortCaseBuilder caseBuilder = new InPortCaseBuilder();
final InPortBuilder portBuilder = new InPortBuilder();
portBuilder.setPortNumber(new PortNumber(Uint32.ONE));
caseBuilder.setInPort(portBuilder.build());
entriesBuilder.setMatchEntryValue(caseBuilder.build());
entries.add(entriesBuilder.build());
final InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort.class);
entriesBuilder.setHasMask(false);
final InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(Uint32.TWO));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
entriesBuilder.setHasMask(false);
final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();
metadataBuilder.setMetadata(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 });
metadataCaseBuilder.setMetadata(metadataBuilder.build());
entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(PacketType.class);
entriesBuilder.setHasMask(false);
final PacketTypeCaseBuilder packetTypeCaseBuilder = new PacketTypeCaseBuilder();
final PacketTypeBuilder packetTypeBuilder = new PacketTypeBuilder();
packetTypeBuilder.setPacketType(Uint32.valueOf(0x1894f));
packetTypeCaseBuilder.setPacketType(packetTypeBuilder.build());
entriesBuilder.setMatchEntryValue(packetTypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthDst.class);
entriesBuilder.setHasMask(false);
final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
final EthDstBuilder ethDstBuilder = new EthDstBuilder();
ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));
ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthSrc.class);
entriesBuilder.setHasMask(false);
final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));
ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthType.class);
entriesBuilder.setHasMask(false);
final EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();
final EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();
ethTypeBuilder.setEthType(new EtherType(Uint16.valueOf(3)));
ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());
entriesBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanVid.class);
final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
entriesBuilder.setHasMask(false);
final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setVlanVid(Uint16.valueOf(4));
vlanVidBuilder.setCfiBit(true);
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanPcp.class);
final VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();
entriesBuilder.setHasMask(false);
final VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();
vlanPcpBuilder.setVlanPcp(Uint8.valueOf(5));
vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());
entriesBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpDscp.class);
entriesBuilder.setHasMask(false);
final IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();
final IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();
ipDscpBuilder.setDscp(new Dscp(Uint8.valueOf(6)));
ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());
entriesBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
final IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
final IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn(Uint8.valueOf(7));
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpProto.class);
final IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();
entriesBuilder.setHasMask(false);
final IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();
ipProtoBuilder.setProtocolNumber(Uint8.valueOf(8));
ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());
entriesBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Src.class);
entriesBuilder.setHasMask(false);
final Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));
ipv4AddressBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4AddressBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(false);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TcpSrc.class);
entriesBuilder.setHasMask(false);
final TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
final TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(Uint16.valueOf(9)));
tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
entriesBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TcpDst.class);
entriesBuilder.setHasMask(false);
final TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
final TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(Uint16.valueOf(10)));
tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
entriesBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv4Type.class);
entriesBuilder.setHasMask(false);
final Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
final Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
icmpv4TypeBuilder.setIcmpv4Type(Uint8.valueOf(15));
icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv4Code.class);
entriesBuilder.setHasMask(false);
final Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
final Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
icmpv4CodeBuilder.setIcmpv4Code(Uint8.valueOf(16));
icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv6Type.class);
entriesBuilder.setHasMask(false);
final Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
final Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
icmpv6TypeBuilder.setIcmpv6Type(Uint8.valueOf(19));
icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv6Code.class);
entriesBuilder.setHasMask(false);
final Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
final Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
icmpv6CodeBuilder.setIcmpv6Code(Uint8.valueOf(20));
icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(MplsLabel.class);
entriesBuilder.setHasMask(false);
final MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();
final MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();
mplsLabelBuilder.setMplsLabel(Uint32.valueOf(21));
mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());
entriesBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(MplsTc.class);
entriesBuilder.setHasMask(false);
final MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();
final MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();
mplsTcBuilder.setTc(Uint8.valueOf(22));
mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());
entriesBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(MplsBos.class);
entriesBuilder.setHasMask(false);
final MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();
final MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();
mplsBosBuilder.setBos(true);
mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());
entriesBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(PbbIsid.class);
entriesBuilder.setHasMask(false);
final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
pbbIsidBuilder.setIsid(Uint32.valueOf(23));
pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TunnelId.class);
entriesBuilder.setHasMask(false);
final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
tunnelIdBuilder.setTunnelId(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
entries.add(entriesBuilder.build());
final MatchBuilder builder = new MatchBuilder();
builder.setMatchEntry(entries);
final Match match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatch = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();
Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());
Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue());
Assert.assertEquals("Wrong metadata", Uint64.valueOf("0001020304050607", 16), builtMatch.getMetadata().getMetadata());
Assert.assertEquals("Wrong packet type", 0x1894f, builtMatch.getPacketTypeMatch().getPacketType().longValue());
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());
Assert.assertEquals("Wrong eth type", 3, builtMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().getVlanIdPresent());
Assert.assertEquals("Wrong vlan pcp", 5, builtMatch.getVlanMatch().getVlanPcp().getValue().intValue());
Assert.assertEquals("Wrong ip dscp", 6, builtMatch.getIpMatch().getIpDscp().getValue().intValue());
Assert.assertEquals("Wrong ip ecn", 7, builtMatch.getIpMatch().getIpEcn().intValue());
Assert.assertEquals("Wrong ip proto", null, builtMatch.getIpMatch().getIpProto());
Assert.assertEquals("Wrong ip protocol", 8, builtMatch.getIpMatch().getIpProtocol().intValue());
final TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();
Assert.assertEquals("Wrong tcp src port", 9, tcpMatch.getTcpSourcePort().getValue().intValue());
Assert.assertEquals("Wrong tcp dst port", 10, tcpMatch.getTcpDestinationPort().getValue().intValue());
Assert.assertEquals("Wrong icmpv4 type", 15, builtMatch.getIcmpv4Match().getIcmpv4Type().intValue());
Assert.assertEquals("Wrong icmpv4 code", 16, builtMatch.getIcmpv4Match().getIcmpv4Code().intValue());
Assert.assertEquals("Wrong icmpv6 type", 19, builtMatch.getIcmpv6Match().getIcmpv6Type().intValue());
Assert.assertEquals("Wrong icmpv6 code", 20, builtMatch.getIcmpv6Match().getIcmpv6Code().intValue());
final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/32", ipv4Match.getIpv4Source().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/32", ipv4Match.getIpv4Destination().getValue());
Assert.assertEquals("Wrong mpls label", 21, builtMatch.getProtocolMatchFields().getMplsLabel().intValue());
Assert.assertEquals("Wrong mpls bos", 1, builtMatch.getProtocolMatchFields().getMplsBos().intValue());
Assert.assertEquals("Wrong mpls tc", 22, builtMatch.getProtocolMatchFields().getMplsTc().intValue());
Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());
Assert.assertEquals("Wrong tunnel id", Uint64.valueOf("0102030405060708", 16), builtMatch.getTunnel().getTunnelId());
}
Aggregations