You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by se...@apache.org on 2018/01/08 08:30:36 UTC

[incubator-servicecomb-saga] 04/04: SCB-174 remove useless NativeMessageFormat implementation

This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 6d4c0848b8ef1344823f2fca0cd35ed83fbdc4db
Author: Eric Lee <da...@huawei.com>
AuthorDate: Mon Jan 8 15:09:01 2018 +0800

    SCB-174 remove useless NativeMessageFormat implementation
    
    Signed-off-by: Eric Lee <da...@huawei.com>
---
 .../saga/omega/format/NativeMessageFormat.java     | 50 ----------------------
 .../saga/omega/format/NativeMessageFormatTest.java | 44 -------------------
 2 files changed, 94 deletions(-)

diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
deleted file mode 100644
index 383afeb..0000000
--- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
+++ /dev/null
@@ -1,50 +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.servicecomb.saga.omega.format;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import org.apache.servicecomb.saga.omega.transaction.OmegaException;
-
-public class NativeMessageFormat implements MessageFormat {
-  @Override
-  public byte[] serialize(Object[] objects) {
-    try {
-      ByteArrayOutputStream out = new ByteArrayOutputStream();
-      try (ObjectOutputStream outputStream = new ObjectOutputStream(out)) {
-        outputStream.writeObject(objects);
-        return out.toByteArray();
-      }
-    } catch (IOException e) {
-      throw new OmegaException("Unable to serialize object", e);
-    }
-  }
-
-  @Override
-  public Object[] deserialize(byte[] message) {
-    try (ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(message))) {
-      return (Object[]) inputStream.readObject();
-    } catch (IOException | ClassNotFoundException e) {
-      throw new OmegaException("Unable to deserialize message", e);
-    }
-  }
-}
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
deleted file mode 100644
index e460f63..0000000
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
+++ /dev/null
@@ -1,44 +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.servicecomb.saga.omega.format;
-
-import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertThat;
-
-import org.apache.servicecomb.saga.omega.transaction.OmegaException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class NativeMessageFormatTest extends MessageFormatTestBase {
-
-  @BeforeClass
-  public static void setUp() {
-    format = new NativeMessageFormat();
-  }
-
-  @Test
-  public void blowsUpWhenSerializeEmptyClass() {
-    try {
-      format.serialize(eventOf(new EmptyClass()));
-      expectFailing(OmegaException.class);
-    } catch (OmegaException e) {
-      assertThat(e.getMessage(), startsWith("Unable to serialize event with global tx id"));
-    }
-  }
-}

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.