You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/29 07:13:33 UTC
svn commit: r468837 - in
/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src:
main/java/java/rmi/activation/ test/api/java/org/apache/harmony/rmi/tests/
test/api/java/org/apache/harmony/rmi/tests/java/
test/api/java/org/apache/harmony/rmi/tests/...
Author: ndbeyer
Date: Sat Oct 28 23:13:32 2006
New Revision: 468837
URL: http://svn.apache.org/viewvc?view=rev&rev=468837
Log:
Cleanup ActivationGroupDesc and add RI-based test cases to assert correctness.
Added:
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDescTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDesc_CommandEnvironmentTest.java (with props)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroupDesc.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroupDesc.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroupDesc.java?view=diff&rev=468837&r1=468836&r2=468837
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroupDesc.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroupDesc.java Sat Oct 28 23:13:32 2006
@@ -16,67 +16,49 @@
* limitations under the License.
*/
-/**
- * @author Victor A. Martynov
- * @version $Revision: 1.9.2.2 $
- */
package java.rmi.activation;
import java.io.Serializable;
import java.rmi.MarshalledObject;
+import java.util.Arrays;
import java.util.Properties;
-
-/**
- * @com.intel.drl.spec_ref
- *
- * @author Victor A. Martynov
- * @version $Revision: 1.9.2.2 $
- */
public final class ActivationGroupDesc implements Serializable {
-
private static final long serialVersionUID = -4936225423168276595L;
/**
* The group's fully package qualified class name.
*/
- String className;
+ private String className;
/**
* The location from where to load the group's class.
*/
- String location;
+ private String location;
/**
* The group's initialization data.
*/
- MarshalledObject data;
+ private MarshalledObject data;
/**
* The controlling options for executing the VM in another process.
*/
- ActivationGroupDesc.CommandEnvironment env;
+ private ActivationGroupDesc.CommandEnvironment env;
/**
- * A properties map which will override those set by default in the subprocess environment
+ * A properties map which will override those set by default in the
+ * subprocess environment
*/
- Properties props;
+ private Properties props;
- /**
- * @com.intel.drl.spec_ref
- */
- public ActivationGroupDesc(Properties props,
- ActivationGroupDesc.CommandEnvironment env) {
+ public ActivationGroupDesc(Properties props, ActivationGroupDesc.CommandEnvironment env) {
this(null, null, null, props, env);
}
- /**
- * @com.intel.drl.spec_ref
- */
- public ActivationGroupDesc(String className, String codebase,
- MarshalledObject data, Properties props,
- ActivationGroupDesc.CommandEnvironment env) {
-
+ public ActivationGroupDesc(String className, String codebase, MarshalledObject data,
+ Properties props, ActivationGroupDesc.CommandEnvironment env) {
+ super();
this.className = className;
this.location = codebase;
this.data = data;
@@ -84,141 +66,119 @@
this.env = env;
}
- /**
- * @com.intel.drl.spec_ref
- */
public String getClassName() {
return className;
}
- /**
- * @com.intel.drl.spec_ref
- */
public String getLocation() {
return location;
}
- /**
- * @com.intel.drl.spec_ref
- */
public MarshalledObject getData() {
return data;
}
- /**
- * @com.intel.drl.spec_ref
- */
public ActivationGroupDesc.CommandEnvironment getCommandEnvironment() {
return env;
}
- /**
- * @com.intel.drl.spec_ref
- */
public Properties getPropertyOverrides() {
- if (props == null) {
- return null;
- } else {
- return (Properties) props.clone();
- }
+ return props == null ? null : (Properties) props.clone();
}
- /**
- * @com.intel.drl.spec_ref
- */
- public boolean equals(Object obj) {
- if (obj instanceof ActivationGroupDesc) {
- ActivationGroupDesc obj_agd = (ActivationGroupDesc) obj;
- boolean p0, p1, p2, p3, p4, p5;
-
- p0 = (location == null) ? obj_agd.location == null : location
- .equals(obj_agd.location);
- p1 = (className == null) ? obj_agd.className == null : className
- .equals(obj_agd.className);
- p2 = (data == null) ? obj_agd.data == null : data
- .equals(obj_agd.data);
- p3 = (env == null) ? obj_agd.env == null : env.equals(obj_agd.env);
- p4 = (props == null) ? obj_agd.props == null : props
- .equals(obj_agd.props);
-
- return p0 & p1 & p2 & p3 & p4;
- }
- return false;
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
+ @Override
public int hashCode() {
- int h0 = (className == null) ? 0 : className.hashCode();
- int h1 = (location == null) ? 0 : location.hashCode();
- int h2 = (data == null) ? 0 : data.hashCode();
- int h3 = (props == null) ? 0 : props.hashCode();
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((className == null) ? 0 : className.hashCode());
+ result = prime * result + ((data == null) ? 0 : data.hashCode());
+ result = prime * result + ((env == null) ? 0 : env.hashCode());
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((props == null) ? 0 : props.hashCode());
+ return result;
+ }
- return h0 ^ h1 ^ h2 ^ h3;
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof ActivationGroupDesc)) {
+ return false;
+ }
+ final ActivationGroupDesc that = (ActivationGroupDesc) obj;
+ if (!(className == null ? that.className == null : className.equals(that.className))) {
+ return false;
+ }
+ if (!(data == null ? that.data == null : data.equals(that.data))) {
+ return false;
+ }
+ if (!(env == null ? that.env == null : env.equals(that.env))) {
+ return false;
+ }
+ if (!(location == null ? that.location == null : location.equals(that.location))) {
+ return false;
+ }
+ return (props == null ? that.props == null : props.equals(that.props));
}
- /**
- * @com.intel.drl.spec_ref
- */
public static class CommandEnvironment implements Serializable {
-
private static final long serialVersionUID = 6165754737887770191L;
- private String command = null;
+ private String command;
- private String options[] = null;
+ private String options[];
- /**
- * @com.intel.drl.spec_ref
- */
public CommandEnvironment(String command, String[] options) {
+ super();
this.command = command;
- this.options = options;
+ if (options == null) {
+ this.options = null;
+ } else {
+ this.options = new String[options.length];
+ System.arraycopy(options, 0, this.options, 0, options.length);
+ }
}
- /**
- * @com.intel.drl.spec_ref
- */
public String[] getCommandOptions() {
- if (this.options == null) {
+ if (options == null) {
return new String[0];
}
- return this.options;
+ return options.clone();
}
- /**
- * @com.intel.drl.spec_ref
- */
public String getCommandPath() {
return this.command;
}
- /**
- * @com.intel.drl.spec_ref
- */
- public boolean equals(Object obj) {
- if (obj instanceof CommandEnvironment) {
- CommandEnvironment casted_obj = (CommandEnvironment) obj;
- boolean p0 = casted_obj.getCommandPath().equals(command);
- boolean p1 = casted_obj.getCommandOptions().equals(options);
- return p0 && p1;
- }
- return false;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((command == null) ? 0 : command.hashCode());
+ result = prime * result + Arrays.hashCode(options);
+ return result;
}
- /**
- * @com.intel.drl.spec_ref
- */
- public int hashCode() {
- int hc = 0;
- if (command != null) {
- hc = hc ^ command.hashCode();
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof CommandEnvironment)) {
+ return false;
}
- if (options != null) {
- hc = hc ^ options.hashCode();
+ final CommandEnvironment that = (CommandEnvironment) obj;
+ if (!(command == null ? that.command == null : command.equals(that.command))) {
+ return false;
}
- return hc;
+ return Arrays.equals(options, that.options);
}
}
}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDescTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDescTest.java?view=auto&rev=468837
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDescTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDescTest.java Sat Oct 28 23:13:32 2006
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.rmi.tests.java.rmi.activation;
+
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupDesc.CommandEnvironment;
+import java.util.Properties;
+import junit.framework.TestCase;
+
+public class ActivationGroupDescTest extends TestCase {
+ public void testActivationGroupDescPropertiesCommandEnvironment() {
+ ActivationGroupDesc agd = new ActivationGroupDesc(null, null);
+ assertNull(agd.getClassName());
+ assertNull(agd.getLocation());
+ assertNull(agd.getData());
+ assertNull(agd.getPropertyOverrides());
+ assertNull(agd.getCommandEnvironment());
+ Properties p = new Properties();
+ p.setProperty("key", "value");
+ CommandEnvironment ce = new ActivationGroupDesc.CommandEnvironment("cmd", new String[] {
+ "option1", "option1" });
+ agd = new ActivationGroupDesc(p, ce);
+ assertNull(agd.getClassName());
+ assertNull(agd.getLocation());
+ assertNull(agd.getData());
+ assertNotSame(p, agd.getPropertyOverrides());
+ assertEquals(p, agd.getPropertyOverrides());
+ assertEquals(ce, agd.getCommandEnvironment());
+ }
+
+ public void testActivationGroupDescStringStringMarshalledObjectPropertiesCommandEnvironment() {
+ ActivationGroupDesc agd = new ActivationGroupDesc(null, null, null, null, null);
+ assertNull(agd.getClassName());
+ assertNull(agd.getLocation());
+ assertNull(agd.getData());
+ assertNull(agd.getPropertyOverrides());
+ assertNull(agd.getCommandEnvironment());
+ Properties p = new Properties();
+ p.setProperty("key", "value");
+ CommandEnvironment ce = new ActivationGroupDesc.CommandEnvironment("cmd", new String[] {
+ "option1", "option1" });
+ agd = new ActivationGroupDesc("className", "location", null, p, ce);
+ assertEquals("className", agd.getClassName());
+ assertEquals("location", agd.getLocation());
+ assertNull(agd.getData());
+ assertNotSame(p, agd.getPropertyOverrides());
+ assertEquals(p, agd.getPropertyOverrides());
+ assertEquals(ce, agd.getCommandEnvironment());
+ }
+
+ public void testHashCode() {
+ ActivationGroupDesc agd = new ActivationGroupDesc(null, null, null, null, null);
+ assertEquals(agd.hashCode(), new ActivationGroupDesc(null, null, null, null, null)
+ .hashCode());
+ agd = new ActivationGroupDesc("className", "codebase", null, null, null);
+ assertEquals(agd.hashCode(), new ActivationGroupDesc("className", "codebase", null,
+ null, null).hashCode());
+ }
+
+ public void testEqualsObject() {
+ ActivationGroupDesc agd = new ActivationGroupDesc(null, null, null, null, null);
+ assertEquals(agd, new ActivationGroupDesc(null, null, null, null, null));
+ Properties p = new Properties();
+ p.setProperty("key", "value");
+ CommandEnvironment ce = new ActivationGroupDesc.CommandEnvironment("cmd", new String[] {
+ "option1", "option1" });
+ agd = new ActivationGroupDesc("className", "location", null, p, ce);
+ assertEquals(agd, new ActivationGroupDesc("className", "location", null, p, ce));
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDescTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDesc_CommandEnvironmentTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDesc_CommandEnvironmentTest.java?view=auto&rev=468837
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDesc_CommandEnvironmentTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDesc_CommandEnvironmentTest.java Sat Oct 28 23:13:32 2006
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.rmi.tests.java.rmi.activation;
+
+import java.rmi.activation.ActivationGroupDesc.CommandEnvironment;
+import java.util.Arrays;
+import junit.framework.TestCase;
+
+public class ActivationGroupDesc_CommandEnvironmentTest extends TestCase {
+ public void testCommandEnvironment() {
+ CommandEnvironment ce = new CommandEnvironment(null, null);
+ assertNull(ce.getCommandPath());
+ assertNotNull(ce.getCommandOptions());
+ assertEquals(0, ce.getCommandOptions().length);
+ String[] options = new String[] { "option1", "option2" };
+ ce = new CommandEnvironment("cmd", options);
+ assertEquals("cmd", ce.getCommandPath());
+ assertNotSame(options, ce.getCommandOptions());
+ assertTrue(Arrays.equals(options, ce.getCommandOptions()));
+ }
+
+ public void testHashCode() {
+ CommandEnvironment ce = new CommandEnvironment(null, null);
+ assertEquals(ce.hashCode(), new CommandEnvironment(null, null).hashCode());
+ ce = new CommandEnvironment("cmd", new String[] { "option1", "option2" });
+ assertEquals(ce.hashCode(), new CommandEnvironment("cmd", new String[] { "option1",
+ "option2" }).hashCode());
+ }
+
+ public void testEqualsObject() {
+ CommandEnvironment ce = new CommandEnvironment(null, null);
+ assertEquals(ce, new CommandEnvironment(null, null));
+ ce = new CommandEnvironment("cmd", new String[] { "option1", "option2" });
+ assertEquals(ce, new CommandEnvironment("cmd", new String[] { "option1", "option2" }));
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/tests/java/rmi/activation/ActivationGroupDesc_CommandEnvironmentTest.java
------------------------------------------------------------------------------
svn:eol-style = native