NO-JIRA: Final merge from trunk before reintegration

git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-bdb-ha2@1583552 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/qpid/cpp/CMakeLists.txt b/qpid/cpp/CMakeLists.txt
index 837a71c..d057254 100644
--- a/qpid/cpp/CMakeLists.txt
+++ b/qpid/cpp/CMakeLists.txt
@@ -29,6 +29,8 @@
     set (OPTIONAL_ARG OPTIONAL)
 endif()
 
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)
+
 # Parse the version from QPID_VERSION.txt.
 # Use the top level qpid/ file if we're in an SVN checkout, source dir otherwise.
 find_file(QPID_VERSION_FILE NAMES QPID_VERSION.txt PATHS ${PROJECT_SOURCE_DIR}/.. ${PROJECT_SOURCE_DIR} NO_DEFAULT_PATH)
diff --git a/qpid/cpp/CMakeModules/FindProton.cmake b/qpid/cpp/CMakeModules/FindProton.cmake
new file mode 100644
index 0000000..e6eae5d
--- /dev/null
+++ b/qpid/cpp/CMakeModules/FindProton.cmake
@@ -0,0 +1,70 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+include(FindPackageHandleStandardArgs)
+include(FindPackageMessage)
+
+# First try to find the Installed Proton config (Proton 0.7 and later)
+find_package(Proton QUIET NO_MODULE)
+if (Proton_FOUND)
+    find_package_message(Proton "Found Proton: ${Proton_LIBRARIES} (found version \"${Proton_VERSION}\")" "$Proton_DIR ${Proton_LIBRARIES} $Proton_VERSION")
+    return()
+endif ()
+
+# Now look for the cooky Proton config installed with some earlier
+# versions of Proton
+find_package(proton QUIET NO_MODULE)
+if (proton_FOUND)
+    include("${proton_DIR}/libqpid-proton.cmake")
+    set (Proton_VERSION ${PROTON_VERSION})
+    set (Proton_INCLUDE_DIRS ${PROTON_INCLUDE_DIRS})
+    set (Proton_LIBRARIES ${PROTON_LIBRARIES})
+    set (Proton_FOUND true)
+    find_package_message(Proton "Found Proton: ${Proton_LIBRARIES} (found version \"${Proton_VERSION}\")" "$Proton_DIR ${Proton_LIBRARIES} $Proton_VERSION")
+    return()
+endif ()
+
+# Now look for any pkg-config configuration
+find_package(PkgConfig QUIET)
+
+if (PKG_CONFIG_FOUND)
+    # Check for cmake 2.6
+    if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.0")
+        set (FindPkgQUIET QUIET)
+    endif()
+
+    if (NOT Proton_FIND_VERSION)
+        pkg_check_modules(Proton ${FindPkgQUIET} libqpid-proton)
+    elseif(NOT Proton_FIND_VERSION_EXACT)
+        pkg_check_modules(Proton ${FindPkgQUIET} libqpid-proton>=${Proton_FIND_VERSION})
+    else()
+        pkg_check_modules(Proton ${FindPkgQUIET} libqpid-proton=${Proton_FIND_VERSION})
+    endif()
+    if (Proton_FOUND)
+        find_library(Proton_LIBRARY ${Proton_LIBRARIES} HINTS ${Proton_LIBRARY_DIRS})
+        set (Proton_LIBRARIES ${Proton_LIBRARY})
+        find_package_message(Proton "Found Proton: ${Proton_LIBRARIES} (found version \"${Proton_VERSION}\")" "$Proton_DIR ${Proton_LIBRARIES} $Proton_VERSION")
+        return()
+    endif ()
+endif()
+
+# Proton not found print a standard error message
+if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.0")
+    find_package_handle_standard_args(Proton CONFIG_MODE)
+endif()
diff --git a/qpid/cpp/src/qpid/linearstore/journal/jdir.cpp b/qpid/cpp/src/qpid/linearstore/journal/jdir.cpp
index 36f180c..72b94d0 100644
--- a/qpid/cpp/src/qpid/linearstore/journal/jdir.cpp
+++ b/qpid/cpp/src/qpid/linearstore/journal/jdir.cpp
@@ -104,6 +104,7 @@
     DIR* dir = open_dir(dirname, "clear_dir", true);
     if (!dir && create_flag) {
         create_dir(dirname);
+        dir = open_dir(dirname, "clear_dir", true);
     }
 //#ifndef RHM_JOWRITE
     struct dirent* entry;
