You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2012/01/25 14:30:25 UTC
svn commit: r1235737 [2/7] - in /jackrabbit/branches/2.4: ./
examples/jackrabbit-firsthops/src/main/java/org/apache/jackrabbit/firsthops/
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jmx...
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/SeededSecureRandom.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/SeededSecureRandom.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/SeededSecureRandom.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/SeededSecureRandom.java Wed Jan 25 13:30:17 2012
@@ -1,110 +1,110 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core.id;
-
-import java.security.SecureRandom;
-import java.util.Random;
-
-/**
- * Automatically seeded singleton secure random number generator.
- *
- * @see <a href="https://issues.apache.org/jira/browse/JCR-1206">JCR-1206</a>:
- * UUID generation: SecureRandom should be used by default
- */
-class SeededSecureRandom extends SecureRandom implements Runnable {
-
- /**
- * Maximum number of milliseconds to wait for the seeding.
- */
- private static final int MAX_SEED_TIME = 1000;
-
- /**
- * Singleton instance of this class. Initialized when first accessed.
- */
- private static volatile Random instance = null;
-
- /**
- * Returns the singleton instance of this class. The instance is
- * created and seeded when this method is first called.
- *
- * @return seeded secure random number generator
- */
- public static Random getInstance() {
- if (instance == null) {
- synchronized (SeededSecureRandom.class) {
- if (instance == null) {
- instance = new SeededSecureRandom();
- }
- }
- }
- return instance;
- }
-
- /**
- * Flag to indicate whether seeding is complete.
- */
- private volatile boolean seeded = false;
-
- /**
- * Creates and seeds a secure random number generator.
- */
- private SeededSecureRandom() {
- // Can not do that in a static initializer block, because
- // threads are not started after the initializer block exits
- Thread thread = new Thread(this, "SeededSecureRandom");
- thread.start();
- try {
- thread.join(MAX_SEED_TIME);
- } catch (InterruptedException e) {
- // ignore
- }
-
- if (!seeded) {
- // Alternative seed algorithm if the default is very slow
- setSeed(System.currentTimeMillis());
- setSeed(System.nanoTime());
- setSeed(new Object().hashCode());
- Runtime runtime = Runtime.getRuntime();
- setSeed(runtime.freeMemory());
- setSeed(runtime.maxMemory());
- setSeed(runtime.totalMemory());
- setSeed(System.getProperties().toString().hashCode());
-
- // Thread timing (a second thread is already running)
- for (int j = 0; j < 16; j++) {
- int i = 0;
- long start = System.currentTimeMillis();
- while (start == System.currentTimeMillis()) {
- i++;
- }
- // Supplement the existing seed
- setSeed(i);
- }
- }
- }
-
- /**
- * Seeds this random number generator with 32 bytes of random data.
- * Run in an initializer thread as this may be slow on some systems, see
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6202721.
- */
- public void run() {
- setSeed(generateSeed(32));
- seeded = true;
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.id;
+
+import java.security.SecureRandom;
+import java.util.Random;
+
+/**
+ * Automatically seeded singleton secure random number generator.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/JCR-1206">JCR-1206</a>:
+ * UUID generation: SecureRandom should be used by default
+ */
+class SeededSecureRandom extends SecureRandom implements Runnable {
+
+ /**
+ * Maximum number of milliseconds to wait for the seeding.
+ */
+ private static final int MAX_SEED_TIME = 1000;
+
+ /**
+ * Singleton instance of this class. Initialized when first accessed.
+ */
+ private static volatile Random instance = null;
+
+ /**
+ * Returns the singleton instance of this class. The instance is
+ * created and seeded when this method is first called.
+ *
+ * @return seeded secure random number generator
+ */
+ public static Random getInstance() {
+ if (instance == null) {
+ synchronized (SeededSecureRandom.class) {
+ if (instance == null) {
+ instance = new SeededSecureRandom();
+ }
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Flag to indicate whether seeding is complete.
+ */
+ private volatile boolean seeded = false;
+
+ /**
+ * Creates and seeds a secure random number generator.
+ */
+ private SeededSecureRandom() {
+ // Can not do that in a static initializer block, because
+ // threads are not started after the initializer block exits
+ Thread thread = new Thread(this, "SeededSecureRandom");
+ thread.start();
+ try {
+ thread.join(MAX_SEED_TIME);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
+ if (!seeded) {
+ // Alternative seed algorithm if the default is very slow
+ setSeed(System.currentTimeMillis());
+ setSeed(System.nanoTime());
+ setSeed(new Object().hashCode());
+ Runtime runtime = Runtime.getRuntime();
+ setSeed(runtime.freeMemory());
+ setSeed(runtime.maxMemory());
+ setSeed(runtime.totalMemory());
+ setSeed(System.getProperties().toString().hashCode());
+
+ // Thread timing (a second thread is already running)
+ for (int j = 0; j < 16; j++) {
+ int i = 0;
+ long start = System.currentTimeMillis();
+ while (start == System.currentTimeMillis()) {
+ i++;
+ }
+ // Supplement the existing seed
+ setSeed(i);
+ }
+ }
+ }
+
+ /**
+ * Seeds this random number generator with 32 bytes of random data.
+ * Run in an initializer thread as this may be slow on some systems, see
+ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6202721.
+ */
+ public void run() {
+ setSeed(generateSeed(32));
+ seeded = true;
+ }
+
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/SeededSecureRandom.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jmx/QueryStatManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/RotatingLogFile.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ConsistencyChecker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ConsistencyReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ConsistencyReportImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItemImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DecimalField.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorDecorator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RedoLog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldComparatorSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/hits/AbstractHitCollector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ConstraintSplitInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/RowPathComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/AbstractFieldComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/DynamicOperandFieldComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/DynamicOperandFieldComparatorSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/RowComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/ValueComparableWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleWorkspaceAccessManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/action/AbstractAuthorizableAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/action/AccessControlAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/action/AuthorizableAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/action/ClearMembershipAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/action/PasswordValidationAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/DummyUpdateEventChannel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatCore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatDtoComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatDtoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatDtoOccurrenceComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesAverage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/CooperativeFileLock.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/RepositoryLockMechanism.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/RepositoryLockMechanismFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BinaryValueImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ValueFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InconsistentVersioningState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersioningLock.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java Wed Jan 25 13:30:17 2012
@@ -1,168 +1,168 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import javax.jcr.RepositoryException;
-
-import org.xml.sax.InputSource;
-
-/**
- * Input source that clones existing input source. After cloning the existing
- * input source should not be used anymore. To make more copies call
- * {@link #cloneInputSource()} method.
- */
-public class ClonedInputSource extends InputSource {
- private final char[] characterArray;
- private final byte[] byteArray;
-
- /**
- * Clone existing input source.
- *
- * @param input
- * @throws RepositoryException
- */
- public ClonedInputSource(InputSource input) throws RepositoryException {
-
- if (input == null) {
- throw new IllegalArgumentException(
- "Argument 'input' may not be null.");
- }
-
- characterArray = read(input.getCharacterStream());
- byteArray = read(input.getByteStream());
-
- setEncoding(input.getEncoding());
- setPublicId(input.getPublicId());
- setSystemId(input.getSystemId());
- if (characterArray != null) {
- setCharacterStream(new CharArrayReader(characterArray));
- }
- if (byteArray != null) {
- setByteStream(new ByteArrayInputStream(byteArray));
- }
- }
-
- private ClonedInputSource(char[] characterArray, byte[] byteArray) {
- super();
- this.characterArray = characterArray;
- this.byteArray = byteArray;
- }
-
- public char[] getCharacterArray() {
- return characterArray;
- }
-
- public byte[] getByteArray() {
- return byteArray;
- }
-
- /**
- * Make a clone if this input source. The input source being cloned is still
- * valid after cloning.
- *
- * @return input source clone.
- */
- public ClonedInputSource cloneInputSource() {
-
- ClonedInputSource res = new ClonedInputSource(characterArray, byteArray);
-
- res.setEncoding(getEncoding());
- res.setPublicId(getPublicId());
- res.setSystemId(getSystemId());
-
- if (byteArray != null) {
- res.setByteStream(new ByteArrayInputStream(byteArray));
- }
- if (characterArray != null) {
- res.setCharacterStream(new CharArrayReader(characterArray));
- }
-
- return res;
- }
-
- private static byte[] read(InputStream stream) throws RepositoryException {
- if (stream != null) {
- try {
- final int bufferSize = Math.min(stream.available(), 4096);
- ByteArrayOutputStream s = new ByteArrayOutputStream(bufferSize);
-
- byte[] buffer = new byte[bufferSize];
- while (true) {
- int numRead = stream.read(buffer);
- if (numRead > 0) {
- s.write(buffer, 0, numRead);
- }
- if (numRead != bufferSize) {
- break;
- }
- }
-
- return s.toByteArray();
- } catch (IOException e) {
- throw new RepositoryException(e);
- } finally {
- try {
- stream.close();
- } catch (IOException ignore) {
-
- }
- }
- } else {
- return null;
- }
- }
-
- private static char[] read(Reader reader) throws RepositoryException {
- if (reader != null) {
- try {
- final int bufferSize = 4096;
- CharArrayWriter w = new CharArrayWriter(bufferSize);
-
- char[] buffer = new char[bufferSize];
- while (true) {
- int numRead = reader.read(buffer);
- if (numRead > 0) {
- w.write(buffer, 0, numRead);
- }
- if (numRead != bufferSize) {
- break;
- }
- }
- return w.toCharArray();
- } catch (IOException e) {
- throw new RepositoryException(e);
- } finally {
- try {
- reader.close();
- } catch (IOException ignore) {
-
- }
- }
- } else {
- return null;
- }
-
- }
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.jcr.RepositoryException;
+
+import org.xml.sax.InputSource;
+
+/**
+ * Input source that clones existing input source. After cloning the existing
+ * input source should not be used anymore. To make more copies call
+ * {@link #cloneInputSource()} method.
+ */
+public class ClonedInputSource extends InputSource {
+ private final char[] characterArray;
+ private final byte[] byteArray;
+
+ /**
+ * Clone existing input source.
+ *
+ * @param input
+ * @throws RepositoryException
+ */
+ public ClonedInputSource(InputSource input) throws RepositoryException {
+
+ if (input == null) {
+ throw new IllegalArgumentException(
+ "Argument 'input' may not be null.");
+ }
+
+ characterArray = read(input.getCharacterStream());
+ byteArray = read(input.getByteStream());
+
+ setEncoding(input.getEncoding());
+ setPublicId(input.getPublicId());
+ setSystemId(input.getSystemId());
+ if (characterArray != null) {
+ setCharacterStream(new CharArrayReader(characterArray));
+ }
+ if (byteArray != null) {
+ setByteStream(new ByteArrayInputStream(byteArray));
+ }
+ }
+
+ private ClonedInputSource(char[] characterArray, byte[] byteArray) {
+ super();
+ this.characterArray = characterArray;
+ this.byteArray = byteArray;
+ }
+
+ public char[] getCharacterArray() {
+ return characterArray;
+ }
+
+ public byte[] getByteArray() {
+ return byteArray;
+ }
+
+ /**
+ * Make a clone if this input source. The input source being cloned is still
+ * valid after cloning.
+ *
+ * @return input source clone.
+ */
+ public ClonedInputSource cloneInputSource() {
+
+ ClonedInputSource res = new ClonedInputSource(characterArray, byteArray);
+
+ res.setEncoding(getEncoding());
+ res.setPublicId(getPublicId());
+ res.setSystemId(getSystemId());
+
+ if (byteArray != null) {
+ res.setByteStream(new ByteArrayInputStream(byteArray));
+ }
+ if (characterArray != null) {
+ res.setCharacterStream(new CharArrayReader(characterArray));
+ }
+
+ return res;
+ }
+
+ private static byte[] read(InputStream stream) throws RepositoryException {
+ if (stream != null) {
+ try {
+ final int bufferSize = Math.min(stream.available(), 4096);
+ ByteArrayOutputStream s = new ByteArrayOutputStream(bufferSize);
+
+ byte[] buffer = new byte[bufferSize];
+ while (true) {
+ int numRead = stream.read(buffer);
+ if (numRead > 0) {
+ s.write(buffer, 0, numRead);
+ }
+ if (numRead != bufferSize) {
+ break;
+ }
+ }
+
+ return s.toByteArray();
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException ignore) {
+
+ }
+ }
+ } else {
+ return null;
+ }
+ }
+
+ private static char[] read(Reader reader) throws RepositoryException {
+ if (reader != null) {
+ try {
+ final int bufferSize = 4096;
+ CharArrayWriter w = new CharArrayWriter(bufferSize);
+
+ char[] buffer = new char[bufferSize];
+ while (true) {
+ int numRead = reader.read(buffer);
+ if (numRead > 0) {
+ w.write(buffer, 0, numRead);
+ }
+ if (numRead != bufferSize) {
+ break;
+ }
+ }
+ return w.toCharArray();
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException ignore) {
+
+ }
+ }
+ } else {
+ return null;
+ }
+
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitNodeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/TestAll.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/JackrabbitAccessControlManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/TestAll.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ConcurrentCreateUserTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerSearchTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentWorkspaceCopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentWorkspaceCopyTest.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentWorkspaceCopyTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentWorkspaceCopyTest.java Wed Jan 25 13:30:17 2012
@@ -1,119 +1,119 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
-import javax.jcr.NodeIterator;
-import javax.jcr.Session;
-import javax.jcr.RepositoryException;
-import java.util.Random;
-
-
-public class ConcurrentWorkspaceCopyTest extends AbstractJCRTest {
-
- private static final int NUM_ITERATIONS = 40;
- private static final int NUM_SESSIONS = 2;
-
- static final String TARGET_NAME = "copy of src";
- String sourcePath;
- String destParentPath;
- String destPath;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // create a parent node where allowSameNameSiblings is set to false
- destParentPath =
- testRootNode.addNode("destParent",
- "nt:folder").getPath();
- destPath = destParentPath + "/" + TARGET_NAME;
- // create a source node
- sourcePath = testRootNode.addNode("src", "nt:folder").getPath();
-
- testRootNode.getSession().save();
- }
-
- public void testConcurrentCopy() throws Exception {
- for (int n = 0; n < NUM_ITERATIONS; n++) {
- // cleanup
- while (superuser.nodeExists(destPath)) {
- superuser.getNode(destPath).remove();
- superuser.save();
- }
-
- Thread[] threads = new Thread[NUM_SESSIONS];
- for (int i = 0; i < threads.length; i++) {
- // create new session
- Session session = getHelper().getSuperuserSession();
- String id = "session#" + i;
- TestSession ts = new TestSession(id, session);
- Thread t = new Thread(ts);
- t.setName(id);
- t.start();
- threads[i] = t;
- }
- for (int i = 0; i < threads.length; i++) {
- threads[i].join();
- }
-
- NodeIterator results = superuser.getNode(destParentPath).getNodes(TARGET_NAME);
-
- assertEquals(1, results.getSize());
- }
- }
-
-
- // -------------------------------------------------------< inner classes >
- class TestSession implements Runnable {
-
- Session session;
- String identity;
- Random r;
-
- TestSession(String identity, Session s) {
- session = s;
- this.identity = identity;
- r = new Random();
- }
-
- private void randomSleep() {
- long l = r.nextInt(90) + 20;
- try {
- Thread.sleep(l);
- } catch (InterruptedException ie) {
- }
- }
-
- public void run() {
-
- try {
- session.getWorkspace().copy(sourcePath, destPath);
- session.save();
-
- randomSleep();
- } catch (RepositoryException e) {
- // expected
- } finally {
- session.logout();
- }
-
- }
- }
-
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+import javax.jcr.RepositoryException;
+import java.util.Random;
+
+
+public class ConcurrentWorkspaceCopyTest extends AbstractJCRTest {
+
+ private static final int NUM_ITERATIONS = 40;
+ private static final int NUM_SESSIONS = 2;
+
+ static final String TARGET_NAME = "copy of src";
+ String sourcePath;
+ String destParentPath;
+ String destPath;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // create a parent node where allowSameNameSiblings is set to false
+ destParentPath =
+ testRootNode.addNode("destParent",
+ "nt:folder").getPath();
+ destPath = destParentPath + "/" + TARGET_NAME;
+ // create a source node
+ sourcePath = testRootNode.addNode("src", "nt:folder").getPath();
+
+ testRootNode.getSession().save();
+ }
+
+ public void testConcurrentCopy() throws Exception {
+ for (int n = 0; n < NUM_ITERATIONS; n++) {
+ // cleanup
+ while (superuser.nodeExists(destPath)) {
+ superuser.getNode(destPath).remove();
+ superuser.save();
+ }
+
+ Thread[] threads = new Thread[NUM_SESSIONS];
+ for (int i = 0; i < threads.length; i++) {
+ // create new session
+ Session session = getHelper().getSuperuserSession();
+ String id = "session#" + i;
+ TestSession ts = new TestSession(id, session);
+ Thread t = new Thread(ts);
+ t.setName(id);
+ t.start();
+ threads[i] = t;
+ }
+ for (int i = 0; i < threads.length; i++) {
+ threads[i].join();
+ }
+
+ NodeIterator results = superuser.getNode(destParentPath).getNodes(TARGET_NAME);
+
+ assertEquals(1, results.getSize());
+ }
+ }
+
+
+ // -------------------------------------------------------< inner classes >
+ class TestSession implements Runnable {
+
+ Session session;
+ String identity;
+ Random r;
+
+ TestSession(String identity, Session s) {
+ session = s;
+ this.identity = identity;
+ r = new Random();
+ }
+
+ private void randomSleep() {
+ long l = r.nextInt(90) + 20;
+ try {
+ Thread.sleep(l);
+ } catch (InterruptedException ie) {
+ }
+ }
+
+ public void run() {
+
+ try {
+ session.getWorkspace().copy(sourcePath, destPath);
+ session.save();
+
+ randomSleep();
+ } catch (RepositoryException e) {
+ // expected
+ } finally {
+ session.logout();
+ }
+
+ }
+ }
+
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentWorkspaceCopyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java Wed Jan 25 13:30:17 2012
@@ -1,48 +1,48 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core;
-
-import org.apache.jackrabbit.core.persistence.check.ConsistencyReport;
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.test.LogPrintWriter;
-
-public class ConsistencyCheck extends AbstractJCRTest {
-
- private LogPrintWriter log = new LogPrintWriter(logger);
-
- // Why are we running these twice?
- public void testDo1() throws Exception {
- runCheck();
- }
-
- // ...because AbstractJCRTests iterates through multiple test repositories.
- // this way, we should check at least two of them. Yes, this is a hack.
- public void testDo2() throws Exception {
- runCheck();
- }
-
- private void runCheck() throws Exception {
- log.print("running consistency check on repository "
- + getHelper().getRepository());
-
- ConsistencyReport rep = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
- assertEquals("Found broken nodes in repository: " + rep, 0, rep.getItems().size());
-
- rep = TestHelper.checkVersionStoreConsistency(testRootNode.getSession(), false, null);
- assertEquals("Found broken nodes in version storage: " + rep, 0, rep.getItems().size());
- }
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core;
+
+import org.apache.jackrabbit.core.persistence.check.ConsistencyReport;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.LogPrintWriter;
+
+public class ConsistencyCheck extends AbstractJCRTest {
+
+ private LogPrintWriter log = new LogPrintWriter(logger);
+
+ // Why are we running these twice?
+ public void testDo1() throws Exception {
+ runCheck();
+ }
+
+ // ...because AbstractJCRTests iterates through multiple test repositories.
+ // this way, we should check at least two of them. Yes, this is a hack.
+ public void testDo2() throws Exception {
+ runCheck();
+ }
+
+ private void runCheck() throws Exception {
+ log.print("running consistency check on repository "
+ + getHelper().getRepository());
+
+ ConsistencyReport rep = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
+ assertEquals("Found broken nodes in repository: " + rep, 0, rep.getItems().size());
+
+ rep = TestHelper.checkVersionStoreConsistency(testRootNode.getSession(), false, null);
+ assertEquals("Found broken nodes in version storage: " + rep, 0, rep.getItems().size());
+ }
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LockedWrapperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveAtRootTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NPEandCMETest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OracleRepositoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OracleRetrocompatibleRepositoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OverlappingNodeAddTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OverlappingNodeAddTest.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OverlappingNodeAddTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OverlappingNodeAddTest.java Wed Jan 25 13:30:17 2012
@@ -1,132 +1,132 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.Node;
-import javax.jcr.Session;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
-public class OverlappingNodeAddTest extends AbstractJCRTest {
-
- private Node testfolder;
- private Session s1;
- private Session s2;
-
- public void setUp() throws Exception {
- super.setUp();
- testfolder = testRootNode.addNode("container", "nt:folder");
- s1 = testfolder.getSession();
- s2 = getHelper().getReadWriteSession();
- s1.save();
- }
-
- /**
- * Performs add operations on a single node (no SNS) through 2 sessions
- */
- public void testWith2Folders() throws Exception {
-
- boolean bWasSaved = false;
-
- String testpath = testfolder.getPath();
-
- Node f1 = s1.getNode(testpath).addNode("folder", "nt:folder");
- Node c1 = f1.addNode("a", "nt:file");
- Node r1 = c1.addNode("jcr:content", "nt:resource");
- r1.setProperty("jcr:data", "foo");
-
- Node f2 = s2.getNode(testpath).addNode("folder", "nt:folder");
- Node c2 = f2.addNode("b", "nt:file");
- Node r2 = c2.addNode("jcr:content", "nt:resource");
- r2.setProperty("jcr:data", "bar");
-
- s1.save();
-
- String s1FolderId = f1.getIdentifier();
-
- try {
- s2.save();
- bWasSaved = true;
- } catch (InvalidItemStateException ex) {
- // expected
-
- // retry; adding refresh doesn't change anything here
- try {
- s2.save();
-
- bWasSaved = true;
-
- } catch (InvalidItemStateException ex2) {
- // we would be cool with this
- }
- }
-
- // we don't have changes in s1, so the keepChanges flag should be
- // irrelevant
- s1.refresh(false);
-
- // be nice and get a new Node instance
- Node newf1 = s1.getNode(testpath + "/folder");
-
- // if bWasSaved it should now be visible to Session 1
- assertEquals("'b' was saved, so session 1 should see it", bWasSaved,
- newf1.hasNode("b"));
-
- // 'a' was saved by Session 1 earlier on
- if (!newf1.hasNode("a")) {
- String message = "child node 'a' not present";
-
- if (bWasSaved && !s1FolderId.equals(newf1.getIdentifier())) {
- message += ", and also the folder's identifier changed from "
- + s1FolderId + " to " + newf1.getIdentifier();
- }
-
- Node oldf1 = null;
-
- try {
- oldf1 = s1.getNodeByIdentifier(s1FolderId);
- } catch (ItemNotFoundException ex) {
- message += "; node with id "
- + s1FolderId
- + " can't be retrieved using getNodeByIdentifier either";
- }
-
- if (oldf1 != null) {
- try {
- oldf1.getPath();
- } catch (Exception ex) {
- message += "; node with id "
- + s1FolderId
- + " can be retrieved using getNodeByIdentifier, but getPath() fails with: "
- + ex.getMessage();
- }
- }
-
- fail(message);
- }
- }
-
- protected void tearDown() throws Exception {
- if (s2 != null) {
- s2.logout();
- s2 = null;
- }
- super.tearDown();
- }
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+public class OverlappingNodeAddTest extends AbstractJCRTest {
+
+ private Node testfolder;
+ private Session s1;
+ private Session s2;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ testfolder = testRootNode.addNode("container", "nt:folder");
+ s1 = testfolder.getSession();
+ s2 = getHelper().getReadWriteSession();
+ s1.save();
+ }
+
+ /**
+ * Performs add operations on a single node (no SNS) through 2 sessions
+ */
+ public void testWith2Folders() throws Exception {
+
+ boolean bWasSaved = false;
+
+ String testpath = testfolder.getPath();
+
+ Node f1 = s1.getNode(testpath).addNode("folder", "nt:folder");
+ Node c1 = f1.addNode("a", "nt:file");
+ Node r1 = c1.addNode("jcr:content", "nt:resource");
+ r1.setProperty("jcr:data", "foo");
+
+ Node f2 = s2.getNode(testpath).addNode("folder", "nt:folder");
+ Node c2 = f2.addNode("b", "nt:file");
+ Node r2 = c2.addNode("jcr:content", "nt:resource");
+ r2.setProperty("jcr:data", "bar");
+
+ s1.save();
+
+ String s1FolderId = f1.getIdentifier();
+
+ try {
+ s2.save();
+ bWasSaved = true;
+ } catch (InvalidItemStateException ex) {
+ // expected
+
+ // retry; adding refresh doesn't change anything here
+ try {
+ s2.save();
+
+ bWasSaved = true;
+
+ } catch (InvalidItemStateException ex2) {
+ // we would be cool with this
+ }
+ }
+
+ // we don't have changes in s1, so the keepChanges flag should be
+ // irrelevant
+ s1.refresh(false);
+
+ // be nice and get a new Node instance
+ Node newf1 = s1.getNode(testpath + "/folder");
+
+ // if bWasSaved it should now be visible to Session 1
+ assertEquals("'b' was saved, so session 1 should see it", bWasSaved,
+ newf1.hasNode("b"));
+
+ // 'a' was saved by Session 1 earlier on
+ if (!newf1.hasNode("a")) {
+ String message = "child node 'a' not present";
+
+ if (bWasSaved && !s1FolderId.equals(newf1.getIdentifier())) {
+ message += ", and also the folder's identifier changed from "
+ + s1FolderId + " to " + newf1.getIdentifier();
+ }
+
+ Node oldf1 = null;
+
+ try {
+ oldf1 = s1.getNodeByIdentifier(s1FolderId);
+ } catch (ItemNotFoundException ex) {
+ message += "; node with id "
+ + s1FolderId
+ + " can't be retrieved using getNodeByIdentifier either";
+ }
+
+ if (oldf1 != null) {
+ try {
+ oldf1.getPath();
+ } catch (Exception ex) {
+ message += "; node with id "
+ + s1FolderId
+ + " can be retrieved using getNodeByIdentifier, but getPath() fails with: "
+ + ex.getMessage();
+ }
+ }
+
+ fail(message);
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ if (s2 != null) {
+ s2.logout();
+ s2 = null;
+ }
+ super.tearDown();
+ }
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/OverlappingNodeAddTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/SessionGarbageCollectedTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserPerWorkspaceSecurityManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/ConcurrentGcTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreAPITest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/LazyFileInputStreamTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/OpenFilesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/WriteWhileReadingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/TestAll.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/TestAll.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/TestAll.java Wed Jan 25 13:30:17 2012
@@ -1,44 +1,44 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core.fs;
-
-import org.apache.jackrabbit.core.fs.db.DerbyFileSystemTest;
-import org.apache.jackrabbit.core.fs.local.LocalFileSystemTest;
-import org.apache.jackrabbit.core.fs.mem.MemoryFileSystemTest;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test suite that includes all test cases for this module.
- */
-public class TestAll extends TestCase {
-
- /**
- * Returns a test suite that executes all tests inside this package.
- *
- * @return a test suite that executes all tests inside this package
- */
- public static Test suite() {
- TestSuite suite = new TestSuite("FileSystem tests");
- suite.addTestSuite(DerbyFileSystemTest.class);
- suite.addTestSuite(LocalFileSystemTest.class);
- suite.addTestSuite(MemoryFileSystemTest.class);
- return suite;
- }
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.fs;
+
+import org.apache.jackrabbit.core.fs.db.DerbyFileSystemTest;
+import org.apache.jackrabbit.core.fs.local.LocalFileSystemTest;
+import org.apache.jackrabbit.core.fs.mem.MemoryFileSystemTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all test cases for this module.
+ */
+public class TestAll extends TestCase {
+
+ /**
+ * Returns a test suite that executes all tests inside this package.
+ *
+ * @return a test suite that executes all tests inside this package
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite("FileSystem tests");
+ suite.addTestSuite(DerbyFileSystemTest.class);
+ suite.addTestSuite(LocalFileSystemTest.class);
+ suite.addTestSuite(MemoryFileSystemTest.class);
+ return suite;
+ }
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/TestAll.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/OracleFileSystemTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/OracleRetrocompatibleFileSystemTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java Wed Jan 25 13:30:17 2012
@@ -1,106 +1,106 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core.id;
-
-import junit.framework.TestCase;
-
-public class NodeIdTest extends TestCase {
-
- private static final NodeId[] ids = {
- NodeId.randomId(), // random id
- new NodeId(0, 0),
- new NodeId(-1, -1),
- new NodeId("cafebabe-cafe-babe-cafe-babecafebabe")
- };
-
- public void testDenotesNode() {
- for (NodeId id : ids) {
- assertTrue(id.denotesNode());
- }
- }
-
- public void testGetMostAndLeastSignificantBits() {
- for (NodeId id : ids) {
- long msb = id.getMostSignificantBits();
- long lsb = id.getLeastSignificantBits();
- assertEquals(id, new NodeId(msb, lsb));
- }
- }
-
- public void testGetRawBytes() {
- for (NodeId id : ids) {
- assertEquals(id, new NodeId(id.getRawBytes()));
- }
- }
-
- public void testToString() {
- for (NodeId id : ids) {
- assertEquals(id, new NodeId(id.toString()));
- }
- }
-
- public void testCompareTo() {
- for (NodeId id : ids) {
- assertEquals(0, id.compareTo(id));
- }
-
- NodeId[] ordered = {
- new NodeId(-1, -1),
- new NodeId(-1, 0),
- new NodeId(0, -1),
- new NodeId(0, 0),
- new NodeId(0, 1),
- new NodeId(1, 0),
- new NodeId(1, 1)
- };
- for (int i = 0; i < ordered.length; i++) {
- for (int j = 0; j < i; j++) {
- assertEquals(1, ordered[i].compareTo(ordered[j]));
- }
- assertEquals(0, ordered[i].compareTo(ordered[i]));
- for (int j = i + 1; j < ordered.length; j++) {
- assertEquals(-1, ordered[i].compareTo(ordered[j]));
- }
- }
- }
-
- public void testUuidFormat() {
- long maxHigh = 0, maxLow = 0, minHigh = -1L, minLow = -1L;
- for (int i = 0; i < 100; i++) {
- NodeId id = NodeId.randomId();
- assertUuidFormat(id);
- maxHigh |= id.getMostSignificantBits();
- maxLow |= id.getLeastSignificantBits();
- minHigh &= id.getMostSignificantBits();
- minLow &= id.getLeastSignificantBits();
- }
- NodeId max = new NodeId(maxHigh, maxLow);
- assertEquals("ffffffff-ffff-4fff-bfff-ffffffffffff", max.toString());
- NodeId min = new NodeId(minHigh, minLow);
- assertEquals("00000000-0000-4000-8000-000000000000", min.toString());
- }
-
- private void assertUuidFormat(NodeId id) {
- long high = id.getMostSignificantBits();
- long low = id.getLeastSignificantBits();
- long high2 = (high & (~0xf000L)) | 0x4000L; // version 4 (random)
- assertEquals(high, high2);
- long low2 = (low & 0x3fffffffffffffffL) | 0x8000000000000000L; // variant (Leach-Salz)
- assertEquals(low, low2);
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.id;
+
+import junit.framework.TestCase;
+
+public class NodeIdTest extends TestCase {
+
+ private static final NodeId[] ids = {
+ NodeId.randomId(), // random id
+ new NodeId(0, 0),
+ new NodeId(-1, -1),
+ new NodeId("cafebabe-cafe-babe-cafe-babecafebabe")
+ };
+
+ public void testDenotesNode() {
+ for (NodeId id : ids) {
+ assertTrue(id.denotesNode());
+ }
+ }
+
+ public void testGetMostAndLeastSignificantBits() {
+ for (NodeId id : ids) {
+ long msb = id.getMostSignificantBits();
+ long lsb = id.getLeastSignificantBits();
+ assertEquals(id, new NodeId(msb, lsb));
+ }
+ }
+
+ public void testGetRawBytes() {
+ for (NodeId id : ids) {
+ assertEquals(id, new NodeId(id.getRawBytes()));
+ }
+ }
+
+ public void testToString() {
+ for (NodeId id : ids) {
+ assertEquals(id, new NodeId(id.toString()));
+ }
+ }
+
+ public void testCompareTo() {
+ for (NodeId id : ids) {
+ assertEquals(0, id.compareTo(id));
+ }
+
+ NodeId[] ordered = {
+ new NodeId(-1, -1),
+ new NodeId(-1, 0),
+ new NodeId(0, -1),
+ new NodeId(0, 0),
+ new NodeId(0, 1),
+ new NodeId(1, 0),
+ new NodeId(1, 1)
+ };
+ for (int i = 0; i < ordered.length; i++) {
+ for (int j = 0; j < i; j++) {
+ assertEquals(1, ordered[i].compareTo(ordered[j]));
+ }
+ assertEquals(0, ordered[i].compareTo(ordered[i]));
+ for (int j = i + 1; j < ordered.length; j++) {
+ assertEquals(-1, ordered[i].compareTo(ordered[j]));
+ }
+ }
+ }
+
+ public void testUuidFormat() {
+ long maxHigh = 0, maxLow = 0, minHigh = -1L, minLow = -1L;
+ for (int i = 0; i < 100; i++) {
+ NodeId id = NodeId.randomId();
+ assertUuidFormat(id);
+ maxHigh |= id.getMostSignificantBits();
+ maxLow |= id.getLeastSignificantBits();
+ minHigh &= id.getMostSignificantBits();
+ minLow &= id.getLeastSignificantBits();
+ }
+ NodeId max = new NodeId(maxHigh, maxLow);
+ assertEquals("ffffffff-ffff-4fff-bfff-ffffffffffff", max.toString());
+ NodeId min = new NodeId(minHigh, minLow);
+ assertEquals("00000000-0000-4000-8000-000000000000", min.toString());
+ }
+
+ private void assertUuidFormat(NodeId id) {
+ long high = id.getMostSignificantBits();
+ long low = id.getLeastSignificantBits();
+ long high2 = (high & (~0xf000L)) | 0x4000L; // version 4 (random)
+ assertEquals(high, high2);
+ long low2 = (low & 0x3fffffffffffffffL) | 0x8000000000000000L; // variant (Leach-Salz)
+ assertEquals(low, low2);
+ }
+
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java Wed Jan 25 13:30:17 2012
@@ -1,41 +1,41 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core.id;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test suite that includes all test cases for the id module.
- */
-public class TestAll extends TestCase {
-
- /**
- * Returns a test suite that executes all tests inside this package.
- *
- * @return a test suite that executes all tests inside this package
- */
- public static Test suite() {
- TestSuite suite = new TestSuite("Identifier tests");
-
- suite.addTestSuite(NodeIdFactoryTest.class);
- suite.addTestSuite(NodeIdTest.class);
-
- return suite;
- }
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.id;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all test cases for the id module.
+ */
+public class TestAll extends TestCase {
+
+ /**
+ * Returns a test suite that executes all tests inside this package.
+ *
+ * @return a test suite that executes all tests inside this package
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Identifier tests");
+
+ suite.addTestSuite(NodeIdFactoryTest.class);
+ suite.addTestSuite(NodeIdTest.class);
+
+ return suite;
+ }
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/ItemSequenceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java Wed Jan 25 13:30:17 2012
@@ -1,93 +1,93 @@
-/*
- * 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.
- */
-package org.apache.jackrabbit.core.integration;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.version.Version;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
-/**
- * Integration tests for the Node implementation in Jackrabbit core.
- */
-public class NodeImplTest extends AbstractJCRTest {
-
- private Node node;
-
- protected void setUp() throws Exception {
- super.setUp();
- node = testRootNode.addNode("testNodeImpl", "nt:unstructured");
- testRootNode.save();
- }
-
- protected void tearDown() throws Exception {
- node.remove();
- testRootNode.save();
- super.tearDown();
- }
-
- /**
- * Test case for JCR-1389.
- *
- * @see <a href="https://issues.apache.org/jira/browse/JCR-1389">JCR-1389</a>
- */
- public void testSetEmptyMultiValueProperty() throws RepositoryException {
- Property property =
- node.setProperty("test", new Value[0], PropertyType.LONG);
- assertEquals(
- "JCR-1389: setProperty(name, new Value[0], PropertyType.LONG)"
- + " loses property type",
- PropertyType.LONG, property.getType());
- }
-
- /**
- * Test case for JCR-1227.
- *
- * @see <a href="https://issues.apache.org/jira/browse/JCR-1227">JCR-1227</a>
- */
- public void testRestoreEmptyMultiValueProperty() throws Exception {
- node.addMixin("mix:versionable");
- node.setProperty("test", new Value[0], PropertyType.LONG);
- node.save();
- assertEquals(PropertyType.LONG, node.getProperty("test").getType());
-
- Version version = node.checkin();
- assertEquals(PropertyType.LONG, node.getProperty("test").getType());
-
- node.restore(version, false);
- assertEquals(
- "JCR-1227: Restore of empty multivalue property always"
- + " changes property type to String",
- PropertyType.LONG, node.getProperty("test").getType());
-
- node.checkout();
- node.setProperty("test", new Value[0], PropertyType.BOOLEAN);
- node.save();
- assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType());
-
- node.restore(version, false);
- assertEquals(
- "JCR-1227: Restore of empty multivalue property always"
- + " changes property type to String",
- PropertyType.LONG, node.getProperty("test").getType());
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.integration;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.version.Version;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+/**
+ * Integration tests for the Node implementation in Jackrabbit core.
+ */
+public class NodeImplTest extends AbstractJCRTest {
+
+ private Node node;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ node = testRootNode.addNode("testNodeImpl", "nt:unstructured");
+ testRootNode.save();
+ }
+
+ protected void tearDown() throws Exception {
+ node.remove();
+ testRootNode.save();
+ super.tearDown();
+ }
+
+ /**
+ * Test case for JCR-1389.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/JCR-1389">JCR-1389</a>
+ */
+ public void testSetEmptyMultiValueProperty() throws RepositoryException {
+ Property property =
+ node.setProperty("test", new Value[0], PropertyType.LONG);
+ assertEquals(
+ "JCR-1389: setProperty(name, new Value[0], PropertyType.LONG)"
+ + " loses property type",
+ PropertyType.LONG, property.getType());
+ }
+
+ /**
+ * Test case for JCR-1227.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/JCR-1227">JCR-1227</a>
+ */
+ public void testRestoreEmptyMultiValueProperty() throws Exception {
+ node.addMixin("mix:versionable");
+ node.setProperty("test", new Value[0], PropertyType.LONG);
+ node.save();
+ assertEquals(PropertyType.LONG, node.getProperty("test").getType());
+
+ Version version = node.checkin();
+ assertEquals(PropertyType.LONG, node.getProperty("test").getType());
+
+ node.restore(version, false);
+ assertEquals(
+ "JCR-1227: Restore of empty multivalue property always"
+ + " changes property type to String",
+ PropertyType.LONG, node.getProperty("test").getType());
+
+ node.checkout();
+ node.setProperty("test", new Value[0], PropertyType.BOOLEAN);
+ node.save();
+ assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType());
+
+ node.restore(version, false);
+ assertEquals(
+ "JCR-1227: Restore of empty multivalue property always"
+ + " changes property type to String",
+ PropertyType.LONG, node.getProperty("test").getType());
+ }
+
+}
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/NodeImplTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/TreeTraverserTest.java
------------------------------------------------------------------------------
svn:eol-style = native