You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/04/02 17:47:53 UTC
[11/52] [abbrv] polygene-java git commit: New (de)serialization API
and SPI & new implementations
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractCollectionSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractCollectionSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractCollectionSerializationTest.java
deleted file mode 100644
index 4660421..0000000
--- a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractCollectionSerializationTest.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.test.value;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.polygene.api.common.Optional;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.property.Property;
-import org.apache.polygene.api.type.CollectionType;
-import org.apache.polygene.api.type.MapType;
-import org.apache.polygene.api.type.ValueCompositeType;
-import org.apache.polygene.api.type.ValueType;
-import org.apache.polygene.api.value.ValueBuilder;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Test;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Assert that ValueSerialization behaviour on Collections and Maps is correct.
- */
-// TODO How to assert that given a collection of valuecomposites when serializing and deserializing we have no OOME?
-public class AbstractCollectionSerializationTest
- extends AbstractPolygeneTest
-{
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.values( SomeValue.class );
- }
-
- @Service
- @SuppressWarnings( "ProtectedField" )
- protected ValueSerialization valueSerialization;
-
- @Test
- public void givenPrimitiveArrayWithIntsWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- int[] primitiveArray = new int[]
- {
- 23, 42, -23, -42
- };
- String output = valueSerialization.serialize( primitiveArray );
- int[] deserialized = valueSerialization.deserialize( module, int[].class, output );
- assertArrayEquals( primitiveArray, deserialized );
- }
-
- @Test
- public void givenArrayWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- Byte[] array = new Byte[]
- {
- 9, null, -12, -12, 127, -128, 73
- };
- String output = valueSerialization.serialize( array );
- Byte[] deserialized = valueSerialization.deserialize( module, Byte[].class, output );
- assertArrayEquals( array, deserialized );
- }
-
- @Test
- public void givenIterableTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( new AdHocIterable<>( byteCollection() ) );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Byte.class ) );
- List<Byte> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( byteCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( byteCollection() );
- CollectionType collectionType = new CollectionType( Set.class, new ValueType( Byte.class ) );
- Set<Byte> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( new LinkedHashSet<>( byteCollection() ), list );
- }
-
- @Test
- public void givenCollectionTypeWithCharacterAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( characterCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Character.class ) );
- List<Character> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( characterCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithShortAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( shortCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Short.class ) );
- List<Short> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( shortCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithIntegerAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( integerCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Integer.class ) );
- List<Integer> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( integerCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithLongAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( longCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Long.class ) );
- List<Long> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( longCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithFloatAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( floatCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Float.class ) );
- List<Float> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( floatCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithDoubleAndNullElementWhenSerializingExpectCorrectJsonOutput()
- throws Exception
- {
- String output = valueSerialization.serialize( doubleCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( Double.class ) );
- List<Double> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( doubleCollection(), list );
-
- }
-
- @Test
- public void givenCollectionTypeWithBigIntegerAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( bigIntegerCollection() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( BigInteger.class ) );
- List<BigInteger> list = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( bigIntegerCollection(), list );
- }
-
- @Test
- public void givenCollectionTypeWithBigDecimalAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( bigDecimalCollection() );
- CollectionType collectionType = new CollectionType( Collection.class, new ValueType( BigDecimal.class ) );
- Collection<BigDecimal> collection = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( bigDecimalCollection(), collection );
- }
-
- @Test
- public void givenMapOfStringByteAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( stringByteMap() );
- MapType mapType = new MapType( Map.class, new ValueType( String.class ), new ValueType( Byte.class ) );
- Map<String, Byte> value = valueSerialization.deserialize( module, mapType, output );
- assertEquals( stringByteMap(), value );
- }
-
- @Test
- public void givenMapOfStringListStringAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( stringMultiMap() );
- CollectionType collectionType = new CollectionType( List.class, new ValueType( String.class ) );
- MapType mapType = new MapType( Map.class, new ValueType( String.class ), collectionType );
- Map<String, List<String>> value = valueSerialization.deserialize( module, mapType, output );
- assertEquals( stringMultiMap(), value );
- }
-
- @Test
- public void givenListOfMapStringStringAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( stringListOfMaps() );
- ValueType stringType = new ValueType( String.class );
- CollectionType collectionType = new CollectionType( List.class, new MapType( Map.class, stringType, stringType ) );
- List<Map<String, String>> value = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( stringListOfMaps(), value );
- }
-
- @Test
- public void givenListOfValueCompositesAndNullElementWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- String output = valueSerialization.serialize( valueCompositesList() );
- ValueCompositeType valueType = module.valueDescriptor( SomeValue.class.getName() ).valueType();
- CollectionType collectionType = new CollectionType( List.class, valueType );
- List<SomeValue> value = valueSerialization.deserialize( module, collectionType, output );
- assertEquals( valueCompositesList(), value );
- }
-
- private ArrayList<Byte> byteCollection()
- {
- ArrayList<Byte> value = new ArrayList<>();
- value.add( (byte) 9 );
- value.add( null );
- value.add( (byte) -12 );
- value.add( (byte) -12 );
- value.add( (byte) 127 );
- value.add( (byte) -128 );
- value.add( (byte) 73 );
- return value;
- }
-
- private List<Character> characterCollection()
- {
- List<Character> value = new ArrayList<>();
- value.add( 'Q' );
- value.add( 'i' );
- value.add( null );
- value.add( '4' );
- value.add( 'j' );
- return value;
- }
-
- private Collection<Short> shortCollection()
- {
- Collection<Short> value = new ArrayList<>();
- value.add( (short) -32768 );
- value.add( (short) 32767 );
- value.add( (short) -82 );
- value.add( null );
- return value;
- }
-
- private Collection<Integer> integerCollection()
- {
- Collection<Integer> value = new ArrayList<>();
- value.add( Integer.MAX_VALUE );
- value.add( -283 );
- value.add( null );
- value.add( Integer.MIN_VALUE );
- value.add( 238 );
- return value;
- }
-
- private Collection<Long> longCollection()
- {
- Collection<Long> value = new ArrayList<>();
- value.add( 98239723L );
- value.add( -1298233L );
- value.add( -1L );
- value.add( 0L );
- value.add( null );
- value.add( 1L );
- value.add( Long.MAX_VALUE );
- value.add( Long.MIN_VALUE );
- return value;
- }
-
- private Collection<Float> floatCollection()
- {
- Collection<Float> value = new ArrayList<>();
- value.add( -1f );
- value.add( 1f );
- value.add( 1f );
- value.add( 0f );
- value.add( Float.MAX_VALUE );
- value.add( Float.MIN_VALUE );
- value.add( null );
- value.add( 0.123456f );
- value.add( -0.232321f );
- return value;
- }
-
- private Collection<Double> doubleCollection()
- {
- Collection<Double> value = new ArrayList<>();
- value.add( -1.0 );
- value.add( 1.0 );
- value.add( 0.0 );
- value.add( Double.MAX_VALUE );
- value.add( null );
- value.add( Double.MIN_VALUE );
- value.add( 0.123456 );
- value.add( -0.232321 );
- return value;
- }
-
- private Collection<BigInteger> bigIntegerCollection()
- {
- Collection<BigInteger> value = new ArrayList<>();
- value.add( new BigInteger( "-1" ) );
- value.add( BigInteger.ZERO );
- value.add( BigInteger.ONE );
- value.add( null );
- value.add( BigInteger.TEN );
- value.add( new BigInteger( "-1827368263823729372397239829332" ) );
- value.add( new BigInteger( "2398723982982379827373972398723" ) );
- return value;
- }
-
- private Collection<BigDecimal> bigDecimalCollection()
- {
- Collection<BigDecimal> value = new ArrayList<>();
- value.add( new BigDecimal( "1.2" ) );
- value.add( new BigDecimal( "3.4" ) );
- value.add( null );
- value.add( new BigDecimal( "5.6" ) );
- return value;
- }
-
- private Map<String, Byte> stringByteMap()
- {
- Map<String, Byte> value = new LinkedHashMap<>();
- value.put( "a", (byte) 9 );
- value.put( "b", null );
- value.put( "c", (byte) -12 );
- return value;
- }
-
- private Map<String, List<String>> stringMultiMap()
- {
- Map<String, List<String>> value = new LinkedHashMap<>();
- List<String> list = new ArrayList<>();
- list.add( "foo" );
- list.add( "bar" );
- list.add( null );
- list.add( "cathedral" );
- list.add( "bazar" );
- value.put( "alpha", list );
- value.put( "beta", null );
- value.put( "gamma", Collections.<String>emptyList() );
- return value;
- }
-
- private List<Map<String, String>> stringListOfMaps()
- {
- List<Map<String, String>> value = new ArrayList<>();
- Map<String, String> map = new LinkedHashMap<>();
- map.put( "foo", "bar" );
- map.put( "cathedral", "bazar" );
- map.put( "yield", null );
- map.put( "42", "23" );
- value.add( map );
- value.add( null );
- value.add( Collections.<String, String>emptyMap() );
- return value;
- }
-
- private List<SomeValue> valueCompositesList()
- {
- List<SomeValue> list = new ArrayList<>();
- list.add( newSomeValue( "", "bazar" ) );
- list.add( null );
- list.add( newSomeValue( "bar", null ) );
- return list;
- }
-
- public interface SomeValue
- {
-
- Property<String> foo();
-
- @Optional
- Property<String> cathedral();
- }
-
- private SomeValue newSomeValue( String foo, String cathedral )
- {
- ValueBuilder<SomeValue> builder = module.instance().newValueBuilder( SomeValue.class );
- SomeValue value = builder.prototype();
- value.foo().set( foo );
- if( cathedral != null )
- {
- value.cathedral().set( cathedral );
- }
- return builder.newInstance();
- }
-
- private static class AdHocIterable<T> implements Iterable<T>
- {
- private final Iterable<T> delegate;
-
- private AdHocIterable( Iterable<T> delegate )
- {
- this.delegate = delegate;
- }
-
- @Override
- public Iterator<T> iterator()
- {
- return delegate.iterator();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractJsonDateFormatTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractJsonDateFormatTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractJsonDateFormatTest.java
deleted file mode 100644
index 35f310e..0000000
--- a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractJsonDateFormatTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.test.value;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.OffsetDateTime;
-import java.time.Period;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.util.List;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.type.CollectionType;
-import org.apache.polygene.api.type.ValueType;
-import org.apache.polygene.api.value.ValueDeserializer;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Test;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-/**
- * Assert that a JSON ValueDeserializer support various date formats.
- */
-@SuppressWarnings( "ProtectedField" )
-public class AbstractJsonDateFormatTest
- extends AbstractPolygeneTest
-{
-
- private final ValueType offsetDateTimeType = new ValueType( OffsetDateTime.class );
- private final ValueType zonedDateTimeType = new ValueType( ZonedDateTime.class );
- private final ValueType localDateTimeType = new ValueType( LocalDateTime.class );
- private final ValueType localTimeType = new ValueType( LocalTime.class );
- private final ValueType localDateType = new ValueType( LocalDate.class );
- private final ValueType instantType = new ValueType( Instant.class );
- private final ValueType durationType = new ValueType( Duration.class );
- private final ValueType periodType = new ValueType( Period.class );
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- }
-
- @Service
- protected ValueDeserializer valueDeserializer;
-
- @Test
- public void givenLocalDateTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, localDateTimeType );
- List<LocalDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27\"]" );
- LocalDateTime expected = LocalDateTime.of( 2009, 8, 12, 14, 54, 27 );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenLocalDateFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, localDateType );
- List<LocalDate> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12\"]" );
- LocalDate expected = LocalDate.of( 2009, 8, 12 );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenLocalTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, localTimeType );
- List<LocalTime> value = valueDeserializer.deserialize( module, collectionType, "[\"14:54:27\"]" );
- LocalTime expected = LocalTime.of( 14, 54, 27 );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenOffsetDateTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, offsetDateTimeType );
- List<OffsetDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27.895+08:00\"]" );
- OffsetDateTime expected = OffsetDateTime.of( 2009, 8, 12, 14, 54, 27, 895000000, ZoneOffset.ofHours( 8 ) );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenZonedDateTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, zonedDateTimeType );
- List<ZonedDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27.895+02:00[CET]\"]" );
- ZonedDateTime expected = ZonedDateTime.of( 2009, 8, 12, 14, 54, 27, 895000000, ZoneId.of( "CET" ) );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenInstantFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, instantType);
- List<Instant> value = valueDeserializer.deserialize( module, collectionType, "[\"2016-06-11T08:47:12.620Z\"]" );
- Instant expected = Instant.parse("2016-06-11T08:47:12.620Z" );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenDurationFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, durationType );
- List<Duration> value = valueDeserializer.deserialize( module, collectionType, "[\"PT3.5S\"]" );
- Duration expected = Duration.ofMillis( 3500 );
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
- @Test
- public void givenPeriodFormatWhenConvertingFromSerializedStateExpectValidDate()
- throws Exception
- {
- CollectionType collectionType = new CollectionType( List.class, periodType );
- List<Period> value = valueDeserializer.deserialize( module, collectionType, "[\"P3Y5M13D\"]" );
- Period expected = Period.of( 3, 5, 13);
- assertThat( value.get( 0 ), equalTo( expected ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
deleted file mode 100644
index c001b6f..0000000
--- a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.test.value;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.OffsetDateTime;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Test;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertThat;
-
-/**
- * Assert that ValueSerialization behaviour on plain values is correct.
- */
-public abstract class AbstractPlainValueSerializationTest
- extends AbstractPolygeneTest
-{
- @Service
- protected ValueSerialization valueSerialization;
-
- @Test
- public void givenCharacterValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( 'q' );
- assertThat( "Serialized", serialized, equalTo( "q" ) );
-
- Character deserialized = valueSerialization.deserialize( module, Character.class, serialized );
- assertThat( "Deserialized", deserialized, equalTo( 'q' ) );
- }
-
- @Test
- public void givenEmptyStringValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( "" );
- assertThat( "Serialized", serialized, equalTo( "" ) );
-
- String deserialized = valueSerialization.deserialize( module, String.class, serialized );
- assertThat( "Deserialized", deserialized, equalTo( "" ) );
- }
-
- @Test
- public void givenStringValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( "test" );
- assertThat( serialized, equalTo( "test" ) );
-
- String deserialized = valueSerialization.deserialize( module, String.class, serialized );
- assertThat( deserialized, equalTo( "test" ) );
- }
-
- @Test
- public void givenBooleanValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( Boolean.TRUE );
- assertThat( serialized, equalTo( "true" ) );
-
- Boolean deserialized = valueSerialization.deserialize( module, Boolean.class, serialized );
- assertThat( deserialized, equalTo( Boolean.TRUE ) );
- }
-
- @Test
- public void givenIntegerValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( 42 );
- assertThat( serialized, equalTo( "42" ) );
- Integer deserialized = valueSerialization.deserialize( module, Integer.class, serialized );
- assertThat( deserialized, equalTo( 42 ) );
- }
-
- @Test
- public void givenLongValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( 42L );
- assertThat( serialized, equalTo( "42" ) );
-
- Long deserialized = valueSerialization.deserialize( module, Long.class, serialized );
- assertThat( deserialized, equalTo( 42L ) );
- }
-
- @Test
- public void givenShortValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( (short) 42 );
- assertThat( serialized, equalTo( "42" ) );
-
- Short deserialized = valueSerialization.deserialize( module, Short.class, serialized );
- assertThat( deserialized, equalTo( (short) 42 ) );
- }
-
- @Test
- public void givenByteValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( (byte) 42 );
- assertThat( serialized, equalTo( "42" ) );
- Byte deserialized = valueSerialization.deserialize( module, Byte.class, serialized );
- assertThat( deserialized, equalTo( (byte) 42 ) );
- }
-
- @Test
- public void givenFloatValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( 42F );
- assertThat( serialized, equalTo( "42.0" ) );
-
- Float deserialized = valueSerialization.deserialize( module, Float.class, serialized );
- assertThat( deserialized, equalTo( 42F ) );
- }
-
- @Test
- public void givenDoubleValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( 42D );
- assertThat( serialized, equalTo( "42.0" ) );
-
- Double deserialized = valueSerialization.deserialize( module, Double.class, serialized );
- assertThat( deserialized, equalTo( 42D ) );
- }
-
- @Test
- public void givenBigIntegerValueWhenSerializingAndDeserializingExpectEquals()
- {
- BigInteger bigInteger = new BigInteger( "42424242424242424242424242" );
- assertThat( bigInteger, not( equalTo( BigInteger.valueOf( bigInteger.longValue() ) ) ) );
-
- String serialized = valueSerialization.serialize( bigInteger );
- assertThat( serialized, equalTo( "42424242424242424242424242" ) );
-
- BigInteger deserialized = valueSerialization.deserialize( module, BigInteger.class, serialized );
- assertThat( deserialized, equalTo( bigInteger ) );
- }
-
- @Test
- public void givenBigDecimalValueWhenSerializingAndDeserializingExpectEquals()
- {
- BigDecimal bigDecimal = new BigDecimal( "42.2376931348623157e+309" );
- assertThat( bigDecimal.doubleValue(), equalTo( Double.POSITIVE_INFINITY ) );
-
- String serialized = valueSerialization.serialize( bigDecimal );
- assertThat( serialized, equalTo( "4.22376931348623157E+310" ) );
-
- BigDecimal deserialized = valueSerialization.deserialize( module, BigDecimal.class, serialized );
- assertThat( deserialized, equalTo( bigDecimal ) );
- }
-
- @Test
- public void givenDateTimeValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( OffsetDateTime.of( 2020, 3, 4, 13, 24, 35, 123000000, ZoneOffset.ofHours( 1 ) ) );
- assertThat( serialized, equalTo( "2020-03-04T13:24:35.123+01:00" ) );
- ZonedDateTime deserialized = valueSerialization.deserialize( module, ZonedDateTime.class, serialized );
- assertThat( deserialized, equalTo( ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 123000000, ZoneOffset.ofHours( 1 ) ) ) );
- }
-
- @Test
- public void givenLocalDateTimeValueWhenSerializingAndDeserializingExpectEquals()
- {
- // Serialized without TimeZone
- String serialized = valueSerialization.serialize( LocalDateTime.of( 2020, 3, 4, 13, 23, 12 ) );
- assertThat( serialized, equalTo( "2020-03-04T13:23:12" ) );
-
- LocalDateTime deserialized = valueSerialization.deserialize( module, LocalDateTime.class, serialized );
- assertThat( deserialized, equalTo( LocalDateTime.of( 2020, 3, 4, 13, 23, 12 ) ) );
- }
-
- @Test
- public void givenLocalDateValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( LocalDate.of( 2020, 3, 4 ) );
- assertThat( serialized, equalTo( "2020-03-04" ) );
-
- LocalDate deserialized = valueSerialization.deserialize( module, LocalDate.class, serialized );
- assertThat( deserialized, equalTo( LocalDate.of( 2020,3,4 ) ) );
- }
-
- @Test
- public void givenEntityReferenceValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( EntityReference.parseEntityReference( "ABCD-1234" ) );
- assertThat( serialized, equalTo( "ABCD-1234" ) );
-
- EntityReference deserialized = valueSerialization.deserialize( module, EntityReference.class, serialized );
- assertThat( deserialized, equalTo( EntityReference.parseEntityReference( "ABCD-1234" ) ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractValueCompositeSerializationTest.java
deleted file mode 100644
index 44ab1f4..0000000
--- a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractValueCompositeSerializationTest.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.test.value;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Serializable;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.OffsetDateTime;
-import java.time.ZoneOffset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.polygene.api.injection.scope.Structure;
-import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.apache.polygene.api.association.Association;
-import org.apache.polygene.api.association.ManyAssociation;
-import org.apache.polygene.api.association.NamedAssociation;
-import org.apache.polygene.api.common.Optional;
-import org.apache.polygene.api.common.UseDefaults;
-import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.api.entity.EntityBuilder;
-import org.apache.polygene.api.entity.EntityComposite;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.property.Property;
-import org.apache.polygene.api.unitofwork.UnitOfWork;
-import org.apache.polygene.api.value.ValueBuilder;
-import org.apache.polygene.api.value.ValueComposite;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.EntityTestAssembler;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Assert that ValueSerialization behaviour on ValueComposites is correct.
- */
-// TODO Assert Arrays behaviour!
-// TODO Assert Generics behaviour!
-public abstract class AbstractValueCompositeSerializationTest
- extends AbstractPolygeneTest
-{
- @Rule
- public TestName testName = new TestName();
-
- @Structure
- Module moduleInstance;
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.values( SomeValue.class, AnotherValue.class, FooValue.class, CustomFooValue.class,
- SpecificCollection.class /*, SpecificValue.class, GenericValue.class */ );
-
- new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module.layer().module( "persistence" ) );
- module.entities( BarEntity.class );
- }
-
- @Service
- protected ValueSerialization valueSerialization;
-
- @Test
- public void givenValueCompositeWhenSerializingAndDeserializingExpectEquals()
- throws Exception
- {
- try(UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
- {
- SomeValue some = buildSomeValue();
-
- // Serialize using injected service
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- valueSerialization.serialize( some, output );
- String stateString = output.toString( "UTF-8" );
-
- // Deserialize using Module API
- System.out.println(stateString);
- SomeValue some2 = moduleInstance.newValueFromSerializedState( SomeValue.class, stateString );
-
- assertThat( "String Integer Map", some2.stringIntMap().get().get( "foo" ), equalTo( 42 ) );
- assertThat( "String Value Map", some2.stringValueMap().get().get( "foo" ).internalVal(), equalTo( "Bar" ) );
- assertThat( "Nested Entities", some2.barAssociation().get().cathedral().get(), equalTo( "bazar in barAssociation" ) );
-
- assertThat( "Same value", some, equalTo( some2 ) );
- assertThat( "Same JSON value toString", stateString, equalTo( some2.toString() ) );
- assertThat( "Same JSON value", some.customFoo().get() instanceof CustomFooValue, is( true ) );
- assertThat( "Same JSON value explicit", some.customFooValue().get() instanceof CustomFooValue, is( true ) );
- assertThat( "Same value toString", some.toString(), equalTo( some2.toString() ) );
- }
- }
-
- /**
- * @return a SomeValue ValueComposite whose state is populated with test data.
- */
- private SomeValue buildSomeValue()
- {
- ValueBuilder<SomeValue> builder = moduleInstance.newValueBuilder( SomeValue.class );
- SomeValue proto = builder.prototype();
- proto.anotherList().get().add( moduleInstance.newValue( AnotherValue.class ) );
-
- ValueBuilder<SpecificCollection> specificColBuilder = moduleInstance.newValueBuilder( SpecificCollection.class );
- SpecificCollection specificColProto = specificColBuilder.prototype();
- List<String> genericList = new ArrayList<>( 2 );
- genericList.add( "Some" );
- genericList.add( "String" );
- specificColProto.genericList().set( genericList );
- proto.specificCollection().set( specificColBuilder.newInstance() );
-
- AnotherValue anotherValue1 = createAnotherValue( "Foo", "Bar" );
- AnotherValue anotherValue2 = createAnotherValue( "Habba", "ZoutZout" );
- AnotherValue anotherValue3 = createAnotherValue( "Niclas", "Hedhman" );
-
- // FIXME Some Control Chars are not supported in JSON nor in XML, what should we do about it?
- // Should Polygene Core ensure the chars used in strings are supported by the whole stack?
- // proto.string().set( "Foo\"Bar\"\nTest\f\t\b" );
- proto.string().set( "Foo\"Bar\"\nTest\t" );
- proto.string2().set( "/Foo/bar" );
- proto.number().set( 43L );
- proto.localTime().set( LocalTime.now() );
- proto.dateTime().set( OffsetDateTime.of( 2020, 3, 4, 13, 24, 35, 0, ZoneOffset.ofHours( 1 ) ) );
- proto.localDate().set( LocalDate.now() );
- proto.localDateTime().set( LocalDateTime.now() );
- proto.entityReference().set( EntityReference.parseEntityReference( "12345" ) );
- proto.stringIntMap().get().put( "foo", 42 );
-
- // Can't put more than one entry in Map because this test rely on the fact that the underlying implementations
- // maintain a certain order but it's not the case on some JVMs. On OpenJDK 8 they are reversed for example.
- // This should not be enforced tough as both the Map API and the JSON specification state that name-value pairs
- // are unordered.
- // As a consequence this test should be enhanced to be Map order independant.
- //
- // proto.stringIntMap().get().put( "bar", 67 );
-
- proto.stringValueMap().get().put( "foo", anotherValue1 );
- proto.another().set( anotherValue1 );
- // proto.arrayOfValues().set( new AnotherValue[] { anotherValue1, anotherValue2, anotherValue3 } );
- proto.serializable().set( new SerializableObject() );
- proto.foo().set( moduleInstance.newValue( FooValue.class ) );
- proto.fooValue().set( moduleInstance.newValue( FooValue.class ) );
- proto.customFoo().set( moduleInstance.newValue( CustomFooValue.class ) );
- proto.customFooValue().set( moduleInstance.newValue( CustomFooValue.class ) );
-
- // Arrays
- // TODO FIXME Disabled as ValueComposite equality fails here
- //proto.primitiveByteArray().set( new byte[]
- // {
- // 9, -12, 42, -12, 127, 23, -128, 73
- // } );
- //proto.byteArray().set( new Byte[]
- // {
- // 9, null, -12, 23, -12, 127, -128, 73
- // } );
-
- // NestedEntities
- proto.barAssociation().set( buildBarEntity( "bazar in barAssociation" ) );
- proto.barEntityAssociation().set( buildBarEntity( "bazar in barEntityAssociation" ) );
- proto.barManyAssociation().add( buildBarEntity( "bazar ONE in barManyAssociation" ) );
- proto.barManyAssociation().add( buildBarEntity( "bazar TWO in barManyAssociation" ) );
- proto.barEntityManyAssociation().add( buildBarEntity( "bazar ONE in barEntityManyAssociation" ) );
- proto.barEntityManyAssociation().add( buildBarEntity( "bazar TWO in barEntityManyAssociation" ) );
- proto.barNamedAssociation().put( "bazar", buildBarEntity( "bazar in barNamedAssociation" ) );
- proto.barNamedAssociation().put( "cathedral", buildBarEntity( "cathedral in barNamedAssociation" ) );
- proto.barEntityNamedAssociation().put( "bazar", buildBarEntity( "bazar in barEntityNamedAssociation" ) );
- proto.barEntityNamedAssociation().put( "cathedral", buildBarEntity( "cathedral in barEntityNamedAssociation" ) );
-
- return builder.newInstance();
- }
-
- private AnotherValue createAnotherValue( String val1, String val2 )
- {
- ValueBuilder<AnotherValue> valueBuilder = moduleInstance.newValueBuilder( AnotherValue.class );
- valueBuilder.prototype().val1().set( val1 );
- valueBuilder.prototypeFor( AnotherValueInternalState.class ).val2().set( val2 );
- return valueBuilder.newInstance();
- }
-
- private BarEntity buildBarEntity( String cathedral )
- {
- EntityBuilder<BarEntity> barBuilder = unitOfWorkFactory.currentUnitOfWork().newEntityBuilder( BarEntity.class );
- barBuilder.instance().cathedral().set( cathedral );
- return barBuilder.newInstance();
- }
-
- public enum TestEnum
- {
- somevalue, anothervalue
- }
-
- public interface SomeValue
- extends ValueComposite
- {
- Property<String> string();
-
- Property<String> string2();
-
- @Optional
- Property<String> nullString();
-
- @UseDefaults
- Property<String> emptyString();
-
- @UseDefaults
- Property<Long> number();
-
- Property<LocalTime> localTime();
-
- Property<OffsetDateTime> dateTime();
-
- Property<LocalDate> localDate();
-
- Property<LocalDateTime> localDateTime();
-
- Property<EntityReference> entityReference();
-
- @UseDefaults
- Property<List<String>> stringList();
-
- @UseDefaults
- Property<Map<String, Integer>> stringIntMap();
-
- @UseDefaults
- Property<Map<String, AnotherValue>> stringValueMap();
-
- Property<AnotherValue> another();
-
- // Property<AnotherValue[]> arrayOfValues();
-
- @Optional
- Property<AnotherValue> anotherNull();
-
- @UseDefaults
- Property<List<AnotherValue>> anotherList();
-
- @Optional
- Property<List<AnotherValue>> anotherListNull();
-
- @UseDefaults
- Property<List<AnotherValue>> anotherListEmpty();
-
- @UseDefaults
- Property<TestEnum> testEnum();
-
- // TODO FIXME Disabled as ValueComposite equality fails here
- //Property<byte[]> primitiveByteArray();
- //
- //@Optional
- //Property<byte[]> primitiveByteArrayNull();
- //
- //Property<Byte[]> byteArray();
- //
- //@Optional
- //Property<Byte[]> byteArrayNull();
-
- Property<Object> serializable();
-
- Property<Foo> foo();
-
- Property<FooValue> fooValue();
-
- Property<Foo> customFoo();
-
- Property<FooValue> customFooValue();
-
- Property<SpecificCollection> specificCollection();
-
- /* Too complicated to do generics here for now
- Property<SpecificValue> specificValue();
- */
- @Optional
- Association<Bar> barAssociationOptional();
-
- Association<Bar> barAssociation();
-
- Association<BarEntity> barEntityAssociation();
-
- ManyAssociation<Bar> barManyAssociationEmpty();
-
- ManyAssociation<Bar> barManyAssociation();
-
- ManyAssociation<BarEntity> barEntityManyAssociation();
-
- NamedAssociation<Bar> barNamedAssociationEmpty();
-
- NamedAssociation<Bar> barNamedAssociation();
-
- NamedAssociation<BarEntity> barEntityNamedAssociation();
- }
-
- public interface SpecificCollection
- extends GenericCollection<String>
- {
- }
-
- public interface GenericCollection<TYPE>
- extends ValueComposite
- {
- @UseDefaults
- Property<List<TYPE>> genericList();
- }
-
- public interface SpecificValue
- extends GenericValue<String>
- {
- }
-
- public interface GenericValue<TYPE>
- extends ValueComposite
- {
- @Optional
- Property<TYPE> item();
- }
-
- @Mixins( AnotherValueMixin.class )
- public interface AnotherValue
- extends ValueComposite
- {
- @UseDefaults
- Property<String> val1();
-
- String internalVal();
- }
-
- public interface AnotherValueInternalState
- {
- @UseDefaults
- Property<String> val2();
- }
-
- public static abstract class AnotherValueMixin
- implements AnotherValue
- {
- @This
- private AnotherValueInternalState internalState;
-
- @Override
- public String internalVal()
- {
- return internalState.val2().get();
- }
- }
-
- public interface Foo
- {
- @UseDefaults
- Property<String> bar();
- }
-
- public interface FooValue
- extends Foo, ValueComposite
- {
- }
-
- public interface CustomFooValue
- extends FooValue
- {
- @UseDefaults
- Property<String> custom();
- }
-
- public interface Bar
- {
- @UseDefaults
- Property<String> cathedral();
- }
-
- public interface BarEntity
- extends Bar, EntityComposite
- {
- }
-
- public static class SerializableObject
- implements Serializable
- {
- private static final long serialVersionUID = 1L;
- private final String foo = "Foo";
- private final int val = 35;
-
- @Override
- public boolean equals( Object o )
- {
- if( this == o )
- {
- return true;
- }
- if( o == null || getClass() != o.getClass() )
- {
- return false;
- }
- SerializableObject that = (SerializableObject) o;
- return val == that.val && foo.equals( that.foo );
- }
-
- @Override
- public int hashCode()
- {
- int result = foo.hashCode();
- result = 31 * result + val;
- return result;
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/core/testsupport/src/main/java/org/apache/polygene/test/value/package.html
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/value/package.html b/core/testsupport/src/main/java/org/apache/polygene/test/value/package.html
deleted file mode 100644
index 31f0033..0000000
--- a/core/testsupport/src/main/java/org/apache/polygene/test/value/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>ValueSerialization SPI Test Support.</h2>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/dependencies.gradle
----------------------------------------------------------------------
diff --git a/dependencies.gradle b/dependencies.gradle
index 61f2b2a..7b5ebfd 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -28,13 +28,13 @@ dependencies.repositoriesUrls << [
// Core dependencies
def asmVersion = '5.2'
-def orgJsonVersion = '20130213'
+def javaxJsonVersion = '1.0'
def osgiVersion = '4.3.1'
dependencies.libraries << [
asm : "org.ow2.asm:asm:$asmVersion",
asm_commons: "org.ow2.asm:asm-commons:$asmVersion",
asm_util : "org.ow2.asm:asm-util:$asmVersion",
- org_json : "org.codeartisans:org.json:$orgJsonVersion",
+ javax_json : "javax.json:javax.json-api:$javaxJsonVersion",
osgi_core : "org.osgi:org.osgi.core:$osgiVersion",
]
@@ -61,10 +61,13 @@ def jcloudsVersion = '2.0.1'
def jdbmVersion = '2.4'
def jedisVersion = '2.9.0'
def jettyVersion = '9.2.17.v20160517' // 9.3.x Tests fail!
+def johnzonVersion = '1.0.0'
+def jooqVersion = '3.9.0'
def leveldbVersion = '0.9'
def leveldbJniVersion = '1.8'
def liquibaseVersion = '3.5.3'
def mongodbVersion = '3.4.2'
+def msgpackVersion = '0.8.11'
def restletVersion = '2.3.9'
def rdfVersion = '2.7.16' // 2.8.x change query results!! 4.x exists
def riakVersion = '2.1.1'
@@ -114,6 +117,8 @@ dependencies.libraries << [
jetty_continuation : "org.eclipse.jetty:jetty-continuation:$jettyVersion",
jetty_client : "org.eclipse.jetty:jetty-client:$jettyVersion",
jetty_xml : "org.eclipse.jetty:jetty-xml:$jettyVersion",
+ johnzon : "org.apache.johnzon:johnzon-core:$johnzonVersion",
+ jooq : "org.jooq:jooq:$jooqVersion",
jdbm : "jdbm:jdbm:$jdbmVersion",
jedis : "redis.clients:jedis:$jedisVersion",
leveldb_api : "org.iq80.leveldb:leveldb-api:$leveldbVersion",
@@ -121,6 +126,7 @@ dependencies.libraries << [
leveldb_jni_all : "org.fusesource.leveldbjni:leveldbjni-all:$leveldbJniVersion",
liquibase : "org.liquibase:liquibase-core:$liquibaseVersion",
mongodb : "org.mongodb:mongo-java-driver:$mongodbVersion",
+ msgpack : "org.msgpack:msgpack-core:$msgpackVersion",
osgi_compendium : "org.osgi:org.osgi.compendium:$osgiVersion",
osgi_enterprise : "org.osgi:org.osgi.enterprise:$osgiVersion",
restlet : [ "org.restlet.jee:org.restlet:$restletVersion",
@@ -178,11 +184,12 @@ def h2Version = '1.4.193'
def hamcrestVersion = '1.3'
def jaxRsApiVersion = '2.0.1'
def junitVersion = '4.12'
-def logbackVersion = '1.2.1'
+def logbackVersion = '1.2.1' // TODO Replace with Apache Log4j 2
def mockitoVersion = '2.7.14'
def mysqlVersion = '6.0.5'
def postgresqlVersion = '42.0.0'
def sqliteVersion = '3.16.1'
+def xmlUnitVersion = '2.3.0'
dependencies.libraries << [
awaitility : "org.awaitility:awaitility:$awaitilityVersion",
derby : "org.apache.derby:derby:$derbyVersion",
@@ -200,6 +207,7 @@ dependencies.libraries << [
postgres : "org.postgresql:postgresql:$postgresqlVersion",
spring_testsupport: "org.springframework:spring-test:$springVersion",
sqlite : "org.xerial:sqlite-jdbc:$sqliteVersion",
+ xmlunit : "org.xmlunit:xmlunit-matchers:$xmlUnitVersion",
]
// Default dependencies
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/cache-ehcache/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/cache-ehcache/build.gradle b/extensions/cache-ehcache/build.gradle
index 48bd5a5..c61a790 100644
--- a/extensions/cache-ehcache/build.gradle
+++ b/extensions/cache-ehcache/build.gradle
@@ -34,7 +34,6 @@ dependencies {
runtimeOnly polygene.core.runtime
testImplementation polygene.core.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/cache-memcache/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/cache-memcache/build.gradle b/extensions/cache-memcache/build.gradle
index 034661e..8aa67a7 100644
--- a/extensions/cache-memcache/build.gradle
+++ b/extensions/cache-memcache/build.gradle
@@ -32,7 +32,6 @@ dependencies {
runtimeOnly polygene.core.runtime
testImplementation polygene.internals.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-cassandra/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/build.gradle b/extensions/entitystore-cassandra/build.gradle
index ffe2cd8..b1f32a8 100644
--- a/extensions/entitystore-cassandra/build.gradle
+++ b/extensions/entitystore-cassandra/build.gradle
@@ -34,7 +34,6 @@ dependencies {
runtimeOnly polygene.core.runtime
testImplementation polygene.internals.testsupport
- testImplementation polygene.extension( 'valueserialization-jackson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
index 234a76f..80b638a 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
@@ -47,14 +47,11 @@ import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.api.property.PropertyDescriptor;
import org.apache.polygene.api.service.ServiceActivation;
-import org.apache.polygene.api.service.qualifier.Tagged;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.api.structure.ModuleDescriptor;
import org.apache.polygene.api.unitofwork.NoSuchEntityTypeException;
import org.apache.polygene.api.unitofwork.UnitOfWork;
import org.apache.polygene.api.usecase.Usecase;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.api.value.ValueSerializer;
import org.apache.polygene.spi.entity.EntityState;
import org.apache.polygene.spi.entity.EntityStatus;
import org.apache.polygene.spi.entity.ManyAssociationState;
@@ -66,6 +63,7 @@ import org.apache.polygene.spi.entitystore.EntityStoreSPI;
import org.apache.polygene.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.polygene.spi.entitystore.StateCommitter;
import org.apache.polygene.spi.entitystore.helpers.DefaultEntityState;
+import org.apache.polygene.spi.serialization.JsonSerialization;
import static java.util.stream.StreamSupport.stream;
import static org.apache.polygene.entitystore.cassandra.CassandraCluster.APP_VERSION_COLUMN;
@@ -88,7 +86,6 @@ public class CassandraEntityStoreMixin
implements EntityStore, EntityStoreSPI, ServiceActivation
{
- private static final ValueSerializer.Options MAP_OPTIONS = new ValueSerializer.Options().withMapEntriesAsObjects();
@This
private CassandraCluster cluster;
@@ -100,8 +97,7 @@ public class CassandraEntityStoreMixin
private CassandraMigration migration;
@Service
- @Tagged( ValueSerialization.Formats.JSON )
- private ValueSerialization valueSerialization;
+ private JsonSerialization valueSerialization;
@Optional
@Service
@@ -414,7 +410,7 @@ public class CassandraEntityStoreMixin
.collect(
Collectors.toMap( Map.Entry::getKey,
entry -> entry.getValue().toString() ) );
- String serialized = valueSerialization.serialize( MAP_OPTIONS, refs );
+ String serialized = valueSerialization.serialize( refs );
named.put( descriptor.qualifiedName().name(), serialized );
} );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
index 7194340..08e5dfd 100644
--- a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
+++ b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
@@ -27,7 +27,6 @@ import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
import org.apache.polygene.test.entity.CanRemoveAll;
import org.apache.polygene.test.internal.DockerRule;
-import org.apache.polygene.valueserialization.jackson.assembly.JacksonValueSerializationAssembler;
import org.junit.ClassRule;
/**
@@ -51,7 +50,6 @@ public class CassandraMapEntityStoreTest
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
module.services( CassandraEntityStoreService.class ).withTypes( CanRemoveAll.class ).withMixins( EmptyCassandraTableMixin.class );
- new JacksonValueSerializationAssembler().assemble( module );
// START SNIPPET: assembly
new CassandraEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-file/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/build.gradle b/extensions/entitystore-file/build.gradle
index bc73c80..b430e7d 100644
--- a/extensions/entitystore-file/build.gradle
+++ b/extensions/entitystore-file/build.gradle
@@ -30,9 +30,7 @@ dependencies {
implementation polygene.library( 'constraints' )
runtimeOnly polygene.core.runtime
-
testImplementation polygene.core.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-file/src/main/java/org/apache/polygene/entitystore/file/FileEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/main/java/org/apache/polygene/entitystore/file/FileEntityStoreMixin.java b/extensions/entitystore-file/src/main/java/org/apache/polygene/entitystore/file/FileEntityStoreMixin.java
index f1605a5..270503d 100644
--- a/extensions/entitystore-file/src/main/java/org/apache/polygene/entitystore/file/FileEntityStoreMixin.java
+++ b/extensions/entitystore-file/src/main/java/org/apache/polygene/entitystore/file/FileEntityStoreMixin.java
@@ -154,7 +154,7 @@ public class FileEntityStoreMixin
@Override
public void applyChanges( MapChanges changes )
- throws IOException
+ throws Exception
{
try
{
@@ -183,7 +183,7 @@ public class FileEntityStoreMixin
}
@Override
- public Writer updateEntity( final EntityReference ref, EntityDescriptor descriptor )
+ public Writer updateEntity( MapChange mapChange )
throws IOException
{
return new StringWriter( 1000 )
@@ -194,7 +194,7 @@ public class FileEntityStoreMixin
{
super.close();
String state = this.toString();
- File dataFile = getDataFile( ref );
+ File dataFile = getDataFile( mapChange.reference() );
store( dataFile, state );
}
};
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTest.java b/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTest.java
index 14ba8a8..d18be11 100644
--- a/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTest.java
+++ b/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTest.java
@@ -27,7 +27,6 @@ import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationOverride;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
@@ -49,7 +48,6 @@ public class FileEntityStoreTest
.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
// START SNIPPET: assembly
new FileEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreWithCacheTest.java b/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreWithCacheTest.java
index 512feb0..95988da 100644
--- a/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreWithCacheTest.java
@@ -27,7 +27,6 @@ import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationOverride;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.cache.AbstractEntityStoreWithCacheTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
@@ -47,7 +46,6 @@ public class FileEntityStoreWithCacheTest
.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
new FileEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-geode/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/build.gradle b/extensions/entitystore-geode/build.gradle
index e38e9f1..5cf6185 100644
--- a/extensions/entitystore-geode/build.gradle
+++ b/extensions/entitystore-geode/build.gradle
@@ -33,7 +33,6 @@ dependencies {
runtimeOnly polygene.core.runtime
testImplementation polygene.core.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-geode/src/main/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/src/main/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreMixin.java b/extensions/entitystore-geode/src/main/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreMixin.java
index 0cfe27a..c140c28 100644
--- a/extensions/entitystore-geode/src/main/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreMixin.java
+++ b/extensions/entitystore-geode/src/main/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreMixin.java
@@ -154,7 +154,7 @@ public class GeodeEntityStoreMixin
}
@Override
- public void applyChanges( MapChanges changes ) throws IOException
+ public void applyChanges( MapChanges changes ) throws Exception
{
changes.visitMap( new MapChanger()
{
@@ -177,10 +177,10 @@ public class GeodeEntityStoreMixin
}
@Override
- public Writer updateEntity( EntityReference ref, EntityDescriptor entityDescriptor )
+ public Writer updateEntity( MapChange mapChange )
throws IOException
{
- return newEntity( ref, entityDescriptor );
+ return newEntity( mapChange.reference(), mapChange.descriptor() );
}
@Override
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTest.java b/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTest.java
index 5f2a4f9..a6aa1e1 100644
--- a/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTest.java
+++ b/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTest.java
@@ -25,7 +25,6 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.geode.assembly.GeodeEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
public class GeodeEntityStoreTest
extends AbstractEntityStoreTest
@@ -39,7 +38,6 @@ public class GeodeEntityStoreTest
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
// START SNIPPET: assembly
new GeodeEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreWithCacheTest.java b/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreWithCacheTest.java
index 6dd02c4..3b30a1b 100644
--- a/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreWithCacheTest.java
@@ -25,7 +25,6 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.geode.assembly.GeodeEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.cache.AbstractEntityStoreWithCacheTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
public class GeodeEntityStoreWithCacheTest
extends AbstractEntityStoreWithCacheTest
@@ -37,7 +36,6 @@ public class GeodeEntityStoreWithCacheTest
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
new GeodeEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-hazelcast/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/build.gradle b/extensions/entitystore-hazelcast/build.gradle
index 176f586..ae1046c 100644
--- a/extensions/entitystore-hazelcast/build.gradle
+++ b/extensions/entitystore-hazelcast/build.gradle
@@ -33,7 +33,6 @@ dependencies {
runtimeOnly polygene.core.runtime
testImplementation polygene.core.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-hazelcast/src/main/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/src/main/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreMixin.java b/extensions/entitystore-hazelcast/src/main/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreMixin.java
index 57d646c..749d980 100644
--- a/extensions/entitystore-hazelcast/src/main/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreMixin.java
+++ b/extensions/entitystore-hazelcast/src/main/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreMixin.java
@@ -104,7 +104,7 @@ public class HazelcastEntityStoreMixin
@Override
public void applyChanges( MapChanges changes )
- throws IOException
+ throws Exception
{
changes.visitMap( new MapChanger()
{
@@ -127,10 +127,10 @@ public class HazelcastEntityStoreMixin
}
@Override
- public Writer updateEntity( EntityReference ref, EntityDescriptor entityDescriptor )
+ public Writer updateEntity( MapChange mapChange )
throws IOException
{
- return newEntity( ref, entityDescriptor );
+ return newEntity( mapChange.reference(), mapChange.descriptor());
}
@Override
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTest.java b/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTest.java
index de6c474..c2d705f 100644
--- a/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTest.java
+++ b/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTest.java
@@ -19,8 +19,6 @@
*/
package org.apache.polygene.entitystore.hazelcast;
-import org.junit.After;
-import org.junit.Test;
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.polygene.bootstrap.AssemblyException;
@@ -28,7 +26,8 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.hazelcast.assembly.HazelcastEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
+import org.junit.After;
+import org.junit.Test;
public class HazelcastEntityStoreTest
extends AbstractEntityStoreTest
@@ -43,7 +42,6 @@ public class HazelcastEntityStoreTest
super.assemble( module );
ModuleAssembly configModule = module.layer().module( "config" );
new EntityTestAssembler().assemble( configModule );
- new OrgJsonValueSerializationAssembler().assemble( module );
// START SNIPPET: assembly
new HazelcastEntityStoreAssembler().withConfig( configModule, Visibility.layer ).assemble( module );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreWithCacheTest.java b/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreWithCacheTest.java
index f0a86c3..2b0cfa1 100644
--- a/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreWithCacheTest.java
@@ -25,7 +25,6 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.hazelcast.assembly.HazelcastEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.cache.AbstractEntityStoreWithCacheTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
public class HazelcastEntityStoreWithCacheTest
extends AbstractEntityStoreWithCacheTest
@@ -37,7 +36,6 @@ public class HazelcastEntityStoreWithCacheTest
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
new HazelcastEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-jclouds/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/build.gradle b/extensions/entitystore-jclouds/build.gradle
index 01a732e..8db7d5c 100644
--- a/extensions/entitystore-jclouds/build.gradle
+++ b/extensions/entitystore-jclouds/build.gradle
@@ -37,7 +37,6 @@ dependencies {
runtimeOnly libraries.jaxb_api
testImplementation polygene.internals.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testImplementation libraries.jclouds_filesystem
testRuntimeOnly libraries.logback
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
index 38cdd80..2ab821b 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
@@ -188,7 +188,7 @@ public class JCloudsMapEntityStoreMixin
@Override
public void applyChanges( MapChanges changes )
- throws IOException
+ throws Exception
{
final BlobStore blobStore = storeContext.getBlobStore();
changes.visitMap(
@@ -216,12 +216,13 @@ public class JCloudsMapEntityStoreMixin
}
@Override
- public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor )
+ public Writer updateEntity( MapChange mapChange )
throws IOException
{
- if( !blobStore.blobExists( container, ref.identity().toString() ) )
+ String identity = mapChange.reference().identity().toString();
+ if( !blobStore.blobExists( container, identity ) )
{
- throw new EntityNotFoundException( ref );
+ throw new EntityNotFoundException( mapChange.reference() );
}
return new StringWriter()
{
@@ -231,7 +232,7 @@ public class JCloudsMapEntityStoreMixin
{
super.close();
ByteSource payload = ByteSource.wrap( toString().getBytes( UTF_8 ) );
- Blob blob = blobStore.blobBuilder( ref.identity().toString() )
+ Blob blob = blobStore.blobBuilder( identity )
.payload( payload )
.contentLength( payload.size() )
.build();
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTest.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTest.java
index fc0a16a..91abf14 100644
--- a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTest.java
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTest.java
@@ -22,12 +22,10 @@ package org.apache.polygene.entitystore.jclouds;
import java.util.Collections;
import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
import org.jclouds.filesystem.reference.FilesystemConstants;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
@@ -40,12 +38,10 @@ public class JCloudsFilesystemTest
@Override
public void assemble( ModuleAssembly module )
- throws AssemblyException
{
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
new JCloudsEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
JCloudsMapEntityStoreConfiguration defaults = config.forMixin( JCloudsMapEntityStoreConfiguration.class )
.declareDefaults();
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
index 6b30854..720b072 100644
--- a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
@@ -25,7 +25,6 @@ import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssemb
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
import org.apache.polygene.test.internal.DockerRule;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
import org.junit.ClassRule;
public class JCloudsS3Test extends AbstractEntityStoreTest
@@ -39,7 +38,6 @@ public class JCloudsS3Test extends AbstractEntityStoreTest
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
new JCloudsEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
JCloudsMapEntityStoreConfiguration defaults = config.forMixin( JCloudsMapEntityStoreConfiguration.class )
.declareDefaults();
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTest.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTest.java
index 62074a6..266c0e1 100644
--- a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTest.java
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTest.java
@@ -21,28 +21,22 @@
package org.apache.polygene.entitystore.jclouds;
import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
public class JCloudsTransientTest
extends AbstractEntityStoreTest
{
-
@Override
public void assemble( ModuleAssembly module )
- throws AssemblyException
{
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
// START SNIPPET: assembly
new JCloudsEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
// END SNIPPET: assembly
}
-
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/17b11697/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsWithCacheTest.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsWithCacheTest.java
index 3f18f58..72f89cf 100644
--- a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsWithCacheTest.java
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsWithCacheTest.java
@@ -25,7 +25,6 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.cache.AbstractEntityStoreWithCacheTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
public class JCloudsWithCacheTest
extends AbstractEntityStoreWithCacheTest
@@ -37,7 +36,6 @@ public class JCloudsWithCacheTest
super.assemble( module );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
- new OrgJsonValueSerializationAssembler().assemble( module );
new JCloudsEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
}