Skip to content

Commit

Permalink
blob handling is too slow #235
Browse files Browse the repository at this point in the history
  • Loading branch information
abstratt committed Sep 5, 2017
1 parent b94f202 commit 6fa91be
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.eclipse.core.runtime.CoreException;

import com.abstratt.kirra.Blob;
import com.abstratt.kirra.Instance;
import com.abstratt.kirra.KirraException;
import com.abstratt.kirra.Repository;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class KirraMDDRuntimeDataTests extends AbstractKirraMDDRuntimeTests {
KirraMDDRuntimeDataTests.model += "end;\n";
KirraMDDRuntimeDataTests.model += "enumeration MyEnum value1; value2; value3; end;\n";
KirraMDDRuntimeDataTests.model += "[Entity] class MyClass6\n";
KirraMDDRuntimeDataTests.model += "attribute myImage : Picture;\n";
KirraMDDRuntimeDataTests.model += "attribute myFile : Blob;\n";
KirraMDDRuntimeDataTests.model += "end;\n";
KirraMDDRuntimeDataTests.model += "end.";
}
Expand Down Expand Up @@ -112,6 +113,26 @@ public void testCreateInstance() throws CoreException {
TestCase.assertEquals(10L, created.getValue("attr1"));
TestCase.assertEquals("bar", created.getValue("attr2"));
}

public void testInstanceWithBlob() throws CoreException {
parseAndCheck(KirraMDDRuntimeDataTests.model);
Repository kirra = getKirra();

Instance newInstance = new Instance();
newInstance.setEntityName("MyClass6");
newInstance.setEntityNamespace("mypackage");
newInstance.setValue("myFile", new Blob(null, 0, "text/plain", "original.txt"));

Instance created = kirra.createInstance(newInstance);

Blob blob = kirra.createBlob(created.getTypeRef(), created.getObjectId(), "myFile", "text/plain", "original.txt");
assertNotNull(blob);

Instance retrieved = kirra.getInstance(created.getTypeRef().getEntityNamespace(), created.getTypeRef().getTypeName(), created.getObjectId(), true);
Blob retrievedBlob = (Blob) retrieved.getValue("myFile");
assertNotNull(retrievedBlob);
}


public void testCreateInstanceWithAutoGeneratedIds() throws CoreException {
parseAndCheck(KirraMDDRuntimeDataTests.model);
Expand Down

0 comments on commit 6fa91be

Please sign in to comment.