Skip to content

Commit

Permalink
GDS-1183 Add tests for UDP channel
Browse files Browse the repository at this point in the history
  • Loading branch information
William Drai committed Oct 2, 2013
1 parent 4c4d37f commit e9a68c8
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 9 deletions.
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 43 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ project('granite-client-java') {
testGlassFishv31Runtime 'org.glassfish.main.extras:glassfish-embedded-all:3.1.2.2'

testGlassFishv31Runtime project(':granite-server-glassfishv3').sourceSets.test.output
testGlassFishv31Runtime project(':granite-server-ejb').sourceSets.main.output
testGlassFishv31Runtime project(':granite-server-ejb')
testGlassFishv31Runtime project(':granite-server-eclipselink')
}

Expand Down Expand Up @@ -1592,7 +1592,7 @@ project('granite-client-java') {
source = sourceSets.main.java // Redefine here so filter is applied
}

task testTomcat7(type: Test) {
task testTomcat7(type: Test, dependsOn: [ ':granite-server-core:jar', ':granite-server-servlet3:jar', ':granite-server-tomcat7:jar' ]) {
systemProperties = [ 'container.className' : 'org.granite.test.container.tomcat7.EmbeddedTomcat7' ]

includes = [ 'org/granite/client/test/server/TestMessaging*' ]
Expand All @@ -1605,7 +1605,7 @@ project('granite-client-java') {
classpath = project.sourceSets.test.runtimeClasspath + project.configurations.testTomcat7Runtime
}

task testJetty8(type: Test) {
task testJetty8(type: Test, dependsOn: [ ':granite-server-core:jar', ':granite-server-servlet3:jar', ':granite-server-jetty8:jar' ]) {
systemProperties = [ 'container.className' : 'org.granite.test.container.jetty8.EmbeddedJetty8' ]

includes = [ 'org/granite/client/test/server/TestMessaging*' ]
Expand All @@ -1618,7 +1618,7 @@ project('granite-client-java') {
classpath = project.sourceSets.test.runtimeClasspath + project.configurations.testJetty8Runtime
}

task testGlassFishv31(type: Test) {
task testGlassFishv31(type: Test, dependsOn: [ ':granite-server-core:jar', ':granite-server-servlet3:jar', ':granite-server-ejb:jar', ':granite-server-glassfishv3:jar' ]) {
systemProperties = [ 'container.className' : 'org.granite.test.container.glassfishv31.EmbeddedGlassFishv31' ]

includes = [ 'org/granite/client/test/server/Test*' ]
Expand All @@ -1636,10 +1636,6 @@ project('granite-client-java') {

excludes = [ 'org/granite/client/test/server/Test*' ]
}

test {
exclude 'org/granite/client/test/websocket/**'
}
}

// Java Advanced client library
Expand All @@ -1658,10 +1654,49 @@ project('granite-client-java-udp') {

description = 'GraniteDS UDP support client library (Java)'

configurations {
create('testTomcat7Runtime')
}

dependencies {
compile project(':granite-server-udp')
compile project(':granite-client-java')
compile project(':granite-server-servlet3')

testRuntime 'org.slf4j:slf4j-api:1.7.3',
'org.slf4j:slf4j-log4j12:1.7.3'

testCompile project(':granite-server-servlet3')

testCompile project(':granite-server-core').sourceSets.test.output
testCompile project(':granite-client-java').sourceSets.test.output

testCompile 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.1.3'

testTomcat7Runtime 'org.apache.tomcat.embed:tomcat-embed-core:7.0.42',
'org.apache.tomcat.embed:tomcat-embed-jasper:7.0.42',
'org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.42'

testTomcat7Runtime project(':granite-server-tomcat7').sourceSets.test.output
}

task testTomcat7(type: Test, dependsOn: [ ':granite-server-core:jar', ':granite-server-servlet3:jar', ':granite-server-tomcat7:jar', ':granite-server-udp:jar' ]) {
systemProperties = [ 'container.className' : 'org.granite.test.container.tomcat7.EmbeddedTomcat7' ]

includes = [ 'org/granite/client/test/udp/server/TestMessaging*' ]

workingDir = rootDir
reports.junitXml.destination = new File(buildDir, 'test-results/tomcat7')
reports.html.destination = new File(buildDir, 'reports/tests/tomcat7')

// Add Tomcat jars to the classpath
classpath = project.sourceSets.test.runtimeClasspath + project.configurations.testTomcat7Runtime
}

test {
it.dependsOn 'testTomcat7'

excludes = [ 'org/granite/client/test/udp/server/Test*' ]
}
}

Expand Down
7 changes: 7 additions & 0 deletions granite-client-java-udp/granite-client-java-udp.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="granite-server-core" />
<orderEntry type="module" module-name="granite-client-java" />
<orderEntry type="module" module-name="granite-client-java-advanced" />
<orderEntry type="library" scope="TEST" name="junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="org.slf4j:slf4j-api:1.7.3" level="project" />
<orderEntry type="library" scope="TEST" name="org.slf4j:slf4j-log4j12:1.7.3" level="project" />
<orderEntry type="module" module-name="granite-server-servlet3" scope="TEST" />
<orderEntry type="library" scope="TEST" name="org.jboss.shrinkwrap:shrinkwrap-impl-base:1.1.3" level="project" />
</component>
</module>

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* GRANITE DATA SERVICES
* Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S.
*
* This file is part of the Granite Data Services Platform.
*
* Granite Data Services is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Granite Data Services is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA, or see <http://www.gnu.org/licenses/>.
*/
package org.granite.client.test.udp.server;

import org.granite.client.messaging.*;
import org.granite.client.messaging.udp.UdpChannelBuilder;
import org.granite.client.test.server.ChatApplication;
import org.granite.client.test.server.TestMessaging;
import org.granite.logging.Logger;
import org.granite.test.container.EmbeddedContainer;
import org.granite.test.container.Utils;
import org.granite.util.ContentType;
import org.granite.util.TypeUtil;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Created by william on 30/09/13.
*/
@RunWith(Parameterized.class)
public class TestUdpMessaging extends TestMessaging {

private static final Logger log = Logger.getLogger(TestUdpMessaging.class);

private static String CONTAINER_CLASS_NAME = System.getProperty("container.className");

@Parameterized.Parameters(name = "container: {0}, encoding: {1}")
public static Iterable<Object[]> data() {
List<Object[]> params = new ArrayList<Object[]>();
for (ContentType contentType : Arrays.asList(ContentType.JMF_AMF, ContentType.AMF)) {
params.add(new Object[] { CONTAINER_CLASS_NAME, contentType });
}
return params;
}

private ContentType contentType;
private String containerClassName;
private static EmbeddedContainer container;

private static final ServerApp SERVER_APP_APP = new ServerApp("/chat", false, "localhost", 8787);

public TestUdpMessaging(String containerClassName, ContentType contentType) {
super(containerClassName, contentType, UdpChannelBuilder.UDP_CHANNEL_TYPE);
}

@BeforeClass
public static void startContainer() throws Exception {
// Build a chat server application
WebArchive war = ShrinkWrap.create(WebArchive.class, "chat.war");
war.addClass(ChatApplication.class);
war.addAsLibraries(new File("granite-server-core/build/libs/").listFiles(new Utils.ArtifactFileFilter()));
war.addAsLibraries(new File("granite-server-servlet3/build/libs/").listFiles(new Utils.ArtifactFileFilter()));
war.addAsLibraries(new File("granite-server-udp/build/libs/").listFiles(new Utils.ArtifactFileFilter()));
war.addAsWebInfResource(new File("granite-client-java-udp/src/test/resources/granite-config-udp.xml"), "granite/granite-config.xml");

container = (EmbeddedContainer) TypeUtil.newInstance(CONTAINER_CLASS_NAME, new Class<?>[]{WebArchive.class}, new Object[]{war});
container.start();
log.info("Container started");
}

@AfterClass
public static void stopContainer() throws Exception {
container.stop();
log.info("Container stopped");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE granite-config PUBLIC "-//Granite Data Services//DTD granite-config internal//EN"
"http://www.graniteds.org/public/dtd/3.0.0/granite-config.dtd">

<granite-config>
<gravity>
<udp/>
</gravity>
</granite-config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="org.apache.tomcat.embed:tomcat-embed-core:7.0.42" level="project" />
<orderEntry type="library" scope="TEST" name="org.apache.tomcat.embed:tomcat-embed-jasper:7.0.42" level="project" />
<orderEntry type="library" scope="TEST" name="org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.42" level="project" />
<orderEntry type="module" module-name="granite-server-udp" scope="TEST" />
<orderEntry type="module" module-name="granite-server-tomcat7" scope="TEST" />
<orderEntry type="module" module-name="granite-client-java" />
<orderEntry type="module" module-name="granite-client-java-udp" />
</component>
</module>

Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* GRANITE DATA SERVICES
* Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S.
*
* This file is part of the Granite Data Services Platform.
*
* Granite Data Services is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Granite Data Services is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA, or see <http://www.gnu.org/licenses/>.
*/
package org.granite.client.test;

import org.granite.client.configuration.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static Iterable<Object[]> data() {
private ContentType contentType;
private String containerClassName;
private String channelType;
private static EmbeddedContainer container;
protected static EmbeddedContainer container;

private static final ServerApp SERVER_APP_APP = new ServerApp("/chat", false, "localhost", 8787);

Expand Down

0 comments on commit e9a68c8

Please sign in to comment.