示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadNoKeyIdAsMinusOne() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadNoKeyIdAsMinusOne()
        {
            // GIVEN
            InMemoryClosableChannel channel     = new InMemoryClosableChannel();
            IndexDefineCommand      definitions = new IndexDefineCommand();
            int indexNameId = 10;

            definitions.Init(ObjectIntHashMap.newWithKeysValues("myindex", indexNameId), new ObjectIntHashMap <string>());
            definitions.Serialize(channel);
            IndexCommand.RemoveCommand removeCommand = new IndexCommand.RemoveCommand();
            removeCommand.Init(indexNameId, IndexEntityType.Node.id(), 1234, -1, null);
            removeCommand.Serialize(channel);

            // WHEN
            PhysicalLogCommandReaderV2_2_4 reader = new PhysicalLogCommandReaderV2_2_4();

            assertTrue(reader.Read(channel) is IndexDefineCommand);
            IndexCommand.RemoveCommand readRemoveCommand = (IndexCommand.RemoveCommand)reader.Read(channel);

            // THEN
            assertEquals(removeCommand.IndexNameId, readRemoveCommand.IndexNameId);
            assertEquals(removeCommand.EntityType, readRemoveCommand.EntityType);
            assertEquals(removeCommand.EntityId, readRemoveCommand.EntityId);
            assertEquals(removeCommand.KeyId, readRemoveCommand.KeyId);
            assertNull(removeCommand.Value);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleMultipleIdSpaces() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldHandleMultipleIdSpaces()
        {
            // GIVEN
            string           indexName      = "name";
            string           key            = "key";
            DatabaseLayout   databaseLayout = _testDirectory.databaseLayout();
            IndexConfigStore configStore    = new IndexConfigStore(databaseLayout, _fs);

            configStore.Set(typeof(Node), indexName, EXACT_CONFIG);
            using (Lifespan lifespan = new Lifespan())
            {
                Config           dataSourceConfig   = Config.defaults(LuceneDataSource.Configuration.Ephemeral, Settings.TRUE);
                LuceneDataSource originalDataSource = new LuceneDataSource(databaseLayout, dataSourceConfig, configStore, _fs, OperationalMode.single);
                LuceneDataSource dataSource         = lifespan.Add(spy(originalDataSource));

                using (LuceneCommandApplier applier = new LuceneCommandApplier(dataSource, false))
                {
                    // WHEN issuing a command where the index name is mapped to a certain id
                    IndexDefineCommand definitions = definitions(ObjectIntHashMap.newWithKeysValues(indexName, 0), ObjectIntHashMap.newWithKeysValues(key, 0));
                    applier.VisitIndexDefineCommand(definitions);
                    applier.VisitIndexAddNodeCommand(AddNodeToIndex(definitions, indexName, 0L));
                    // and then later issuing a command for that same index, but in another transaction where
                    // the local index name id is a different one
                    definitions = definitions(ObjectIntHashMap.newWithKeysValues(indexName, 1), ObjectIntHashMap.newWithKeysValues(key, 0));
                    applier.VisitIndexDefineCommand(definitions);
                    applier.VisitIndexAddNodeCommand(AddNodeToIndex(definitions, indexName, 1L));
                }

                // THEN both those updates should have been directed to the same index
                verify(dataSource, times(1)).getIndexSearcher(any(typeof(IndexIdentifier)));
            }
        }