Package org.fcrepo.server.types.gen

Examples of org.fcrepo.server.types.gen.Datastream


        res = get(true);
        String contents = EntityUtils.toString(res.getEntity());
        assertEquals(SC_OK, res.getStatusLine().getStatusCode());

        // check control group modified
        Datastream ds = apim.getDatastream(pid, "DC", null);
        assertEquals("ControlGroup", "M", ds.getControlGroup().value());


        // datastream contents after modification
        byte[] after = TypeUtility.convertDataHandlerToBytes(apia.getDatastreamDissemination(pid, "DC", null).getStream());

        // check they are the same
        // (comparing as strings as the assertEquals is a lot easier to read...)
        String beforeString = new String(before, "UTF-8");
        String afterString = new String(after, "UTF-8");
        assertEquals("Datastream contents ", beforeString, afterString);

        //////////////////////////////////////////////////
        // tests on list of pids
        //////////////////////////////////////////////////

        // test on the second and third objects we found
        String pid1 = objects.toArray(new String[0])[1];
        String pid2 = objects.toArray(new String[0])[2];


        // modify both
        url = this.modifyDatastreamControlGroupUrl(pid1 + "," + pid2, "DC", "M", false, false, false);
        res = get(true);
        assertEquals(SC_OK, res.getStatusLine().getStatusCode());

        contents = EntityUtils.toString(res.getEntity());
        int[] counts = getCounts(contents);

        // check for modification in result stream
        assertEquals("Object count", 2, counts[0]);
        assertEquals("Datastream count", 2, counts[1]);

        // check control groups actually modified
        ds = apim.getDatastream(pid1, "DC", null);
        assertEquals("ControlGroup", "M", ds.getControlGroup().value());

        ds = apim.getDatastream(pid2, "DC", null);
        assertEquals("ControlGroup", "M", ds.getControlGroup().value());
    }
View Full Code Here


        assertXpathEvaluatesTo("6",
                               "count(//foxml:datastream[@ID!='AUDIT'])",
                               doc);

        // check datastream size - compare against original content
        Datastream origManagedContent =
                apim.getDatastream("fedora-system:ContentModel-3.0", "DC", null);
        long managedContentSize = origManagedContent.getSize();

        assertXpathExists("//foxml:datastreamVersion[@ID='NEWDS1.0' and @SIZE='"
                                  + managedContentSize + "']",
                          xmlIn);
View Full Code Here

                .println("Running TestAPIM.testModifyDatastreamByReference...");
        List<String> testDsIds = setUpDatastreamModificationTest(DEMO_14, "MODREF", "M", 1);
        int numNonAudits = getNumberNonAuditDatastreams(DEMO_14);
        String testDsId = testDsIds.get(0);
        assertEquals("MODREFDSM1", testDsId);
        Datastream origManagedContent =
                apim.getDatastream("fedora-system:ContentModel-3.0", "DC", null);
        long managedContentSize = origManagedContent.getSize();

        String [] altIds = new String[1];
        altIds[0] = "Datastream 1 Modified Alternate ID";
        String datastreamId =
                apim.modifyDatastreamByReference(DEMO_14,
                                                 testDsId,
                                                 TypeUtility
                                                         .convertStringtoAOS(altIds),
                                                 "Modified M-type Datastream",
                                                 "text/xml",
                                                 "info:newMyFormatURI/Mtype/stuff#junk",
                                                 getBaseURL()
                                                         + "/get/fedora-system:ContentModel-3.0/DC",
                                                 null,
                                                 null,
                                                 "modified datastream",
                                                 false);

        // test that datastream was modified
        byte [] objectXML =
                TypeUtility.convertDataHandlerToBytes(apim
                        .getObjectXML(DEMO_14));
        assertTrue(objectXML.length > 0);
        String xmlIn = new String(objectXML, "UTF-8");
        Document doc = XMLUnit.buildControlDocument(xmlIn);
        //System.out.println("***** Testcase: TestAPIM.testModifyDatastreamByReference NEWDS1\n"+xmlIn);
        assertXpathExists("foxml:digitalObject[@PID='demo:14']", doc);
        assertXpathExists("//foxml:datastream[@ID='MODREFDSM1' and @CONTROL_GROUP='M' and @STATE='A']",
                          doc);
        assertXpathExists("//foxml:datastreamVersion[@ID='MODREFDSM1.1' and @MIMETYPE='text/xml' and @LABEL='Modified M-type Datastream' and @ALT_IDS='Datastream 1 Modified Alternate ID' and @FORMAT_URI='info:newMyFormatURI/Mtype/stuff#junk']",
                          doc);
        assertXpathExists("//audit:auditTrail/audit:record[last()]/audit:action['modifyDatastreamByReference']",
                          doc);
        assertXpathEvaluatesTo(Integer.toString(numNonAudits),
                               "count(//foxml:datastream[@ID!='AUDIT'])",
                               doc);
        // check size
        assertXpathExists("//foxml:datastreamVersion[@ID='MODREFDSM1.0' and @SIZE='"
                                  + managedContentSize + "']",
                          doc);
        // check size in getDatastreamDissemination
        Datastream ds1 = apim.getDatastream(DEMO_14, "MODREFDSM1", null);
        assertEquals(managedContentSize, ds1.getSize());

        // test modifyDatastreamByReference RELS-EXT, RELS-INT triggers validation for managed content datastreams
        // add RELS-EXT from some other object as that will be invalid for this object
        // using demo:SmileyBeerGlass_M (managed content version of SmileyBeerGlass)
        // TODO: DC also
View Full Code Here

    @Test
    public void testGetDatastream() throws Exception {
        System.out.println("Running TestAPIM.testGetDatastream...");
        // test getting datastream id XML_SOURCE for object demo:26 specifying null for datetime
        Datastream ds = apim.getDatastream("demo:26", "XML_SOURCE", null);
        assertNotNull(ds);
        Datastream[] dsArray = new Datastream[1];
        dsArray[0] = ds;
        System.out
                .println("***** Testcase: TestAPIM.testGetDatastream getDatastream(\"demo:26\", \"XML_SOURCE\", null)");
View Full Code Here

TOP

Related Classes of org.fcrepo.server.types.gen.Datastream

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.