summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2013-02-18 16:06:51 (EST)
committerMartin Taal2013-02-18 16:06:51 (EST)
commite35ff3c4c12e87588df0eaaae9f2988f014b5ac4 (patch)
tree46e7873742c927f9f737df90a6dacbf7f4c39ce6
parent2a47c29fa295f3f6941b5a169019545ffdbb9a32 (diff)
downloadorg.eclipse.emf.texo-e35ff3c4c12e87588df0eaaae9f2988f014b5ac4.zip
org.eclipse.emf.texo-e35ff3c4c12e87588df0eaaae9f2988f014b5ac4.tar.gz
org.eclipse.emf.texo-e35ff3c4c12e87588df0eaaae9f2988f014b5ac4.tar.bz2
Added additional testcase for 399086
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz399086Test.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz399086Test.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz399086Test.java
index ffc6662..c8d7ff0 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz399086Test.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz399086Test.java
@@ -16,23 +16,38 @@
*/
package org.eclipse.emf.texo.server.test.issues;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import junit.framework.Assert;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.texo.component.ComponentProvider;
+import org.eclipse.emf.texo.datagenerator.DataGeneratorUtils;
+import org.eclipse.emf.texo.datagenerator.ModelDataGenerator;
+import org.eclipse.emf.texo.json.EMFJSONConverter;
import org.eclipse.emf.texo.json.JSONTexoResource;
import org.eclipse.emf.texo.server.test.store.TexoResourceTest;
import org.eclipse.emf.texo.store.TexoResource;
import org.eclipse.emf.texo.test.emfmodel.bz399086.Bz399086Factory;
+import org.eclipse.emf.texo.test.emfmodel.bz399086.Bz399086Package;
import org.eclipse.emf.texo.test.emfmodel.bz399086.MapElement;
import org.eclipse.emf.texo.test.emfmodel.bz399086.TheMap;
import org.eclipse.emf.texo.test.emfmodel.bz399086.impl.Bz399086PackageImpl;
import org.eclipse.emf.texo.test.model.issues.bz399086.Bz399086ModelPackage;
+import org.json.JSONArray;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -107,6 +122,50 @@ public class Bz399086Test extends TexoResourceTest {
}
}
+ // http://www.eclipse.org/forums/index.php/t/452843/
+ @Test
+ public void testGenData() {
+ final Bz399086Factory factory = Bz399086Factory.eINSTANCE;
+ final List<EPackage> ePackages = new ArrayList<EPackage>();
+ ePackages.add(Bz399086Package.eINSTANCE);
+
+ final List<EClass> eClasses = DataGeneratorUtils.getRootEClasses(ePackages);
+ final ModelDataGenerator modelDataGenerator = new ModelDataGenerator();
+ modelDataGenerator.setStartEClasses(eClasses);
+ modelDataGenerator.setEPackages(ePackages);
+ modelDataGenerator.setMaxDepth(5);
+ modelDataGenerator.setCollectionSize(2);
+ modelDataGenerator.setDataSize(5);
+ modelDataGenerator.setMaxObjects(1000);
+ modelDataGenerator.generateTestData();
+
+ final EMFJSONConverter conv = ComponentProvider.getInstance().newInstance(EMFJSONConverter.class);
+ final JSONArray array = ComponentProvider.getInstance().newInstance(JSONArray.class);
+
+ try {
+ URL url = new URL(getBaseURL());
+
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("PUT");
+ connection.setDoInput(true);
+ connection.setDoOutput(true);
+ connection.setUseCaches(false);
+ for (EObject obj : modelDataGenerator.getResult()) {
+ obj.eSet(obj.eClass().getEStructuralFeature("db_version"), null);
+ array.put(conv.convert(obj));
+ }
+
+ OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
+ writer.write(array.toString());
+ writer.flush();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ String json = reader.readLine();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
@Override
protected TexoResource createResource(String uriString) {
final ResourceSetImpl resourceSet = new ResourceSetImpl();