You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/27 01:26:01 UTC
svn commit: r397337 [11/11] - in
/incubator/harmony/enhanced/classlib/trunk/modules/jndi: make/common/
src/test/java/com/sun/jndi/url/dir2/ src/test/java/com/sun/jndi/url/nntp/
src/test/java/jndiproperties/ src/test/java/org/ src/test/java/org/apache/
...
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,83 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.directory.Attributes;
+import javax.naming.spi.DirObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+
+public class MockDirObjectFactory implements DirObjectFactory {
+
+ Log log = new Log(MockDirObjectFactory.class);
+
+ /**
+ *
+ */
+ public MockDirObjectFactory() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.DirObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable,
+ * javax.naming.directory.Attributes)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h,
+ Attributes a) throws Exception {
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ if (null != a) {
+ r.put("a", a);
+ }
+ return r;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+ log.setMethod("getObjectInstance");
+ log.log("wrong method call");
+ return getObjectInstance(o, n, c, h, null);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactoryNoException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactoryNoException.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactoryNoException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactoryNoException.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,58 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.directory.Attributes;
+import javax.naming.spi.DirObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+
+public class MockDirObjectFactoryNoException implements DirObjectFactory {
+
+ Log log = new Log(MockDirObjectFactoryNoException.class);
+
+ public static final String OBJ = "MockDirObjectFactoryNoException";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.DirObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable,
+ * javax.naming.directory.Attributes)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c,
+ Hashtable envmt, Attributes a) throws Exception {
+
+ return OBJ;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable envmt)
+ throws Exception {
+ log.setMethod("getObjectInstance");
+ log.log("wrong method call");
+ return OBJ;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactoryNoException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirStateFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirStateFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirStateFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirStateFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,80 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.spi.DirStateFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+
+public class MockDirStateFactory implements DirStateFactory {
+
+ static Log log = new Log(MockDirStateFactory.class);
+
+ public MockDirStateFactory() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.DirStateFactory#getStateToBind(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable,
+ * javax.naming.directory.Attributes)
+ */
+ public Result getStateToBind(Object o, Name n, Context c, Hashtable h,
+ Attributes a) throws NamingException {
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ if (null != a) {
+ r.put("a", a);
+ }
+ return new Result(r, a);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.StateFactory#getStateToBind(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getStateToBind(Object o, Name n, Context c, Hashtable h)
+ throws NamingException {
+ return getStateToBind(o, n, c, h, null);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirStateFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockInitialContextFactoryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockInitialContextFactoryBuilder.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockInitialContextFactoryBuilder.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockInitialContextFactoryBuilder.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,69 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import javax.naming.spi.InitialContextFactoryBuilder;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+
+/*
+ * -------------------------------------------
+ * inner class for mock object
+ * -------------------------------------------
+ */
+public class MockInitialContextFactoryBuilder implements
+ InitialContextFactoryBuilder {
+
+ private static MockInitialContextFactoryBuilder _builder = new MockInitialContextFactoryBuilder();
+
+ public static MockInitialContextFactoryBuilder getInstance() {
+ return MockInitialContextFactoryBuilder._builder;
+ }
+
+ public InitialContextFactory createInitialContextFactory(Hashtable envmt)
+ throws NamingException {
+ NamingManagerTest.issueIndicatedExceptions(envmt);
+ if (NamingManagerTest.returnNullIndicated(envmt)) {
+ return null;
+ }
+ return new MockInitialContextFactory(envmt);
+ }
+
+ public static class MockInitialContextFactory implements
+ InitialContextFactory {
+ private Hashtable ht;
+
+ public Context getInitialContext(Hashtable envmt)
+ throws NamingException {
+ NamingManagerTest.issueIndicatedExceptions(envmt);
+ if (NamingManagerTest.returnNullIndicated(envmt)) {
+ return null;
+ }
+ return new MockContext(envmt);
+ }
+
+ public MockInitialContextFactory(Hashtable envmt) {
+ ht = envmt;
+ }
+
+ public MockInitialContextFactory() {
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockInitialContextFactoryBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContext.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContext.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,82 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.ExtendedRequest;
+import javax.naming.ldap.ExtendedResponse;
+import javax.naming.ldap.LdapContext;
+
+public class MockLdapContext extends MockDirContext implements LdapContext {
+ Hashtable ldapProps;
+
+ public MockLdapContext(Hashtable h) {
+ super(h);
+ this.ldapProps = (Hashtable) h.clone();
+ }
+
+ public Hashtable getProps() {
+ return this.ldapProps;
+ }
+
+ public ExtendedResponse extendedOperation(ExtendedRequest e)
+ throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"), e);
+ takeActions();
+ return null;
+ }
+
+ public LdapContext newInstance(Control[] ac) throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"), ac);
+ takeActions();
+ return null;
+ }
+
+ public void reconnect(Control[] ac) throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"), ac);
+ takeActions();
+ }
+
+ public Control[] getConnectControls() throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"),
+ "getConnectControls");
+ takeActions();
+ return null;
+ }
+
+ public void setRequestControls(Control[] ac) throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"), ac);
+ takeActions();
+ }
+
+ public Control[] getRequestControls() throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"),
+ "getRequestControls");
+ takeActions();
+ return null;
+ }
+
+ public Control[] getResponseControls() throws NamingException {
+ InvokeRecord.set((String) this.props.get("url.schema"),
+ "getResponseControls");
+ takeActions();
+ return null;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,30 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+public class MockLdapContextFactory implements InitialContextFactory {
+
+ public Context getInitialContext(Hashtable envmt) throws NamingException {
+ envmt.remove("url.schema");
+ return new MockLdapContext(envmt);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/SuccessMockDirStateFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/SuccessMockDirStateFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/SuccessMockDirStateFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/SuccessMockDirStateFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,46 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+public class SuccessMockDirStateFactory extends MockDirStateFactory {
+ public Result getStateToBind(Object o, Name n, Context c, Hashtable h,
+ Attributes a) throws NamingException {
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ if (null != a) {
+ r.put("a", a);
+ }
+ return new Result(r, a);
+
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/SuccessMockDirStateFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/a_b_cURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/a_b_cURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/a_b_cURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/a_b_cURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,59 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.a_b_c;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockDirContext;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+
+public class a_b_cURLContextFactory implements ObjectFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ r.put("url.schema", "a_b_c");
+ return new MockDirContext(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/a_b_cURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/abcURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/abcURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/abcURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/abcURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,59 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.abc;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockDirContext;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+
+public class abcURLContextFactory implements ObjectFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ r.put("url.schema", "abc");
+ return new MockDirContext(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/abcURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/direURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/direURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/direURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/direURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,96 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.dire;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.directory.Attributes;
+import javax.naming.spi.DirObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockDirContext3;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+
+public class direURLContextFactory implements DirObjectFactory {
+
+ Log log = new Log(direURLContextFactory.class);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+ // NamingManagerTest.issueIndicatedExceptions(h);
+ // if (NamingManagerTest.returnNullIndicated(h)) {
+ // return null;
+ // }
+ log
+ .setMethod("getObjectInstance(Object o, Name n, Context c, Hashtable h)");
+ log.log("wrong method called!");
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ return new MockDirContext3(r);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.DirObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable,
+ * javax.naming.directory.Attributes)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h,
+ Attributes a) throws Exception {
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ if (null != a) {
+ r.put("a", a);
+ }
+ return new MockDirContext3(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/direURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/ftpURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/ftpURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/ftpURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/ftpURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,50 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.ftp;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+
+// import util.Log;
+
+/**
+ * Allways succeed.
+ */
+public class ftpURLContextFactory implements ObjectFactory {
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ return new NamingManagerTest.MockContext(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/ftpURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/httpURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/httpURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/httpURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/httpURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,59 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.http;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockDirContext;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+
+public class httpURLContextFactory implements ObjectFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ r.put("url.schema", "http");
+ return new MockDirContext(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/httpURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/httpsURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/httpsURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/httpsURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/httpsURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,59 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.https;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockDirContext;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+
+public class httpsURLContextFactory implements ObjectFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
+ return null;
+ }
+
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ r.put("url.schema", "https");
+ return new MockDirContext(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/httpsURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/newsURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/newsURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/newsURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/newsURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,34 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mock.news;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+// import util.Log;
+
+/**
+ * Always return null.
+ */
+public class newsURLContextFactory implements ObjectFactory {
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+ return null;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/newsURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/httpURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/httpURLContextFactory.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/httpURLContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/httpURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,53 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.spi.mocksuccess.http;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockDirContext;
+
+public class httpURLContextFactory implements ObjectFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
+ throws Exception {
+
+ Hashtable r = new Hashtable();
+ if (null != o) {
+ r.put("o", o);
+ }
+ if (null != n) {
+ r.put("n", n);
+ }
+ if (null != c) {
+ r.put("c", c);
+ }
+ if (null != h) {
+ r.put("h", h);
+ }
+ r.put("url.schema", "http");
+ return new MockDirContext(r);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/httpURLContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/FileFilter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/FileFilter.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/FileFilter.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/FileFilter.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,152 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Filter out exception trace stack and any other sensitive or unnecessary
+ * content from the log file.
+ */
+public class FileFilter {
+
+ private static final int FILTER_EXCEPTION = 1;
+
+ private static final int FILTER_SUCCEED = 2;
+
+ // Can't initilaize
+ private FileFilter() {
+ }
+
+ private static boolean junitStartsWith(String line, String pattern) {
+ if (null == line) {
+ return false;
+ } else if (line.trim().startsWith("[junit]")) {
+ if (line.trim().substring(7).trim().startsWith(pattern)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Filter out exception trace stack and any other sensitive or unnecessary
+ * content from the log file.
+ *
+ * @param logFile
+ * @param flag
+ */
+ private static void filter(String logFile, int flag) {
+ FileInputStream fis = null;
+ BufferedReader reader = null;
+ FileOutputStream fos = null;
+ PrintStream ps = null;
+
+ try {
+ String pre = null;
+ String nxt = null;
+
+ File file = new File(logFile);
+
+ fis = new FileInputStream(logFile);
+ reader = new BufferedReader(new InputStreamReader(fis));
+ fos = new FileOutputStream(file.getParent()
+ + System.getProperty("file.separator") + "Clean_"
+ + file.getName());
+ ps = new PrintStream(fos);
+
+ while (true) {
+ nxt = reader.readLine();
+ if (null != pre) {
+ // filter out exception stack trace
+ if (0 != (flag & FILTER_EXCEPTION)) {
+ if (junitStartsWith(pre, "at ")) {
+ if (nxt == null) {
+ break;
+ } else {
+ pre = nxt;
+ }
+ continue;
+ }
+ }
+
+ // filter out succeeded testcase
+ if (0 != (flag & FILTER_SUCCEED)) {
+ if (junitStartsWith(pre, "Testcase: ")) {
+ if (junitStartsWith(nxt, "Testcase: ")
+ || junitStartsWith(nxt, "Testsuite: ")
+ || junitStartsWith(nxt, "TEST ")
+ || null == nxt) {
+ if (nxt == null) {
+ break;
+ } else {
+ pre = nxt;
+ }
+ continue;
+ }
+ }
+ }
+
+ ps.println(pre);
+ }
+
+ if (null == nxt) {
+ break;
+ } else {
+ pre = nxt;
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Filter exception: " + e.getMessage());
+ } finally {
+ try {
+ reader.close();
+ } catch (Exception e) {
+ }
+ try {
+ fis.close();
+ } catch (Exception e) {
+ }
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ fos.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ private static void deleteOldLog(String logFile) {
+ File file = new File(logFile);
+ file.delete();
+ }
+
+ public static void main(String[] args) {
+ try {
+ filter(args[0], Integer.parseInt(args[1]));
+ deleteOldLog(args[0]);
+ } catch (Exception e) {
+ System.out.println("Filter init exception: " + e.getMessage());
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/FileFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Log.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Log.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Log.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Log.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,192 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.text.SimpleDateFormat;
+
+public class Log {
+
+ private static PrintStream _out = null;
+
+ private static String latestClzname = null;
+
+ private static String latestMethod = null;
+
+ public synchronized static PrintStream getPrintStream() {
+ if (null != _out) {
+ return _out;
+ }
+
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ // _out =
+ // new PrintStream(
+ // new FileOutputStream(
+ // "/bluetrace_" + sdf.format(new Date()) + ".log",
+ // true));
+ _out = new PrintStream(new ByteArrayOutputStream());
+ } catch (Exception e) {
+ e.printStackTrace();
+ _out = System.err;
+ }
+ return _out;
+ }
+
+ public synchronized static void close() {
+ if (null != _out && System.err != _out) {
+ _out.println("Close log.");
+ _out.close();
+ }
+ _out = null;
+ }
+
+ private Class clz;
+
+ private String clzname;
+
+ private String method;
+
+ /**
+ * Constructor.
+ *
+ * @param clz
+ */
+ public Log(Class clz) {
+ this.clz = clz;
+
+ if (null != clz) {
+ clzname = clz.getName();
+ int dot = clzname.lastIndexOf('.');
+ clzname = clzname.substring(dot + 1);
+ }
+
+ // getPrintStream().println();
+ // getPrintStream().println(clzname + " inited.");
+ // getPrintStream().println();
+ }
+
+ /**
+ * Set method.
+ *
+ * @param method
+ */
+ public void setMethod(String method) {
+ this.method = method;
+
+ latestClzname = clzname;
+ latestMethod = method;
+ }
+
+ public void log(boolean b) {
+ log("" + b);
+ }
+
+ public void log(int i) {
+ log("" + i);
+ }
+
+ public void log(String msg) {
+ _log(clzname, method, msg);
+ }
+
+ public void log(Throwable t) {
+ if (t == null) {
+ log("Throwable instance is null.");
+ } else {
+ log(t.getMessage());
+ log("Throwable occured, type is " + t.getClass().getName());
+ }
+ //
+ // try {
+ // StringWriter strbuf = new StringWriter();
+ // PrintWriter tempout = new PrintWriter(strbuf);
+ // tempout.println(t.getMessage());
+ // t.printStackTrace(tempout);
+ // tempout.close();
+ // BufferedReader tempin =
+ // new BufferedReader(
+ // new StringReader(strbuf.getBuffer().toString()));
+ // String line;
+ // while ((line = tempin.readLine()) != null) {
+ // line = line.trim();
+ // if (line.startsWith("at javax.naming.Test")) {
+ // String method =
+ // line.substring(
+ // "at javax.naming.".length(),
+ // line.indexOf("("));
+ // String lineNumber =
+ // line.substring(
+ // line.indexOf(":") + 1,
+ // line.indexOf(")"));
+ // try {
+ // Integer.parseInt(lineNumber);
+ // } catch (NumberFormatException e1) {
+ // lineNumber = "";
+ // }
+ // log(method + "(" + lineNumber + ")");
+ // }
+ // }
+ // } catch (IOException e) {
+ // }
+ }
+
+ /**
+ * Log a message and an exception.
+ *
+ * @param method
+ * @param msg
+ * @param t
+ */
+ public void log(String msg, Throwable t) {
+ log(msg);
+ log(t);
+ }
+
+ private static void _log(String clzname, String method, String msg) {
+ if (clzname != null && method != null) {
+ latestClzname = clzname;
+ latestMethod = method;
+ } else {
+ clzname = latestClzname;
+ method = latestMethod;
+ }
+
+ PrintStream out = getPrintStream();
+
+ out.print(clzname);
+ out.print("\t");
+ out.print(method);
+ out.print("\t");
+ out.print(msg);
+ out.println();
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ // NamingException ex = new NamingException("test purpsoe");
+ // ex.setRemainingName(new CompositeName("RemainingName"));
+ // ex.setResolvedName(new CompositeName("RemainingName"));
+ // ex.setResolvedObj(new Integer(1));
+ // ex.setRootCause(new Exception("root exception"));
+ // ObjectOutputStream out =
+ // (ObjectOutputStream) new ObjectOutputStream(
+ // new FileOutputStream("test/data/NamingException.ser"));
+ // out.writeObject(ex);
+ // out.close();
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Log.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Person.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Person.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Person.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Person.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,166 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.util;
+
+import java.io.Serializable;
+
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+
+public class Person implements Serializable, Cloneable, Referenceable {
+ private static int maxId = 0;
+
+ int id;
+
+ String name;
+
+ String address;
+
+ int gender;
+
+ private Person() {
+ }
+
+ public static synchronized Person getInstance() {
+ Person result = new Person();
+ result.setId(++maxId);
+ result.setName("name" + maxId);
+ result.setGender(0);
+ result.setAddress("address" + maxId);
+ return result;
+ }
+
+ /**
+ * @return
+ */
+ public final String getAddress() {
+ return address;
+ }
+
+ /**
+ * @return
+ */
+ public final int getGender() {
+ return gender;
+ }
+
+ /**
+ * @return
+ */
+ public final int getId() {
+ return id;
+ }
+
+ /**
+ * @return
+ */
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * @param string
+ */
+ public final void setAddress(String string) {
+ address = string;
+ }
+
+ /**
+ * @param i
+ */
+ public final void setGender(int i) {
+ gender = i;
+ }
+
+ /**
+ * @param i
+ */
+ public final void setId(int i) {
+ id = i;
+ }
+
+ /**
+ * @param string
+ */
+ public final void setName(String string) {
+ name = string;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(100);
+ buffer.append(this.getClass().getName()).append(" : ");
+ buffer.append("id=").append(id);
+ buffer.append(",name=").append(name);
+ buffer.append(",gender=").append(gender);
+ buffer.append(",address=").append(address);
+ return buffer.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ boolean result = false;
+ if (o instanceof Person) {
+ Person p = (Person) o;
+ int id2 = p.getId();
+ int gender2 = p.getGender();
+ String name2 = p.getName();
+ String address2 = p.getAddress();
+ result = (id == id2)
+ && (gender == gender2)
+ && (null == name2 ? null == name : name2.equals(name))
+ && (null == address2 ? null == address : address2
+ .equals(address));
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + id;
+ result = 37 * result + gender;
+ if (null != name) {
+ result = 37 * result + name.hashCode();
+ }
+ if (null != address) {
+ result = 37 * result + address.hashCode();
+ }
+ return result;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.naming.Referenceable#getReference()
+ */
+ public Reference getReference() {
+ StringRefAddr addr = new StringRefAddr("StringRefAddr", toString());
+ Reference reference = new Reference(getClass().getName(), addr);
+ return reference;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Person.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Util.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Util.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Util.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Util.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,269 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.jndi.tests.javax.naming.util;
+
+import java.util.Hashtable;
+import java.util.Properties;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.directory.SearchResult;
+
+public final class Util {
+
+ /**
+ * Only entry to obtain an InitialContext instance.
+ *
+ * @return a new InitialContext instance
+ */
+ public static InitialContext getInitialContext() {
+ try {
+ Properties p = new Properties();
+ p.load(Util.class.getClassLoader().getResourceAsStream(
+ "jndi.properties"));
+ /*
+ * Hashtable ht = new Hashtable(); ht.put(
+ * Context.INITIAL_CONTEXT_FACTORY,
+ * "dazzle.jndi.testing.spi.DazzleContextFactory");
+ */
+ return new InitialContext(p);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Clean up, opposite to getInitialContext().
+ *
+ * @param ctx
+ * the InitialContext to clean up
+ */
+ public static void cleanUpInitialContext(InitialContext ctx) {
+
+ }
+
+ /**
+ * Only entry to obtain an InitialDirContext instance.
+ *
+ * @return a new InitialDirContext instance
+ */
+ public static InitialDirContext getInitialDirContext() {
+ try {
+ Properties p = new Properties();
+ p.load(Util.class.getClassLoader().getResourceAsStream(
+ "jndi.properties"));
+ Hashtable ht = new Hashtable();
+ ht.put(Context.INITIAL_CONTEXT_FACTORY,
+ "dazzle.jndi.testing.spi.DazzleContextFactory");
+ return new InitialDirContext(p);
+ } catch (Exception e) {
+ // e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Clean up, opposite to getInitialDirContext().
+ *
+ * @param ctx
+ * the InitialDirContext to clean up
+ */
+ public static void cleanUpInitialDirContext(InitialDirContext ctx) {
+
+ }
+
+ /**
+ * Format an Attribute to String
+ *
+ * @param a
+ * @return the string representation
+ */
+ public static String toString(Attribute a) {
+ if (a == null) {
+ return "NULL";
+ }
+
+ try {
+ StringBuffer buf = new StringBuffer();
+ buf.append(a.getID());
+ if (a.isOrdered()) {
+ buf.append("+o");
+ }
+ buf.append("=");
+ if (a.size() == 0) {
+ buf.append("null");
+ } else if (a.size() == 1) {
+ buf.append(a.get());
+ } else {
+ buf.append("[");
+ for (int i = 0; i < a.size(); i++) {
+ if (i != 0) {
+ buf.append(",");
+ }
+ buf.append(a.get(i) == null ? "null" : a.get(i));
+ }
+ buf.append("]");
+ }
+ return buf.toString();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return "NULL";
+ }
+ }
+
+ /**
+ * Format an Attributes to String
+ *
+ * @param as
+ * @return the string representation
+ */
+ public static String toString(Attributes as) {
+ if (as == null) {
+ return "NULL";
+ }
+
+ try {
+ if (as.size() == 0) {
+ return "{}";
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append("{ ");
+ NamingEnumeration enumeration = as.getAll();
+ int i = 0;
+ while (enumeration.hasMoreElements()) {
+ Attribute a = (Attribute) enumeration.nextElement();
+ if (i != 0) {
+ buf.append(", ");
+ }
+ buf.append(toString(a));
+ i++;
+ }
+ buf.append(" }");
+ return buf.toString();
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return "NULL";
+ }
+ }
+
+ /**
+ * Format a SearchResult to String
+ *
+ * @param r
+ * @return the string representation
+ */
+ public static String toString(SearchResult r) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(r.getName());
+ buf.append(" ");
+ buf.append(toString(r.getAttributes()));
+ buf.append(" = ");
+ buf.append(r.getObject());
+ return buf.toString();
+ }
+
+ /**
+ * Format a Context to String
+ *
+ * @param ctx
+ * @return the string representation
+ */
+ public static String toString(Context ctx) {
+ if (ctx == null) {
+ return "NULL";
+ }
+
+ try {
+ StringBuffer buf = new StringBuffer();
+ return toString(buf, 0, ctx);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return "NULL";
+ }
+ }
+
+ /**
+ * Format a DirContext to String
+ *
+ * @param ctx
+ * @return the string representation
+ */
+ public static String toString(DirContext ctx) {
+ if (ctx == null) {
+ return "NULL";
+ }
+
+ try {
+ StringBuffer buf = new StringBuffer();
+ return toString(buf, 0, ctx);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return "NULL";
+ }
+ }
+
+ private static String toString(StringBuffer buf, int i, Context ctx)
+ throws NamingException {
+
+ int j = i + 4;
+ space(buf, i);
+ buf.append(ctx + " {").append("\n");
+
+ NamingEnumeration enumeration = ctx.listBindings("");
+ while (enumeration.hasMoreElements()) {
+ Binding r = (Binding) enumeration.nextElement();
+ space(buf, j);
+ if (r.getName() != null) {
+ buf.append(r.getName());
+ if (ctx instanceof DirContext) {
+ buf.append(" ");
+ buf.append(toString(((DirContext) ctx).getAttributes(r
+ .getName())));
+ }
+ }
+ buf.append(" = ");
+ if (r.getObject() instanceof Context) {
+ toString(buf, j, (Context) r.getObject());
+ } else {
+ buf.append(r.getObject() == null ? "" : r.getObject());
+ }
+ buf.append("\n");
+ }
+
+ space(buf, i);
+ buf.append("}");
+ return buf.toString();
+ }
+
+ private static void space(StringBuffer buf, int n) {
+ for (int i = 0; i < n; i++) {
+ buf.append(' ');
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Context ctx = Util.getInitialContext();
+ ctx.bind("test", new Integer(200));
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Util.java
------------------------------------------------------------------------------
svn:eol-style = native