Skip to content

Instantly share code, notes, and snippets.

@RunWith(FeaturesRunner.class)
@Features({CoreFeature.class})
public class TestClass {
@Inject
protected RuntimeHarness harness.
@Test
public void myTest() throws Exception {
// deploy the complete bundle
@ldoguin
ldoguin / DirectoryProjection.java
Created July 16, 2013 16:38
Operation for the Nuxeo Content Automation API. This operation execute a search on a Nuxeo directory.
/*
* (C) Copyright 2006-2013 Nuxeo SAS (http://nuxeo.com/) and contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ldoguin
ldoguin / pom.xml
Last active August 29, 2015 14:13
spring-data-couchbase starting point
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.couchbase.advocacy</groupId>
<artifactId>couchbase-social-metrics</artifactId>
<version>1.0-SNAPSHOT</version>
@ldoguin
ldoguin / Application.java
Last active August 29, 2015 14:14
Starting application class for spring data couchbase
package org.couchbase.advocacy.metrics;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
@ldoguin
ldoguin / TwitterUpdate.java
Last active August 29, 2015 14:14
A twitter update Spring Document
package org.couchbase.advocacy.metrics.twitter;
import org.springframework.data.annotation.Id;
import org.springframework.data.couchbase.core.mapping.Document;
import org.springframework.data.couchbase.core.mapping.Field;
@Document(expiry = 0)
public class TwitterUpdate {
@Id
@ldoguin
ldoguin / TwitterService.java
Created January 26, 2015 14:54
Spring service to store twit account update in Couchbase
package org.couchbase.advocacy.metrics.twitter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.social.twitter.api.TwitterProfile;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Iterator;
package org.couchbase.couchswitching;
import com.couchbase.client.core.BackpressureException;
import com.couchbase.client.core.RequestCancelledException;
import com.couchbase.client.deps.com.fasterxml.jackson.databind.JsonNode;
import com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper;
import com.couchbase.client.java.AsyncBucket;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.RawJsonDocument;
import com.couchbase.client.java.error.TemporaryFailureException;
@ldoguin
ldoguin / DiscoveryListener.java
Created October 6, 2015 08:56
P2P sync code with JmDNS auto discovery
package org.couchbase.devex;
import com.couchbase.lite.Database;
import com.couchbase.lite.listener.LiteListener;
import com.couchbase.lite.replicator.Replication;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceListener;
import java.io.IOException;
/*
* 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
*
@ldoguin
ldoguin / DockerCouchbaseTest.java
Last active July 18, 2016 10:23
This gist is using testcontainers(http://testcontainers.viewdocs.io/testcontainers-java/) and a custom Couchbase docker image.
package com.couchbase.fullstack;
import com.couchbase.client.core.CouchbaseCore;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import org.junit.ClassRule;
import org.junit.Test;
import org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties;