You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2007/09/17 00:12:09 UTC

svn commit: r576193 [6/6] - in /directory/apacheds/trunk/mitosis/src: main/java/org/apache/directory/mitosis/common/ main/java/org/apache/directory/mitosis/configuration/ main/java/org/apache/directory/mitosis/service/ main/java/org/apache/directory/mi...

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest2.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest2.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest2.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest2.java Sun Sep 16 15:12:06 2007
@@ -1,37 +1,37 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.service.protocol.Constants;
-import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesAckMessage;
-
-
-public class BeginLogEntriesAckMessageCodecTest2 extends AbstractMessageCodecTest
-{
-
-    public BeginLogEntriesAckMessageCodecTest2()
-    {
-        super( new BeginLogEntriesAckMessage( 1234, Constants.NOT_OK, null, null ),
-            new BeginLogEntriesAckMessageEncoder(), new BeginLogEntriesAckMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.service.protocol.Constants;
+import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesAckMessage;
+
+
+public class BeginLogEntriesAckMessageCodecTest2 extends AbstractMessageCodecTest
+{
+
+    public BeginLogEntriesAckMessageCodecTest2()
+    {
+        super( new BeginLogEntriesAckMessage( 1234, Constants.NOT_OK, null, null ),
+            new BeginLogEntriesAckMessageEncoder(), new BeginLogEntriesAckMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,36 +1,36 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesMessage;
-
-
-public class BeginLogEntriesMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public BeginLogEntriesMessageCodecTest()
-    {
-        super( new BeginLogEntriesMessage( 1234 ), new BeginLogEntriesMessageEncoder(),
-            new BeginLogEntriesMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesMessage;
+
+
+public class BeginLogEntriesMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public BeginLogEntriesMessageCodecTest()
+    {
+        super( new BeginLogEntriesMessage( 1234 ), new BeginLogEntriesMessageEncoder(),
+            new BeginLogEntriesMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,36 +1,36 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesAckMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesAckMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesAckMessage;
-
-
-public class EndLogEntriesAckMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public EndLogEntriesAckMessageCodecTest()
-    {
-        super( new EndLogEntriesAckMessage( 1234, 5678 ), new EndLogEntriesAckMessageEncoder(),
-            new EndLogEntriesAckMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesAckMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesAckMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesAckMessage;
+
+
+public class EndLogEntriesAckMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public EndLogEntriesAckMessageCodecTest()
+    {
+        super( new EndLogEntriesAckMessage( 1234, 5678 ), new EndLogEntriesAckMessageEncoder(),
+            new EndLogEntriesAckMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,35 +1,35 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesMessage;
-
-
-public class EndLogEntriesMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public EndLogEntriesMessageCodecTest()
-    {
-        super( new EndLogEntriesMessage( 1234 ), new EndLogEntriesMessageEncoder(), new EndLogEntriesMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.EndLogEntriesMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesMessage;
+
+
+public class EndLogEntriesMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public EndLogEntriesMessageCodecTest()
+    {
+        super( new EndLogEntriesMessage( 1234 ), new EndLogEntriesMessageEncoder(), new EndLogEntriesMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,35 +1,35 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.service.protocol.codec.LogEntryAckMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.LogEntryAckMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.LogEntryAckMessage;
-
-
-public class LogEntryAckMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public LogEntryAckMessageCodecTest()
-    {
-        super( new LogEntryAckMessage( 1234, 5678 ), new LogEntryAckMessageEncoder(), new LogEntryAckMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.service.protocol.codec.LogEntryAckMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.LogEntryAckMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.LogEntryAckMessage;
+
+
+public class LogEntryAckMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public LogEntryAckMessageCodecTest()
+    {
+        super( new LogEntryAckMessage( 1234, 5678 ), new LogEntryAckMessageEncoder(), new LogEntryAckMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,59 +1,59 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import javax.naming.InvalidNameException;
-
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.common.DefaultCSN;
-import org.apache.directory.mitosis.operation.AddAttributeOperation;
-import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
-import org.apache.directory.mitosis.service.protocol.message.LogEntryMessage;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.name.LdapDN;
-
-
-public class LogEntryMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public LogEntryMessageCodecTest() throws InvalidNameException
-    {
-        super(
-            new LogEntryMessage( 1234, new AddAttributeOperation( new DefaultCSN( System.currentTimeMillis(),
-                new ReplicaId( "testReplica0" ), 1234 ), new LdapDN( "ou=system" ),
-                new AttributeImpl( "Hello", "Test" ) ) ), new LogEntryMessageEncoder(), new LogEntryMessageDecoder() );
-    }
-
-
-    protected boolean compare( BaseMessage expected0, BaseMessage actual0 )
-    {
-        LogEntryMessage expected = ( LogEntryMessage ) expected0;
-        LogEntryMessage actual = ( LogEntryMessage ) actual0;
-
-        // We don't compare operation here because it is {@link OperationCodec}'s
-        // duty to serialize and deserialize Invocations.
-        return expected.getType() == actual.getType() && expected.getSequence() == actual.getSequence()
-            && expected.getOperation().getCSN().equals( actual.getOperation().getCSN() )
-            && expected.getOperation().getClass() == actual.getOperation().getClass();
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.common.DefaultCSN;
+import org.apache.directory.mitosis.operation.AddAttributeOperation;
+import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
+import org.apache.directory.mitosis.service.protocol.message.LogEntryMessage;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+public class LogEntryMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public LogEntryMessageCodecTest() throws InvalidNameException
+    {
+        super(
+            new LogEntryMessage( 1234, new AddAttributeOperation( new DefaultCSN( System.currentTimeMillis(),
+                new ReplicaId( "testReplica0" ), 1234 ), new LdapDN( "ou=system" ),
+                new AttributeImpl( "Hello", "Test" ) ) ), new LogEntryMessageEncoder(), new LogEntryMessageDecoder() );
+    }
+
+
+    protected boolean compare( BaseMessage expected0, BaseMessage actual0 )
+    {
+        LogEntryMessage expected = ( LogEntryMessage ) expected0;
+        LogEntryMessage actual = ( LogEntryMessage ) actual0;
+
+        // We don't compare operation here because it is {@link OperationCodec}'s
+        // duty to serialize and deserialize Invocations.
+        return expected.getType() == actual.getType() && expected.getSequence() == actual.getSequence()
+            && expected.getOperation().getCSN().equals( actual.getOperation().getCSN() )
+            && expected.getOperation().getClass() == actual.getOperation().getClass();
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,37 +1,37 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.service.protocol.codec.LoginAckMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.LoginAckMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.LoginAckMessage;
-
-
-public class LoginAckMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public LoginAckMessageCodecTest()
-    {
-        super( new LoginAckMessage( 1234, 5678, new ReplicaId( "ReplicaABCD" ) ), new LoginAckMessageEncoder(),
-            new LoginAckMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.service.protocol.codec.LoginAckMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.LoginAckMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.LoginAckMessage;
+
+
+public class LoginAckMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public LoginAckMessageCodecTest()
+    {
+        super( new LoginAckMessage( 1234, 5678, new ReplicaId( "ReplicaABCD" ) ), new LoginAckMessageEncoder(),
+            new LoginAckMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java Sun Sep 16 15:12:06 2007
@@ -1,37 +1,37 @@
-/*
- *  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.directory.mitosis.service.protocol.codec;
-
-
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.service.protocol.codec.LoginMessageDecoder;
-import org.apache.directory.mitosis.service.protocol.codec.LoginMessageEncoder;
-import org.apache.directory.mitosis.service.protocol.message.LoginMessage;
-
-
-public class LoginMessageCodecTest extends AbstractMessageCodecTest
-{
-
-    public LoginMessageCodecTest()
-    {
-        super( new LoginMessage( 1234, new ReplicaId( "myReplica0" ) ), new LoginMessageEncoder(),
-            new LoginMessageDecoder() );
-    }
-}
+/*
+ *  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.directory.mitosis.service.protocol.codec;
+
+
+import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.service.protocol.codec.LoginMessageDecoder;
+import org.apache.directory.mitosis.service.protocol.codec.LoginMessageEncoder;
+import org.apache.directory.mitosis.service.protocol.message.LoginMessage;
+
+
+public class LoginMessageCodecTest extends AbstractMessageCodecTest
+{
+
+    public LoginMessageCodecTest()
+    {
+        super( new LoginMessage( 1234, new ReplicaId( "myReplica0" ) ), new LoginMessageEncoder(),
+            new LoginMessageDecoder() );
+    }
+}

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java?rev=576193&r1=576192&r2=576193&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java Sun Sep 16 15:12:06 2007
@@ -1,446 +1,446 @@
-/*
- *  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.directory.mitosis.store.derby;
- 
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.naming.Name;
-import javax.naming.ldap.LdapName;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.DirectoryServiceListener;
-import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
-import org.apache.directory.server.core.configuration.StartupConfiguration;
-import org.apache.directory.server.core.interceptor.InterceptorChain;
-import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.core.schema.SchemaManager;
-import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.CSNFactory;
-import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.common.DefaultCSN;
-import org.apache.directory.mitosis.common.DefaultCSNFactory;
-import org.apache.directory.mitosis.common.DefaultUUIDFactory;
-import org.apache.directory.mitosis.common.UUID;
-import org.apache.directory.mitosis.common.UUIDFactory;
-import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
-import org.apache.directory.mitosis.operation.AddAttributeOperation;
-import org.apache.directory.mitosis.operation.AddEntryOperation;
-import org.apache.directory.mitosis.operation.CompositeOperation;
-import org.apache.directory.mitosis.operation.DeleteAttributeOperation;
-import org.apache.directory.mitosis.operation.Operation;
-import org.apache.directory.mitosis.operation.ReplaceAttributeOperation;
-import org.apache.directory.mitosis.store.ReplicationLogIterator;
-import org.apache.directory.mitosis.store.ReplicationStoreException;
-import org.apache.directory.mitosis.store.derby.DerbyReplicationStore;
-
-
-public class DerbyReplicationStoreTest extends TestCase
-{
-    private static final ReplicaId REPLICA_ID = new ReplicaId( "TEST_REPLICA" );
-    private static final ReplicaId OTHER_REPLICA_ID = new ReplicaId( "OTHER_REPLICA" );
-    private static final ReplicaId OTHER_REPLICA_ID_2 = new ReplicaId( "OTHER_REPLICA_2" );
-    private static final File DB_PATH = new File( "target/testDB" );
-
-    private final UUIDFactory uuidFactory = new DefaultUUIDFactory();
-    private final CSNFactory csnFactory = new DefaultCSNFactory();
-    private DerbyReplicationStore store;
-    private int testCount;
-    private long startTime;
-
-
-    public void setUp() throws Exception
-    {
-        dropDatabase();
-        startupDatabase( REPLICA_ID );
-        initStopWatch();
-    }
-
-
-    private void startupDatabase( ReplicaId replicaId ) throws Exception
-    {
-        // Prepare configuration
-        ReplicationConfiguration cfg = new ReplicationConfiguration();
-        cfg.setReplicaId( replicaId );
-
-        // Open store
-        store = new DerbyReplicationStore();
-        store.setTablePrefix( "TEST_" );
-        store.open( new DirectoryServiceConfigurationImpl(), cfg );
-    }
-
-
-    public void tearDown() throws Exception
-    {
-        store.close();
-        dropDatabase();
-    }
-
-
-    private void dropDatabase() throws IOException
-    {
-        FileUtils.deleteDirectory( DB_PATH );
-        File logFile = new File( "derby.log" );
-        if ( !logFile.delete() )
-        {
-            logFile.deleteOnExit();
-        }
-    }
-
-
-    public void testOperations() throws Exception
-    {
-        subTestReopen();
-        printElapsedTime( "Reopen" );
-        subTestUUID();
-        printElapsedTime( "UUID" );
-        subTestEmptyLog();
-        printElapsedTime( "EmptyLog" );
-        subTestWriteLog();
-        printElapsedTime( "WriteLog" );
-        subTestRemoveLogs();
-        printElapsedTime( "RemoveLogs" );
-        subTestVectors();
-        printElapsedTime( "Vectors" );
-    }
-
-
-    private void subTestReopen() throws Exception
-    {
-        store.close();
-        try
-        {
-            startupDatabase( OTHER_REPLICA_ID );
-            Assert.fail( "Store cannot start up with wrong replica ID." );
-        }
-        catch ( ReplicationStoreException e )
-        {
-        }
-        startupDatabase( REPLICA_ID );
-    }
-
-
-    private void subTestUUID() throws Exception
-    {
-        UUID uuid = uuidFactory.newInstance();
-        Name name = new LdapName( "ou=a, ou=b" );
-        Assert.assertTrue( store.putUUID( uuid, name ) );
-        Assert.assertEquals( name, store.getDN( uuid ) );
-        Assert.assertTrue( store.removeUUID( uuid ) );
-        Assert.assertFalse( store.removeUUID( uuid ) );
-        Assert.assertNull( store.getDN( uuid ) );
-    }
-
-
-    private void subTestEmptyLog() throws Exception
-    {
-        ReplicationLogIterator it;
-
-        it = store.getLogs( csnFactory.newInstance( REPLICA_ID ), true );
-        Assert.assertFalse( it.next() );
-        it.close();
-        it = store.getLogs( csnFactory.newInstance( REPLICA_ID ), false );
-        Assert.assertFalse( it.next() );
-        it.close();
-        it = store.getLogs( csnFactory.newInstance( OTHER_REPLICA_ID ), true );
-        Assert.assertFalse( it.next() );
-        it.close();
-        it = store.getLogs( csnFactory.newInstance( OTHER_REPLICA_ID ), false );
-        Assert.assertFalse( it.next() );
-        it.close();
-
-        Assert.assertEquals( 0, store.getLogSize() );
-    }
-
-
-    private void subTestWriteLog() throws Exception
-    {
-        CSN csn = csnFactory.newInstance( REPLICA_ID );
-        CompositeOperation op1 = new CompositeOperation( csn );
-        op1.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new AttributesImpl( true ) ) );
-        op1.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
-        op1.add( new ReplaceAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
-        op1.add( new DeleteAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
-
-        store.putLog( op1 );
-        testGetLogs( csn, op1 );
-
-        csn = csnFactory.newInstance( OTHER_REPLICA_ID );
-        CompositeOperation op2 = new CompositeOperation( csn );
-        op2.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new AttributesImpl( true ) ) );
-        op2.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
-        op2.add( new ReplaceAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
-        op2.add( new DeleteAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
-
-        store.putLog( op2 );
-        testGetLogs( csn, op2 );
-
-        Assert.assertEquals( 2, store.getLogSize() );
-        Assert.assertEquals( 1, store.getLogSize( REPLICA_ID ) );
-        Assert.assertEquals( 1, store.getLogSize( OTHER_REPLICA_ID ) );
-
-        // Test getLogs(CSNVector, true)
-        List<Operation> expected = new ArrayList<Operation>();
-        expected.add( op1 );
-        expected.add( op2 );
-        CSNVector updateVector = new CSNVector();
-        testGetLogs( updateVector, true, expected );
-        updateVector = new CSNVector();
-        updateVector.setCSN( op1.getCSN() );
-        testGetLogs( updateVector, true, expected );
-        updateVector = new CSNVector();
-        updateVector.setCSN( op2.getCSN() );
-        testGetLogs( updateVector, true, expected );
-        updateVector = new CSNVector();
-        updateVector.setCSN( op1.getCSN() );
-        updateVector.setCSN( op2.getCSN() );
-        testGetLogs( updateVector, true, expected );
-
-        // Test getLogs(CSNVector, false)
-        expected = new ArrayList<Operation>();
-        expected.add( op1 );
-        expected.add( op2 );
-        updateVector = new CSNVector();
-        testGetLogs( updateVector, false, expected );
-        expected = new ArrayList<Operation>();
-        expected.add( op2 );
-        updateVector = new CSNVector();
-        updateVector.setCSN( op1.getCSN() );
-        testGetLogs( updateVector, false, expected );
-        expected = new ArrayList<Operation>();
-        expected.add( op1 );
-        updateVector = new CSNVector();
-        updateVector.setCSN( op2.getCSN() );
-        testGetLogs( updateVector, false, expected );
-        expected = new ArrayList<Operation>();
-        updateVector = new CSNVector();
-        updateVector.setCSN( op1.getCSN() );
-        updateVector.setCSN( op2.getCSN() );
-        testGetLogs( updateVector, false, expected );
-    }
-
-
-    private void subTestRemoveLogs()
-    {
-        CSN csn;
-        ReplicationLogIterator it;
-
-        it = store.getLogs( new DefaultCSN( 0, REPLICA_ID, 0 ), false );
-        it.next();
-        csn = it.getOperation().getCSN();
-        it.close();
-
-        Assert.assertEquals( 0, store.removeLogs( csn, false ) );
-        Assert.assertEquals( 1, store.removeLogs( csn, true ) );
-        Assert.assertEquals( 0, store.getLogSize( REPLICA_ID ) );
-
-        it = store.getLogs( new DefaultCSN( 0, OTHER_REPLICA_ID, 0 ), false );
-        Assert.assertTrue( it.next() );
-        csn = it.getOperation().getCSN();
-        it.close();
-
-        Assert.assertEquals( 0, store.removeLogs( csn, false ) );
-        Assert.assertEquals( 1, store.removeLogs( csn, true ) );
-        Assert.assertEquals( 0, store.getLogSize( OTHER_REPLICA_ID ) );
-
-        Assert.assertEquals( 0, store.getLogSize() );
-    }
-
-
-    private void subTestVectors() throws Exception
-    {
-        CSN csnA = new DefaultCSN( 0, REPLICA_ID, 0 );
-        CSN csnB = new DefaultCSN( 1, REPLICA_ID, 0 );
-        CSN csnC = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 0 );
-        CSN csnD = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 1 );
-        store.putLog( new Operation( csnA ) );
-        store.putLog( new Operation( csnB ) );
-        store.putLog( new Operation( csnC ) );
-        store.putLog( new Operation( csnD ) );
-
-        Set<ReplicaId> expectedKnownReplicaIds = new HashSet<ReplicaId>();
-        expectedKnownReplicaIds.add( REPLICA_ID );
-        expectedKnownReplicaIds.add( OTHER_REPLICA_ID );
-        expectedKnownReplicaIds.add( OTHER_REPLICA_ID_2 );
-
-        Assert.assertEquals( expectedKnownReplicaIds, store.getKnownReplicaIds() );
-
-        CSNVector expectedUpdateVector = new CSNVector();
-        expectedUpdateVector.setCSN( csnB );
-        expectedUpdateVector.setCSN( csnD );
-
-        Assert.assertEquals( expectedUpdateVector, store.getUpdateVector() );
-
-        CSNVector expectedPurgeVector = new CSNVector();
-        expectedPurgeVector.setCSN( csnA );
-        expectedPurgeVector.setCSN( csnC );
-
-        Assert.assertEquals( expectedPurgeVector, store.getPurgeVector() );
-    }
-
-
-    private void testGetLogs( CSN csn, Operation operation )
-    {
-        List<Operation> operations = new ArrayList<Operation>();
-        operations.add( operation );
-        testGetLogs( csn, operations );
-    }
-
-
-    private void testGetLogs( CSN csn, List operations )
-    {
-        Iterator it = operations.iterator();
-        ReplicationLogIterator rit;
-
-        rit = store.getLogs( csn, true );
-        testGetLogs( it, rit );
-
-        rit = store.getLogs( csn, false );
-        Assert.assertFalse( rit.next() );
-        rit.close();
-    }
-
-
-    private void testGetLogs( CSNVector updateVector, boolean inclusive, List operations )
-    {
-        Iterator it = operations.iterator();
-        ReplicationLogIterator rit;
-
-        rit = store.getLogs( updateVector, inclusive );
-        testGetLogs( it, rit );
-    }
-
-
-    private void testGetLogs( Iterator expectedIt, ReplicationLogIterator actualIt )
-    {
-        while ( expectedIt.hasNext() )
-        {
-            Operation expected = ( Operation ) expectedIt.next();
-            Assert.assertTrue( actualIt.next() );
-
-            Operation actual = actualIt.getOperation();
-            Assert.assertEquals( expected.getCSN(), actual.getCSN() );
-            assertEquals( expected, actual );
-        }
-        Assert.assertFalse( actualIt.next() );
-        actualIt.close();
-    }
-
-
-    private void initStopWatch()
-    {
-        startTime = System.currentTimeMillis();
-    }
-
-
-    private void printElapsedTime( String testName )
-    {
-        long endTime = System.currentTimeMillis();
-        System.out.println( "Subtest #" + ( ++testCount ) + " [" + testName + "]: " + ( endTime - startTime ) + " ms" );
-        startTime = System.currentTimeMillis();
-    }
-
-
-    private static void assertEquals( Operation expected, Operation actual )
-    {
-        Assert.assertEquals( expected.toString(), actual.toString() );
-    }
-
-    private static class DirectoryServiceConfigurationImpl implements DirectoryServiceConfiguration
-    {
-        public DirectoryService getService()
-        {
-            return null;
-        }
-
-
-        public String getInstanceId()
-        {
-            return null;
-        }
-
-
-        public Hashtable getEnvironment()
-        {
-            return null;
-        }
-
-
-        public StartupConfiguration getStartupConfiguration()
-        {
-            MutableStartupConfiguration cfg = new MutableStartupConfiguration();
-            cfg.setWorkingDirectory( DB_PATH );
-            return cfg;
-        }
-
-
-        public Registries getRegistries()
-        {
-            return null;
-        }
-
-
-        public PartitionNexus getPartitionNexus()
-        {
-            return null;
-        }
-
-
-        public InterceptorChain getInterceptorChain()
-        {
-            return null;
-        }
-
-
-        public boolean isFirstStart()
-        {
-            return false;
-        }
-
-
-        public DirectoryServiceListener getServiceListener()
-        {
-            return null;
-        }
-
-
-        public SchemaManager getSchemaManager()
-        {
-            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.directory.mitosis.store.derby;
+ 
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.Name;
+import javax.naming.ldap.LdapName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.DirectoryServiceListener;
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.directory.server.core.interceptor.InterceptorChain;
+import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.SchemaManager;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.CSNFactory;
+import org.apache.directory.mitosis.common.CSNVector;
+import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.common.DefaultCSN;
+import org.apache.directory.mitosis.common.DefaultCSNFactory;
+import org.apache.directory.mitosis.common.DefaultUUIDFactory;
+import org.apache.directory.mitosis.common.UUID;
+import org.apache.directory.mitosis.common.UUIDFactory;
+import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
+import org.apache.directory.mitosis.operation.AddAttributeOperation;
+import org.apache.directory.mitosis.operation.AddEntryOperation;
+import org.apache.directory.mitosis.operation.CompositeOperation;
+import org.apache.directory.mitosis.operation.DeleteAttributeOperation;
+import org.apache.directory.mitosis.operation.Operation;
+import org.apache.directory.mitosis.operation.ReplaceAttributeOperation;
+import org.apache.directory.mitosis.store.ReplicationLogIterator;
+import org.apache.directory.mitosis.store.ReplicationStoreException;
+import org.apache.directory.mitosis.store.derby.DerbyReplicationStore;
+
+
+public class DerbyReplicationStoreTest extends TestCase
+{
+    private static final ReplicaId REPLICA_ID = new ReplicaId( "TEST_REPLICA" );
+    private static final ReplicaId OTHER_REPLICA_ID = new ReplicaId( "OTHER_REPLICA" );
+    private static final ReplicaId OTHER_REPLICA_ID_2 = new ReplicaId( "OTHER_REPLICA_2" );
+    private static final File DB_PATH = new File( "target/testDB" );
+
+    private final UUIDFactory uuidFactory = new DefaultUUIDFactory();
+    private final CSNFactory csnFactory = new DefaultCSNFactory();
+    private DerbyReplicationStore store;
+    private int testCount;
+    private long startTime;
+
+
+    public void setUp() throws Exception
+    {
+        dropDatabase();
+        startupDatabase( REPLICA_ID );
+        initStopWatch();
+    }
+
+
+    private void startupDatabase( ReplicaId replicaId ) throws Exception
+    {
+        // Prepare configuration
+        ReplicationConfiguration cfg = new ReplicationConfiguration();
+        cfg.setReplicaId( replicaId );
+
+        // Open store
+        store = new DerbyReplicationStore();
+        store.setTablePrefix( "TEST_" );
+        store.open( new DirectoryServiceConfigurationImpl(), cfg );
+    }
+
+
+    public void tearDown() throws Exception
+    {
+        store.close();
+        dropDatabase();
+    }
+
+
+    private void dropDatabase() throws IOException
+    {
+        FileUtils.deleteDirectory( DB_PATH );
+        File logFile = new File( "derby.log" );
+        if ( !logFile.delete() )
+        {
+            logFile.deleteOnExit();
+        }
+    }
+
+
+    public void testOperations() throws Exception
+    {
+        subTestReopen();
+        printElapsedTime( "Reopen" );
+        subTestUUID();
+        printElapsedTime( "UUID" );
+        subTestEmptyLog();
+        printElapsedTime( "EmptyLog" );
+        subTestWriteLog();
+        printElapsedTime( "WriteLog" );
+        subTestRemoveLogs();
+        printElapsedTime( "RemoveLogs" );
+        subTestVectors();
+        printElapsedTime( "Vectors" );
+    }
+
+
+    private void subTestReopen() throws Exception
+    {
+        store.close();
+        try
+        {
+            startupDatabase( OTHER_REPLICA_ID );
+            Assert.fail( "Store cannot start up with wrong replica ID." );
+        }
+        catch ( ReplicationStoreException e )
+        {
+        }
+        startupDatabase( REPLICA_ID );
+    }
+
+
+    private void subTestUUID() throws Exception
+    {
+        UUID uuid = uuidFactory.newInstance();
+        Name name = new LdapName( "ou=a, ou=b" );
+        Assert.assertTrue( store.putUUID( uuid, name ) );
+        Assert.assertEquals( name, store.getDN( uuid ) );
+        Assert.assertTrue( store.removeUUID( uuid ) );
+        Assert.assertFalse( store.removeUUID( uuid ) );
+        Assert.assertNull( store.getDN( uuid ) );
+    }
+
+
+    private void subTestEmptyLog() throws Exception
+    {
+        ReplicationLogIterator it;
+
+        it = store.getLogs( csnFactory.newInstance( REPLICA_ID ), true );
+        Assert.assertFalse( it.next() );
+        it.close();
+        it = store.getLogs( csnFactory.newInstance( REPLICA_ID ), false );
+        Assert.assertFalse( it.next() );
+        it.close();
+        it = store.getLogs( csnFactory.newInstance( OTHER_REPLICA_ID ), true );
+        Assert.assertFalse( it.next() );
+        it.close();
+        it = store.getLogs( csnFactory.newInstance( OTHER_REPLICA_ID ), false );
+        Assert.assertFalse( it.next() );
+        it.close();
+
+        Assert.assertEquals( 0, store.getLogSize() );
+    }
+
+
+    private void subTestWriteLog() throws Exception
+    {
+        CSN csn = csnFactory.newInstance( REPLICA_ID );
+        CompositeOperation op1 = new CompositeOperation( csn );
+        op1.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new AttributesImpl( true ) ) );
+        op1.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
+        op1.add( new ReplaceAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
+        op1.add( new DeleteAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
+
+        store.putLog( op1 );
+        testGetLogs( csn, op1 );
+
+        csn = csnFactory.newInstance( OTHER_REPLICA_ID );
+        CompositeOperation op2 = new CompositeOperation( csn );
+        op2.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new AttributesImpl( true ) ) );
+        op2.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
+        op2.add( new ReplaceAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
+        op2.add( new DeleteAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
+
+        store.putLog( op2 );
+        testGetLogs( csn, op2 );
+
+        Assert.assertEquals( 2, store.getLogSize() );
+        Assert.assertEquals( 1, store.getLogSize( REPLICA_ID ) );
+        Assert.assertEquals( 1, store.getLogSize( OTHER_REPLICA_ID ) );
+
+        // Test getLogs(CSNVector, true)
+        List<Operation> expected = new ArrayList<Operation>();
+        expected.add( op1 );
+        expected.add( op2 );
+        CSNVector updateVector = new CSNVector();
+        testGetLogs( updateVector, true, expected );
+        updateVector = new CSNVector();
+        updateVector.setCSN( op1.getCSN() );
+        testGetLogs( updateVector, true, expected );
+        updateVector = new CSNVector();
+        updateVector.setCSN( op2.getCSN() );
+        testGetLogs( updateVector, true, expected );
+        updateVector = new CSNVector();
+        updateVector.setCSN( op1.getCSN() );
+        updateVector.setCSN( op2.getCSN() );
+        testGetLogs( updateVector, true, expected );
+
+        // Test getLogs(CSNVector, false)
+        expected = new ArrayList<Operation>();
+        expected.add( op1 );
+        expected.add( op2 );
+        updateVector = new CSNVector();
+        testGetLogs( updateVector, false, expected );
+        expected = new ArrayList<Operation>();
+        expected.add( op2 );
+        updateVector = new CSNVector();
+        updateVector.setCSN( op1.getCSN() );
+        testGetLogs( updateVector, false, expected );
+        expected = new ArrayList<Operation>();
+        expected.add( op1 );
+        updateVector = new CSNVector();
+        updateVector.setCSN( op2.getCSN() );
+        testGetLogs( updateVector, false, expected );
+        expected = new ArrayList<Operation>();
+        updateVector = new CSNVector();
+        updateVector.setCSN( op1.getCSN() );
+        updateVector.setCSN( op2.getCSN() );
+        testGetLogs( updateVector, false, expected );
+    }
+
+
+    private void subTestRemoveLogs()
+    {
+        CSN csn;
+        ReplicationLogIterator it;
+
+        it = store.getLogs( new DefaultCSN( 0, REPLICA_ID, 0 ), false );
+        it.next();
+        csn = it.getOperation().getCSN();
+        it.close();
+
+        Assert.assertEquals( 0, store.removeLogs( csn, false ) );
+        Assert.assertEquals( 1, store.removeLogs( csn, true ) );
+        Assert.assertEquals( 0, store.getLogSize( REPLICA_ID ) );
+
+        it = store.getLogs( new DefaultCSN( 0, OTHER_REPLICA_ID, 0 ), false );
+        Assert.assertTrue( it.next() );
+        csn = it.getOperation().getCSN();
+        it.close();
+
+        Assert.assertEquals( 0, store.removeLogs( csn, false ) );
+        Assert.assertEquals( 1, store.removeLogs( csn, true ) );
+        Assert.assertEquals( 0, store.getLogSize( OTHER_REPLICA_ID ) );
+
+        Assert.assertEquals( 0, store.getLogSize() );
+    }
+
+
+    private void subTestVectors() throws Exception
+    {
+        CSN csnA = new DefaultCSN( 0, REPLICA_ID, 0 );
+        CSN csnB = new DefaultCSN( 1, REPLICA_ID, 0 );
+        CSN csnC = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 0 );
+        CSN csnD = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 1 );
+        store.putLog( new Operation( csnA ) );
+        store.putLog( new Operation( csnB ) );
+        store.putLog( new Operation( csnC ) );
+        store.putLog( new Operation( csnD ) );
+
+        Set<ReplicaId> expectedKnownReplicaIds = new HashSet<ReplicaId>();
+        expectedKnownReplicaIds.add( REPLICA_ID );
+        expectedKnownReplicaIds.add( OTHER_REPLICA_ID );
+        expectedKnownReplicaIds.add( OTHER_REPLICA_ID_2 );
+
+        Assert.assertEquals( expectedKnownReplicaIds, store.getKnownReplicaIds() );
+
+        CSNVector expectedUpdateVector = new CSNVector();
+        expectedUpdateVector.setCSN( csnB );
+        expectedUpdateVector.setCSN( csnD );
+
+        Assert.assertEquals( expectedUpdateVector, store.getUpdateVector() );
+
+        CSNVector expectedPurgeVector = new CSNVector();
+        expectedPurgeVector.setCSN( csnA );
+        expectedPurgeVector.setCSN( csnC );
+
+        Assert.assertEquals( expectedPurgeVector, store.getPurgeVector() );
+    }
+
+
+    private void testGetLogs( CSN csn, Operation operation )
+    {
+        List<Operation> operations = new ArrayList<Operation>();
+        operations.add( operation );
+        testGetLogs( csn, operations );
+    }
+
+
+    private void testGetLogs( CSN csn, List operations )
+    {
+        Iterator it = operations.iterator();
+        ReplicationLogIterator rit;
+
+        rit = store.getLogs( csn, true );
+        testGetLogs( it, rit );
+
+        rit = store.getLogs( csn, false );
+        Assert.assertFalse( rit.next() );
+        rit.close();
+    }
+
+
+    private void testGetLogs( CSNVector updateVector, boolean inclusive, List operations )
+    {
+        Iterator it = operations.iterator();
+        ReplicationLogIterator rit;
+
+        rit = store.getLogs( updateVector, inclusive );
+        testGetLogs( it, rit );
+    }
+
+
+    private void testGetLogs( Iterator expectedIt, ReplicationLogIterator actualIt )
+    {
+        while ( expectedIt.hasNext() )
+        {
+            Operation expected = ( Operation ) expectedIt.next();
+            Assert.assertTrue( actualIt.next() );
+
+            Operation actual = actualIt.getOperation();
+            Assert.assertEquals( expected.getCSN(), actual.getCSN() );
+            assertEquals( expected, actual );
+        }
+        Assert.assertFalse( actualIt.next() );
+        actualIt.close();
+    }
+
+
+    private void initStopWatch()
+    {
+        startTime = System.currentTimeMillis();
+    }
+
+
+    private void printElapsedTime( String testName )
+    {
+        long endTime = System.currentTimeMillis();
+        System.out.println( "Subtest #" + ( ++testCount ) + " [" + testName + "]: " + ( endTime - startTime ) + " ms" );
+        startTime = System.currentTimeMillis();
+    }
+
+
+    private static void assertEquals( Operation expected, Operation actual )
+    {
+        Assert.assertEquals( expected.toString(), actual.toString() );
+    }
+
+    private static class DirectoryServiceConfigurationImpl implements DirectoryServiceConfiguration
+    {
+        public DirectoryService getService()
+        {
+            return null;
+        }
+
+
+        public String getInstanceId()
+        {
+            return null;
+        }
+
+
+        public Hashtable getEnvironment()
+        {
+            return null;
+        }
+
+
+        public StartupConfiguration getStartupConfiguration()
+        {
+            MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+            cfg.setWorkingDirectory( DB_PATH );
+            return cfg;
+        }
+
+
+        public Registries getRegistries()
+        {
+            return null;
+        }
+
+
+        public PartitionNexus getPartitionNexus()
+        {
+            return null;
+        }
+
+
+        public InterceptorChain getInterceptorChain()
+        {
+            return null;
+        }
+
+
+        public boolean isFirstStart()
+        {
+            return false;
+        }
+
+
+        public DirectoryServiceListener getServiceListener()
+        {
+            return null;
+        }
+
+
+        public SchemaManager getSchemaManager()
+        {
+            return null;
+        }
+    }
+}