@Deprecated(forRemoval=true, since = "13.0")
   public static byte[] convertJavaToOctetStream(Object source, MediaType sourceMediaType, Marshaller marshaller) throws IOException, InterruptedException {
      if (source == null) return null;
      if (!sourceMediaType.match(MediaType.APPLICATION_OBJECT)) {
         throw new EncodingException("sourceMediaType not conforming to application/x-java-object!");
      }
      return marshaller.objectToByteBuffer(decodeObjectContent(source, sourceMediaType));
   }
@Test
   public void testJavaToOctetStreamConversion() throws IOException, InterruptedException {
      Marshaller marshaller = new ProtoStreamMarshaller();
      String string = "I've seen things you people wouldn't believe.";
      Double number = 12.1d;
      Instant complex = Instant.now();
      byte[] binary = new byte[]{1, 2, 3};

      MediaType stringType = APPLICATION_OBJECT.withParameter("type", "java.lang.String");
      byte[] result = StandardConversions.convertJavaToOctetStream(string, stringType, marshaller);
      assertArrayEquals(marshaller.objectToByteBuffer(string), result);

      MediaType doubleType = APPLICATION_OBJECT.withParameter("type", "java.lang.Double");
      result = StandardConversions.convertJavaToOctetStream(number, doubleType, marshaller);
      assertArrayEquals(marshaller.objectToByteBuffer(number), result);

      MediaType customType = APPLICATION_OBJECT.withParameter("type", complex.getClass().getName());
      result = StandardConversions.convertJavaToOctetStream(complex, customType, marshaller);
      assertArrayEquals(marshaller.objectToByteBuffer(complex), result);

      MediaType byteArrayType = APPLICATION_OBJECT.withParameter("type", "ByteArray");
      result = StandardConversions.convertJavaToOctetStream(binary, byteArrayType, marshaller);
      assertArrayEquals(marshaller.objectToByteBuffer(binary), result);
   }