byte[] data = storeBinaryResourceFromFile( new File( "webapp/logo.jpg"), testCollection);
byte[] data = storeBinaryResourceFromFile( new File( existDir,"webapp/logo.jpg"), testCollection);
	public void testCreateCollection() {				try {			System.out.println(				"Created Collection: "					+ root.getName()					+ "( "					+ root.getClass()					+ " )");			Service[] services = root.getServices();			System.out.println("services array: " + services);			assertTrue(				"Collection must provide at least one Service",				services != null && services.length > 0);			System.out.println("  number of services: " + services.length);			for (int i = 0; i < services.length; i++) {				System.out.println(					"  Service: "						+ services[i].getName()						+ "( "						+ services[i].getClass()						+ " )");			}			Collection parentCollection = root.getParentCollection();			assertEquals("xmldb:exist://" + DBBroker.ROOT_COLLECTION, ((org.exist.xmldb.CollectionImpl)root).getURI().toString());			System.out.println("root parentCollection: " + parentCollection);			assertNull("root collection has no parent", parentCollection);			CollectionManagementService service =				(CollectionManagementService) root.getService(					"CollectionManagementService",					"1.0");			assertNotNull(service);			Collection testCollection = service.createCollection("test");			assertNotNull(testCollection);			assertEquals("xmldb:exist://" + DBBroker.ROOT_COLLECTION + "/test", ((org.exist.xmldb.CollectionImpl)testCollection).getURI().toString());			int ccc = testCollection.getChildCollectionCount();			assertTrue(				"Collection just created: ChildCollectionCount==0",				ccc == 0);			assertTrue(				"Collection state should be Open after creation",				testCollection.isOpen());			String directory = "samples/shakespeare";			System.out.println("---------------------------------------");			System.out.println("storing all XML files in directory " +directory+"...");			System.out.println("---------------------------------------");			File f = new File(directory);			File files[] = f.listFiles(new XMLFilenameFilter());			for (int i = 0; i < files.length; i++) {				storeResourceFromFile(files[i], testCollection);			}			HashSet fileNamesJustStored = new HashSet();			for (int i = 0; i < files.length; i++) {				String file = files[i].toString();				int lastSeparator = file.lastIndexOf(File.separatorChar);				fileNamesJustStored.add(file.substring(lastSeparator + 1));			}			System.out.println("fileNames stored: " + fileNamesJustStored.toString());			String[] resourcesNames = testCollection.listResources();			int resourceCount = testCollection.getResourceCount();			System.out.println(  "testCollection.getResourceCount()=" + resourceCount);			ArrayList fileNamesPresentInDatabase = new ArrayList();			for (int i = 0; i < resourcesNames.length; i++) {				fileNamesPresentInDatabase.add( resourcesNames[i]);			}			assertTrue( "resourcesNames must contain fileNames just stored",					fileNamesPresentInDatabase. containsAll( fileNamesJustStored) );			String fileToRemove = "macbeth.xml";			Resource resMacbeth = testCollection.getResource(fileToRemove);			assertNotNull("getResource(" + fileToRemove + "\")", resMacbeth);			testCollection.removeResource(resMacbeth);			assertTrue(				"After removal resource count must decrease",				testCollection.getResourceCount() == resourceCount - 1);			// restore the resource just removed :			storeResourceFromFile(				new File(					directory + File.separatorChar + fileToRemove),				testCollection);			byte[] data = storeBinaryResourceFromFile( new File( "webapp/logo.jpg"), testCollection);			Object content = testCollection.getResource("logo.jpg").getContent();			byte[] dataStored = (byte[])content;			assertTrue("After storing binary resource, data out==data in", 					Arrays.equals(dataStored, data) );					} catch (Exception e) {						fail(e.getMessage());		}	}