*not part of the build*

fix for 80938
a = avm@sparc.spb.su
    ovk@sparc.spb.su
    sva@sparc.spb.su

Tests for blackConnect


git-svn-id: svn://10.0.0.236/trunk@95860 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
2001-05-24 05:22:13 +00:00
parent d74ff774aa
commit 6e4a0fdecc
214 changed files with 17250 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
*/
/*
* ExecutionThread.java
*/
import org.mozilla.xpcom.*;
import java.util.Date;
public class ExecutionThread extends Thread {
public static int MAX_TIMEOUT = 20000;
int timeout = Integer.MAX_VALUE;
public static long ID = 0;
iMThreadComponent component;
public ExecutionThread(iMThreadComponent component){
this.ID = new Date().getTime();
this.setName(Long.toHexString(ID));
this.component = component;
}
public ExecutionThread(iMThreadComponent component, int timeout){
this.ID = new Date().getTime();
this.setName(Long.toHexString(ID));
this.component = component;
if(timeout < MAX_TIMEOUT) {
this.timeout = timeout;
}else {
this.timeout = MAX_TIMEOUT;
}
}
public int timeoutGen() {
return (int)Math.round(Math.random()*MAX_TIMEOUT);
}
public void run(){
try {
if(timeout == Integer.MAX_VALUE) {
timeout = timeoutGen();
}
System.out.println("ExecutionThread(" + getName() + ") sleep to " + timeout);
sleep(timeout);
component.execute(getName());
} catch (Exception e) {
System.out.println("Execution thread had been interrupted");
}
}
}

View File

@@ -0,0 +1,181 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
The contents of this file are subject to the Mozilla Public
License Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
Client QA Team, St. Petersburg, Russia
*/
#include "plstr.h"
#include "prenv.h"
#include "stdio.h"
#include "nsMemory.h"
#include "BCTest.h"
#include <sys/stat.h>
#include <stdlib.h>
#include "MThreadContext.h"
#include "prmem.h"
#include "nsString.h"
#include "nsStringUtil.h"
#include "nsID.h"
nsIComponentManager* cm;
char **componentList;
int currentPosition = 0;
#define MT_COMPONENT_LIST_VAR_NAME "MT_COMPONENT_LIST"
MThreadContextImpl::MThreadContextImpl()
{
NS_INIT_REFCNT();
printf("DEbug:avm:MThreadContextImpl::MThreadContextImp\n");
nsresult rv = NS_GetGlobalComponentManager(&cm);
if(NS_FAILED(rv)) {
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
}
componentList = LoadComponentList();
}
MThreadContextImpl::~MThreadContextImpl()
{
//nb
}
NS_IMPL_ISUPPORTS1(MThreadContextImpl, iMThreadContext);
NS_IMETHODIMP MThreadContextImpl::GetNext(char **_retstr) {
nsCID aClass;
if(componentList == NULL) {
*_retstr = NULL;
return NS_OK; //nb
}
if(componentList[currentPosition]) {
*_retstr = componentList[currentPosition];
printf("MThreadContextImpl::GetNext. ContractID = %s\n",*_retstr);
nsresult rv = cm->ContractIDToClassID(*_retstr, &aClass);
if(NS_FAILED(rv)) {
printf("MThreadContextImpl::GetNext. Can't convert ContractID to ClassID\n");
*_retstr = NULL;
return NS_OK;
}else {
printf("MThreadContextImpl::GetNext. SUCCESS convert ContractID to ClassID\n");
}
*_retstr = aClass.ToString();
printf("MThreadContextImpl::GetNext. ClassID = %s\n",*_retstr);
currentPosition++;
} else {
*_retstr = NULL;
}
return NS_OK;
}
/*
NS_IMETHODIMP MThreadContextImpl::Initialize(const char* serverProgID)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP MThreadContextImpl::Execute(){
return NS_ERROR_NOT_IMPLEMENTED;
}
*/
NS_IMETHODIMP MThreadContextImpl::GetComponentManager(nsIComponentManager **_retval) {
*_retval = cm;
return NS_OK;
}
char** MThreadContextImpl::LoadComponentList() {
struct stat st;
FILE *file = NULL;
char *content;
int nRead, nTests, count = 0;
char *pos, *pos1;
char **testList;
char *lstFile = PR_GetEnv(MT_COMPONENT_LIST_VAR_NAME);
if(lstFile == NULL) {
fprintf(stderr, "ERROR: %s value is'n set\n",MT_COMPONENT_LIST_VAR_NAME);
return NULL;
}
if (stat(lstFile, &st) < 0) {
fprintf(stderr, "ERROR: can't get stat from file %s\n",lstFile);
return NULL;
}
content = (char*)calloc(1, st.st_size+1);
if ((file = fopen(lstFile, "r")) == NULL) {
fprintf(stderr, "ERROR: can't open file %s\n",lstFile);
return NULL;
}
if ((nRead = fread(content, 1, st.st_size, file)) < st.st_size) {
fprintf(stderr, "WARNING: can't read entire file in text mode (%d of %d) !\n", nRead, st.st_size);
//return;
}
content[nRead] = 0;
printf("File content: %s\n", content);
fclose(file);
//allocate maximal possible size
nTests = countChars(content, '\n') + 2;
printf("nTests = %d\n", nTests);
testList = (char**)calloc(sizeof(char*), nTests);
testList[0] = 0;
pos = content;
while((pos1 = PL_strchr(pos, '\n'))) {
*pos1 = 0;
if(PL_strlen(pos) > 0 && *pos != '#') {
//printf("First char: %c\n", *pos);
testList[count++] = PL_strdup(pos);
}
pos = pos1+1;
if (!(*pos)) {
printf("Parser done: %d .. ", count);
testList[count] = 0;
printf("ok\n");
break;
}
}
//If there is no \n after last line
if (PL_strlen(pos) > 0 && *pos != '#') {
testList[count++] = PL_strdup(pos);
testList[count] = 0;
}
//free(content);
return testList;
}
int MThreadContextImpl::countChars(char* buf, char ch) {
char *pos = buf;
int count = 0;
while((pos = PL_strchr(pos, ch))) {
pos++;
count++;
}
return count;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
The contents of this file are subject to the Mozilla Public
License Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
Client QA Team, St. Petersburg, Russia
*/
#include "iMThreadContext.h"
class MThreadContextImpl : public iMThreadContext
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMTHREADCONTEXT
char** LoadComponentList();
int countChars(char* buf, char ch);
MThreadContextImpl();
virtual ~MThreadContextImpl();
};
class _MYCLASS_ : public iMThreadContext
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMTHREADCONTEXT
_MYCLASS_();
virtual ~_MYCLASS_();
/* additional members */
};