diff --git a/qpid/java/lib/poms/cryptojs-3.1.2.xml b/qpid/java/lib/poms/cryptojs-3.1.2.xml
new file mode 100644
index 0000000..2c07143
--- /dev/null
+++ b/qpid/java/lib/poms/cryptojs-3.1.2.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<dep>
+  <groupId>org.webjars</groupId>
+  <artifactId>cryptojs</artifactId>
+  <version>3.1.2</version>
+</dep>
diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml
index 8cce157..d2afc2b 100644
--- a/qpid/java/pom.xml
+++ b/qpid/java/pom.xml
@@ -53,7 +53,7 @@
     <readme.text>Documentation for the Qpid components can be accessed on our website at:${line.separator}http://qpid.apache.org/documentation.html</readme.text>
 
     <!-- enforcer plugin config properties -->
-    <supported-test-profiles-regex>(java-mms.0-9|java-mms.0-9-1|java-mms.0-10|java-bdb.0-9|java-bdb.0-9-1|java-bdb.0-10|java-dby.0-9|java-dby.0-9-1|java-dby.0-10|java-dby-mem.0-9|java-dby-mem.0-9-1|java-dby-mem.0-10)</supported-test-profiles-regex>
+    <supported-test-profiles-regex>(java-mms.0-9|java-mms.0-9-1|java-mms.0-10|java-bdb.0-9|java-bdb.0-9-1|java-bdb.0-10|java-dby.0-9|java-dby.0-9-1|java-dby.0-10|java-dby-mem.0-9|java-dby-mem.0-9-1|java-dby-mem.0-10|cpp)</supported-test-profiles-regex>
 
     <!-- plugin properties-->
     <license-maven-plugin-output-dir>${project.build.directory}/license-maven-plugin</license-maven-plugin-output-dir>
@@ -644,6 +644,54 @@
       </properties>
     </profile>
 
+    <profile>
+      <id>cpp</id>
+      <activation>
+        <property>
+          <name>profile</name>
+          <value>cpp</value>
+        </property>
+      </activation>
+      <properties>
+        <profile>cpp</profile>
+        <profile.broker.language>cpp</profile.broker.language>
+        <profile.broker.type>spawned</profile.broker.type>
+        <profile.broker.stopped>Exception constructed</profile.broker.stopped>
+        <profile.broker.ready>Listening on TCP</profile.broker.ready>
+        <profile.broker.command>${cpp-broker-dir}/qpidd -p @PORT --data-dir ${qpid.work}/@PORT -t --auth no --no-module-dir</profile.broker.command>
+        <profile.broker.command.windows></profile.broker.command.windows>
+        <profile.test.excludes>Excludes CPPExcludes ${profile}.excludes ${profile.specific.excludes} cpp.excludes</profile.test.excludes>
+        <profile.specific.excludes>CPPPrefetchExcludes CPPTransientExcludes</profile.specific.excludes>
+        <profile.broker.version>v0_10</profile.broker.version>
+        <profile.broker.persistent>true</profile.broker.persistent>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-enforcer-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>enforce-cpp-broker-dir-defined</id>
+                <goals>
+                  <goal>enforce</goal>
+                </goals>
+                <configuration>
+                  <rules>
+                    <requireProperty>
+                      <property>cpp-broker-dir</property>
+                      <message>You must set a the CPP broker directory property for this profile. (e.g. -Dcpp-broker-dir=/somedir/cpp/src)</message>
+                    </requireProperty>
+                  </rules>
+                  <fail>true</fail>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
   </profiles>
 </project>
 
diff --git a/qpid/java/qpid-perftests-systests/pom.xml b/qpid/java/qpid-perftests-systests/pom.xml
index 4557e90..e77ad53 100644
--- a/qpid/java/qpid-perftests-systests/pom.xml
+++ b/qpid/java/qpid-perftests-systests/pom.xml
@@ -115,16 +115,5 @@
       </testResource>
     </testResources>
 
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-deploy-plugin</artifactId>
-        <!--version specified in parent pluginManagement -->
-        <configuration>
-          <skip>true</skip>
-        </configuration>
-      </plugin>
-    </plugins>
-
   </build>
 </project>
diff --git a/qpid/java/qpid-systests-parent/pom.xml b/qpid/java/qpid-systests-parent/pom.xml
index eaea72c..e3633e4 100644
--- a/qpid/java/qpid-systests-parent/pom.xml
+++ b/qpid/java/qpid-systests-parent/pom.xml
@@ -216,6 +216,16 @@
             <skip>true</skip>
         </configuration>
       </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <!--version specified in parent pluginManagement -->
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+
     </plugins>
   </build>
 
diff --git a/qpid/java/test-profiles/cpp.excludes b/qpid/java/test-profiles/cpp.excludes
index c8fae17..2e7610e 100644
--- a/qpid/java/test-profiles/cpp.excludes
+++ b/qpid/java/test-profiles/cpp.excludes
@@ -27,3 +27,5 @@
 // This test requires a broker capable of 0-8/9 and 0-10
 org.apache.qpid.test.client.message.JMSDestinationTest#testReceiveResend
 
+//BDB System Tests
+org.apache.qpid.server.store.berkeleydb.*