X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fschema%2Fprovider%2Fimpl%2FYangTextSourceSerializationProxyTest.java;h=ced954640cd142fbb4f01b63231a61eb37162801;hb=HEAD;hp=c943451ae2a386e62bcb1388dd5366566d8c36cb;hpb=ea6d6a867e47ea40f97d910300bd2afdcf4e1e88;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSourceSerializationProxyTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSourceSerializationProxyTest.java index c943451ae2..ced954640c 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSourceSerializationProxyTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSourceSerializationProxyTest.java @@ -5,61 +5,55 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.schema.provider.impl; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import com.google.common.io.ByteSource; +import com.google.common.io.CharSource; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.nio.charset.StandardCharsets; import org.junit.Before; import org.junit.Test; -import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier; +import org.opendaylight.yangtools.yang.model.api.source.YangTextSource; +import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource; public class YangTextSourceSerializationProxyTest { - private YangTextSchemaSource schemaSource; + private YangTextSource schemaSource; @Before public void setUp() { - String source = "Test source."; - schemaSource = YangTextSchemaSource.delegateForByteSource(new SourceIdentifier("test", "2015-10-30"), - ByteSource.wrap(source.getBytes(StandardCharsets.UTF_8))); + schemaSource = new DelegatedYangTextSource(new SourceIdentifier("test", "2015-10-30"), + CharSource.wrap("Test source.")); } - @Test public void serializeAndDeserializeProxy() throws ClassNotFoundException, IOException { - YangTextSchemaSourceSerializationProxy proxy = new YangTextSchemaSourceSerializationProxy(schemaSource); + final var proxy = new YangTextSchemaSourceSerializationProxy(schemaSource); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(proxy); final byte[] bytes = bos.toByteArray(); - assertEquals(353, bytes.length); + assertEquals(323, bytes.length); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes)); - YangTextSchemaSourceSerializationProxy deserializedProxy = - (YangTextSchemaSourceSerializationProxy) ois.readObject(); + final var deserializedProxy = (YangTextSchemaSourceSerializationProxy) ois.readObject(); - assertEquals(deserializedProxy.getRepresentation().getIdentifier(), proxy.getRepresentation().getIdentifier()); - assertArrayEquals(deserializedProxy.getRepresentation().read(), proxy.getRepresentation().read()); + assertEquals(deserializedProxy.getRepresentation().sourceId(), proxy.getRepresentation().sourceId()); + assertEquals(deserializedProxy.getRepresentation().read(), proxy.getRepresentation().read()); } @Test public void testProxyEqualsBackingYangTextSource() throws IOException { - YangTextSchemaSourceSerializationProxy serializationProxy = - new YangTextSchemaSourceSerializationProxy(schemaSource); + final var serializationProxy = new YangTextSchemaSourceSerializationProxy(schemaSource); - assertEquals(serializationProxy.getRepresentation().getIdentifier(), schemaSource.getIdentifier()); - assertArrayEquals(serializationProxy.getRepresentation().read(), schemaSource.read()); + assertEquals(serializationProxy.getRepresentation().sourceId(), schemaSource.sourceId()); + assertEquals(serializationProxy.getRepresentation().read(), schemaSource.read()); } }