Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bughue committed Feb 26, 2024
1 parent 4faffc7 commit 2554991
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,11 @@ public static SeataMQProducer createSingle(String nameServer, String namespace,
tccRocketMQProxy.setProducer(defaultProducer);
defaultProducer.setTccRocketMQ(tccRocketMQProxy);
defaultProducer.start();
return defaultProducer;
}
}
}
if (!ObjectUtils.equals(nameServer, defaultProducer.getNamesrvAddr())
|| !ObjectUtils.equals(namespace, defaultProducer.getNamespace())
|| !ObjectUtils.equals(groupName, defaultProducer.getProducerGroup())
) {
throw new NotSupportYetException("only one seata producer is permitted");
}
return defaultProducer;
throw new NotSupportYetException("only one seata producer is permitted");
}

public static SeataMQProducer getProducer() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.seata.integration.rocketmq;

import org.apache.seata.common.exception.NotSupportYetException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* seata mq producer factory test
**/
public class SeataMQProducerFactoryTest {

@Test
public void testCreateSingle() throws Exception {
SeataMQProducerFactory.createSingle("127.0.0.1:9876", "test");

Assertions.assertThrows(NotSupportYetException.class, () -> SeataMQProducerFactory.createSingle("127.0.0.1:9876", "test"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.seata.integration.rocketmq;

import org.junit.jupiter.api.Test;

/**
* seata mq producer test
**/
public class SeataMQProducerTest {

@Test
public void testCreate(){
new SeataMQProducer("testProducerGroup");
new SeataMQProducer("testNamespace", "testProducerGroup",null);
}
}
25 changes: 25 additions & 0 deletions rocketmq/src/test/resources/file.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# 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.
#

service {
#transaction service group mapping
vgroupMapping.default_tx_group = "default"
#only support when registry.type=file, please don't set multiple addresses
default.grouplist = "127.0.0.1:8091"
#disable seata
disableGlobalTransaction = false
}
34 changes: 34 additions & 0 deletions rocketmq/src/test/resources/registry.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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.
#

registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file"

file {
name = "file.conf"
}
}

config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"

file {
name = "file.conf"
}
}

0 comments on commit 2554991

Please sign in to comment.