You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2017/02/24 14:36:55 UTC
[3/3] flex-blazeds git commit: - Converted the testsuite to JUnit 4
- Converted the testsuite to JUnit 4
Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/9f2a242d
Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/9f2a242d
Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/9f2a242d
Branch: refs/heads/develop
Commit: 9f2a242d36ee577bdfca54e20bf728946374c14d
Parents: 11b0aa1
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Feb 24 15:36:43 2017 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Feb 24 15:36:43 2017 +0100
----------------------------------------------------------------------
.../java/flex/messaging/DestinationTest.java | 171 +++----
.../java/flex/messaging/MessageBrokerTest.java | 272 +++++------
.../messaging/client/FlexClientManagerTest.java | 99 ++--
.../cluster/SerializationProxyTest.java | 14 +-
.../config/ChannelSettingsParseUriTest.java | 118 ++---
.../config/ConfigurationConfirmation.java | 475 +++++++++----------
.../config/ConfigurationParserTest.java | 145 ++----
.../messaging/config/ThrottleSettingsTest.java | 144 ++----
.../io/ClassDeserializationValidatorTest.java | 7 -
.../messaging/io/amf/AmfDeserializerTest.java | 83 ++--
.../flex/messaging/io/amf/MessageGenerator.java | 214 +++------
.../amf/translator/HashReferenceTableTest.java | 208 ++++----
.../translator/StrictReferenceTableTest.java | 108 ++---
.../AmfDeserializationValidatorTest.java | 62 +--
.../io/amfx/AllowDocumentTypeDeclaration.java | 16 +-
.../io/amfx/AmfxSerializationTest.java | 218 ++++-----
.../test/java/flex/messaging/log/LogTest.java | 139 +++---
.../java/flex/messaging/log/LoggerTest.java | 97 ++--
.../java/flex/messaging/log/TestingTarget.java | 15 +-
.../BlazeDsXmlProcessingXXEVulnerability.java | 64 ---
.../messaging/services/AbstractServiceTest.java | 367 --------------
.../messaging/services/ServiceAdapterTest.java | 89 ++--
.../services/http/SettingsReplaceUtilTest.java | 166 +++----
.../services/messaging/SubtopicTest.java | 65 +--
.../java/flex/messaging/util/Basae64Test.java | 44 +-
.../test/java/flex/messaging/util/HexTest.java | 56 +--
.../java/flex/messaging/util/UUIDUtilTest.java | 73 ++-
.../DefaultThreadPoolExecutorTest.java | 53 +--
28 files changed, 1249 insertions(+), 2333 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/DestinationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/DestinationTest.java b/core/src/test/java/flex/messaging/DestinationTest.java
index 65985a9..382531e 100644
--- a/core/src/test/java/flex/messaging/DestinationTest.java
+++ b/core/src/test/java/flex/messaging/DestinationTest.java
@@ -17,58 +17,34 @@
package flex.messaging;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import flex.messaging.config.ChannelSettings;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.config.NetworkSettings;
-import flex.messaging.config.SecurityConstraint;
+import flex.messaging.config.*;
import flex.messaging.services.AbstractService;
import flex.messaging.services.MessageService;
import flex.messaging.services.ServiceAdapter;
import flex.messaging.services.messaging.adapters.ActionScriptAdapter;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* Important: While adding new tests, make sure you don't create dependencies
* to other modules. (eg. don't use RemotingDestination as that would create
* dependency on remoting module; instead add the test in remoting module).
*/
-public class DestinationTest extends TestCase
-{
+public class DestinationTest {
protected Destination destination;
- protected MessageBroker broker;
-
- public DestinationTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(DestinationTest.class);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
destination = new MessageDestination();
destination.setId("destId");
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testSetService()
- {
+ @Test
+ public void testSetService() {
MessageBroker broker = new MessageBroker(false);
broker.initThreadLocals();
@@ -77,7 +53,7 @@ public class DestinationTest extends TestCase
broker.addService(service);
destination.setService(service);
- MessageService actualSvc = (MessageService)destination.getService();
+ MessageService actualSvc = (MessageService) destination.getService();
Assert.assertEquals(service, actualSvc);
@@ -85,23 +61,20 @@ public class DestinationTest extends TestCase
Assert.assertEquals(destination, actualDest);
}
- public void testSetServiceNull()
- {
- try
- {
+ @Test
+ public void testSetServiceNull() {
+ try {
destination.setService(null);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = 11116; //ManageableComponent.NULL_COMPONENT_PROPERTY;
Assert.assertEquals(ce.getNumber(), error);
}
}
- public void testSetAdapter()
- {
+ @Test
+ public void testSetAdapter() {
ServiceAdapter expected = new ActionScriptAdapter();
expected.setId("adapterId");
destination.setAdapter(expected);
@@ -111,16 +84,16 @@ public class DestinationTest extends TestCase
}
- public void testSetAdapterNull()
- {
+ @Test
+ public void testSetAdapterNull() {
destination.setAdapter(null);
ServiceAdapter actual = destination.getAdapter();
Assert.assertNull(actual);
}
- public void testSetAdapterNullId()
- {
+ @Test
+ public void testSetAdapterNullId() {
ServiceAdapter adapter = new ActionScriptAdapter();
destination.setAdapter(adapter);
@@ -129,8 +102,8 @@ public class DestinationTest extends TestCase
}
- public void testAddChannelNotStarted()
- {
+ @Test
+ public void testAddChannelNotStarted() {
String id = "default-channel";
destination.addChannel(id);
@@ -142,12 +115,12 @@ public class DestinationTest extends TestCase
* In running code, the channels would be added from the services-config.xml.
* Here, we have to force them into the broker.
*/
- public void testAddChannelStartedBrokerKnows()
- {
- start();
+ @Test
+ public void testAddChannelStartedBrokerKnows() {
String id = "default-channel";
Map<String, ChannelSettings> csMap = new HashMap<String, ChannelSettings>();
csMap.put(id, null);
+ MessageBroker broker = start();
broker.setChannelSettings(csMap);
destination.addChannel(id);
@@ -155,11 +128,11 @@ public class DestinationTest extends TestCase
Assert.assertTrue(contains);
}
- public void testCreateAdapterRegisteredWithService ()
- {
+ @Test
+ public void testCreateAdapterRegisteredWithService() {
MessageService service = new MessageService();
service.setId("dummy-service");
- broker = new MessageBroker(false);
+ MessageBroker broker = new MessageBroker(false);
broker.addService(service);
String adapterId = "id";
@@ -173,65 +146,55 @@ public class DestinationTest extends TestCase
Assert.assertEquals(expected, actual);
}
- public void testCreateAdapterWithoutService()
- {
- try
- {
+ @Test
+ public void testCreateAdapterWithoutService() {
+ try {
destination.createAdapter("id");
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = 11117; // Destination.NO_SERVICE;
Assert.assertEquals(ce.getNumber(), error);
}
}
- public void testCreateAdapterUnregisteredWithService()
- {
+ @Test
+ public void testCreateAdapterUnregisteredWithService() {
MessageService service = new MessageService();
service.setId("dummy-service");
- broker = new MessageBroker(false);
+ MessageBroker broker = new MessageBroker(false);
broker.addService(service);
destination.setService(service);
- try
- {
+ try {
destination.createAdapter("id");
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.UNREGISTERED_ADAPTER;
Assert.assertEquals(ce.getNumber(), error);
}
}
- public void testCreateAdapterWithExistingId()
- {
+ @Test
+ public void testCreateAdapterWithExistingId() {
String id = "java-adapter";
start();
- try
- {
+ try {
destination.createAdapter(id);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.UNREGISTERED_ADAPTER;
Assert.assertEquals(error, ce.getNumber());
}
}
-
- public void testSetNetworkSettings()
- {
+ @Test
+ public void testSetNetworkSettings() {
NetworkSettings ns = new NetworkSettings();
ns.setSubscriptionTimeoutMinutes(1);
destination.setNetworkSettings(ns);
@@ -240,8 +203,8 @@ public class DestinationTest extends TestCase
Assert.assertEquals(ns, actual);
}
- public void testSetSecurityConstraint()
- {
+ @Test
+ public void testSetSecurityConstraint() {
SecurityConstraint sc = new SecurityConstraint();
destination.setSecurityConstraint(sc);
@@ -249,8 +212,8 @@ public class DestinationTest extends TestCase
Assert.assertEquals(sc, actual);
}
- public void testSetSecurityConstraintRefNotStarted()
- {
+ @Test
+ public void testSetSecurityConstraintRefNotStarted() {
String ref = "sample-security";
destination.setSecurityConstraint(ref);
@@ -258,8 +221,8 @@ public class DestinationTest extends TestCase
Assert.assertNull(sc);
}
- public void testStop()
- {
+ @Test
+ public void testStop() {
start();
destination.stop();
@@ -267,20 +230,20 @@ public class DestinationTest extends TestCase
Assert.assertFalse(started);
}
- public void testSetManaged()
- {
+ @Test
+ public void testSetManaged() {
destination.setManaged(true);
boolean managed = destination.isManaged();
Assert.assertTrue(managed);
}
- public void testSetManagedParentUnmanaged()
- {
+ @Test
+ public void testSetManagedParentUnmanaged() {
MessageService service = new MessageService();
service.setId("dummy-service");
service.setManaged(false);
- broker = new MessageBroker(false);
+ MessageBroker broker = new MessageBroker(false);
broker.addService(service);
destination.setService(service);
@@ -290,15 +253,15 @@ public class DestinationTest extends TestCase
Assert.assertFalse(managed);
}
- public void testGetLogCategory()
- {
+ @Test
+ public void testGetLogCategory() {
String logCat = destination.getLogCategory();
String logCat2 = destination.getLogCategory();
Assert.assertEquals(logCat, logCat2);
}
- public void testExtraProperties()
- {
+ @Test
+ public void testExtraProperties() {
String propertyName = "extraProperty";
String propertyValue = "extraValue";
@@ -317,9 +280,8 @@ public class DestinationTest extends TestCase
Assert.assertEquals(actualDest.getExtraProperty(propertyName), propertyValue);
}
- private void start()
- {
- broker = new MessageBroker(false);
+ private MessageBroker start() {
+ MessageBroker broker = new MessageBroker(false);
MessageService service = new MessageService();
service.setId("dummy-service");
service.setMessageBroker(broker);
@@ -331,5 +293,6 @@ public class DestinationTest extends TestCase
destination.addChannel("some-Channel");
destination.setService(service);
destination.start();
+ return broker;
}
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/MessageBrokerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/MessageBrokerTest.java b/core/src/test/java/flex/messaging/MessageBrokerTest.java
index f5be8d7..8151793 100644
--- a/core/src/test/java/flex/messaging/MessageBrokerTest.java
+++ b/core/src/test/java/flex/messaging/MessageBrokerTest.java
@@ -17,136 +17,108 @@
package flex.messaging;
-import java.util.List;
-import java.util.Map;
-
import flex.messaging.config.ConfigurationConstants;
import flex.messaging.config.ConfigurationException;
import flex.messaging.factories.JavaFactory;
import flex.messaging.services.MessageService;
import flex.messaging.services.Service;
import org.junit.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
/**
* Important: While adding new tests, make sure you don't create dependencies
* to other modules. (eg. don't use RemotingDestination as that would create
* dependency on remoting module; instead add the test in remoting module).
*/
-public class MessageBrokerTest extends TestCase
-{
-
- protected MessageBroker broker;
+public class MessageBrokerTest {
- public MessageBrokerTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(MessageBrokerTest.class);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
+ private MessageBroker broker;
+ @Before
+ public void setUp() throws Exception {
broker = new MessageBroker(false);
broker.initThreadLocals();
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testAddFactory()
- {
+ @Test
+ public void testAddFactory() {
String id = "java2";
- JavaFactory expected = new JavaFactory();
+ JavaFactory expected = new JavaFactory();
broker.addFactory("java2", expected);
-
- JavaFactory actual = (JavaFactory)broker.getFactory(id);
- Assert.assertEquals(expected, actual);
+
+ JavaFactory actual = (JavaFactory) broker.getFactory(id);
+ Assert.assertEquals(expected, actual);
}
-
- public void testAddSameFactoryIdTwice()
- {
+
+ @Test
+ public void testAddSameFactoryIdTwice() {
String id = "java";
- JavaFactory expected = new JavaFactory();
- try
- {
+ JavaFactory expected = new JavaFactory();
+ try {
broker.addFactory(id, expected);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.DUPLICATE_COMPONENT_ID;
Assert.assertTrue(ce.getNumber() == error);
- }
+ }
}
-
- public void testAddSameFactoryInstanceTwice()
- {
+
+ @Test
+ public void testAddSameFactoryInstanceTwice() {
String id = "java2";
JavaFactory expected = new JavaFactory();
broker.addFactory("java2", expected);
broker.addFactory("java2", expected);
-
- JavaFactory actual = (JavaFactory)broker.getFactory(id);
+
+ JavaFactory actual = (JavaFactory) broker.getFactory(id);
Assert.assertEquals(expected, actual);
}
-
- public void testAddFactoryNullId()
- {
- String id = null;
+
+ @Test
+ public void testAddFactoryNullId() {
JavaFactory expected = new JavaFactory();
- try
- {
- broker.addFactory(id, expected);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ try {
+ broker.addFactory(null, expected);
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.NULL_COMPONENT_ID;
Assert.assertTrue(ce.getNumber() == error);
}
- }
-
- public void testGetFactories()
- {
+ }
+
+ @Test
+ public void testGetFactories() {
String id = "java2";
- JavaFactory expected = new JavaFactory();
+ JavaFactory expected = new JavaFactory();
broker.addFactory(id, expected);
-
+
int size = broker.getFactories().size();
Assert.assertEquals(2, size);
}
-
- public void testRemoveFactory()
- {
+
+ @Test
+ public void testRemoveFactory() {
String id = "java";
broker.removeFactory(id);
FlexFactory actual = broker.getFactory(id);
- Service expected = null;
- Assert.assertEquals(expected, actual);
+ Assert.assertEquals(null, actual);
}
-
- public void testRemoveFactoryNonexistent()
- {
+
+ @Test
+ public void testRemoveFactoryNonexistent() {
String id = "nonexistent";
FlexFactory actual = broker.removeFactory(id);
-
+
Assert.assertNull(actual);
}
-
-
- public void testAddService()
- {
+
+ @Test
+ public void testAddService() {
String id = "dummy-service";
MessageService expected = new MessageService();
expected.setId(id);
@@ -157,8 +129,8 @@ public class MessageBrokerTest extends TestCase
Assert.assertEquals(expected.isManaged(), actual.isManaged());
}
- public void testAddServiceNonManaged()
- {
+ @Test
+ public void testAddServiceNonManaged() {
String id = "dummy-service";
MessageService expected = new MessageService(false);
expected.setId(id);
@@ -167,43 +139,36 @@ public class MessageBrokerTest extends TestCase
Service actual = broker.getService(id);
Assert.assertEquals(expected, actual);
Assert.assertEquals(expected.isManaged(), actual.isManaged());
- }
-
- public void testAddServiceNull()
- {
- try
- {
+ }
+
+ @Test
+ public void testAddServiceNull() {
+ try {
broker.addService(null);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.NULL_COMPONENT;
Assert.assertTrue(ce.getNumber() == error);
}
}
- public void testAddServiceNullId()
- {
- try
- {
+ @Test
+ public void testAddServiceNullId() {
+ try {
MessageService svc = new MessageService();
broker.addService(svc);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.NULL_COMPONENT_ID;
Assert.assertTrue(ce.getNumber() == error);
}
}
- public void testAddServiceExists()
- {
- try
- {
+ @Test
+ public void testAddServiceExists() {
+ try {
String id = "dummy-service";
MessageService svc1 = new MessageService();
svc1.setId(id);
@@ -212,17 +177,15 @@ public class MessageBrokerTest extends TestCase
svc2.setId(id);
broker.addService(svc2);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
int error = ConfigurationConstants.DUPLICATE_COMPONENT_ID;
Assert.assertTrue(ce.getNumber() == error);
}
}
- public void testCreateService()
- {
+ @Test
+ public void testCreateService() {
String serviceId = "message-service";
String serviceClass = MessageService.class.getName();
@@ -232,45 +195,39 @@ public class MessageBrokerTest extends TestCase
Assert.assertEquals(expected, actual);
}
- public void testCreateServiceNonexistingClass()
- {
+ @Test
+ public void testCreateServiceNonexistingClass() {
String serviceId = "remoting-service";
String serviceClass = "NonexistingClass";
-
- try
- {
+
+ try {
broker.createService(serviceId, serviceClass);
- fail ("MessageException expected");
- }
- catch (MessageException me)
- {
+ Assert.fail("MessageException expected");
+ } catch (MessageException me) {
int error = 10008; //ClassUtil.TYPE_NOT_FOUND
Assert.assertEquals(me.getNumber(), error);
}
}
-
- public void testCreateServiceWithExistingId()
- {
+
+ @Test
+ public void testCreateServiceWithExistingId() {
String id = "message-service";
String serviceClass = MessageService.class.getName();
-
+
broker.createService(id, serviceClass);
- try
- {
+ try {
broker.createService(id, serviceClass);
-
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
- int error = ConfigurationConstants.DUPLICATE_COMPONENT_ID;
+
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
+ int error = ConfigurationConstants.DUPLICATE_COMPONENT_ID;
Assert.assertEquals(ce.getNumber(), error);
- }
+ }
}
-
- public void testRemoveService()
- {
+
+ @Test
+ public void testRemoveService() {
String id = "dummy-service";
MessageService svc = new MessageService();
svc.setId(id);
@@ -278,46 +235,45 @@ public class MessageBrokerTest extends TestCase
broker.removeService(id);
Service actual = broker.getService(id);
- Service expected = null;
- Assert.assertEquals(expected, actual);
+ Assert.assertEquals(null, actual);
}
-
- public void testRemoveServiceNonexistent()
- {
+
+ @Test
+ public void testRemoveServiceNonexistent() {
Service actual = broker.removeService("id");
- Assert.assertNull(actual);
+ Assert.assertNull(actual);
}
-
- public void testGetService()
- {
+
+ @Test
+ public void testGetService() {
String id = "dummy-service";
MessageService expected = new MessageService();
expected.setId(id);
broker.addService(expected);
-
+
Service actual = broker.getService(id);
Assert.assertEquals(expected, actual);
}
-
-
+
+
//Get services_no AUthentication
- public void testGetServices()
- {
+ @Test
+ public void testGetServices() {
String id = "remoting-service";
MessageService expected1 = new MessageService();
expected1.setId(id);
id = "message-service";
MessageService expected2 = new MessageService();
expected2.setId(id);
-
+
broker.addService(expected1);
broker.addService(expected2);
-
+
Map<String, Service> actual = broker.getServices();
Assert.assertEquals(expected1, actual.get("remoting-service"));
Assert.assertEquals(expected2, actual.get("message-service"));
}
-
+
//GetServices should not return an AuthenticationService to the client
// public void testGetServicesNoAuthenticationSvc()
// {
@@ -336,15 +292,15 @@ public class MessageBrokerTest extends TestCase
// Assert.assertNotSame(notExpected, actual.get(1));
// Assert.assertEquals(1, actual.size());
// }
-
- public void testGetServiceNonExistent()
- {
+
+ @Test
+ public void testGetServiceNonExistent() {
Service actual = broker.getService("non-existent-id");
Assert.assertNull(actual);
}
-
- public void testGetChannelIdsNull()
- {
+
+ @Test
+ public void testGetChannelIdsNull() {
List<String> channelIds = broker.getChannelIds();
Assert.assertNull(channelIds);
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/client/FlexClientManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/client/FlexClientManagerTest.java b/core/src/test/java/flex/messaging/client/FlexClientManagerTest.java
index 3bf5cc3..f4c3f08 100644
--- a/core/src/test/java/flex/messaging/client/FlexClientManagerTest.java
+++ b/core/src/test/java/flex/messaging/client/FlexClientManagerTest.java
@@ -18,105 +18,92 @@ package flex.messaging.client;
import flex.messaging.MessageBroker;
import org.junit.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Before;
+import org.junit.Test;
/**
* Unit tests for the flex.messaging.client.FlexClientManager
*/
-public class FlexClientManagerTest extends TestCase {
-
- protected MessageBroker broker;
- protected FlexClientManager manager;
+public class FlexClientManagerTest {
- public FlexClientManagerTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(FlexClientManagerTest.class);
- }
+ private FlexClientManager manager;
- protected void setUp() throws Exception
- {
- super.setUp();
-
- broker = new MessageBroker(false);
+ @Before
+ public void setUp() throws Exception {
+ MessageBroker broker = new MessageBroker(false);
broker.initThreadLocals();
manager = new FlexClientManager(broker);
}
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
+
/**
- * Test that FlexClientManager.createFlexClient(id) returns
- * a FlexClient instance with the correct id.
+ * Test that FlexClientManager.createFlexClient(id) returns
+ * a FlexClient instance with the correct id.
*/
- public void testCreateFlexClientWithId()
- {
+ @Test
+ public void testCreateFlexClientWithId() {
String id = "abc";
- FlexClient client = manager.createFlexClient(id);
- Assert.assertEquals(id, client.getId());
+ FlexClient client = manager.createFlexClient(id);
+ Assert.assertEquals(id, client.getId());
}
+
/**
- * Test that calling FlexClientManager.getFlexClient(id) with
+ * Test that calling FlexClientManager.getFlexClient(id) with
* a new id, returns a new FlexClient instance with the correct
- * id.
+ * id.
*/
- public void testGetFlexClientNewId()
- {
+ @Test
+ public void testGetFlexClientNewId() {
String id = "def";
FlexClient client = manager.getFlexClient(id);
Assert.assertNotNull(client);
- Assert.assertEquals(id, client.getId());
+ Assert.assertEquals(id, client.getId());
}
+
/**
- * Test that calling FlexClientManager.getFlexClient(id) with
- * an id for an existing FlexClient, returns the FlexClient
- * instance with the correct id.
+ * Test that calling FlexClientManager.getFlexClient(id) with
+ * an id for an existing FlexClient, returns the FlexClient
+ * instance with the correct id.
*/
- public void testGetFlexClientExistingId()
- {
+ @Test
+ public void testGetFlexClientExistingId() {
String id = "ghi";
manager.createFlexClient(id);
- FlexClient client = manager.getFlexClient(id);
- Assert.assertEquals(id, client.getId());
+ FlexClient client = manager.getFlexClient(id);
+ Assert.assertEquals(id, client.getId());
}
+
/**
- * Test that calling FlexClientManager.getFlexClient(id, createNewIfNotExist)
+ * Test that calling FlexClientManager.getFlexClient(id, createNewIfNotExist)
* with an id for a nonexistent FlexClient and false returns null.
*/
- public void testGetFlexClientCreateNewFalse()
- {
+ @Test
+ public void testGetFlexClientCreateNewFalse() {
String id = "jkl";
- FlexClient client = manager.getFlexClient(id,false);
- Assert.assertNull(client);
+ FlexClient client = manager.getFlexClient(id, false);
+ Assert.assertNull(client);
}
+
/**
* Test that calling FlexClientManager.getFlexClientCount() returns
* 2 when there are 2 FlexClients.
*/
- public void testGetFlexClientCount()
- {
+ @Test
+ public void testGetFlexClientCount() {
manager.getFlexClient("client1");
manager.getFlexClient("client2");
- Assert.assertEquals(2, manager.getFlexClientCount());
+ Assert.assertEquals(2, manager.getFlexClientCount());
}
+
/**
* Test that FlexClientManager.removeFlexClient(FlexClient) removes
- * the correct FlexClient.
+ * the correct FlexClient.
*/
- public void testRemoveFlexClient()
- {
+ @Test
+ public void testRemoveFlexClient() {
FlexClient client = manager.getFlexClient("client1");
manager.getFlexClient("client2");
manager.removeFlexClient(client);
- Assert.assertEquals(1, manager.getFlexClientCount());
+ Assert.assertEquals(1, manager.getFlexClientCount());
Assert.assertEquals("client2", manager.getClientIds()[0]);
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/cluster/SerializationProxyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/cluster/SerializationProxyTest.java b/core/src/test/java/flex/messaging/cluster/SerializationProxyTest.java
index 8cbce75..ceb9d05 100644
--- a/core/src/test/java/flex/messaging/cluster/SerializationProxyTest.java
+++ b/core/src/test/java/flex/messaging/cluster/SerializationProxyTest.java
@@ -18,21 +18,18 @@ package flex.messaging.cluster;
import flex.messaging.io.SerializationProxy;
import flex.messaging.io.amf.ASObject;
+import org.junit.Assert;
+import org.junit.Test;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import junit.framework.TestCase;
-public class SerializationProxyTest extends TestCase
+public class SerializationProxyTest
{
- public SerializationProxyTest(String valueExpression)
- {
- super(valueExpression);
- }
-
/**
* For clustering, SerializationProxys must be serialized and
* deserialized. This is because any message with a SerializationProxy,
@@ -41,6 +38,7 @@ public class SerializationProxyTest extends TestCase
* cluster.
* Bug: LCDS-910
*/
+ @Test
public void testRoundTripSerialization() throws Exception
{
ASObject as = new ASObject();
@@ -59,6 +57,6 @@ public class SerializationProxyTest extends TestCase
ObjectInputStream ois = new ObjectInputStream(in);
Object o = ois.readObject();
- assertNotNull("The object should be correctly serialized/deserialized.", o);
+ Assert.assertNotNull("The object should be correctly serialized/deserialized.", o);
}
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/config/ChannelSettingsParseUriTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/config/ChannelSettingsParseUriTest.java b/core/src/test/java/flex/messaging/config/ChannelSettingsParseUriTest.java
index 22c68a9..a6fd55c 100644
--- a/core/src/test/java/flex/messaging/config/ChannelSettingsParseUriTest.java
+++ b/core/src/test/java/flex/messaging/config/ChannelSettingsParseUriTest.java
@@ -20,12 +20,9 @@ package flex.messaging.config;
import flex.messaging.endpoints.AMFEndpoint;
import flex.messaging.endpoints.Endpoint;
import org.junit.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
-public class ChannelSettingsParseUriTest extends TestCase
-{
+public class ChannelSettingsParseUriTest {
private static String confirm = "/messagebroker/amf";
private static String data1 = "http://{server.name}:{server.port}/{context.root}/messagebroker/amf";
@@ -58,139 +55,118 @@ public class ChannelSettingsParseUriTest extends TestCase
private static String clientData6a = "{context.root}";
private static String clientData6b = "/{context.root}";
-
- public ChannelSettingsParseUriTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(ChannelSettingsParseUriTest.class);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testReplaceContextRoot()
- {
+ @Test
+ public void testReplaceContextRoot() {
Endpoint fooEndpoint = new AMFEndpoint();
- fooEndpoint.setUrl(data1);
+ fooEndpoint.setUrl(data1);
String actual = fooEndpoint.getParsedUrl("/ctx");
Assert.assertEquals(confirm, actual);
}
- public void testReplaceContextRootDash()
- {
+ @Test
+ public void testReplaceContextRootDash() {
Endpoint fooEndpoint = new AMFEndpoint();
- fooEndpoint.setUrl(data2);
+ fooEndpoint.setUrl(data2);
String actual = fooEndpoint.getParsedUrl("/ctx");
Assert.assertEquals(confirm, actual);
}
- public void testReplaceContextRootStart()
- {
+ @Test
+ public void testReplaceContextRootStart() {
Endpoint fooEndpoint = new AMFEndpoint();
- fooEndpoint.setUrl(data3);
+ fooEndpoint.setUrl(data3);
String actual = fooEndpoint.getParsedUrl("/ctx");
Assert.assertEquals(confirm, actual);
}
- public void testReplaceContextRootSlashStart()
- {
+ @Test
+ public void testReplaceContextRootSlashStart() {
Endpoint fooEndpoint = new AMFEndpoint();
- fooEndpoint.setUrl(data4);
+ fooEndpoint.setUrl(data4);
String actual = fooEndpoint.getParsedUrl("/ctx");
Assert.assertEquals(confirm, actual);
}
-
+
// Client Channel Tests
-
- public void testClientReplaceContextRoot()
- {
+
+ @Test
+ public void testClientReplaceContextRoot() {
ChannelSettings fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData1a);
+ fooChannel.setUri(clientData1a);
String actual = fooChannel.getClientParsedUri("/");
Assert.assertEquals(clientConfirm1, actual);
- fooChannel.setUri(clientData1a);
+ fooChannel.setUri(clientData1a);
actual = fooChannel.getClientParsedUri("");
Assert.assertEquals(clientConfirm1, actual);
-
- fooChannel.setUri(clientData2a);
+
+ fooChannel.setUri(clientData2a);
actual = fooChannel.getClientParsedUri("/ctx");
Assert.assertEquals(clientConfirm2, actual);
}
- public void testClientReplaceContextRootDash()
- {
+ @Test
+ public void testClientReplaceContextRootDash() {
ChannelSettings fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData1b);
+ fooChannel.setUri(clientData1b);
String actual = fooChannel.getClientParsedUri("/");
Assert.assertEquals(clientConfirm1, actual);
- fooChannel.setUri(clientData1b);
+ fooChannel.setUri(clientData1b);
actual = fooChannel.getClientParsedUri("");
Assert.assertEquals(clientConfirm1, actual);
- fooChannel.setUri(clientData2b);
+ fooChannel.setUri(clientData2b);
actual = fooChannel.getClientParsedUri("/ctx");
Assert.assertEquals(clientConfirm2, actual);
}
-
- public void testClientReplaceContextRootStart()
- {
+
+ @Test
+ public void testClientReplaceContextRootStart() {
ChannelSettings fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData3a);
+ fooChannel.setUri(clientData3a);
String actual = fooChannel.getClientParsedUri("/");
Assert.assertEquals(clientConfirm3, actual);
fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData4a);
+ fooChannel.setUri(clientData4a);
actual = fooChannel.getClientParsedUri("/ctx");
Assert.assertEquals(clientConfirm4, actual);
}
-
- public void testClientReplaceContextRootSlashStart()
- {
+
+ @Test
+ public void testClientReplaceContextRootSlashStart() {
ChannelSettings fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData3b);
+ fooChannel.setUri(clientData3b);
String actual = fooChannel.getClientParsedUri("");
Assert.assertEquals(clientConfirm3, actual);
- fooChannel.setUri(clientData4b);
+ fooChannel.setUri(clientData4b);
actual = fooChannel.getClientParsedUri("/ctx");
Assert.assertEquals(clientConfirm4, actual);
}
-
- public void testClientReplaceContextRootOnly()
- {
+
+ @Test
+ public void testClientReplaceContextRootOnly() {
ChannelSettings fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData5a);
+ fooChannel.setUri(clientData5a);
String actual = fooChannel.getClientParsedUri("/");
Assert.assertEquals(clientConfirm5, actual);
- fooChannel.setUri(clientData6a);
+ fooChannel.setUri(clientData6a);
actual = fooChannel.getClientParsedUri("/ctx");
Assert.assertEquals(clientConfirm6, actual);
}
-
- public void testClientReplaceSlashContextRootOnly()
- {
+
+ @Test
+ public void testClientReplaceSlashContextRootOnly() {
ChannelSettings fooChannel = new ChannelSettings("channel-one");
- fooChannel.setUri(clientData5b);
+ fooChannel.setUri(clientData5b);
String actual = fooChannel.getClientParsedUri("/");
Assert.assertEquals(clientConfirm5, actual);
- fooChannel.setUri(clientData6b);
+ fooChannel.setUri(clientData6b);
actual = fooChannel.getClientParsedUri("/ctx");
Assert.assertEquals(clientConfirm6, actual);
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/config/ConfigurationConfirmation.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/config/ConfigurationConfirmation.java b/core/src/test/java/flex/messaging/config/ConfigurationConfirmation.java
index bd78c7a..a2b5957 100644
--- a/core/src/test/java/flex/messaging/config/ConfigurationConfirmation.java
+++ b/core/src/test/java/flex/messaging/config/ConfigurationConfirmation.java
@@ -19,23 +19,15 @@ package flex.messaging.config;
import flex.messaging.LocalizedException;
-import java.util.Collection;
-import java.util.Date;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public abstract class ConfigurationConfirmation
-{
+import java.util.*;
+
+public abstract class ConfigurationConfirmation {
private IdentityHashMap knownObjects;
- public ConfigurationConfirmation()
- {
+ public ConfigurationConfirmation() {
}
- private void init()
- {
+ private void init() {
knownObjects = new IdentityHashMap(64);
}
@@ -43,71 +35,64 @@ public abstract class ConfigurationConfirmation
public abstract LocalizedException getExpectedException();
- public boolean isNegativeTest()
- {
+ public boolean isNegativeTest() {
return false;
}
- public boolean matches(MessagingConfiguration config)
- {
+ public boolean matches(MessagingConfiguration config) {
init();
- try
- {
- boolean match = configMatch(config, getExpectedConfiguration());
- return match;
- }
- catch (Exception ex)
- {
+ try {
+ return configMatch(config, getExpectedConfiguration());
+ } catch (Exception ex) {
return false;
}
}
- public boolean negativeMatches(LocalizedException ex)
- {
+ public boolean negativeMatches(LocalizedException ex) {
init();
String message1 = ex.getMessage();
String message2 = getExpectedException().getMessage();
- if (message1 == null && message2 == null)
+ if (message1 == null && message2 == null) {
return true;
+ }
- if ((message1 == null && message2 != null) || (message1 != null && message2 == null))
+ if (message1 == null || message2 == null) {
return false;
+ }
return message1.equalsIgnoreCase(message2);
}
- public boolean configMatch(MessagingConfiguration c1, MessagingConfiguration c2)
- {
- if (c1 == null && c2 == null)
+ public boolean configMatch(MessagingConfiguration c1, MessagingConfiguration c2) {
+ if (c1 == null && c2 == null) {
return true;
+ }
- if (c1 == null || c2 == null)
- return fail("Services sections didn't match: {0} != {1}", new Object[] {c1, c2});
+ if (c1 == null || c2 == null) {
+ return fail("Services sections didn't match: {0} != {1}", new Object[]{c1, c2});
+ }
// Services
List s1 = c1.getAllServiceSettings();
List s2 = c2.getAllServiceSettings();
- if (!servicesMatch(s1, s2))
+ if (!servicesMatch(s1, s2)) {
return false;
+ }
// Security
SecuritySettings sec1 = c1.getSecuritySettings();
SecuritySettings sec2 = c2.getSecuritySettings();
- if (!securityMatch(sec1, sec2))
- return false;
- return true;
+ return securityMatch(sec1, sec2);
}
- private boolean securityMatch(SecuritySettings sec1, SecuritySettings sec2)
- {
+ private boolean securityMatch(SecuritySettings sec1, SecuritySettings sec2) {
Collection<SecurityConstraint> constraintSet1 = sec1.getConstraints();
- for (SecurityConstraint sc1 : constraintSet1)
- {
+ for (SecurityConstraint sc1 : constraintSet1) {
SecurityConstraint sc2 = sec2.getConstraint(sc1.getId());
if (!securityConstraintsMatch(sc1, sc2))
return false;
@@ -116,29 +101,24 @@ public abstract class ConfigurationConfirmation
}
- protected boolean servicesMatch(List s1, List s2)
- {
+ protected boolean servicesMatch(List s1, List s2) {
if (s1 == null && s2 == null)
return true;
if (s1 == null || s2 == null)
- return fail("Services sections didn't match: {0} != {1}", new Object[] {s1, s2});
+ return fail("Services sections didn't match: {0} != {1}", new Object[]{s1, s2});
if (s1.size() != s2.size())
- return fail("Services sections didn't match by size: {0} != {1}", new Object[] {new Integer(s1.size()), new Integer(s2.size())});
+ return fail("Services sections didn't match by size: {0} != {1}", new Object[]{new Integer(s1.size()), new Integer(s2.size())});
- Iterator it = s1.iterator();
- while (it.hasNext())
- {
- ServiceSettings ss1 =(ServiceSettings) it.next();
+ for (Object aS1 : s1) {
+ ServiceSettings ss1 = (ServiceSettings) aS1;
String key = ss1.getId();
ServiceSettings ss2 = null;
- for (Iterator iter = s2.iterator(); iter.hasNext();)
- {
- ServiceSettings element = (ServiceSettings) iter.next();
- if (element.getId().equals(key))
- {
+ for (Object aS2 : s2) {
+ ServiceSettings element = (ServiceSettings) aS2;
+ if (element.getId().equals(key)) {
ss2 = element;
break;
}
@@ -151,267 +131,285 @@ public abstract class ConfigurationConfirmation
return true;
}
- protected boolean serviceSettingsMatch(ServiceSettings ss1, ServiceSettings ss2)
- {
- if (ss1 == null && ss2 == null)
+ protected boolean serviceSettingsMatch(ServiceSettings ss1, ServiceSettings ss2) {
+ if (ss1 == null && ss2 == null) {
return true;
+ }
- if (ss1 == null || ss2 == null)
- return fail("Service sections didn't match: {0} != {1}", new Object[] {ss1, ss2});
+ if (ss1 == null || ss2 == null) {
+ return fail("Service sections didn't match: {0} != {1}", new Object[]{ss1, ss2});
+ }
- if (!ss1.getId().equals(ss2.getId()))
- return fail("Service ids didn't match: {0} != {1}", new Object[] {ss1.getId(), ss2.getId()});
+ if (!ss1.getId().equals(ss2.getId())) {
+ return fail("Service ids didn't match: {0} != {1}", new Object[]{ss1.getId(), ss2.getId()});
+ }
+
+ if (!ss1.getClassName().equals(ss2.getClassName())) {
+ return fail("Service class names didn't match: {0} != {1}", new Object[]{ss1.getClassName(), ss2.getClassName()});
+ }
- if (!ss1.getClassName().equals(ss2.getClassName()))
- return fail("Service class names didn't match: {0} != {1}", new Object[] {ss1.getClassName(), ss2.getClassName()});
-
// Adapters
Map a1 = ss1.getAllAdapterSettings();
Map a2 = ss2.getAllAdapterSettings();
- if (!adaptersMatch(a1, a2))
+ if (!adaptersMatch(a1, a2)) {
return false;
+ }
// Default Adapters
- AdapterSettings as1 = (AdapterSettings)ss1.getDefaultAdapter();
- AdapterSettings as2 = (AdapterSettings)ss2.getDefaultAdapter();
- if (!adapterDefinitionsMatch(as1, as2))
+ AdapterSettings as1 = ss1.getDefaultAdapter();
+ AdapterSettings as2 = ss2.getDefaultAdapter();
+ if (!adapterDefinitionsMatch(as1, as2)) {
return false;
+ }
// Default Channels
List dc1 = ss1.getDefaultChannels();
List dc2 = ss2.getDefaultChannels();
- if (dc1.size() != dc2.size())
- return fail("Default channels sections didn't match by size: {0} != {1}", new Object[] {new Integer(dc1.size()), new Integer(dc2.size())});
-
- for (int i = 0; i < dc1.size(); i++)
- {
- ChannelSettings c1 = (ChannelSettings)dc1.get(i);
- ChannelSettings c2 = (ChannelSettings)dc2.get(i);
- if (!channelDefinitionsMatch(c1, c2))
+ if (dc1.size() != dc2.size()) {
+ return fail("Default channels sections didn't match by size: {0} != {1}", new Object[]{new Integer(dc1.size()), new Integer(dc2.size())});
+ }
+
+ for (int i = 0; i < dc1.size(); i++) {
+ ChannelSettings c1 = (ChannelSettings) dc1.get(i);
+ ChannelSettings c2 = (ChannelSettings) dc2.get(i);
+ if (!channelDefinitionsMatch(c1, c2)) {
return false;
+ }
}
// Destinations
Map d1 = ss1.getDestinationSettings();
Map d2 = ss2.getDestinationSettings();
- if (!destinationsMatch(d1, d2))
- return false;
-
- return true;
+ return destinationsMatch(d1, d2);
}
- protected boolean adaptersMatch(Map a1, Map a2)
- {
- if (a1 == null && a2 == null)
+ protected boolean adaptersMatch(Map a1, Map a2) {
+ if (a1 == null && a2 == null) {
return true;
+ }
- if (a1 == null || a2 == null)
- return fail("Adapters sections didn't match: {0} != {1}", new Object[] {a1, a2});
+ if (a1 == null || a2 == null) {
+ return fail("Adapters sections didn't match: {0} != {1}", new Object[]{a1, a2});
+ }
- if (a1.size() != a2.size())
- return fail("Adapters sections didn't match by size: {0} != {1}", new Object[] {new Integer(a1.size()), new Integer(a2.size())});
+ if (a1.size() != a2.size()) {
+ return fail("Adapters sections didn't match by size: {0} != {1}", new Object[]{new Integer(a1.size()), new Integer(a2.size())});
+ }
- Iterator it = a1.keySet().iterator();
- while (it.hasNext())
- {
- String key = (String)it.next();
+ for (Object o : a1.keySet()) {
+ String key = (String) o;
- AdapterSettings as1 = (AdapterSettings)a1.get(key);
- AdapterSettings as2 = (AdapterSettings)a2.get(key);
- if (!adapterDefinitionsMatch(as1, as2))
+ AdapterSettings as1 = (AdapterSettings) a1.get(key);
+ AdapterSettings as2 = (AdapterSettings) a2.get(key);
+ if (!adapterDefinitionsMatch(as1, as2)) {
return false;
+ }
}
return true;
}
- protected boolean adapterDefinitionsMatch(AdapterSettings as1, AdapterSettings as2)
- {
- if (as1 == null && as2 == null)
+ protected boolean adapterDefinitionsMatch(AdapterSettings as1, AdapterSettings as2) {
+ if (as1 == null && as2 == null) {
return true;
+ }
- if (as1 == null || as2 == null)
- return fail("Adapters didn't match: {0} != {1}", new Object[] {as1, as2});
+ if (as1 == null || as2 == null) {
+ return fail("Adapters didn't match: {0} != {1}", new Object[]{as1, as2});
+ }
- if (!as1.getId().equals(as2.getId()))
- return fail("Adapter ids didn't match: {0} != {1}", new Object[] {as1.getId(), as2.getId()});
+ if (!as1.getId().equals(as2.getId())) {
+ return fail("Adapter ids didn't match: {0} != {1}", new Object[]{as1.getId(), as2.getId()});
+ }
- if (!as1.getClassName().equals(as2.getClassName()))
- return fail("Adapter class names didn't match: {0} != {1}", new Object[] {as1.getClassName(), as2.getClassName()});
+ if (!as1.getClassName().equals(as2.getClassName())) {
+ return fail("Adapter class names didn't match: {0} != {1}", new Object[]{as1.getClassName(), as2.getClassName()});
+ }
- if (as1.isDefault() != as2.isDefault())
- return fail("Adapter default attributes didn't match: {0} != {1}", new Object[] {Boolean.valueOf(as1.isDefault()), Boolean.valueOf(as2.isDefault())});
+ if (as1.isDefault() != as2.isDefault()) {
+ return fail("Adapter default attributes didn't match: {0} != {1}", new Object[]{Boolean.valueOf(as1.isDefault()), Boolean.valueOf(as2.isDefault())});
+ }
- if (!propertiesMatch(as1.getProperties(), as2.getProperties()))
+ if (!propertiesMatch(as1.getProperties(), as2.getProperties())) {
return false;
+ }
return true;
}
- protected boolean channelDefinitionsMatch(ChannelSettings c1, ChannelSettings c2)
- {
- if (c1 == null && c2 == null)
+ protected boolean channelDefinitionsMatch(ChannelSettings c1, ChannelSettings c2) {
+ if (c1 == null && c2 == null) {
return true;
+ }
- if (c1 == null || c2 == null)
- return fail("Channels didn't match: {0} != {1}", new Object[] {c1, c2});
+ if (c1 == null || c2 == null) {
+ return fail("Channels didn't match: {0} != {1}", new Object[]{c1, c2});
+ }
- if (!c1.getId().equals(c2.getId()))
- return fail("Channel ids didn't match: {0} != {1}", new Object[] {c1.getId(), c2.getId()});
+ if (!c1.getId().equals(c2.getId())) {
+ return fail("Channel ids didn't match: {0} != {1}", new Object[]{c1.getId(), c2.getId()});
+ }
- if (!c1.getEndpointType().equals(c1.getEndpointType()))
- return fail("Channel endpoint types didn't match: {0} != {1}", new Object[] {c1.getEndpointType(), c2.getEndpointType()});
+ if (!c1.getEndpointType().equals(c1.getEndpointType())) {
+ return fail("Channel endpoint types didn't match: {0} != {1}", new Object[]{c1.getEndpointType(), c2.getEndpointType()});
+ }
- if (!c1.getUri().equals(c2.getUri()))
- return fail("Channel endpoint URIs didn't match: {0} != {1}", new Object[] {c1.getUri(), c2.getUri()});
+ if (!c1.getUri().equals(c2.getUri())) {
+ return fail("Channel endpoint URIs didn't match: {0} != {1}", new Object[]{c1.getUri(), c2.getUri()});
+ }
- if (!propertiesMatch(c1.getProperties(), c2.getProperties()))
+ if (!propertiesMatch(c1.getProperties(), c2.getProperties())) {
return false;
+ }
return true;
}
- protected boolean destinationsMatch(Map d1, Map d2)
- {
- if (d1 == null && d2 == null)
+ protected boolean destinationsMatch(Map d1, Map d2) {
+ if (d1 == null && d2 == null) {
return true;
+ }
- if (d1 == null || d2 == null)
- return fail("Destinations sections didn't match: {0} != {1}", new Object[] {d1, d2});
+ if (d1 == null || d2 == null) {
+ return fail("Destinations sections didn't match: {0} != {1}", new Object[]{d1, d2});
+ }
- if (d1.size() != d2.size())
- return fail("Destinations sections didn't match by size: {0} != {1}", new Object[] {new Integer(d1.size()), new Integer(d2.size())});
+ if (d1.size() != d2.size()) {
+ return fail("Destinations sections didn't match by size: {0} != {1}", new Object[]{new Integer(d1.size()), new Integer(d2.size())});
+ }
- Iterator it = d1.keySet().iterator();
- while (it.hasNext())
- {
- String key = (String)it.next();
+ for (Object o : d1.keySet()) {
+ String key = (String) o;
- DestinationSettings ds1 = (DestinationSettings)d1.get(key);
- DestinationSettings ds2 = (DestinationSettings)d2.get(key);
- if (!destinationDefinitionsMatch(ds1, ds2))
+ DestinationSettings ds1 = (DestinationSettings) d1.get(key);
+ DestinationSettings ds2 = (DestinationSettings) d2.get(key);
+ if (!destinationDefinitionsMatch(ds1, ds2)) {
return false;
+ }
}
return true;
}
- protected boolean destinationDefinitionsMatch(DestinationSettings d1, DestinationSettings d2)
- {
- if (d1 == null && d2 == null)
+ protected boolean destinationDefinitionsMatch(DestinationSettings d1, DestinationSettings d2) {
+ if (d1 == null && d2 == null) {
return true;
+ }
- if (d1 == null || d2 == null)
- return fail("Destinations didn't match: {0} != {1}", new Object[] {d1, d2});
+ if (d1 == null || d2 == null) {
+ return fail("Destinations didn't match: {0} != {1}", new Object[]{d1, d2});
+ }
- if (!d1.getId().equals(d2.getId()))
- return fail("Destination ids didn't match: {0} != {1}", new Object[] {d1.getId(), d2.getId()});
+ if (!d1.getId().equals(d2.getId())) {
+ return fail("Destination ids didn't match: {0} != {1}", new Object[]{d1.getId(), d2.getId()});
+ }
// Properties
- if (!propertiesMatch(d1.getProperties(), d1.getProperties()))
+ if (!propertiesMatch(d1.getProperties(), d1.getProperties())) {
return false;
+ }
- // Channels
+ // Channels
List dc1 = d1.getChannelSettings();
List dc2 = d2.getChannelSettings();
- if (dc1.size() != dc2.size())
- return fail("Destination channels sections didn't match by size: {0} != {1}", new Object[] {new Integer(dc1.size()), new Integer(dc2.size())});
-
- for (int i = 0; i < dc1.size(); i++)
- {
- ChannelSettings c1 = (ChannelSettings)dc1.get(i);
- ChannelSettings c2 = (ChannelSettings)dc2.get(i);
- if (!channelDefinitionsMatch(c1, c2))
+ if (dc1.size() != dc2.size()) {
+ return fail("Destination channels sections didn't match by size: {0} != {1}", new Object[]{new Integer(dc1.size()), new Integer(dc2.size())});
+ }
+
+ for (int i = 0; i < dc1.size(); i++) {
+ ChannelSettings c1 = (ChannelSettings) dc1.get(i);
+ ChannelSettings c2 = (ChannelSettings) dc2.get(i);
+ if (!channelDefinitionsMatch(c1, c2)) {
return false;
+ }
}
// Security
SecurityConstraint sc1 = d1.getConstraint();
SecurityConstraint sc2 = d2.getConstraint();
- if (!securityConstraintsMatch(sc1, sc2))
+ if (!securityConstraintsMatch(sc1, sc2)) {
return false;
+ }
// Adapter
AdapterSettings as1 = d1.getAdapterSettings();
AdapterSettings as2 = d2.getAdapterSettings();
- if (!adapterDefinitionsMatch(as1, as2))
+ if (!adapterDefinitionsMatch(as1, as2)) {
return false;
+ }
return true;
}
- protected boolean securityConstraintsMatch(SecurityConstraint sc1, SecurityConstraint sc2)
- {
- if (sc1 == null && sc2 == null)
+ protected boolean securityConstraintsMatch(SecurityConstraint sc1, SecurityConstraint sc2) {
+ if (sc1 == null && sc2 == null) {
return true;
+ }
+
+ if (sc1 == null || sc2 == null) {
+ return fail("Security constraints didn't match: {0} != {1}", new Object[]{sc1, sc2});
+ }
- if (sc1 == null || sc2 == null)
- return fail("Security constraints didn't match: {0} != {1}", new Object[] {sc1, sc2});
+ if (!sc1.getId().equals(sc2.getId())) {
+ return fail("Security constraint ids didn't match: {0} != {1}", new Object[]{sc1.getId(), sc2.getId()});
+ }
- if (!sc1.getId().equals(sc2.getId()))
- return fail("Security constraint ids didn't match: {0} != {1}", new Object[] {sc1.getId(), sc2.getId()});
+ if (!sc1.getMethod().equals(sc2.getMethod())) {
+ return fail("Security constraint methods didn't match: {0} != {1}", new Object[]{sc1.getMethod(), sc2.getMethod()});
+ }
- if (!sc1.getMethod().equals(sc2.getMethod()))
- return fail("Security constraint methods didn't match: {0} != {1}", new Object[] {sc1.getMethod(), sc2.getMethod()});
-
// Roles
- List r1 = sc1.getRoles();
- List r2 = sc2.getRoles();
- if (r1.size() != r2.size())
- return fail("Security constraint roles sections didn't match by size: {0} != {1}", new Object[] {new Integer(r1.size()), new Integer(r2.size())});
+ List r1 = sc1.getRoles();
+ List r2 = sc2.getRoles();
+ if (r1.size() != r2.size()) {
+ return fail("Security constraint roles sections didn't match by size: {0} != {1}", new Object[]{new Integer(r1.size()), new Integer(r2.size())});
+ }
- for (int i = 0; i < r1.size(); i++)
- {
- String role1 = (String)r1.get(i);
- String role2 = (String)r2.get(i);
- if (!role1.equals(role2))
- return fail("Security constraint roles didn't match: {0} != {1}", new Object[] {role1, role2});
+ for (int i = 0; i < r1.size(); i++) {
+ String role1 = (String) r1.get(i);
+ String role2 = (String) r2.get(i);
+ if (!role1.equals(role2)) {
+ return fail("Security constraint roles didn't match: {0} != {1}", new Object[]{role1, role2});
+ }
}
return true;
}
- protected boolean propertiesMatch(Map p1, Map p2)
- {
- if (p1 == null && p2 == null)
+ protected boolean propertiesMatch(Map p1, Map p2) {
+ if (p1 == null && p2 == null) {
return true;
+ }
- if (p1 == null || p2 == null)
- return fail("Properties didn't match: {0} != {1}", new Object[] {p1, p2});
+ if (p1 == null || p2 == null) {
+ return fail("Properties didn't match: {0} != {1}", new Object[]{p1, p2});
+ }
- if (!mapsMatch(p1, p2))
+ if (!mapsMatch(p1, p2)) {
return false;
+ }
return true;
}
- protected boolean valuesMatch(Object o1, Object o2)
- {
- if (o1 == null && o2 == null)
+ protected boolean valuesMatch(Object o1, Object o2) {
+ if (o1 == null && o2 == null) {
return true;
-
- if (o1 instanceof Map)
- {
- return mapsMatch((Map)o1, (Map)o2);
}
- else if (o1 instanceof List)
- {
- return listsMatch((List)o1, (List)o2);
- }
- else if (o1 != null)
- {
- if (hasComplexChildren(o1))
- {
+
+ if (o1 instanceof Map) {
+ return mapsMatch((Map) o1, (Map) o2);
+ } else if (o1 instanceof List) {
+ return listsMatch((List) o1, (List) o2);
+ } else if (o1 != null) {
+ if (hasComplexChildren(o1)) {
// We avoid checking a complex/custom types twice in
// case of circular dependencies
Object known = knownObjects.get(o1);
- if (known != null)
- {
+ if (known != null) {
return true;
- }
- else
- {
+ } else {
knownObjects.put(o1, o2);
}
}
@@ -422,49 +420,41 @@ public abstract class ConfigurationConfirmation
return false;
}
- protected boolean stringValuesMatch(String str1, String str2)
- {
- if (str1 == null && str2 == null)
+ protected boolean stringValuesMatch(String str1, String str2) {
+ if (str1 == null && str2 == null) {
return true;
+ }
- if (str1 != null && !str1.equals(str2))
+ if (str1 != null && !str1.equals(str2)) {
return false;
+ }
return true;
}
- protected boolean mapsMatch(Map map1, Map map2)
- {
- if (map1.size() != map2.size())
+ protected boolean mapsMatch(Map map1, Map map2) {
+ if (map1.size() != map2.size()) {
return false;
+ }
// We avoid checking a Map twice in case
// of circular dependencies
Object known = knownObjects.get(map1);
- if (known != null)
- {
+ if (known != null) {
return true;
- }
- else
- {
+ } else {
knownObjects.put(map1, map2);
}
- Iterator it = map1.keySet().iterator();
- while (it.hasNext())
- {
- Object next = it.next();
- if (next instanceof String)
- {
- String key = (String)next;
+ for (Object next : map1.keySet()) {
+ if (next instanceof String) {
+ String key = (String) next;
Object val1 = map1.get(key);
Object val2 = map2.get(key);
if (!valuesMatch(val1, val2))
return false;
- }
- else
- {
+ } else {
return false;
}
}
@@ -472,66 +462,51 @@ public abstract class ConfigurationConfirmation
return true;
}
- protected boolean listsMatch(List list1, List list2)
- {
- if (list1.size() != list2.size())
+ protected boolean listsMatch(List list1, List list2) {
+ if (list1.size() != list2.size()) {
return false;
+ }
// We avoid checking a List twice in case
// of circular dependencies
Object known = knownObjects.get(list1);
- if (known != null)
- {
+ if (known != null) {
return true;
- }
- else
- {
+ } else {
knownObjects.put(list1, list2);
}
- for (int i = 0; i < list1.size(); i++)
- {
+ for (int i = 0; i < list1.size(); i++) {
Object o1 = list1.get(i);
Object o2 = list2.get(i);
- if (!valuesMatch(o1, o2))
+ if (!valuesMatch(o1, o2)) {
return false;
+ }
}
return true;
}
- private static boolean hasComplexChildren(Object o)
- {
- if (o instanceof String
+ private static boolean hasComplexChildren(Object o) {
+ return !(o instanceof String
|| o instanceof Boolean
|| o instanceof Number
|| o instanceof Character
- || o instanceof Date)
- {
- return false;
- }
-
- return true;
+ || o instanceof Date);
}
- protected boolean fail(String message)
- {
+ protected boolean fail(String message) {
return fail(message, null);
}
- protected boolean fail(String message, Object[] parameters)
- {
- if (!isNegativeTest())
- {
- if (parameters != null)
- {
+ protected boolean fail(String message, Object[] parameters) {
+ if (!isNegativeTest()) {
+ if (parameters != null) {
// replace all of the parameters in the msg string
- for (int i = 0; i < parameters.length; i++)
- {
+ for (int i = 0; i < parameters.length; i++) {
String replacement = parameters[i] != null ? parameters[i].toString() : "null";
-
message = message.replaceAll("\\{" + i + "\\}", replacement);
}
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/config/ConfigurationParserTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/config/ConfigurationParserTest.java b/core/src/test/java/flex/messaging/config/ConfigurationParserTest.java
index 338285e..924c007 100644
--- a/core/src/test/java/flex/messaging/config/ConfigurationParserTest.java
+++ b/core/src/test/java/flex/messaging/config/ConfigurationParserTest.java
@@ -19,95 +19,65 @@ package flex.messaging.config;
import flex.messaging.LocalizedException;
import flex.messaging.MessageBroker;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
-public class ConfigurationParserTest extends TestCase
-{
+public class ConfigurationParserTest {
private String resourceBase = "/flex/messaging/config/";
private String baseFilePath;
- public ConfigurationParserTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(ConfigurationParserTest.class);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
MessageBroker broker = new MessageBroker(false);
broker.initThreadLocals();
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
-
/*
* TESTS
*/
-
- public void testConfiguration()
- {
- try
- {
+ @Test
+ public void testConfiguration() {
+ try {
URL url = this.getClass().getResource(resourceBase + "ConfigurationParserTest.class");
File file = new File(url.getFile());
File dir = new File(file.getParent());
baseFilePath = dir.getAbsolutePath();
- if (dir.isDirectory())
- {
+ if (dir.isDirectory()) {
String resourcePath = getResourcePath(baseFilePath);
processDirectory(dir, resourcePath);
}
- }
- catch (IOException ioe)
- {
- fail("Configuration test failed: " + ioe.getMessage());
+ } catch (IOException ioe) {
+ Assert.fail("Configuration test failed: " + ioe.getMessage());
}
}
- private void processDirectory(File dir, String resourcePath) throws IOException
- {
+ private void processDirectory(File dir, String resourcePath) throws IOException {
File[] files = dir.listFiles(new XMLFilenameFilter());
- for (int i = 0; i < files.length; i++)
- {
- File f = files[i];
- if (f.isDirectory())
- {
- resourcePath = getResourcePath(f.getAbsolutePath());
- processDirectory(f, resourcePath);
- }
- else
- {
- String testName = getTestName(f.getName());
- System.out.println("Running test: " + testName);
- processRequest(f.toString(), testName, resourcePath);
+ if(files != null) {
+ for (File f : files) {
+ if (f.isDirectory()) {
+ resourcePath = getResourcePath(f.getAbsolutePath());
+ processDirectory(f, resourcePath);
+ } else {
+ String testName = getTestName(f.getName());
+ System.out.println("Running test: " + testName);
+ processRequest(f.toString(), testName, resourcePath);
+ }
}
}
}
- private String getResourcePath(String path)
- {
- if (path.startsWith(baseFilePath))
- {
+ private String getResourcePath(String path) {
+ if (path.startsWith(baseFilePath)) {
path = path.substring(baseFilePath.length());
path = path.replace('\\', '/');
return path;
@@ -116,84 +86,69 @@ public class ConfigurationParserTest extends TestCase
return null;
}
- private String getTestName(String fileName)
- {
+ private String getTestName(String fileName) {
fileName = fileName.toLowerCase();
int pos = fileName.indexOf(".xml");
return fileName.substring(0, pos);
}
- private void processRequest(String filename, String testName, String resourcePath) throws IOException
- {
+ private void processRequest(String filename, String testName, String resourcePath) throws IOException {
MessagingConfiguration config = new MessagingConfiguration();
ConfigurationParser parser = new ApacheXPathServerConfigurationParser();
- try
- {
+ try {
parser.parse(filename, new LocalFileResolver(), config);
ConfigurationConfirmation confirmation = getConfirmation(resourcePath, testName);
- if (!confirmation.matches(config))
- fail("MessagingConfiguration did not match test: " + testName);
- }
- catch (LocalizedException ex)
- {
+ if (!confirmation.matches(config)) {
+ Assert.fail("MessagingConfiguration did not match test: " + testName);
+ }
+ } catch (LocalizedException ex) {
ConfigurationConfirmation confirmation = getConfirmation(resourcePath, testName);
- if (confirmation.isNegativeTest())
- {
- if (!confirmation.negativeMatches(ex))
- fail("MessageException did not match negative test " + testName);
- }
- else
- {
+ if (confirmation.isNegativeTest()) {
+ if (!confirmation.negativeMatches(ex)) {
+ Assert.fail("MessageException did not match negative test " + testName);
+ }
+ } else {
throw ex;
}
}
}
- private ConfigurationConfirmation getConfirmation(String resourcePath, String testName) throws IOException
- {
- try
- {
- if (resourceBase.endsWith("/") && resourcePath.startsWith("/"))
+ private ConfigurationConfirmation getConfirmation(String resourcePath, String testName) throws IOException {
+ try {
+ if (resourceBase.endsWith("/") && resourcePath.startsWith("/")) {
resourcePath = resourcePath.substring(1);
+ }
String resource = resourceBase + resourcePath;
- if (resource.startsWith("/"))
+ if (resource.startsWith("/")) {
resource = resource.substring(1);
+ }
String packageName = resource.replace('/', '.');
- if (packageName.length() > 0 && !packageName.endsWith("."))
+ if (packageName.length() > 0 && !packageName.endsWith(".")) {
packageName = packageName + ".";
+ }
String className = packageName + "Confirm" + testName;
Class c = Class.forName(className);
Object obj = c.newInstance();
- ConfigurationConfirmation confirm = (ConfigurationConfirmation)obj;
- return confirm;
- }
- catch (Exception e)
- {
+ return (ConfigurationConfirmation) obj;
+ } catch (Exception e) {
throw new IOException("Unable to load confirmation for testName: " + testName + " in " + resourcePath);
}
}
- static class XMLFilenameFilter implements FilenameFilter
- {
- public boolean accept(File dir, String name)
- {
+ static class XMLFilenameFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
String child = dir.getAbsolutePath() + File.separator + name;
File f = new File(child);
- if (f.isDirectory())
- return true;
- else if (name.toLowerCase().endsWith(".xml") && name.indexOf("include") == -1)
- return true;
- else
- return false;
+ return f.isDirectory() || name.toLowerCase().endsWith(".xml") && !name.contains("include");
}
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/config/ThrottleSettingsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/config/ThrottleSettingsTest.java b/core/src/test/java/flex/messaging/config/ThrottleSettingsTest.java
index 019e258..fe9d37e 100644
--- a/core/src/test/java/flex/messaging/config/ThrottleSettingsTest.java
+++ b/core/src/test/java/flex/messaging/config/ThrottleSettingsTest.java
@@ -20,119 +20,77 @@ package flex.messaging.config;
import flex.messaging.config.ThrottleSettings.Policy;
import flex.messaging.services.messaging.ThrottleManager;
import org.junit.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
-public class ThrottleSettingsTest extends TestCase
-{
+public class ThrottleSettingsTest {
private static final String UNEXPECTED_EXCEPTION_STRING = "Unexpected exception: ";
- public ThrottleSettingsTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
- suite.addTest(new ThrottleSettingsTest("testSetIncomingClientFrequencyHigherThanDestinationFrequency"));
- suite.addTest(new ThrottleSettingsTest("testSetIncomingDestinationFrequencyLowerThanClientFrequency"));
- suite.addTest(new ThrottleSettingsTest("testSetOutgoingClientFrequencyHigherThanDestinationFrequency"));
- suite.addTest(new ThrottleSettingsTest("testSetOutgoingDestinationFrequencyLowerThanClientFrequency"));
- suite.addTest(new ThrottleSettingsTest("testSetIncomingClientFrequencyWithZeroDestinationFrequency"));
- suite.addTest(new ThrottleSettingsTest("testSetIncomingDestinationFrequencyWithZeroClientFrequency"));
- suite.addTest(new ThrottleSettingsTest("testUnknownPolicy"));
- suite.addTest(new ThrottleSettingsTest("testOutgoingPolicyError"));
- return suite;
- }
-
- public void testSetIncomingClientFrequencyHigherThanDestinationFrequency()
- {
+ @Test
+ public void testSetIncomingClientFrequencyHigherThanDestinationFrequency() {
ThrottleSettings ts = new ThrottleSettings();
ts.setIncomingDestinationFrequency(10);
- try
- {
+ try {
ts.setIncomingClientFrequency(15);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
// Success.
- }
- catch (Exception e)
- {
- fail(UNEXPECTED_EXCEPTION_STRING + e);
+ } catch (Exception e) {
+ Assert.fail(UNEXPECTED_EXCEPTION_STRING + e);
}
}
- public void testSetIncomingDestinationFrequencyLowerThanClientFrequency()
- {
+ @Test
+ public void testSetIncomingDestinationFrequencyLowerThanClientFrequency() {
ThrottleSettings ts = new ThrottleSettings();
ts.setIncomingClientFrequency(15);
- try
- {
+ try {
ts.setIncomingDestinationFrequency(10);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
// Success.
- }
- catch (Exception e)
- {
- fail(UNEXPECTED_EXCEPTION_STRING + e);
+ } catch (Exception e) {
+ Assert.fail(UNEXPECTED_EXCEPTION_STRING + e);
}
}
- public void testSetOutgoingClientFrequencyHigherThanDestinationFrequency()
- {
+ @Test
+ public void testSetOutgoingClientFrequencyHigherThanDestinationFrequency() {
ThrottleSettings ts = new ThrottleSettings();
ts.setOutgoingDestinationFrequency(10);
- try
- {
+ try {
ts.setOutgoingClientFrequency(15);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
// Success.
- }
- catch (Exception e)
- {
- fail(UNEXPECTED_EXCEPTION_STRING + e);
+ } catch (Exception e) {
+ Assert.fail(UNEXPECTED_EXCEPTION_STRING + e);
}
}
- public void testSetOutgoingDestinationFrequencyLowerThanClientFrequency()
- {
+ @Test
+ public void testSetOutgoingDestinationFrequencyLowerThanClientFrequency() {
ThrottleSettings ts = new ThrottleSettings();
ts.setOutgoingClientFrequency(15);
- try
- {
+ try {
ts.setOutgoingDestinationFrequency(10);
- fail("ConfigurationException expected");
- }
- catch (ConfigurationException ce)
- {
+ Assert.fail("ConfigurationException expected");
+ } catch (ConfigurationException ce) {
// Success.
- }
- catch (Exception e)
- {
- fail(UNEXPECTED_EXCEPTION_STRING + e);
+ } catch (Exception e) {
+ Assert.fail(UNEXPECTED_EXCEPTION_STRING + e);
}
}
- public void testSetIncomingClientFrequencyWithZeroDestinationFrequency()
- {
+ @Test
+ public void testSetIncomingClientFrequencyWithZeroDestinationFrequency() {
ThrottleSettings ts = new ThrottleSettings();
ts.setIncomingDestinationFrequency(0);
ts.setIncomingClientFrequency(10);
Assert.assertEquals(10, ts.getIncomingClientFrequency());
}
- public void testSetIncomingDestinationFrequencyWithZeroClientFrequency()
- {
+ @Test
+ public void testSetIncomingDestinationFrequencyWithZeroClientFrequency() {
ThrottleSettings ts = new ThrottleSettings();
ts.setIncomingClientFrequency(0);
ts.setIncomingDestinationFrequency(10);
@@ -142,41 +100,31 @@ public class ThrottleSettingsTest extends TestCase
/**
* Test that an UNKNOWN policy throws ConfigurationException.
*/
- public void testUnknownPolicy()
- {
- try
- {
+ @Test
+ public void testUnknownPolicy() {
+ try {
ThrottleSettings.parsePolicy("UNKNOWN");
- }
- catch (ConfigurationException ce)
- {
+ } catch (ConfigurationException ce) {
// Success.
- }
- catch (Exception e)
- {
- fail(UNEXPECTED_EXCEPTION_STRING + e);
+ } catch (Exception e) {
+ Assert.fail(UNEXPECTED_EXCEPTION_STRING + e);
}
}
/**
* Test that outgoing policy of ERROR throws ConfigurationException.
*/
- public void testOutgoingPolicyError()
- {
+ @Test
+ public void testOutgoingPolicyError() {
ThrottleManager manager = new ThrottleManager();
ThrottleSettings ts = new ThrottleSettings();
ts.setOutboundPolicy(Policy.ERROR);
- try
- {
+ try {
manager.setThrottleSettings(ts);
- }
- catch (ConfigurationException ce)
- {
+ } catch (ConfigurationException ce) {
// Success.
- }
- catch (Exception e)
- {
- fail(UNEXPECTED_EXCEPTION_STRING + e);
+ } catch (Exception e) {
+ Assert.fail(UNEXPECTED_EXCEPTION_STRING + e);
}
}
}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/9f2a242d/core/src/test/java/flex/messaging/io/ClassDeserializationValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/io/ClassDeserializationValidatorTest.java b/core/src/test/java/flex/messaging/io/ClassDeserializationValidatorTest.java
deleted file mode 100644
index f61f5f7..0000000
--- a/core/src/test/java/flex/messaging/io/ClassDeserializationValidatorTest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package flex.messaging.io;
-
-/**
- * Created by christoferdutz on 09.08.16.
- */
-public class ClassDeserializationValidatorTest {
-}