Index: test/dryad-metadata-profile-invalid.xml
===================================================================
--- test/dryad-metadata-profile-invalid.xml	(nonexistent)
+++ test/dryad-metadata-profile-invalid.xml	(revision 8625)
@@ -0,0 +1,19 @@
+<DryadDataPackage xmlns="http://purl.org/dryad/schema/terms/v3.1" xmlns:dwc="http://rs.tdwg.org/dwc/terms/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:bibo="http://purl.org/dryad/schema/dryad-bibo/v3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://purl.org/dryad/schema/terms/v3.1 http://datadryad.org/profile/v3.1/dryad.xsd">
+  <bad>Should not be valid</bad>
+  <dcterms:type>package</dcterms:type>
+  <dcterms:creator>Zmasek, Christian M.</dcterms:creator>
+  <dcterms:creator>Zhang, Qing</dcterms:creator>
+  <dcterms:creator>Ye, Yuzhen</dcterms:creator>
+  <dcterms:creator>Godzik, Adam</dcterms:creator>
+  <dcterms:dateSubmitted>2007-12-06T20:55:28Z</dcterms:dateSubmitted>
+  <dcterms:available>2007-12-06T20:55:28Z</dcterms:available>
+  <dcterms:title>Data from: Surprising complexity of the ancestral apoptosis network</dcterms:title>
+  <dcterms:identifier>http://dx.doi.org/10.5061/dryad.12</dcterms:identifier>
+  <dcterms:references>http://dx.doi.org/10.1186/gb-2007-8-10-r226</dcterms:references>
+  <dcterms:hasPart>http://dx.doi.org/10.5061/dryad.12/1</dcterms:hasPart>
+  <dcterms:hasPart>http://dx.doi.org/10.5061/dryad.12/2</dcterms:hasPart>
+  <dcterms:hasPart>http://dx.doi.org/10.5061/dryad.12/3</dcterms:hasPart>
+  <dcterms:hasPart>http://dx.doi.org/10.5061/dryad.12/4</dcterms:hasPart>
+  <dcterms:hasPart>http://dx.doi.org/10.5061/dryad.12/5</dcterms:hasPart>
+  <dcterms:hasPart>http://dx.doi.org/10.5061/dryad.12/6</dcterms:hasPart>
+</DryadDataPackage>
\ No newline at end of file

Property changes on: test/dryad-metadata-profile-invalid.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: test/edu/ucsb/nceas/metacattest/DryadTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/DryadTest.java	(revision 8624)
+++ test/edu/ucsb/nceas/metacattest/DryadTest.java	(revision 8625)
@@ -32,6 +32,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.io.IOUtils;
+import org.dataone.service.exceptions.ServiceFailure;
 import org.dataone.service.types.v1.Identifier;
 import org.dataone.service.types.v1.ObjectFormatIdentifier;
 import org.dataone.service.types.v1.Session;
@@ -47,6 +48,8 @@
     extends D1NodeServiceTest {
     
     private static final String DRYAD_TEST_DOC = "test/dryad-metadata-profile-sample.xml";
+    
+    private static final String DRYAD_TEST_DOC_INVALID = "test/dryad-metadata-profile-invalid.xml";
 
     /**
      * Constructor to build the test
@@ -65,6 +68,7 @@
         suite.addTest(new DryadTest("initialize"));
         // Test basic functions
         suite.addTest(new DryadTest("d1InsertDoc"));
+        suite.addTest(new DryadTest("d1InsertInvalidDoc"));
 
         return suite;
     }
@@ -103,4 +107,35 @@
     	
     }
     
+    /**
+     * Insert test doc using D1 API
+     */
+    public void d1InsertInvalidDoc() {
+		try {
+	    	String docid = this.generateDocumentId();
+			String documentContents = this.getTestDocFromFile(DRYAD_TEST_DOC_INVALID);
+			Session session = getTestSession();
+			Identifier pid = new Identifier();
+			pid.setValue(docid);
+			SystemMetadata sysmeta = this.createSystemMetadata(pid, session.getSubject(), IOUtils.toInputStream(documentContents, "UTF-8"));
+			ObjectFormatIdentifier formatId = new ObjectFormatIdentifier();
+			formatId.setValue("http://datadryad.org/profile/v3.1");
+			sysmeta.setFormatId(formatId);
+			sysmeta.setSize(BigInteger.valueOf(IOUtils.toByteArray(documentContents).length));
+			try {
+				MNodeService.getInstance(request).create(session, pid, IOUtils.toInputStream(documentContents, "UTF-8"), sysmeta);
+			} catch (Exception expectedException) {
+
+				// expected exception
+				assertTrue(expectedException instanceof ServiceFailure);
+				return;
+			}
+			fail("Should not allow inserting invalid Dryad content");
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail(e.getMessage());
+		}
+    	
+    }
+    
 }
