Package org.apache.poi.openxml4j.opc.internal

Examples of org.apache.poi.openxml4j.opc.internal.ContentTypeManager


    if(targetFile.exists()) targetFile.delete();
   
    OPCPackage pkg = OPCPackage.create(targetFile);
   
    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here


    if(targetFile.exists()) targetFile.delete();

    OPCPackage pkg = OPCPackage.create(targetFile);

    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here

    if(targetFile.exists()) targetFile.delete();
   
    Package pkg = Package.create(targetFile);
   
    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here

    if(targetFile.exists()) targetFile.delete();

    OPCPackage pkg = OPCPackage.create(targetFile);

    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here

    if(targetFile.exists()) targetFile.delete();

    OPCPackage pkg = OPCPackage.create(targetFile);

    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here

    public void testReplaceContentType() throws Exception {
        InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.xlsx");
        OPCPackage p = OPCPackage.open(is);

        ContentTypeManager mgr = getContentTypeManager(p);

        assertTrue(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
        assertFalse(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml"));

        assertTrue(
                p.replaceContentType(
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
                "application/vnd.ms-excel.sheet.macroEnabled.main+xml")
        );

        assertFalse(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
        assertTrue(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml"));
    }
View Full Code Here

    if(targetFile.exists()) targetFile.delete();

    OPCPackage pkg = OPCPackage.create(targetFile);

    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here

    public void testReplaceContentType() throws Exception {
        InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.xlsx");
        OPCPackage p = OPCPackage.open(is);

        ContentTypeManager mgr = getContentTypeManager(p);

        assertTrue(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
        assertFalse(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml"));

        assertTrue(
                p.replaceContentType(
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
                "application/vnd.ms-excel.sheet.macroEnabled.main+xml")
        );

        assertFalse(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
        assertTrue(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml"));
    }
View Full Code Here

    if(targetFile.exists()) targetFile.delete();

    OPCPackage pkg = OPCPackage.create(targetFile);

    // Check it has content types for rels and xml
    ContentTypeManager ctm = getContentTypeManager(pkg);
    assertEquals(
        "application/xml",
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.xml")
        )
    );
    assertEquals(
        ContentTypes.RELATIONSHIPS_PART,
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.rels")
        )
    );
    assertNull(
        ctm.getContentType(
            PackagingURIHelper.createPartName("/foo.txt")
        )
    );
  }
View Full Code Here

    public void testReplaceContentType() throws Exception {
        InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.xlsx");
        OPCPackage p = OPCPackage.open(is);

        ContentTypeManager mgr = getContentTypeManager(p);

        assertTrue(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
        assertFalse(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml"));

        assertTrue(
                p.replaceContentType(
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
                "application/vnd.ms-excel.sheet.macroEnabled.main+xml")
        );

        assertFalse(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
        assertTrue(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml"));
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.openxml4j.opc.internal.ContentTypeManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.