You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2012/12/17 11:50:47 UTC
svn commit: r1422847 - in /openejb/trunk/openejb:
container/openejb-core/src/test/java/org/apache/openejb/config/
server/openejb-client/src/main/java/org/apache/openejb/client/
server/openejb-client/src/test/java/org/apache/openejb/client/
server/opene...
Author: andygumbrecht
Date: Mon Dec 17 10:50:45 2012
New Revision: 1422847
URL: http://svn.apache.org/viewvc?rev=1422847&view=rev
Log:
Use 'ejbd.port' also for default.
Use junit assert for tests ;-)
Throw RuntimeException on ProtocolMetaData mismatch.
Modified:
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/ApplicationPropertiesTest.java
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ProtocolMetaData.java
openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JNDIContextTest.java
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/ApplicationPropertiesTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/ApplicationPropertiesTest.java?rev=1422847&r1=1422846&r2=1422847&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/ApplicationPropertiesTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/ApplicationPropertiesTest.java Mon Dec 17 10:50:45 2012
@@ -71,9 +71,9 @@ public class ApplicationPropertiesTest e
/**
* A child module META-INF/application.properties sets color to white
- *
+ * <p/>
* In the root ear META-INF/application.properties color is set to orange
- *
+ * <p/>
* The root ear META-INF/application.properties wins
*
* @throws Exception
@@ -96,11 +96,11 @@ public class ApplicationPropertiesTest e
final Map<String, String> appFiles = new HashMap<String, String>();
appFiles.put("META-INF/application.xml", "" +
- "<application id=\"fooApp\">\n" +
- " <module>\n" +
- " <ejb>"+module.getName()+"</ejb>\n" +
- " </module>\n" +
- "</application>");
+ "<application id=\"fooApp\">\n" +
+ " <module>\n" +
+ " <ejb>" + module.getName() + "</ejb>\n" +
+ " </module>\n" +
+ "</application>");
appFiles.put("META-INF/application.properties", "color=orange");
final File app = Archives.fileArchive(appFiles);
@@ -226,8 +226,9 @@ public class ApplicationPropertiesTest e
/**
* Not implemented. Don't do it if you want deterministic behavior
- *
+ * <p/>
* Use one or the other, use both and no guarantee is made
+ *
* @throws Exception
*/
public void _testOverrideUnprefixedVsPrefixedTomEEAndOpenEJB() throws Exception {
Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java?rev=1422847&r1=1422846&r2=1422847&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java (original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java Mon Dec 17 10:50:45 2012
@@ -128,15 +128,16 @@ public class JNDIContext implements Init
* Assuming that java.net.URI or java.net.URL are going to be used is overly stated
*/
String addMissingParts(String providerUrl) throws URISyntaxException {
+
+ final int port = Integer.parseInt(System.getProperty("ejbd.port", "4201"));
+
if (providerUrl == null || providerUrl.length() == 0) {
- providerUrl = DEFAULT_PROVIDER_URL;
+ providerUrl = "ejbd://localhost:" + port;
} else {
final int colonIndex = providerUrl.indexOf(":");
final int slashesIndex = providerUrl.indexOf("//");
- final int port = Integer.parseInt(System.getProperty("ejbd.port", "4201"));
-
if (colonIndex == -1 && slashesIndex == -1) { // hostname or ip address only
providerUrl = "ejbd://" + providerUrl + ":" + port;
} else if (colonIndex == -1) {
Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ProtocolMetaData.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ProtocolMetaData.java?rev=1422847&r1=1422846&r2=1422847&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ProtocolMetaData.java (original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ProtocolMetaData.java Mon Dec 17 10:50:45 2012
@@ -17,18 +17,18 @@
package org.apache.openejb.client;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.EOFException;
/**
* OpenEJB Enterprise Javabean Protocol (OEJP)
- *
+ * <p/>
* OEJP uses a "<major>.<minor>" numbering scheme to indicate versions of the protocol.
- *
- * Protocol-Version = "OEJP" "/" 1*DIGIT "." 1*DIGIT
- *
+ * <p/>
+ * Protocol-Version = "OEJP" "/" 1*DIGIT "." 1*DIGIT
+ * <p/>
* Some compatability is guaranteed with the major part of the version number.
*
* @version $Revision$ $Date$
@@ -45,18 +45,21 @@ public class ProtocolMetaData {
}
public ProtocolMetaData(final String version) {
- init(OEJB+"/"+version);
+ init(OEJB + "/" + version);
}
private void init(final String spec) {
- assert spec.matches("^OEJP/[0-9]\\.[0-9]$"): "Protocol version spec must follow format [ \"OEJB\" \"/\" 1*DIGIT \".\" 1*DIGIT ]";
+
+ if (!spec.matches("^OEJP/[0-9]\\.[0-9]$")) {
+ throw new RuntimeException("Protocol version spec must follow format [ \"OEJB\" \"/\" 1*DIGIT \".\" 1*DIGIT ]");
+ }
final char[] chars = new char[8];
spec.getChars(0, chars.length, chars, 0);
this.id = new String(chars, 0, 4);
- this.major = Integer.parseInt(new String(chars, 5,1));
- this.minor = Integer.parseInt(new String(chars, 7,1));
+ this.major = Integer.parseInt(new String(chars, 5, 1));
+ this.minor = Integer.parseInt(new String(chars, 7, 1));
}
public String getId() {
@@ -72,11 +75,11 @@ public class ProtocolMetaData {
}
public String getVersion() {
- return major+"."+minor;
+ return major + "." + minor;
}
public String getSpec() {
- return id+"/"+major+"."+minor;
+ return id + "/" + major + "." + minor;
}
public void writeExternal(final OutputStream out) throws IOException {
@@ -88,10 +91,10 @@ public class ProtocolMetaData {
final byte[] spec = new byte[8];
for (int i = 0; i < spec.length; i++) {
spec[i] = (byte) in.read();
- if (spec[i] == -1){
+ if (spec[i] == -1) {
throw new EOFException("Unable to read protocol version. Reached the end of the stream.");
}
}
- init(new String(spec,"UTF-8"));
+ init(new String(spec, "UTF-8"));
}
}
Modified: openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JNDIContextTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JNDIContextTest.java?rev=1422847&r1=1422846&r2=1422847&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JNDIContextTest.java (original)
+++ openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JNDIContextTest.java Mon Dec 17 10:50:45 2012
@@ -16,6 +16,7 @@
*/
package org.apache.openejb.client;
+import org.junit.Assert;
import org.junit.Test;
import javax.naming.Context;
@@ -72,6 +73,6 @@ public class JNDIContextTest {
env.put(Context.PROVIDER_URL, providerUrl);
final JNDIContext ctx = (JNDIContext) jndiContext.getInitialContext(env);
final String actualProviderUrl = ctx.addMissingParts(providerUrl);
- assert expectedProviderUrl.equals(actualProviderUrl) : "Expected " + expectedProviderUrl + " but was " + actualProviderUrl;
+ Assert.assertEquals("Expected " + expectedProviderUrl + " but was " + actualProviderUrl, expectedProviderUrl, actualProviderUrl);
}
}
Modified: openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java?rev=1422847&r1=1422846&r2=1422847&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java (original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java Mon Dec 17 10:50:45 2012
@@ -24,6 +24,7 @@ import org.apache.openejb.client.EJBMeta
import org.apache.openejb.client.EJBRequest;
import org.apache.openejb.client.InterfaceType;
import org.apache.openejb.loader.SystemInstance;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -40,23 +41,24 @@ public class DeploymentIndexTest {
public void setUp() throws SystemException {
method = Method.class.getMethods()[0];
beanContext = new BeanContext("aDeploymentId", null, new ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null, null, null, false), null), DeploymentIndexTest.class, null, null, null, null, null, null, null, null, null, null, false);
- deploymentIndex = new DeploymentIndex(new BeanContext[] {beanContext, beanContext});
+ deploymentIndex = new DeploymentIndex(new BeanContext[]{beanContext, beanContext});
}
@Test
public void testGetDeploymentEJBRequest() throws RemoteException {
- EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null, 1, InterfaceType.BUSINESS_REMOTE, null, null);
- EJBRequest request = new EJBRequest(null, ejbMetadataWithId, method, null, null);
- BeanContext info = deploymentIndex.getDeployment(request);
- assert beanContext.equals(info);
- assert request.getDeploymentId().equals(info.getDeploymentID());
+ final EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null, 1, InterfaceType.BUSINESS_REMOTE, null, null);
+ final EJBRequest request = new EJBRequest(null, ejbMetadataWithId, method, null, null);
+ final BeanContext info = deploymentIndex.getDeployment(request);
+
+ Assert.assertEquals(beanContext, info);
+ Assert.assertEquals(request.getDeploymentId(), info.getDeploymentID());
}
@Test(expected = RemoteException.class)
public void testGetDeploymentEJBRequestRemoteException() throws RemoteException {
// 0 causes DeploymentIndex to move further
- EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0, InterfaceType.BUSINESS_REMOTE, null, null);
- EJBRequest request = new EJBRequest(null, ejbMetadata, method, null, null);
+ final EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0, InterfaceType.BUSINESS_REMOTE, null, null);
+ final EJBRequest request = new EJBRequest(null, ejbMetadata, method, null, null);
deploymentIndex.getDeployment(request);
}