Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for multiple type package URIs in ConfigurableJsonResource #4

Open
wants to merge 19 commits into
base: snapshot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ header:
- '**/*.basic'
- '**/.classpath'
- 'org.gecko.emf.osgi.codegen/src/org/gecko/emf/osgi/codegen/templates/model/*'
- 'org.gecko.emf.json.tests/data/*'
- 'LICENSE'
- 'Jenkinsfile'
- 'NOTICE'
Expand Down
2 changes: 1 addition & 1 deletion cnf/central.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.1.1

#org.geckoprojects.emf:org.gecko.emf.osgi.api:4.1.1.202202162308
org.geckoprojects.emf:org.gecko.emf.osgi.bnd.library.workspace:4.1.1-SNAPSHOT
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:4.1.1-SNAPSHOT

com.fasterxml.jackson.core:jackson-core:2.13.2
com.fasterxml.jackson.core:jackson-databind:2.13.2
Expand All @@ -168,3 +167,4 @@ org.eclipse.emfcloud:emfjson-jackson:2.1.0-SNAPSHOT
de.undercouch:bson4jackson:2.13.1
org.yaml:snakeyaml:1.30
#org.emfjson:emfjson-jackson:1.3.0
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:4.1.1-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
package org.gecko.emf.bson.tests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand All @@ -24,9 +25,7 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.gecko.emf.osgi.ResourceFactoryConfigurator;
import org.gecko.emf.osgi.example.model.basic.BasicFactory;
import org.gecko.emf.osgi.example.model.basic.BasicPackage;
import org.gecko.emf.osgi.example.model.basic.Contact;
Expand All @@ -35,6 +34,7 @@
import org.gecko.emf.osgi.example.model.basic.GenderType;
import org.gecko.emf.osgi.example.model.basic.Person;
import org.gecko.emf.osgi.example.model.basic.util.BasicResourceFactoryImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.osgi.service.cm.Configuration;
Expand All @@ -52,6 +52,11 @@
@ExtendWith(BundleContextExtension.class)
@ExtendWith(ServiceExtension.class)
public class BsonConfiguratorTest {

@BeforeEach
public void beforeEach(@InjectService(timeout = 2000) BasicFactory bp) {
System.out.println("Test");
}

@Test
public void testBson(@InjectService ConfigurationAdmin ca) throws IOException {
Expand All @@ -67,14 +72,18 @@ public void testBson(@InjectService ConfigurationAdmin ca) throws IOException {
System.out.println(c.getPid());//foo~bar
System.out.println(c.getFactoryPid());//foo
}

@Test
public void testBson(@InjectService(filter = "(component.name=EMFBsonConfigurator)") ServiceAware<ResourceFactoryConfigurator> sa, @InjectService BasicFactory bf, @InjectService BasicPackage bp) {
public void testBson(@InjectService(timeout = 2000) ServiceAware<ResourceSet> rsAware,
@InjectService BasicFactory bf,
@InjectService BasicPackage bp) {

assertNotNull(rsAware);
assertThat(rsAware.getServices()).hasSize(1);
ResourceSet resourceSet = rsAware.getService();
assertNotNull(resourceSet);

System.out.println(sa.getServiceReference().getPropertyKeys());
ResourceSet resourceSet = createResourceSet(bp);
ResourceFactoryConfigurator configurator = sa.getService();
configurator.configureResourceFactory(resourceSet.getResourceFactoryRegistry());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("test", new BasicResourceFactoryImpl());

Person p = createSamplePerson(bf);
Resource xmiResource = resourceSet.createResource(URI.createURI("person.test"));
Expand Down Expand Up @@ -154,17 +163,4 @@ private Person createSamplePerson(BasicFactory bf) {
p.getContact().add(email);
return p;
}

/**
* @param bp
* @return
*/
private ResourceSet createResourceSet(BasicPackage bp) {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(BasicPackage.eNS_URI, bp);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("test", new BasicResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(BasicPackage.eCONTENT_TYPE, new BasicResourceFactoryImpl());
return resourceSet;
}

}
13 changes: 7 additions & 6 deletions org.gecko.emf.bson.tests/test.bndrun
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
-runrequires: \
bnd.identity;id='org.gecko.emf.bson.tests'
-runrequires: bnd.identity;id='org.gecko.emf.bson.tests'
-runfw: org.apache.felix.framework
-runee: JavaSE-11
-runbundles.junit5: ${test.runbundles}
-runbundles: \
org.apache.felix.configadmin;version='[1.9.22,1.9.23)',\
org.eclipse.emf.ecore.xmi;version='[2.16.0,2.16.1)',\
org.opentest4j;version='[1.2.0,1.2.1)',\
org.osgi.service.component;version='[1.4.0,1.4.1)',\
org.osgi.util.function;version='[1.1.0,1.1.1)',\
org.osgi.util.promise;version='[1.1.1,1.1.2)',\
com.fasterxml.jackson.core.jackson-annotations;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.core.jackson-core;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.core.jackson-databind;version='[2.13.2,2.13.3)',\
Expand All @@ -23,12 +20,16 @@
org.gecko.emf.osgi.example.model.basic;version='[4.1.1,4.1.2)',\
com.fasterxml.jackson.dataformat.jackson-dataformat-properties;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.dataformat.jackson-dataformat-yaml;version='[2.13.2,2.13.3)',\
emfjson-jackson;version='[2.1.0,2.1.1)',\
org.gecko.emf.bson;version=snapshot,\
org.gecko.emf.json;version=snapshot,\
org.yaml.snakeyaml;version='[1.30.0,1.30.1)',\
org.gecko.emf.bson.tests;version=snapshot,\
junit-jupiter-api;version='[5.8.2,5.8.3)',\
junit-jupiter-params;version='[5.8.2,5.8.3)',\
org.osgi.test.common;version='[1.1.0,1.1.1)',\
org.osgi.test.junit5;version='[1.1.0,1.1.1)'
org.osgi.test.junit5;version='[1.1.0,1.1.1)',\
org.apache.felix.converter;version='[1.0.18,1.0.19)',\
org.eclipse.emfcloud.emfjson-jackson;version='[2.1.0,2.1.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
org.osgi.util.promise;version='[1.2.0,1.2.1)',\
assertj-core;version='[3.22.0,3.22.1)'
13 changes: 12 additions & 1 deletion org.gecko.emf.json.tests/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ javac.target: 11

Bundle-Version: 1.0.1.SNAPSHOT
-buildpath: \
org.eclipse.emfcloud.emfjson-jackson;version=latest
org.eclipse.emfcloud.emfjson-jackson;version=latest,\
org.gecko.emf.osgi.component,\
org.eclipse.emf.ecore.xmi,\
org.eclipse.emf.ecore,\
org.gecko.emf.osgi.example.model.basic,\
org.gecko.emf.util.example.model;version=latest

-includeresource.resources: \
data=data/

-runproperties.properties: \
base.path=${.}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
5 changes: 5 additions & 0 deletions org.gecko.emf.json.tests/data/exampleDateFormat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "Building",
"startDate": "2022-07-26T08:46:53"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"eClass":"http://datainmotion.com/emf/util/examplemodel/1.0#//Building","startDate":"2022-07-26T08:46:53"}
4 changes: 4 additions & 0 deletions org.gecko.emf.json.tests/data/exampleOutputIndentTrue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"startDate" : "2022-07-26T08:46:53"
}
7 changes: 7 additions & 0 deletions org.gecko.emf.json.tests/data/exampleSerializeDefFalse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
8 changes: 8 additions & 0 deletions org.gecko.emf.json.tests/data/exampleSerializeDefTrue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"type" : "Building",
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
5 changes: 5 additions & 0 deletions org.gecko.emf.json.tests/data/exampleSerializeTypeFalse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"location" : {
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
7 changes: 7 additions & 0 deletions org.gecko.emf.json.tests/data/exampleSerializeTypeTrue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"new_type_field" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"location" : {
"new_type_field" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
31 changes: 31 additions & 0 deletions org.gecko.emf.json.tests/data/exampleTypeByClass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"type": "Building",
"location": {
"type": "org.gecko.emf.util.example.model.examplemodel.Polygon",
"coordinates": [
[
[
100,
0
],
[
101,
0
],
[
101,
1
],
[
100,
1
],
[
100,
0
]
]
]
}
}

31 changes: 31 additions & 0 deletions org.gecko.emf.json.tests/data/exampleTypeByName.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"type": "Building",
"location": {
"type": "Polygon",
"coordinates": [
[
[
100,
0
],
[
101,
0
],
[
101,
1
],
[
100,
1
],
[
100,
0
]
]
]
}
}

30 changes: 30 additions & 0 deletions org.gecko.emf.json.tests/data/exampleTypeByURI.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"location": {
"type": "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates": [
[
[
100,
0
],
[
101,
0
],
[
101,
1
],
[
100,
1
],
[
100,
0
]
]
]
}
}

7 changes: 7 additions & 0 deletions org.gecko.emf.json.tests/data/exampleUseIdFalse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
9 changes: 9 additions & 0 deletions org.gecko.emf.json.tests/data/exampleUseIdTrue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Building",
"@id" : null,
"location" : {
"eClass" : "http://datainmotion.com/emf/util/examplemodel/1.0#//Polygon",
"@id" : null,
"coordinates" : [ [ [ 100.0, 0.0 ], [ 101.0, 0.0 ], [ 101.0, 1.0 ], [ 100.0, 1.0 ], [ 100.0, 0.0 ] ] ]
}
}
Loading