private byte[] getFoxmlObject(String pid, String contentLocation) throws Exception { Foxml11Document doc = createFoxmlObject(pid, contentLocation); ByteArrayOutputStream out = new ByteArrayOutputStream(); doc.serialize(out); return out.toByteArray(); }
@Test public void testRebuild() throws Exception { int count = 10; rebuild(); try { ingestObjects(count); // shutdown tomcat shutdownTomcat(); // rebuild rebuild(); // start tomcat startTomcat(); } finally { if (!isTomcatRunning()) { startTomcat(); } purgeObjects(count); } }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { osName = System.getProperty("os.name"); if (!isTomcatRunning()) { startTomcat(); } apim = FedoraTestCase.getFedoraClient().getAPIMMTOM(); }
private void ingestObjects(int count) throws Exception { String url = "http://www.fedora-commons.org/"; System.out.print("ingesting " + count + " objects "); for (int i = 0; i < count; i++) { String pid = String.format("demo:ri%s", i); apim.ingest(TypeUtility.convertBytesToDataHandler(getFoxmlObject(pid, url)), Constants.FOXML1_1.uri, null); if (i % 100 == 0) { System.out.print("\n\t"); } System.out.print("."); } System.out.println(); }
private void startTomcat() throws Exception { String cmd = Constants.FEDORA_HOME + "/tomcat/bin/startup"; if (!osName.startsWith("Windows")) { cmd += ".sh"; } ExecUtility.execCommandLineUtility(cmd); System.out.print("Starting Tomcat "); int count = 0; int timeout = 1000 * 30; while (!isFedoraRunning()) { System.out.print("."); Thread.sleep(1000); count += 1000; if (count > timeout) { throw new RuntimeException("Tomcat startup timeout"); } } System.out.println(); }
private void shutdownTomcat() throws Exception { if (!isTomcatRunning()) { System.out.println("Tomcat was already shut down."); return; } String cmd = Constants.FEDORA_HOME + "/tomcat/bin/shutdown"; String osName = System.getProperty("os.name"); if (!osName.startsWith("Windows")) { cmd += ".sh"; } System.out.print("Shutting down Tomcat "); ExecUtility.execCommandLineUtility(cmd); int count = 0; int timeout = 1000 * 30; while (isTomcatRunning()) { System.out.print("."); Thread.sleep(1000); count += 1000; if (count > timeout) { throw new RuntimeException("Tomcat shutdown timeout"); } } Thread.sleep(5000); System.out.println(); }