template version of LdapAdaptor No "real" content yet.
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9f309ff --- /dev/null +++ b/.gitmodules
@@ -0,0 +1,3 @@ +[submodule "lib/plexi"] + path = lib/plexi + url = https://code.google.com/p/plexi/
diff --git a/build.xml b/build.xml index a91cd6c..e4a5e70 100644 --- a/build.xml +++ b/build.xml
@@ -188,7 +188,7 @@ <fileset dir="${lib.dir}" includes="${tmp.adaptor.fileset}"/> </copy> - <!-- adaptor-ad-withlib.jar --> + <!-- adaptor-ldap-withlib.jar --> <jar filesetmanifest="mergewithoutmain" destfile="${dist.staging.dir}/adaptor-ldap${adaptor.suffix}-withlib.jar"> <zipfileset
diff --git a/lib/JUnitLogFixFormatter.java b/lib/JUnitLogFixFormatter.java new file mode 100644 index 0000000..415355e --- /dev/null +++ b/lib/JUnitLogFixFormatter.java
@@ -0,0 +1,109 @@ +// Copyright 2013 Google Inc. All Rights Reserved. +// +// 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. + +import junit.framework.AssertionFailedError; +import junit.framework.Test; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; + +import java.io.*; +import java.util.*; +import java.util.logging.*; + +/** + * Ant formatter for fixing logging output when runing multiple JUnit tests in + * the same JVM. + * + * <p>The default {@link ConsoleHandler} caches the value of {@code System.err}. + * The Ant task changes {@code System.err} after every test. Thus, only the + * first test gets logging logged when running JUnit tests from Ant. This + * formatter changes swaps out any ConsoleHandlers with new console handlers + * that have the correct {@code System.err} reference, and the swaps them back + * after the test is over. + */ +public class JUnitLogFixFormatter implements JUnitResultFormatter { + private List<ConsoleHandler> removedHandlers + = new ArrayList<ConsoleHandler>(); + private List<ConsoleHandler> addedHandlers = new ArrayList<ConsoleHandler>(); + + @Override + public void startTestSuite(JUnitTest suite) throws BuildException { + if (removedHandlers.size() != 0) { + throw new IllegalStateException("removedHandlers must be empty"); + } + if (addedHandlers.size() != 0) { + throw new IllegalStateException("addedHandlers must be empty"); + } + + Logger root = Logger.getLogger(""); + for (Handler handler : root.getHandlers()) { + if (handler instanceof ConsoleHandler) { + removedHandlers.add((ConsoleHandler) handler); + } + } + + for (ConsoleHandler oldHandler : removedHandlers) { + ConsoleHandler newHandler = new ConsoleHandler(); + newHandler.setLevel(oldHandler.getLevel()); + newHandler.setFilter(oldHandler.getFilter()); + newHandler.setFormatter(oldHandler.getFormatter()); + try { + newHandler.setEncoding(oldHandler.getEncoding()); + } catch (UnsupportedEncodingException ex) { + throw new IllegalStateException(ex); + } + newHandler.setErrorManager(oldHandler.getErrorManager()); + root.addHandler(newHandler); + addedHandlers.add(newHandler); + root.removeHandler(oldHandler); + } + } + + @Override + public void endTestSuite(JUnitTest suite) throws BuildException { + Logger root = Logger.getLogger(""); + for (ConsoleHandler handler : removedHandlers) { + root.addHandler(handler); + } + removedHandlers.clear(); + + for (ConsoleHandler handler : addedHandlers) { + root.removeHandler(handler); + } + addedHandlers.clear(); + } + + @Override + public void setOutput(OutputStream out) {} + + @Override + public void setSystemError(String err) {} + + @Override + public void setSystemOutput(String out) {} + + @Override + public void addError(Test test, Throwable t) {} + + @Override + public void addFailure(Test test, AssertionFailedError t) {} + + @Override + public void endTest(Test test) {} + + @Override + public void startTest(Test test) {} +}
diff --git a/lib/junit-4.8.2.jar b/lib/junit-4.8.2.jar new file mode 100644 index 0000000..5b4bb84 --- /dev/null +++ b/lib/junit-4.8.2.jar Binary files differ
diff --git a/lib/plexi b/lib/plexi new file mode 160000 index 0000000..a0ceeba --- /dev/null +++ b/lib/plexi
@@ -0,0 +1 @@ +Subproject commit a0ceeba4a0c9eba529446a8b8995488a8c441dc9
diff --git a/logging.properties b/logging.properties new file mode 100644 index 0000000..3cc9074 --- /dev/null +++ b/logging.properties
@@ -0,0 +1,9 @@ +handlers = java.util.logging.ConsoleHandler +.level = INFO +com.google.enterprise.adaptor.ldap.LdapAdaptor.level = FINER +com.google.enterprise.adaptor.level = FINER +java.util.logging.ConsoleHandler.level = FINEST +java.util.logging.ConsoleHandler.formatter = com.google.enterprise.adaptor.CustomFormatter +# Uncomment if your terminal can't handle colors and the auto-detection +# is incorrect. +# com.google.enterprise.adaptor.CustomFormatter.useColor = false
diff --git a/src/com/google/enterprise/adaptor/ldap/LdapAdaptor.java b/src/com/google/enterprise/adaptor/ldap/LdapAdaptor.java new file mode 100644 index 0000000..c9c6a0f --- /dev/null +++ b/src/com/google/enterprise/adaptor/ldap/LdapAdaptor.java
@@ -0,0 +1,49 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// 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 com.google.enterprise.adaptor.ldap; + +import com.google.enterprise.adaptor.AbstractAdaptor; +import com.google.enterprise.adaptor.AdaptorContext; +import com.google.enterprise.adaptor.Config; +import com.google.enterprise.adaptor.DocId; +import com.google.enterprise.adaptor.DocIdPusher; +import com.google.enterprise.adaptor.Request; +import com.google.enterprise.adaptor.Response; + +/** For getting LDAP content (not just ACLs) into a Google Search Appliance. */ +public class LdapAdaptor extends AbstractAdaptor { + + public static void main(String[] args) { + AbstractAdaptor.main(new LdapAdaptor(), args); + } + + @Override + public void initConfig(Config config) { + } + + @Override + public void init(AdaptorContext context) throws Exception { + } + + /** Get all doc ids from LDAP. */ + @Override + public void getDocIds(DocIdPusher pusher) { + } + + /** Gives the bytes of a document referenced with id. */ + @Override + public void getDocContent(Request req, Response resp) { + } +}
diff --git a/test/com/google/enterprise/adaptor/ldap/LdapAdaptorTest.java b/test/com/google/enterprise/adaptor/ldap/LdapAdaptorTest.java new file mode 100644 index 0000000..5731be8 --- /dev/null +++ b/test/com/google/enterprise/adaptor/ldap/LdapAdaptorTest.java
@@ -0,0 +1,34 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// 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 com.google.enterprise.adaptor.ldap; + +import static org.junit.Assert.*; + +import org.junit.*; +import org.junit.rules.ExpectedException; + +import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + +public class LdapAdaptorTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void testAbsolutelyNothing() { + // throw new RuntimeException("add test here"); + } +}