View File

@@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
The contents of this file are subject to the Mozilla Public
License Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
Client QA Team, St. Petersburg, Russia
*/
#include "nsIGenericFactory.h"
#include "MThreadContext.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(MThreadContextImpl)
static nsModuleComponentInfo components[] =
{
{ "J2XIN Server Test Component", MTHREADCONTEXT_CID, MTHREADCONTEXT_PROGID, MThreadContextImplConstructor,
NULL /* NULL if you dont need one */,
NULL /* NULL if you dont need one */
}
};
NS_IMPL_NSGETMODULE("MThreadContextFactory", components)

View File

@@ -0,0 +1,60 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (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.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=../../../../../..
topsrcdir = $(DEPTH)
srcdir = .
VPATH = .
include $(DEPTH)/config/autoconf.mk
MODULE = MThreadContext
LIBRARY_NAME = $(MODULE)
XPIDL_MODULE = $(MODULE)
IS_COMPONENT = 1
CPPSRCS = \
MThreadContext.cpp \
MThreadContextFactory.cpp \
$(NULL)
DSO_LDOPTS += \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
XPIDLSRCS = iMThreadContext.idl \
iMThreadComponent.idl
JAVAI_SRC = iMThreadContext.java \
iMThreadComponent.java
JAVA_SRC = ExecutionThread.java
include $(topsrcdir)/config/rules.mk
export::
$(JDKHOME)/bin/javac -classpath $(DIST)/classes -d $(DIST)/classes $(JAVAI_SRC)
$(JDKHOME)/bin/javac -classpath $(DIST)/classes -d $(DIST)/classes $(JAVA_SRC)

View File

@@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
The contents of this file are subject to the Mozilla Public
License Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
Client QA Team, St. Petersburg, Russia
*/
#include "nsISupports.idl"
#include "iMThreadContext.idl"
[scriptable, uuid(b4d98604-3226-4077-abf0-b3aa2a4eff26)]
interface iMThreadComponent : nsISupports
{
void Initialize(in iMThreadContext c);
void Execute(in string tName);
};

View File

@@ -0,0 +1,33 @@
/*
* ************* DO NOT EDIT THIS FILE ***********
*
* This file was automatically generated from iMThreadComponent.idl.
*/
package org.mozilla.xpcom;
/**
* Interface iMThreadComponent
*
* IID: 0xb4d98604-3226-4077-abf0-b3aa2a4eff26
*/
public interface iMThreadComponent extends nsISupports
{
public static final IID IID =
new IID("b4d98604-3226-4077-abf0-b3aa2a4eff26");
/* void Initialize (in iMThreadContext c); */
public void initialize(iMThreadContext c);
/* void Execute (in string tName); */
public void execute(String tName);
}
/*
* end
*/

View File

@@ -0,0 +1,95 @@
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM iMThreadContext.idl
*/
#ifndef __gen_iMThreadContext_h__
#define __gen_iMThreadContext_h__
#include "nsISupports.h"
#include "nsIComponentManager.h"
/* starting interface: iMThreadContext */
#define IMTHREADCONTEXT_IID_STR "a7b26685-9816-4eb6-a075-36f539a7a823"
#define IMTHREADCONTEXT_IID \
{0xa7b26685, 0x9816, 0x4eb6, \
{ 0xa0, 0x75, 0x36, 0xf5, 0x39, 0xa7, 0xa8, 0x23 }}
class NS_NO_VTABLE iMThreadContext : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(IMTHREADCONTEXT_IID)
/* string GetNext (); */
NS_IMETHOD GetNext(char **_retval) = 0;
/* nsIComponentManager GetComponentManager (); */
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval) = 0;
};
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_IMTHREADCONTEXT \
NS_IMETHOD GetNext(char **_retval); \
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_IMTHREADCONTEXT(_to) \
NS_IMETHOD GetNext(char **_retval) { return _to ## GetNext(_retval); } \
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval) { return _to ## GetComponentManager(_retval); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class _MYCLASS_ : public iMThreadContext
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMTHREADCONTEXT
_MYCLASS_();
virtual ~_MYCLASS_();
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(_MYCLASS_, iMThreadContext)
_MYCLASS_::_MYCLASS_()
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
}
_MYCLASS_::~_MYCLASS_()
{
/* destructor code */
}
/* string GetNext (); */
NS_IMETHODIMP _MYCLASS_::GetNext(char **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIComponentManager GetComponentManager (); */
NS_IMETHODIMP _MYCLASS_::GetComponentManager(nsIComponentManager **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#define MTHREADCONTEXT_CID \
{ /* 139b8350-280a-46d0-8afc-f1939173c2ea */ \
0x139b8350, \
0x280a, \
0x46d0, \
{0x8a, 0xfc, 0xf1, 0x93, 0x91, 0x73, 0xc2, 0xea} \
}
#define MTHREADCONTEXT_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MThreadContext"
#endif /* __gen_iMThreadContext_h__ */

View File

@@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
The contents of this file are subject to the Mozilla Public
License Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
Client QA Team, St. Petersburg, Russia
*/
#include "nsISupports.idl"
#include "nsIComponentManager.idl"
[scriptable, uuid(a7b26685-9816-4eb6-a075-36f539a7a823)]
interface iMThreadContext : nsISupports
{
string GetNext();
nsIComponentManager GetComponentManager();
};
%{ C++
#define MTHREADCONTEXT_CID \
{ /* 139b8350-280a-46d0-8afc-f1939173c2ea */ \
0x139b8350, \
0x280a, \
0x46d0, \
{0x8a, 0xfc, 0xf1, 0x93, 0x91, 0x73, 0xc2, 0xea} \
}
#define MTHREADCONTEXT_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MThreadContext"
%}

View File

@@ -0,0 +1,33 @@
/*
* ************* DO NOT EDIT THIS FILE ***********
*
* This file was automatically generated from iMThreadContext.idl.
*/
package org.mozilla.xpcom;
/**
* Interface iMThreadContext
*
* IID: 0xa7b26685-9816-4eb6-a075-36f539a7a823
*/
public interface iMThreadContext extends nsISupports
{
public static final IID IID =
new IID("a7b26685-9816-4eb6-a075-36f539a7a823");
/* string GetNext (); */
public String getNext();
/* nsIComponentManager GetComponentManager (); */
public nsIComponentManager getComponentManager();
}
/*
* end
*/

View File

@@ -0,0 +1,63 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (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.mozilla.org\NPL\
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..\..\..
topsrcdir = $(DEPTH)
srcdir = .
VPATH = .
MODULE = MThreadContext
MAKE_OBJ_TYPE =DLL
DLLNAME =$(MODULE)
DLL =.\$(OBJDIR)\$(DLLNAME).dll
COMPONENT = 1
JAVAI = iMThreadContext.java \
iMThreadComponent.java
JAVA_SRC = ExecutionThread.java
XPIDLSRCS = \
.\iMThreadContext.idl \
.\iMThreadComponent.idl\
$(NULL)
CPP_OBJS = \
.\$(OBJDIR)\MThreadContext.obj \
.\$(OBJDIR)\MThreadContextFactory.obj \
$(NULL)
LLIBS =$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib
include <$(topsrcdir)\config\rules.mak>
javai:
echo $(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes:$(CLASSPATH) -d $(DEPTH)\dist\classes $(JAVAI) $(JAVA_SRC)
$(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes:$(CLASSPATH) -d $(DEPTH)\dist\classes $(JAVAI) $(JAVA_SRC)
install:: $(DLL) javai
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
clobber::
del /f $(DIST)\bin\components\$(DLLNAME).dll
del /f $(DIST)\bin\components\$(DLLNAME).xpt
del /f $(DIST)\..\classes\org\mozilla\xpcom\iMThreadComponent.class
del /f $(DIST)\..\classes\org\mozilla\xpcom\iMThreadContext.class