/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* A simple application used by unit tests. The first argument to this
* class is the name of a file to which a TCP port number can be written.
*
* By default, this class does nothing other than bind to a TCP port,
* write the TCP port number to a file, and wait for an incoming connection
* in order to complete the application shutdown protocol.
*/
public class SimpleApplication {
// protected so a subclass can extend it; not public so creation is
// limited.
protected SimpleApplication() {
// save simple app (or subclass) name for messages
}
// return the simple application (or a subclass)
return myApp;
}
// set the simple application (for use by a subclass)
}
// execute the application finish protocol
myPort);
// wait for test harness to connect
s.close();
}
// execute the application start protocol
" port-file [arg(s)]");
}
// bind to a random port
// Write the port number to the given file
myPort);
}
// execute the app work (subclass can override this)
}
// create myApp since a subclass hasn't done so
myApp = new SimpleApplication();
}
" doMyAppWork()");
}
}