Skip to content
Permalink
Browse files
Merge branch 'support_skipped_fields' into 'ibm-trunk'
Support skipped fields

See merge request !57
  • Loading branch information
ngmr committed Aug 3, 2015
2 parents 4fb8a47 + f05ad39 commit 42b91100eba4a6877cbfe1bc311b826919d385f6
Showing 23 changed files with 1,173 additions and 94 deletions.
@@ -127,15 +127,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djava.endorsed.dirs=${basedir}/target/endorsed</argLine>
<includes>
<include>**/org/apache/yoko/*Test.java</include>
</includes>
<systemProperties>
<property>
<name>java.endorsed.dirs</name>
<value>${basedir}/target/endorsed</value>
</property>
</systemProperties>
</configuration>
</plugin>

@@ -1229,8 +1229,9 @@ static public void _OB_embedRecTC(TypeCode outer, TypeCode inner) {
if (inner.recId_ != null) {
if (inner.recId_.equals(outer.id_)) {
if (inner.recType_ != null) {
// Recursive TC already embedded - ensure it's the right one
org.apache.yoko.orb.OB.Assert
._OB_assert(inner.recType_ != outer);
._OB_assert(inner.recType_ == outer);
} else {
//
// Embed the recursive placeholder TypeCode
@@ -37,23 +37,23 @@
* It also sets the java.endorsed.dirs property and launches the client process.
*
* Currently, the client waits for the server to create a file containing an IOR. This
* is used to delay the client until the server has started. the setWaitFile(File) method
* is used to delay the client until the server has started. the setWaitFile(File) method
* can be used to set the name of this file, which varies in the ORB tests.
*/
public class AbstractOrbTestBase extends TestCase {
protected ProcessManager processManager;
protected JavaProcess server, client;
protected File waitForFile;
int waitForFileTimeout = 10000;

public AbstractOrbTestBase() {
super();
}

public AbstractOrbTestBase(String name) {
super(name);
}

protected void setUp() throws Exception {
super.setUp();
processManager = new ProcessManager(Registry.REGISTRY_PORT);
@@ -84,15 +84,15 @@ public void tearDown() throws Exception {
getWaitForFile().delete();
}
}

protected void runServerClientTest(Class<?> serverClass, Class<?> clientClass, String...commonArgs) throws Exception {
runServerClientTest(serverClass.getName(), commonArgs, clientClass.getName(), commonArgs);
}

protected void runServerClientTest(String serverClass, String clientClass) throws Exception {
runServerClientTest(serverClass, new String[0], clientClass, new String[0]);
}
protected void runServerClientTest(String serverClass, String[] serverArgs,
protected void runServerClientTest(String serverClass, String[] serverArgs,
String clientClass, String[] clientArgs) throws Exception {
server.launch();
Future<Void> serverFuture = server.invokeMainAsync(serverClass, serverArgs);
@@ -108,34 +108,38 @@ protected void runServerClientTest(String serverClass, String[] serverArgs,
}
server.exit(0);
}

public void setWaitForFile(String file) {
this.waitForFile = new File(file);
}

public File getWaitForFile() {
public final File getWaitForFile() {
return waitForFile;
}

protected void waitForFile() {
File file = getWaitForFile();
if(file != null) {
waitFor(file, waitForFileTimeout);
}
}

public static void waitFor(File file, int timeout) throws Error {
long timeBefore = System.currentTimeMillis();
if(getWaitForFile() != null) {
while(true) {
do {
try {
if(getWaitForFile().exists()) {
if(file.exists()) {
break;
}
Thread.sleep(50);
if(System.currentTimeMillis() > timeBefore + waitForFileTimeout) {
fail("The file " + getWaitForFile() +
" was not created within " + waitForFileTimeout + "ms");
if(System.currentTimeMillis() > timeBefore + timeout) {
fail("The file " + file + " was not created within " + timeout + "ms");
}
}
catch(InterruptedException e) {
throw new Error(e);
}
getWaitForFile().deleteOnExit();
}
}
}
} while(true);
file.deleteOnExit();
}
}
@@ -0,0 +1,36 @@
/**
*
* 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.
*/

/**
* @version $Rev: 491396 $ $Date: 2006-12-30 22:06:13 -0800 (Sat, 30 Dec 2006) $
*/
package org.apache.yoko;

import static test.fvd.Marshalling.VERSION1;
import static test.fvd.Marshalling.VERSION2;
import test.fvd.MissingFieldsClient;
import test.fvd.MissingFieldsServer;

public class FVDTest extends AbstractOrbTestBase {
public void testMissingFields() throws Exception {
if (true) return;
final String refFile = "missingfields.ref";
setWaitForFile(refFile);
runServerClientTest(MissingFieldsServer.class, MissingFieldsClient.class, refFile, VERSION1.name(), VERSION2.name());
}
}
@@ -1,18 +1,49 @@
package org.apache.yoko;

import java.io.Serializable;

import javax.rmi.CORBA.Util;
import javax.rmi.CORBA.ValueHandler;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.omg.CORBA.ValueDefPackage.FullValueDescription;
import org.omg.SendingContext.CodeBase;

import test.fvd.Marshalling;

public class MetaTest extends TestCase {

public class MetaTest extends AbstractOrbTestBase {
public static void testMetaForClassWithASelfReference() throws Exception {
ValueHandler vh = Util.createValueHandler();
CodeBase codebase = (CodeBase)vh.getRunTimeCodeBase();
String dataClassRepid = vh.getRMIRepositoryID(Data.class);
FullValueDescription fvd = codebase.meta(dataClassRepid);
Assert.assertNotNull(fvd);
}

public void testMetaForClassWithTwoSelfReferences() {
Marshalling.DEFAULT_VERSION.select();
ValueHandler vh = Util.createValueHandler();
CodeBase codebase = (CodeBase)vh.getRunTimeCodeBase();
String dataClassRepid = vh.getRMIRepositoryID(X.class);
System.out.println(dataClassRepid);
FullValueDescription fvd = codebase.meta(dataClassRepid);
Assert.assertNotNull(fvd);
}

@Before
public void setUp() throws Exception {
super.setUp();
setWaitForFile("Test.ref");
public static class Data implements Serializable {
private static final long serialVersionUID = 1L;
public Data d;
}

@Test
public void testMeta() throws Exception {
client.invokeMain("test.meta.TestMeta");
public static class X {
X x1;
X x2;
}
}


@@ -18,11 +18,19 @@
package test.common;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.rmi.Remote;

import javax.rmi.PortableRemoteObject;

import org.omg.CORBA.ORB;
import org.omg.CORBA.portable.IDLEntity;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextPackage.InvalidName;
@@ -43,14 +51,20 @@ public static org.omg.CORBA.TypeCode getOrigType(org.omg.CORBA.TypeCode tc) {

protected static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object obj,
NamingContextExt context, NameComponent[] name) throws InvalidName {
writeRef(orb, out, obj, context.to_string(name));
}

private static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object obj, String name) {
out.println("ref:");
String ref = orb.object_to_string(obj);
out.println(ref);
String nameString = context.to_string(name);
out.println(nameString);
out.println(orb.object_to_string(obj));
out.println(name);
}

protected static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object obj) {
writeRef(orb, out, obj, "");
}

protected static void readRef(BufferedReader reader, String[] refStrings) throws IOException {
protected static String[] readRef(BufferedReader reader, String[] refStrings) throws IOException {
String line = reader.readLine();
if (line == null) {
throw new RuntimeException("Unknown Server error");
@@ -65,8 +79,35 @@ protected static void readRef(BufferedReader reader, String[] refStrings) throws
throw new RuntimeException(sw.toString());
}
}
refStrings[0] = reader.readLine(); // IOR
refStrings[1] = reader.readLine(); // name
System.out.println(refStrings[1] + " = "+ refStrings[0]);
refStrings[0] = reader.readLine();
refStrings[1] = reader.readLine();
return refStrings;
}

private static org.omg.CORBA.Object readGenericStub(ORB orb, BufferedReader reader) throws IOException {
return orb.string_to_object(readRef(reader, new String[2])[0]);
}

@SuppressWarnings("unchecked")
protected static<T extends Remote> T readRmiStub(ORB orb, BufferedReader reader, Class<T> type) throws ClassCastException, IOException {
return (T)PortableRemoteObject.narrow(readGenericStub(orb, reader), type);
}

@SuppressWarnings("unchecked")
protected static<T extends IDLEntity> T readIdlStub(ORB orb, BufferedReader reader, Class<T> type) throws ClassCastException, IOException {
return (T)PortableRemoteObject.narrow(readGenericStub(orb, reader), type);
}

protected static BufferedReader openFileReader(final String refFile) throws FileNotFoundException {
return new BufferedReader(new FileReader(refFile)) {
@Override
public void close() throws IOException {
try {
super.close();
} finally {
Files.delete(Paths.get(refFile));
}
}
};
}
}
@@ -0,0 +1,7 @@
package test.fvd;

import java.io.Serializable;

public interface Abstract extends Serializable {

}

0 comments on commit 42b9110

Please sign in to comment.