Search in sources :

Example 1 with ModeSelector

use of org.openmuc.jasn1.compiler.iso8823_presentation.ModeSelector in project jasn1 by openmuc.

the class PresentationLayerTest method encodingDecoding.

@Test
public void encodingDecoding() throws IOException {
    ReverseByteArrayOutputStream berOS = new ReverseByteArrayOutputStream(1000);
    List<TransferSyntaxName> berObjectIdentifierList = new ArrayList<>(1);
    berObjectIdentifierList.add(new TransferSyntaxName(new int[] { 2, 1, 1 }));
    ContextList.SEQUENCE.TransferSyntaxNameList tsnl = new ContextList.SEQUENCE.TransferSyntaxNameList(berObjectIdentifierList);
    ContextList.SEQUENCE context_listSubSeq = new ContextList.SEQUENCE(new PresentationContextIdentifier(1), new AbstractSyntaxName(new int[] { 2, 2, 1, 0, 1 }), tsnl);
    ContextList.SEQUENCE context_listSubSeq2 = new ContextList.SEQUENCE(new PresentationContextIdentifier(3), new AbstractSyntaxName(new int[] { 1, 0, 9506, 2, 1 }), tsnl);
    List<ContextList.SEQUENCE> context_listSubSeqList = new ArrayList<>(2);
    context_listSubSeqList.add(context_listSubSeq);
    context_listSubSeqList.add(context_listSubSeq2);
    PresentationContextDefinitionList context_list = new PresentationContextDefinitionList(context_listSubSeqList);
    PDVList.PresentationDataValues presDataValues = new PDVList.PresentationDataValues(new BerAny(new byte[] { 2, 1, 1 }), null, null);
    PDVList pdvList = new PDVList(null, new PresentationContextIdentifier(1), presDataValues);
    List<PDVList> pdvListList = new ArrayList<>(1);
    pdvListList.add(pdvList);
    FullyEncodedData fullyEncodedData = new FullyEncodedData(pdvListList);
    UserData userData = new UserData(null, fullyEncodedData);
    CPType.NormalModeParameters normalModeParameter = new CPType.NormalModeParameters(null, new CallingPresentationSelector(new byte[] { 0, 0, 0, 1 }), new CalledPresentationSelector(new byte[] { 0, 0, 0, 1 }), context_list, null, null, null, userData);
    ModeSelector modeSelector = new ModeSelector(new BerInteger(1));
    CPType cpType = new CPType(modeSelector, normalModeParameter);
    cpType.encode(berOS, true);
    ByteArrayInputStream bais = new ByteArrayInputStream(berOS.getArray());
    CPType cpType_decoded = new CPType();
    cpType_decoded.decode(bais, true);
    Assert.assertEquals("2.2.1.0.1", cpType_decoded.normalModeParameters.presentationContextDefinitionList.seqOf.get(0).abstractSyntaxName.toString());
}
Also used : UserData(org.openmuc.jasn1.compiler.iso8823_presentation.UserData) ArrayList(java.util.ArrayList) ContextList(org.openmuc.jasn1.compiler.iso8823_presentation.ContextList) ReverseByteArrayOutputStream(org.openmuc.jasn1.ber.ReverseByteArrayOutputStream) BerAny(org.openmuc.jasn1.ber.types.BerAny) FullyEncodedData(org.openmuc.jasn1.compiler.iso8823_presentation.FullyEncodedData) CPType(org.openmuc.jasn1.compiler.iso8823_presentation.CPType) ModeSelector(org.openmuc.jasn1.compiler.iso8823_presentation.ModeSelector) PresentationContextIdentifier(org.openmuc.jasn1.compiler.iso8823_presentation.PresentationContextIdentifier) CalledPresentationSelector(org.openmuc.jasn1.compiler.iso8823_presentation.CalledPresentationSelector) BerInteger(org.openmuc.jasn1.ber.types.BerInteger) TransferSyntaxName(org.openmuc.jasn1.compiler.iso8823_presentation.TransferSyntaxName) AbstractSyntaxName(org.openmuc.jasn1.compiler.iso8823_presentation.AbstractSyntaxName) ByteArrayInputStream(java.io.ByteArrayInputStream) PresentationContextDefinitionList(org.openmuc.jasn1.compiler.iso8823_presentation.PresentationContextDefinitionList) CallingPresentationSelector(org.openmuc.jasn1.compiler.iso8823_presentation.CallingPresentationSelector) PDVList(org.openmuc.jasn1.compiler.iso8823_presentation.PDVList) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 ReverseByteArrayOutputStream (org.openmuc.jasn1.ber.ReverseByteArrayOutputStream)1 BerAny (org.openmuc.jasn1.ber.types.BerAny)1 BerInteger (org.openmuc.jasn1.ber.types.BerInteger)1 AbstractSyntaxName (org.openmuc.jasn1.compiler.iso8823_presentation.AbstractSyntaxName)1 CPType (org.openmuc.jasn1.compiler.iso8823_presentation.CPType)1 CalledPresentationSelector (org.openmuc.jasn1.compiler.iso8823_presentation.CalledPresentationSelector)1 CallingPresentationSelector (org.openmuc.jasn1.compiler.iso8823_presentation.CallingPresentationSelector)1 ContextList (org.openmuc.jasn1.compiler.iso8823_presentation.ContextList)1 FullyEncodedData (org.openmuc.jasn1.compiler.iso8823_presentation.FullyEncodedData)1 ModeSelector (org.openmuc.jasn1.compiler.iso8823_presentation.ModeSelector)1 PDVList (org.openmuc.jasn1.compiler.iso8823_presentation.PDVList)1 PresentationContextDefinitionList (org.openmuc.jasn1.compiler.iso8823_presentation.PresentationContextDefinitionList)1 PresentationContextIdentifier (org.openmuc.jasn1.compiler.iso8823_presentation.PresentationContextIdentifier)1 TransferSyntaxName (org.openmuc.jasn1.compiler.iso8823_presentation.TransferSyntaxName)1 UserData (org.openmuc.jasn1.compiler.iso8823_presentation.UserData)1