You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestHMEFMessage.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hmef;
  16. import junit.framework.TestCase;
  17. import org.apache.poi.POIDataSamples;
  18. public final class TestHMEFMessage extends TestCase {
  19. private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
  20. public void testOpen() throws Exception {
  21. HMEFMessage msg = new HMEFMessage(
  22. _samples.openResourceAsStream("quick-winmail.dat")
  23. );
  24. assertNotNull(msg);
  25. }
  26. public void testCounts() throws Exception {
  27. HMEFMessage msg = new HMEFMessage(
  28. _samples.openResourceAsStream("quick-winmail.dat")
  29. );
  30. // Should have 4 attributes on the message
  31. assertEquals(4, msg.getMessageAttributes().size());
  32. // And should have 54 MAPI attributes on it
  33. assertEquals(54, msg.getMessageMAPIAttributes().size());
  34. // Should have 5 attachments
  35. assertEquals(5, msg.getAttachments().size());
  36. // Each attachment should have 6 normal attributes, and
  37. // 20 or so MAPI ones
  38. for(Attachment attach : msg.getAttachments()) {
  39. int attrCount = attach.getAttributes().size();
  40. int mapiAttrCount = attach.getMAPIAttributes().size();
  41. assertEquals(6, attrCount);
  42. // TODO
  43. // assertTrue("Should be 3-4 attributes, found " + mapiAttrCount, mapiAttrCount >= 20);
  44. // assertTrue("Should be 3-4 attributes, found " + mapiAttrCount, mapiAttrCount <= 25);
  45. }
  46. // TODO
  47. }
  48. public void testBasicMessageAttributes() throws Exception {
  49. HMEFMessage msg = new HMEFMessage(
  50. _samples.openResourceAsStream("quick-winmail.dat")
  51. );
  52. // Should have version, codepage, class and MAPI
  53. assertEquals(4, msg.getMessageAttributes().size());
  54. assertNotNull(msg.getMessageAttribute(Attribute.ID_TNEFVERSION));
  55. assertNotNull(msg.getMessageAttribute(Attribute.ID_OEMCODEPAGE));
  56. assertNotNull(msg.getMessageAttribute(Attribute.ID_MESSAGECLASS));
  57. assertNotNull(msg.getMessageAttribute(Attribute.ID_MAPIPROPERTIES));
  58. // Check the order
  59. assertEquals(Attribute.ID_TNEFVERSION, msg.getMessageAttributes().get(0).getId());
  60. assertEquals(Attribute.ID_OEMCODEPAGE, msg.getMessageAttributes().get(1).getId());
  61. assertEquals(Attribute.ID_MESSAGECLASS, msg.getMessageAttributes().get(2).getId());
  62. assertEquals(Attribute.ID_MAPIPROPERTIES, msg.getMessageAttributes().get(3).getId());
  63. // Check some that aren't there
  64. assertNull(msg.getMessageAttribute(Attribute.ID_AIDOWNER));
  65. assertNull(msg.getMessageAttribute(Attribute.ID_ATTACHDATA));
  66. // Now check the details of one or two
  67. // TODO
  68. }
  69. public void testBasicMessageMAPIAttributes() throws Exception {
  70. // TODO
  71. }
  72. public void testBasicAttachments() throws Exception {
  73. // TODO
  74. }
  75. public void testMessageAttributeDetails() throws Exception {
  76. // TODO
  77. }
  78. }