http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java deleted file mode 100644 index 8de7f9c..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi; - -import org.apache.camel.CamelContext; -import org.apache.camel.spring.SpringCamelContext; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -public abstract class OSGiIntegrationSpringTestSupport extends OSGiIntegrationTestSupport { - protected OsgiBundleXmlApplicationContext applicationContext; - protected abstract OsgiBundleXmlApplicationContext createApplicationContext(); - - @Override - protected CamelContext createCamelContext() throws Exception { - setThreadContextClassLoader(); - applicationContext = createApplicationContext(); - assertNotNull("Should have created a valid spring context", applicationContext); - applicationContext.setBundleContext(bundleContext); - applicationContext.refresh(); - String[] names = applicationContext.getBeanNamesForType(SpringCamelContext.class); - if (names.length == 1) { - return applicationContext.getBean(names[0], SpringCamelContext.class); - } else { - throw new IllegalStateException("Exactly 1 bean of type SpringCamelContext expected but found " + names.length + " beans."); - } - } - -}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTestSupport.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTestSupport.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTestSupport.java deleted file mode 100644 index a9fce54..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTestSupport.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi; -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.apache.camel.osgi.CamelContextFactory; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.karaf.options.KarafDistributionOption; -import org.ops4j.pax.exam.karaf.options.LogLevelOption; -import org.ops4j.pax.exam.options.MavenArtifactProvisionOption; -import org.ops4j.pax.exam.options.UrlReference; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.ops4j.pax.exam.CoreOptions.maven; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.OptionUtils.combine; - -public class OSGiIntegrationTestSupport extends CamelTestSupport { - protected static final Logger LOG = LoggerFactory.getLogger(OSGiIntegrationTestSupport.class); - protected static final AtomicInteger COUNTER = new AtomicInteger(); - protected static String workDir = "target/paxrunner/"; - @Inject - protected BundleContext bundleContext; - - protected Bundle getInstalledBundle(String symbolicName) { - for (Bundle b : bundleContext.getBundles()) { - if (b.getSymbolicName().equals(symbolicName)) { - return b; - } - } - for (Bundle b : bundleContext.getBundles()) { - LOG.warn("Bundle: " + b.getSymbolicName()); - } - throw new RuntimeException("Bundle " + symbolicName + " does not exist"); - } - - protected CamelContext createCamelContext() throws Exception { - LOG.info("Get the bundleContext is " + bundleContext); - LOG.info("Application installed as bundle id: " + bundleContext.getBundle().getBundleId()); - - setThreadContextClassLoader(); - - CamelContextFactory factory = new CamelContextFactory(); - factory.setBundleContext(bundleContext); - factory.setRegistry(createRegistry()); - return factory.createContext(); - } - - protected void setThreadContextClassLoader() { - // set the thread context classloader current bundle classloader - Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); - } - - public static UrlReference getCamelKarafFeatureUrl() { - return getCamelKarafFeatureUrl(null); - } - - public static MavenArtifactProvisionOption getJUnitBundle() { - MavenArtifactProvisionOption mavenOption = mavenBundle().groupId("org.apache.servicemix.bundles") - .artifactId("org.apache.servicemix.bundles.junit"); - mavenOption.versionAsInProject().start(true).startLevel(10); - return mavenOption; - } - - public static UrlReference getCamelKarafFeatureUrl(String version) { - String type = "xml/features"; - MavenArtifactProvisionOption mavenOption = mavenBundle().groupId("org.apache.camel.karaf").artifactId("apache-camel"); - if (version == null) { - return mavenOption.versionAsInProject().type(type); - } else { - return mavenOption.version(version).type(type); - } - } - - public static UrlReference getKarafFeatureUrl() { - String karafVersion = System.getProperty("karafVersion"); - LOG.info("*** The karaf version is " + karafVersion + " ***"); - - String type = "xml/features"; - return mavenBundle().groupId("org.apache.karaf.assemblies.features"). - artifactId("standard").version(karafVersion).type(type); - } - - public static UrlReference getKarafEnterpriseFeatureUrl() { - String karafVersion = System.getProperty("karafVersion"); - LOG.info("*** The karaf version is " + karafVersion + " ***"); - - String type = "xml/features"; - return mavenBundle().groupId("org.apache.karaf.assemblies.features"). - artifactId("enterprise").version(karafVersion).type(type); - } - - public static Option loadCamelFeatures(String... features) { - - List<String> result = new ArrayList<String>(); - result.add("cxf-jaxb"); - result.add("camel-core"); - result.add("camel-spring"); - result.add("camel-test"); - for (String feature : features) { - result.add(feature); - } - return scanFeatures(getCamelKarafFeatureUrl(), result.toArray(new String[4 + features.length])); - } - public static Option scanFeatures(UrlReference ref, String ... features) { - return KarafDistributionOption.features(ref, features); - } - public static Option scanFeatures(String ref, String ... features) { - return KarafDistributionOption.features(ref, features); - } - public static Option felix() { - return KarafDistributionOption.editConfigurationFileExtend("etc/config.properties", - "karaf.framework", - "felix"); - } - public static Option equinox() { - return KarafDistributionOption.editConfigurationFileExtend("etc/config.properties", - "karaf.framework", - "equinox"); - } - - private static String getKarafVersion() { - InputStream ins = OSGiIntegrationTestSupport.class.getResourceAsStream("/META-INF/maven/dependencies.properties"); - Properties p = new Properties(); - try { - p.load(ins); - } catch (Throwable t) { - // - } - String karafVersion = p.getProperty("org.apache.karaf/apache-karaf/version"); - if (karafVersion == null) { - karafVersion = System.getProperty("karafVersion"); - } - if (karafVersion == null) { - // setup the default version of it - karafVersion = "2.4.4"; - } - return karafVersion; - } - - public static Option[] getDefaultCamelKarafOptions() { - String karafVersion = getKarafVersion(); - LOG.info("*** The karaf version is " + karafVersion + " ***"); - - Option[] options = - // Set the karaf environment with some customer configuration - new Option[] { - // for remote debugging - //org.ops4j.pax.exam.CoreOptions.vmOption("-Xdebug"), - //org.ops4j.pax.exam.CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5008"), - - KarafDistributionOption.karafDistributionConfiguration() - .frameworkUrl(maven().groupId("org.apache.karaf") - .artifactId("apache-karaf").type("tar.gz").versionAsInProject()) - .karafVersion(karafVersion) - .name("Apache Karaf") - .useDeployFolder(false) - .unpackDirectory(new File("target/paxexam/unpack/")), - - //KarafDistributionOption.keepRuntimeFolder(), - // override the config.properties (to fix pax-exam bug) - // KarafDistributionOption.replaceConfigurationFile("etc/config.properties", new File("src/test/resources/org/apache/camel/itest/karaf/config.properties")), - // Need to override the jre setting - KarafDistributionOption.replaceConfigurationFile("etc/jre.properties", new File("src/test/resources/org/apache/camel/itest/karaf/jre.properties")), - KarafDistributionOption.replaceConfigurationFile("etc/custom.properties", new File("src/test/resources/org/apache/camel/itest/karaf/custom.properties")), - KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.url.mvn.cfg", new File("src/test/resources/org/apache/camel/itest/karaf/org.ops4j.pax.url.mvn.cfg")), - - //Grab JUnit and put it very early in the startup to make sure any bundles that are loaded - //will use the same version/bundle - getJUnitBundle(), - // we need INFO logging otherwise we cannot see what happens - new LogLevelOption(LogLevelOption.LogLevel.INFO), - // install the cxf jaxb spec as the karaf doesn't provide it by default - scanFeatures(getCamelKarafFeatureUrl(), "cxf-jaxb", "camel-core", "camel-spring", "camel-test")}; - - return options; - - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions() - ); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ahc/AhcTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ahc/AhcTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ahc/AhcTest.java deleted file mode 100644 index f9ea05b..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ahc/AhcTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.ahc; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerMethod; - -import static org.ops4j.pax.exam.OptionUtils.combine; -/** - * - */ -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerMethod.class) -public class AhcTest extends OSGiIntegrationTestSupport { - - @Test - public void testAhcGet() throws Exception { - String reply = template.requestBody("ahc:http://localhost:9081/foo", null, String.class); - assertEquals("Bye World", reply); - } - - @Test - public void testAhcPost() throws Exception { - String reply = template.requestBody("ahc:http://localhost:9081/foo", "Hello World", String.class); - assertEquals("Bye World", reply); - } - - @Test - @Ignore("Requires online internet for testing") - public void testAhcGoogle() throws Exception { - String reply = template.requestBody("ahc:http://www.google.se", null, String.class); - assertNotNull(reply); - log.info(reply); - } - - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("jetty:http://0.0.0.0:9081/foo") - .transform(constant("Bye World")); - } - }; - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install other camel components - loadCamelFeatures("camel-jetty", "camel-ahc")); - return options; - } - - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonS3ClientMock.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonS3ClientMock.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonS3ClientMock.java deleted file mode 100644 index 4c46eeb..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonS3ClientMock.java +++ /dev/null @@ -1,423 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import com.amazonaws.AmazonClientException; -import com.amazonaws.AmazonServiceException; -import com.amazonaws.AmazonWebServiceRequest; -import com.amazonaws.HttpMethod; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.s3.AmazonS3Client; -import com.amazonaws.services.s3.S3ResponseMetadata; -import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; -import com.amazonaws.services.s3.model.AccessControlList; -import com.amazonaws.services.s3.model.Bucket; -import com.amazonaws.services.s3.model.BucketLoggingConfiguration; -import com.amazonaws.services.s3.model.BucketNotificationConfiguration; -import com.amazonaws.services.s3.model.BucketPolicy; -import com.amazonaws.services.s3.model.BucketVersioningConfiguration; -import com.amazonaws.services.s3.model.CannedAccessControlList; -import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; -import com.amazonaws.services.s3.model.CompleteMultipartUploadResult; -import com.amazonaws.services.s3.model.CopyObjectRequest; -import com.amazonaws.services.s3.model.CopyObjectResult; -import com.amazonaws.services.s3.model.CreateBucketRequest; -import com.amazonaws.services.s3.model.DeleteBucketRequest; -import com.amazonaws.services.s3.model.DeleteObjectRequest; -import com.amazonaws.services.s3.model.DeleteVersionRequest; -import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; -import com.amazonaws.services.s3.model.GetObjectMetadataRequest; -import com.amazonaws.services.s3.model.GetObjectRequest; -import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest; -import com.amazonaws.services.s3.model.InitiateMultipartUploadResult; -import com.amazonaws.services.s3.model.ListBucketsRequest; -import com.amazonaws.services.s3.model.ListMultipartUploadsRequest; -import com.amazonaws.services.s3.model.ListObjectsRequest; -import com.amazonaws.services.s3.model.ListPartsRequest; -import com.amazonaws.services.s3.model.ListVersionsRequest; -import com.amazonaws.services.s3.model.MultipartUploadListing; -import com.amazonaws.services.s3.model.ObjectListing; -import com.amazonaws.services.s3.model.ObjectMetadata; -import com.amazonaws.services.s3.model.Owner; -import com.amazonaws.services.s3.model.PartListing; -import com.amazonaws.services.s3.model.PutObjectRequest; -import com.amazonaws.services.s3.model.PutObjectResult; -import com.amazonaws.services.s3.model.Region; -import com.amazonaws.services.s3.model.S3Object; -import com.amazonaws.services.s3.model.S3ObjectSummary; -import com.amazonaws.services.s3.model.SetBucketLoggingConfigurationRequest; -import com.amazonaws.services.s3.model.SetBucketVersioningConfigurationRequest; -import com.amazonaws.services.s3.model.StorageClass; -import com.amazonaws.services.s3.model.UploadPartRequest; -import com.amazonaws.services.s3.model.UploadPartResult; -import com.amazonaws.services.s3.model.VersionListing; - -public class AmazonS3ClientMock extends AmazonS3Client { - - List<S3Object> objects = new ArrayList<S3Object>(); - - public AmazonS3ClientMock() { - super(new BasicAWSCredentials("myAccessKey", "mySecretKey")); - } - - @Override - public VersionListing listNextBatchOfVersions(VersionListing previousVersionListing) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public VersionListing listVersions(String bucketName, String prefix) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public VersionListing listVersions(String bucketName, String prefix, String keyMarker, String versionIdMarker, String delimiter, Integer maxKeys) - throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public VersionListing listVersions(ListVersionsRequest listVersionsRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public ObjectListing listObjects(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public ObjectListing listObjects(String bucketName, String prefix) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public ObjectListing listObjects(ListObjectsRequest listObjectsRequest) throws AmazonClientException, AmazonServiceException { - ObjectListing objectListing = new ObjectListing(); - int capacity = listObjectsRequest.getMaxKeys(); - - for (int index = 0; index < objects.size() && index < capacity; index++) { - S3ObjectSummary s3ObjectSummary = new S3ObjectSummary(); - s3ObjectSummary.setBucketName(objects.get(index).getBucketName()); - s3ObjectSummary.setKey(objects.get(index).getKey()); - - objectListing.getObjectSummaries().add(s3ObjectSummary); - } - - return objectListing; - } - - @Override - public ObjectListing listNextBatchOfObjects(ObjectListing previousObjectListing) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public List<Bucket> listBuckets(ListBucketsRequest listBucketsRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException { - return new ArrayList<Bucket>(); - } - - @Override - public String getBucketLocation(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public Bucket createBucket(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public Bucket createBucket(String bucketName, Region region) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public Bucket createBucket(String bucketName, String region) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException { - Bucket bucket = new Bucket(); - bucket.setName(createBucketRequest.getBucketName()); - bucket.setCreationDate(new Date()); - bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller")); - return bucket; - } - - @Override - public AccessControlList getObjectAcl(String bucketName, String key) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public AccessControlList getObjectAcl(String bucketName, String key, String versionId) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setObjectAcl(String bucketName, String key, AccessControlList acl) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setObjectAcl(String bucketName, String key, CannedAccessControlList acl) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setObjectAcl(String bucketName, String key, String versionId, AccessControlList acl) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setObjectAcl(String bucketName, String key, String versionId, CannedAccessControlList acl) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public AccessControlList getBucketAcl(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setBucketAcl(String bucketName, AccessControlList acl) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setBucketAcl(String bucketName, CannedAccessControlList acl) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public ObjectMetadata getObjectMetadata(String bucketName, String key) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public S3Object getObject(String bucketName, String key) throws AmazonClientException, AmazonServiceException { - for (S3Object s3Object : objects) { - if (bucketName.equals(s3Object.getBucketName()) && key.equals(s3Object.getKey())) { - return s3Object; - } - } - - return null; - } - - @Override - public boolean doesBucketExist(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void changeObjectStorageClass(String bucketName, String key, StorageClass newStorageClass) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public S3Object getObject(GetObjectRequest getObjectRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public ObjectMetadata getObject(GetObjectRequest getObjectRequest, File destinationFile) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void deleteBucket(String bucketName) throws AmazonClientException, AmazonServiceException { - // noop - } - - @Override - public void deleteBucket(DeleteBucketRequest deleteBucketRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public PutObjectResult putObject(String bucketName, String key, File file) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public PutObjectResult putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public PutObjectResult putObject(PutObjectRequest putObjectRequest) throws AmazonClientException, AmazonServiceException { - S3Object s3Object = new S3Object(); - s3Object.setBucketName(putObjectRequest.getBucketName()); - s3Object.setKey(putObjectRequest.getKey()); - s3Object.setObjectContent(putObjectRequest.getInputStream()); - objects.add(s3Object); - - PutObjectResult putObjectResult = new PutObjectResult(); - putObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264"); - return putObjectResult; - } - - @Override - public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void deleteObject(String bucketName, String key) throws AmazonClientException, AmazonServiceException { - //noop - } - - @Override - public void deleteObject(DeleteObjectRequest deleteObjectRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void deleteVersion(String bucketName, String key, String versionId) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void deleteVersion(DeleteVersionRequest deleteVersionRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest setBucketVersioningConfigurationRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public BucketVersioningConfiguration getBucketVersioningConfiguration(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setBucketNotificationConfiguration(String bucketName, BucketNotificationConfiguration bucketNotificationConfiguration) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public BucketNotificationConfiguration getBucketNotificationConfiguration(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public BucketLoggingConfiguration getBucketLoggingConfiguration(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setBucketLoggingConfiguration(SetBucketLoggingConfigurationRequest setBucketLoggingConfigurationRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public BucketPolicy getBucketPolicy(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void setBucketPolicy(String bucketName, String policyText) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public void deleteBucketPolicy(String bucketName) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public URL generatePresignedUrl(String bucketName, String key, Date expiration) throws AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public URL generatePresignedUrl(GeneratePresignedUrlRequest generatePresignedUrlRequest) throws AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public InitiateMultipartUploadResult initiateMultipartUpload(InitiateMultipartUploadRequest initiateMultipartUploadRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public MultipartUploadListing listMultipartUploads(ListMultipartUploadsRequest listMultipartUploadsRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public PartListing listParts(ListPartsRequest listPartsRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public UploadPartResult uploadPart(UploadPartRequest uploadPartRequest) throws AmazonClientException, AmazonServiceException { - throw new UnsupportedOperationException(); - } - - @Override - public S3ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) { - throw new UnsupportedOperationException(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java deleted file mode 100644 index 2cbc91e..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import com.amazonaws.AmazonClientException; -import com.amazonaws.AmazonServiceException; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.simpledb.AmazonSimpleDBClient; -import com.amazonaws.services.simpledb.model.Attribute; -import com.amazonaws.services.simpledb.model.BatchDeleteAttributesRequest; -import com.amazonaws.services.simpledb.model.BatchPutAttributesRequest; -import com.amazonaws.services.simpledb.model.CreateDomainRequest; -import com.amazonaws.services.simpledb.model.DeleteAttributesRequest; -import com.amazonaws.services.simpledb.model.DeleteDomainRequest; -import com.amazonaws.services.simpledb.model.DomainMetadataRequest; -import com.amazonaws.services.simpledb.model.DomainMetadataResult; -import com.amazonaws.services.simpledb.model.GetAttributesRequest; -import com.amazonaws.services.simpledb.model.GetAttributesResult; -import com.amazonaws.services.simpledb.model.Item; -import com.amazonaws.services.simpledb.model.ListDomainsRequest; -import com.amazonaws.services.simpledb.model.ListDomainsResult; -import com.amazonaws.services.simpledb.model.NoSuchDomainException; -import com.amazonaws.services.simpledb.model.PutAttributesRequest; -import com.amazonaws.services.simpledb.model.SelectRequest; -import com.amazonaws.services.simpledb.model.SelectResult; - -public class AmazonSDBClientMock extends AmazonSimpleDBClient { - - protected BatchDeleteAttributesRequest batchDeleteAttributesRequest; - protected BatchPutAttributesRequest batchPutAttributesRequest; - protected CreateDomainRequest createDomainRequest; - protected DeleteAttributesRequest deleteAttributesRequest; - protected DeleteDomainRequest deleteDomainRequest; - protected DomainMetadataRequest domainMetadataRequest; - protected GetAttributesRequest getAttributesRequest; - protected ListDomainsRequest listDomainsRequest; - protected PutAttributesRequest putAttributesRequest; - protected SelectRequest selectRequest; - - public AmazonSDBClientMock() { - super(new BasicAWSCredentials("user", "secret")); - } - - @Override - public void batchDeleteAttributes(BatchDeleteAttributesRequest batchDeleteAttributesRequest) throws AmazonServiceException, AmazonClientException { - this.batchDeleteAttributesRequest = batchDeleteAttributesRequest; - } - - @Override - public void batchPutAttributes(BatchPutAttributesRequest batchPutAttributesRequest) throws AmazonServiceException, AmazonClientException { - this.batchPutAttributesRequest = batchPutAttributesRequest; - } - - @Override - public void createDomain(CreateDomainRequest createDomainRequest) throws AmazonServiceException, AmazonClientException { - this.createDomainRequest = createDomainRequest; - } - - @Override - public void deleteAttributes(DeleteAttributesRequest deleteAttributesRequest) throws AmazonServiceException, AmazonClientException { - this.deleteAttributesRequest = deleteAttributesRequest; - - String domainName = deleteAttributesRequest.getDomainName(); - if ("MissingDomain".equals(domainName)) { - throw new NoSuchDomainException(domainName); - } - } - - @Override - public void deleteDomain(DeleteDomainRequest deleteDomainRequest) throws AmazonServiceException, AmazonClientException { - this.deleteDomainRequest = deleteDomainRequest; - } - - @Override - public DomainMetadataResult domainMetadata(DomainMetadataRequest domainMetadataRequest) throws AmazonServiceException, AmazonClientException { - this.domainMetadataRequest = domainMetadataRequest; - - if ("NonExistingDomain".equals(domainMetadataRequest.getDomainName())) { - throw new NoSuchDomainException("Domain 'NonExistingDomain' doesn't exist."); - } - - DomainMetadataResult result = new DomainMetadataResult(); - result.setTimestamp(new Integer(10)); - result.setItemCount(new Integer(11)); - result.setAttributeNameCount(new Integer(12)); - result.setAttributeValueCount(new Integer(13)); - result.setAttributeNamesSizeBytes(new Long(1000000)); - result.setAttributeValuesSizeBytes(new Long(2000000)); - result.setItemNamesSizeBytes(new Long(3000000)); - return result; - } - - @Override - public GetAttributesResult getAttributes(GetAttributesRequest getAttributesRequest) throws AmazonServiceException, AmazonClientException { - this.getAttributesRequest = getAttributesRequest; - - return new GetAttributesResult() - .withAttributes(new Attribute("AttributeOne", "Value One")) - .withAttributes(new Attribute("AttributeTwo", "Value Two")); - } - - @Override - public ListDomainsResult listDomains(ListDomainsRequest listDomainsRequest) throws AmazonServiceException, AmazonClientException { - this.listDomainsRequest = listDomainsRequest; - - ListDomainsResult result = new ListDomainsResult(); - result.getDomainNames().add("DOMAIN1"); - result.getDomainNames().add("DOMAIN2"); - result.setNextToken("TOKEN2"); - return result; - } - - @Override - public void putAttributes(PutAttributesRequest putAttributesRequest) throws AmazonServiceException, AmazonClientException { - this.putAttributesRequest = putAttributesRequest; - } - - @Override - public SelectResult select(SelectRequest selectRequest) throws AmazonServiceException, AmazonClientException { - this.selectRequest = selectRequest; - - SelectResult result = new SelectResult(); - result.setNextToken("TOKEN2"); - result.getItems().add(new Item("ITEM1", null)); - result.getItems().add(new Item("ITEM2", null)); - return result; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java deleted file mode 100644 index 2d83424..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import com.amazonaws.AmazonClientException; -import com.amazonaws.AmazonServiceException; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; -import com.amazonaws.services.simpleemail.model.SendEmailRequest; -import com.amazonaws.services.simpleemail.model.SendEmailResult; - -public class AmazonSESClientMock extends AmazonSimpleEmailServiceClient { - private SendEmailRequest sendEmailRequest; - - public AmazonSESClientMock() { - super(new BasicAWSCredentials("myAccessKey", "mySecretKey")); - } - - @Override - public SendEmailResult sendEmail(SendEmailRequest sendEmailRequest) throws AmazonServiceException, AmazonClientException { - this.sendEmailRequest = sendEmailRequest; - SendEmailResult result = new SendEmailResult(); - result.setMessageId("1"); - - return result; - } - - public SendEmailRequest getSendEmailRequest() { - return sendEmailRequest; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSNSClientMock.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSNSClientMock.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSNSClientMock.java deleted file mode 100644 index e2ee427..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSNSClientMock.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import com.amazonaws.AmazonClientException; -import com.amazonaws.AmazonServiceException; -import com.amazonaws.AmazonWebServiceRequest; -import com.amazonaws.ResponseMetadata; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.sns.AmazonSNSClient; -import com.amazonaws.services.sns.model.AddPermissionRequest; -import com.amazonaws.services.sns.model.ConfirmSubscriptionRequest; -import com.amazonaws.services.sns.model.ConfirmSubscriptionResult; -import com.amazonaws.services.sns.model.CreateTopicRequest; -import com.amazonaws.services.sns.model.CreateTopicResult; -import com.amazonaws.services.sns.model.DeleteTopicRequest; -import com.amazonaws.services.sns.model.GetTopicAttributesRequest; -import com.amazonaws.services.sns.model.GetTopicAttributesResult; -import com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest; -import com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult; -import com.amazonaws.services.sns.model.ListSubscriptionsRequest; -import com.amazonaws.services.sns.model.ListSubscriptionsResult; -import com.amazonaws.services.sns.model.ListTopicsRequest; -import com.amazonaws.services.sns.model.ListTopicsResult; -import com.amazonaws.services.sns.model.PublishRequest; -import com.amazonaws.services.sns.model.PublishResult; -import com.amazonaws.services.sns.model.RemovePermissionRequest; -import com.amazonaws.services.sns.model.SetTopicAttributesRequest; -import com.amazonaws.services.sns.model.SubscribeRequest; -import com.amazonaws.services.sns.model.SubscribeResult; -import com.amazonaws.services.sns.model.UnsubscribeRequest; - -public class AmazonSNSClientMock extends AmazonSNSClient { - - public AmazonSNSClientMock() { - super(new BasicAWSCredentials("myAccessKey", "mySecretKey")); - } - - @Override - public ConfirmSubscriptionResult confirmSubscription(ConfirmSubscriptionRequest confirmSubscriptionRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public GetTopicAttributesResult getTopicAttributes(GetTopicAttributesRequest getTopicAttributesRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public SubscribeResult subscribe(SubscribeRequest subscribeRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public void setTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public void deleteTopic(DeleteTopicRequest deleteTopicRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public void removePermission(RemovePermissionRequest removePermissionRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public ListSubscriptionsResult listSubscriptions(ListSubscriptionsRequest listSubscriptionsRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public void addPermission(AddPermissionRequest addPermissionRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public CreateTopicResult createTopic(CreateTopicRequest createTopicRequest) throws AmazonServiceException, AmazonClientException { - CreateTopicResult createTopicResult = new CreateTopicResult(); - createTopicResult.setTopicArn("arn:aws:sns:us-east-1:541925086079:MyTopic"); - return createTopicResult; - } - - @Override - public ListTopicsResult listTopics(ListTopicsRequest listTopicsRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public void unsubscribe(UnsubscribeRequest unsubscribeRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public ListSubscriptionsByTopicResult listSubscriptionsByTopic(ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest) throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public PublishResult publish(PublishRequest publishRequest) throws AmazonServiceException, AmazonClientException { - PublishResult publishResult = new PublishResult(); - publishResult.setMessageId("dcc8ce7a-7f18-4385-bedd-b97984b4363c"); - return publishResult; - } - - @Override - public ListSubscriptionsResult listSubscriptions() throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public ListTopicsResult listTopics() throws AmazonServiceException, AmazonClientException { - throw new UnsupportedOperationException(); - } - - @Override - public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) { - throw new UnsupportedOperationException(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSQSClientMock.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSQSClientMock.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSQSClientMock.java deleted file mode 100644 index 0612646..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSQSClientMock.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import com.amazonaws.AmazonClientException; -import com.amazonaws.AmazonServiceException; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.sqs.AmazonSQSClient; -import com.amazonaws.services.sqs.model.CreateQueueRequest; -import com.amazonaws.services.sqs.model.CreateQueueResult; -import com.amazonaws.services.sqs.model.DeleteMessageRequest; -import com.amazonaws.services.sqs.model.ListQueuesResult; -import com.amazonaws.services.sqs.model.Message; -import com.amazonaws.services.sqs.model.ReceiveMessageRequest; -import com.amazonaws.services.sqs.model.ReceiveMessageResult; -import com.amazonaws.services.sqs.model.SendMessageRequest; -import com.amazonaws.services.sqs.model.SendMessageResult; - -public class AmazonSQSClientMock extends AmazonSQSClient { - - List<Message> messages = new ArrayList<Message>(); - - public AmazonSQSClientMock() { - super(new BasicAWSCredentials("myAccessKey", "mySecretKey")); - } - - @Override - public ListQueuesResult listQueues() throws AmazonServiceException, AmazonClientException { - ListQueuesResult result = new ListQueuesResult(); - return result; - } - - @Override - public CreateQueueResult createQueue(CreateQueueRequest createQueueRequest) throws AmazonServiceException, AmazonClientException { - CreateQueueResult result = new CreateQueueResult(); - result.setQueueUrl("https://queue.amazonaws.com/541925086079/MyQueue"); - return result; - } - - @Override - public SendMessageResult sendMessage(SendMessageRequest sendMessageRequest) throws AmazonServiceException, AmazonClientException { - Message message = new Message(); - message.setBody(sendMessageRequest.getMessageBody()); - message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee"); - message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458"); - message.setReceiptHandle("0NNAq8PwvXsyZkR6yu4nQ07FGxNmOBWi5zC9+4QMqJZ0DJ3gVOmjI2Gh/oFnb0IeJqy5Zc8kH4JX7GVpfjcEDjaAPSeOkXQZRcaBqt" - + "4lOtyfj0kcclVV/zS7aenhfhX5Ixfgz/rHhsJwtCPPvTAdgQFGYrqaHly+etJiawiNPVc="); - - synchronized (messages) { - messages.add(message); - } - - SendMessageResult result = new SendMessageResult(); - result.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458"); - result.setMD5OfMessageBody("6a1559560f67c5e7a7d5d838bf0272ee"); - return result; - } - - @Override - public ReceiveMessageResult receiveMessage(ReceiveMessageRequest receiveMessageRequest) throws AmazonServiceException, AmazonClientException { - Integer maxNumberOfMessages = receiveMessageRequest.getMaxNumberOfMessages() != null ? receiveMessageRequest.getMaxNumberOfMessages() : Integer.MAX_VALUE; - ReceiveMessageResult result = new ReceiveMessageResult(); - Collection<Message> resultMessages = new ArrayList<Message>(); - - synchronized (messages) { - int fetchSize = 0; - for (Iterator<Message> iterator = messages.iterator(); iterator.hasNext() && fetchSize < maxNumberOfMessages; fetchSize++) { - resultMessages.add(iterator.next()); - iterator.remove(); - } - } - - result.setMessages(resultMessages); - return result; - } - - @Override - public void deleteMessage(DeleteMessageRequest deleteMessageRequest) throws AmazonServiceException, AmazonClientException { - // noop - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3IntegrationTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3IntegrationTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3IntegrationTest.java deleted file mode 100644 index 8b490fa..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3IntegrationTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import java.io.InputStream; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.component.aws.s3.S3Constants; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -@RunWith(PaxExam.class) -@Ignore("Test fails") -public class AwsS3IntegrationTest extends AwsTestSupport { - - @EndpointInject(uri = "mock:result") - private MockEndpoint result; - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/aws/CamelContext.xml"}); - } - - @Test - public void sendInOnly() throws Exception { - result.expectedMessageCount(1); - - Exchange exchange = template.send("direct:start-s3", ExchangePattern.InOnly, new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest"); - exchange.getIn().setBody("This is my bucket content."); - } - }); - - assertMockEndpointsSatisfied(); - - assertResultExchange(result.getExchanges().get(0)); - - assertResponseMessage(exchange.getIn()); - } - - @Test - public void sendInOut() throws Exception { - result.expectedMessageCount(1); - - Exchange exchange = template.send("direct:start-s3", ExchangePattern.InOut, new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest"); - exchange.getIn().setBody("This is my bucket content."); - } - }); - - assertMockEndpointsSatisfied(); - - assertResultExchange(result.getExchanges().get(0)); - - assertResponseMessage(exchange.getOut()); - } - - private void assertResultExchange(Exchange resultExchange) { - assertIsInstanceOf(InputStream.class, resultExchange.getIn().getBody()); - assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class)); - assertEquals("mycamelbucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME)); - assertEquals("CamelUnitTest", resultExchange.getIn().getHeader(S3Constants.KEY)); - assertNull(resultExchange.getIn().getHeader(S3Constants.VERSION_ID)); // not enabled on this bucket - assertNull(resultExchange.getIn().getHeader(S3Constants.LAST_MODIFIED)); - assertNull(resultExchange.getIn().getHeader(S3Constants.E_TAG)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_TYPE)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_ENCODING)); - assertEquals(0L, resultExchange.getIn().getHeader(S3Constants.CONTENT_LENGTH)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_DISPOSITION)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_MD5)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CACHE_CONTROL)); - } - - private void assertResponseMessage(Message message) { - assertEquals("3a5c8b1ad448bca04584ecb55b836264", message.getHeader(S3Constants.E_TAG)); - assertNull(message.getHeader(S3Constants.VERSION_ID)); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3Test.java deleted file mode 100644 index 63a457e..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsS3Test.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import java.io.InputStream; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.component.aws.s3.S3Constants; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -@RunWith(PaxExam.class) -public class AwsS3Test extends AwsTestSupport { - - @EndpointInject(uri = "mock:result-s3") - private MockEndpoint result; - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/aws/CamelContext.xml"}); - } - - @Test - public void sendInOnly() throws Exception { - result.expectedMessageCount(1); - - Exchange exchange = template.send("direct:start-s3", ExchangePattern.InOnly, new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest"); - exchange.getIn().setBody("This is my bucket content."); - } - }); - - assertMockEndpointsSatisfied(); - - assertResultExchange(result.getExchanges().get(0)); - - assertResponseMessage(exchange.getIn()); - } - - @Test - public void sendInOut() throws Exception { - result.expectedMessageCount(1); - - Exchange exchange = template.send("direct:start-s3", ExchangePattern.InOut, new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest"); - exchange.getIn().setBody("This is my bucket content."); - } - }); - - assertMockEndpointsSatisfied(); - - assertResultExchange(result.getExchanges().get(0)); - - assertResponseMessage(exchange.getOut()); - } - - private void assertResultExchange(Exchange resultExchange) { - assertIsInstanceOf(InputStream.class, resultExchange.getIn().getBody()); - assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class)); - assertEquals("mycamelbucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME)); - assertEquals("CamelUnitTest", resultExchange.getIn().getHeader(S3Constants.KEY)); - assertNull(resultExchange.getIn().getHeader(S3Constants.VERSION_ID)); // not enabled on this bucket - assertNull(resultExchange.getIn().getHeader(S3Constants.LAST_MODIFIED)); - assertNull(resultExchange.getIn().getHeader(S3Constants.E_TAG)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_TYPE)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_ENCODING)); - assertEquals(0L, resultExchange.getIn().getHeader(S3Constants.CONTENT_LENGTH)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_DISPOSITION)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_MD5)); - assertNull(resultExchange.getIn().getHeader(S3Constants.CACHE_CONTROL)); - } - - private void assertResponseMessage(Message message) { - assertEquals("3a5c8b1ad448bca04584ecb55b836264", message.getHeader(S3Constants.E_TAG)); - assertNull(message.getHeader(S3Constants.VERSION_ID)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java deleted file mode 100644 index 7a49890..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.aws; - -import java.util.Arrays; -import java.util.List; - -import com.amazonaws.services.simpledb.model.Attribute; -import com.amazonaws.services.simpledb.model.DeletableItem; -import com.amazonaws.services.simpledb.model.ReplaceableAttribute; -import com.amazonaws.services.simpledb.model.ReplaceableItem; -import com.amazonaws.services.simpledb.model.UpdateCondition; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.component.aws.sdb.SdbConstants; -import org.apache.camel.component.aws.sdb.SdbOperations; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -@RunWith(PaxExam.class) -@Ignore("Must be manually tested. Provide your own accessKey and secretKey!") -public class AwsSdbIntegrationTest extends AwsTestSupport { - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext( - new String[]{"org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml"}); - } - - @Test - public void batchDeleteAttributes() { - final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] { - new DeletableItem("ITEM1", null), - new DeletableItem("ITEM2", null)}); - - template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes); - exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems); - } - }); - } - - @Test - public void batchPutAttributes() { - final List<ReplaceableItem> replaceableItems = Arrays.asList(new ReplaceableItem[] { - new ReplaceableItem("ITEM1")}); - - template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchPutAttributes); - exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems); - } - }); - } - - @Test - public void deleteAttributes() { - final List<Attribute> attributes = Arrays.asList(new Attribute[] { - new Attribute("NAME1", "VALUE1")}); - final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true); - - template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes); - exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes); - exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1"); - exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition); - } - }); - } - - @Test - public void deleteDomain() { - template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteDomain); - } - }); - } - - @Test - public void domainMetadata() { - Exchange exchange = template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DomainMetadata); - } - }); - - assertNotNull(exchange.getIn().getHeader(SdbConstants.TIMESTAMP)); - assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEM_COUNT)); - assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_COUNT)); - assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_COUNT)); - assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_SIZE)); - assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_SIZE)); - assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEM_NAME_SIZE)); - } - - @Test - public void getAttributes() { - final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"}); - - Exchange exchange = template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes); - exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1"); - exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE); - exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames); - } - }); - - assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class)); - } - - @Test - public void listDomains() { - Exchange exchange = template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.ListDomains); - exchange.getIn().setHeader(SdbConstants.MAX_NUMBER_OF_DOMAINS, new Integer(5)); - exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1"); - } - }); - - assertNotNull(exchange.getIn().getHeader(SdbConstants.DOMAIN_NAMES, List.class)); - } - - @Test - public void putAttributes() { - final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] { - new ReplaceableAttribute("NAME1", "VALUE1", true)}); - final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true); - - template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes); - exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1"); - exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition); - exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes); - } - }); - } - - @Test - public void select() { - Exchange exchange = template.send("direct:start-sdb", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.Select); - exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1"); - exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE); - exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'"); - } - }); - - assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEMS, List.class)); - } -} \ No newline at end of file