diff --git a/jenkins/pom.xml b/jenkins/pom.xml deleted file mode 100644 index feca0b84d..000000000 --- a/jenkins/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - 4.0.0 - - org.apache.jclouds.labs - jclouds-labs - 2.0.0-SNAPSHOT - - - - org.apache.jclouds.labs - jenkins - jclouds jenkins api - jclouds components to access an implementation of Jenkins - bundle - - - http://localhost:8080 - 1.0 - 1.460 - ANONYMOUS - ANONYMOUS - - org.jclouds.jenkins.v1*;version="${project.version}" - - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.apache.jclouds - jclouds-core - ${project.version} - - - org.apache.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.apache.jclouds.driver - jclouds-slf4j - ${project.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.jenkins.endpoint} - ${test.jenkins.api-version} - ${test.jenkins.build-version} - ${test.jenkins.identity} - ${test.jenkins.credential} - - - - - - - - - - - diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApi.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApi.java deleted file mode 100644 index 7106129db..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApi.java +++ /dev/null @@ -1,48 +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.jclouds.jenkins.v1; - -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.jenkins.v1.features.ComputerApi; -import org.jclouds.jenkins.v1.features.JobApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides synchronous access to Jenkins. - *

- * - * @see JenkinsAsyncApi - * @see api doc - */ -public interface JenkinsApi { - /** - * @return the master computer - */ - Node getMaster(); - - /** - * Provides synchronous access to Computer features. - */ - @Delegate - ComputerApi getComputerApi(); - - /** - * Provides synchronous access to Job features. - */ - @Delegate - JobApi getJobApi(); -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApiMetadata.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApiMetadata.java deleted file mode 100644 index 1b8159ff7..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApiMetadata.java +++ /dev/null @@ -1,87 +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.jclouds.jenkins.v1; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.jenkins.v1.config.JenkinsRestClientModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Jenkins 1.0 API - */ -public class JenkinsApiMetadata extends BaseRestApiMetadata { - - public static final String ANONYMOUS_IDENTITY = "ANONYMOUS"; - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public JenkinsApiMetadata() { - this(new Builder()); - } - - protected JenkinsApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(JenkinsApi.class, JenkinsAsyncApi.class); - id("jenkins") - .name("Jenkins API") - .identityName("Username (or " + ANONYMOUS_IDENTITY + " if anonymous)") - .defaultIdentity(ANONYMOUS_IDENTITY) - .credentialName("Password") - .defaultCredential(ANONYMOUS_IDENTITY) - .documentation(URI.create("https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API")) - .version("1.0") - .defaultEndpoint("http://localhost:8080") - .defaultProperties(JenkinsApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.>of(JenkinsRestClientModule.class)); - } - - @Override - public JenkinsApiMetadata build() { - return new JenkinsApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsAsyncApi.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsAsyncApi.java deleted file mode 100644 index 3cada12f0..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsAsyncApi.java +++ /dev/null @@ -1,67 +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.jclouds.jenkins.v1; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.jenkins.v1.features.ComputerAsyncApi; -import org.jclouds.jenkins.v1.features.JobAsyncApi; -import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Jenkins via their REST API. - *

- * - * @see JenkinsApi - * @see api doc - */ -@RequestFilters(BasicAuthenticationUnlessAnonymous.class) -public interface JenkinsAsyncApi { - - /** - * @see JenkinsApi#getMaster - */ - @Named("GetMaster") - @GET - @Path("/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getMaster(); - - /** - * Provides asynchronous access to Computer features. - */ - @Delegate - ComputerAsyncApi getComputerApi(); - - /** - * Provides asynchronous access to Job features. - */ - @Delegate - JobAsyncApi getJobApi(); -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsFallbacks.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsFallbacks.java deleted file mode 100644 index f6f8e60f6..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsFallbacks.java +++ /dev/null @@ -1,50 +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.jclouds.jenkins.v1; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.util.concurrent.Futures.immediateFuture; -import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull; - -import org.jclouds.Fallback; - -import com.google.common.base.Predicates; -import com.google.common.util.concurrent.ListenableFuture; - -public final class JenkinsFallbacks { - private JenkinsFallbacks() { - } - - public static final class VoidOn302Or404 implements Fallback { - @Override - public ListenableFuture create(Throwable t) throws Exception { - return immediateFuture(createOrPropagate(t)); - } - - @Override - public Void createOrPropagate(Throwable t) throws Exception { - Boolean returnVal = returnValueOnCodeOrNull(checkNotNull(t, "throwable"), true, - Predicates. or(equalTo(302), equalTo(404))); - if (returnVal != null && returnVal) - return null; - throw propagate(t); - } - - } -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/binders/BindMapToOptionalParams.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/binders/BindMapToOptionalParams.java deleted file mode 100644 index 51e631f00..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/binders/BindMapToOptionalParams.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.jclouds.jenkins.v1.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.collect.Multimaps; - -/** - * Binds the map to parameters. - */ -public class BindMapToOptionalParams implements Binder { - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Maps!"); - Map map = (Map) input; - return (R) request.toBuilder().replaceQueryParams(Multimaps.forMap(map)).build(); - } - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsProperties.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsProperties.java deleted file mode 100644 index 99fb02fc2..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsProperties.java +++ /dev/null @@ -1,24 +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.jclouds.jenkins.v1.config; - -/** - * Configuration properties and constants used in Jenkins connections. - */ -public class JenkinsProperties { - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsRestClientModule.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsRestClientModule.java deleted file mode 100644 index e1f76c4cb..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsRestClientModule.java +++ /dev/null @@ -1,58 +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.jclouds.jenkins.v1.config; - -import java.util.Map; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.jenkins.v1.JenkinsAsyncApi; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.features.ComputerAsyncApi; -import org.jclouds.jenkins.v1.features.ComputerApi; -import org.jclouds.jenkins.v1.features.JobAsyncApi; -import org.jclouds.jenkins.v1.features.JobApi; -import org.jclouds.jenkins.v1.handlers.JenkinsErrorHandler; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.collect.ImmutableMap; - -/** - * Configures the Jenkins connection. - */ -@ConfiguresRestClient -public class JenkinsRestClientModule extends RestClientModule { - - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(ComputerApi.class, ComputerAsyncApi.class) - .put(JobApi.class, JobAsyncApi.class) - .build(); - - public JenkinsRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(JenkinsErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(JenkinsErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(JenkinsErrorHandler.class); - } -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Computer.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Computer.java deleted file mode 100644 index 66dd922cc..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Computer.java +++ /dev/null @@ -1,150 +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.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * @see api - * doc - */ -public class Computer implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromComputerMetadata(this); - } - - public static class Builder { - protected String displayName; - protected boolean idle; - protected boolean offline; - - /** - * @see Computer#getDisplayName() - */ - public Builder displayName(String displayName) { - this.displayName = checkNotNull(displayName, "displayName"); - return this; - } - - /** - * @see Computer#isIdle() - */ - public Builder idle(boolean idle) { - this.idle = idle; - return this; - } - - /** - * @see Computer#isOffline() - */ - public Builder offline(boolean offline) { - this.offline = offline; - return this; - } - - public Computer build() { - return new Computer(displayName, idle, offline); - } - - public Builder fromComputerMetadata(Computer from) { - return displayName(from.getDisplayName()).idle(from.isIdle()).offline(from.isOffline()); - } - } - - protected final String displayName; - protected final boolean idle; - protected final boolean offline; - - public Computer(String displayName, boolean idle, boolean offline) { - this.displayName = checkNotNull(displayName, "displayName"); - this.idle = idle; - this.offline = offline; - } - - /** - * - * @return the displayName of the computer - */ - public String getDisplayName() { - return displayName; - } - - /** - * - * @return the number of objects in the computer - */ - public boolean isIdle() { - return idle; - } - - /** - * @return the total offline stored in this computer - */ - public boolean isOffline() { - return offline; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Computer) { - final Computer other = Computer.class.cast(object); - return equal(getDisplayName(), other.getDisplayName()) && equal(isIdle(), other.isIdle()) - && equal(isOffline(), other.isOffline()); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(getDisplayName(), isIdle(), isOffline()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return toStringHelper("").add("displayName", getDisplayName()).add("idle", isIdle()).add("offline", isOffline()); - } - - @Override - public int compareTo(Computer that) { - if (that == null) - return 1; - if (this == that) - return 0; - return this.getDisplayName().compareTo(that.getDisplayName()); - } - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/ComputerView.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/ComputerView.java deleted file mode 100644 index 81ff4114c..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/ComputerView.java +++ /dev/null @@ -1,184 +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.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.gson.annotations.SerializedName; - -/** - * @see api - * doc - */ -public class ComputerView implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromComputerMetadata(this); - } - - public static class Builder { - protected String displayName; - protected int busyExecutors; - protected int totalExecutors; - protected Set computers = ImmutableSet.of(); - - /** - * @see ComputerView#getDisplayName() - */ - public Builder displayName(String displayName) { - this.displayName = checkNotNull(displayName, "displayName"); - return this; - } - - /** - * @see ComputerView#getBusyExecutors() - */ - public Builder busyExecutors(int busyExecutors) { - this.busyExecutors = busyExecutors; - return this; - } - - /** - * @see ComputerView#getTotalExecutors() - */ - public Builder totalExecutors(int totalExecutors) { - this.totalExecutors = totalExecutors; - return this; - } - - /** - * @see ComputerView#getLinks() - */ - public Builder computers(Computer... computers) { - return computers(ImmutableSet.copyOf(checkNotNull(computers, "computers"))); - } - - /** - * @see ComputerView#getLinks() - */ - public Builder computers(Set computers) { - this.computers = ImmutableSet.copyOf(checkNotNull(computers, "computers")); - return this; - } - - public ComputerView build() { - return new ComputerView(displayName, busyExecutors, totalExecutors, computers); - } - - public Builder fromComputerMetadata(ComputerView from) { - return displayName(from.getDisplayName()).busyExecutors(from.getBusyExecutors()).totalExecutors(from.getTotalExecutors()).computers(from.getComputers()); - } - } - - protected final String displayName; - protected final int busyExecutors; - protected final int totalExecutors; - @SerializedName("computer") - protected final Set computers; - - public ComputerView(String displayName, int busyExecutors, int totalExecutors, Set computers) { - this.displayName = checkNotNull(displayName, "displayName"); - this.busyExecutors = busyExecutors; - this.totalExecutors = totalExecutors; - this.computers = ImmutableSet.copyOf(checkNotNull(computers, "computers")); - } - - /** - * - * @return the displayName of the computer - */ - public String getDisplayName() { - return displayName; - } - - /** - * - * @return the number of objects in the computer - */ - public int getBusyExecutors() { - return busyExecutors; - } - - /** - * @return the total totalExecutors stored in this computer - */ - public int getTotalExecutors() { - return totalExecutors; - } - - /** - * @return the computers in this set - */ - //TODO: create type adapter for gson that understands ForwardingSet so that we can implement the Set interface - public Set getComputers() { - return computers; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof ComputerView) { - final ComputerView other = ComputerView.class.cast(object); - return equal(getDisplayName(), other.getDisplayName()) && equal(getBusyExecutors(), other.getBusyExecutors()) - && equal(getTotalExecutors(), other.getTotalExecutors()) && equal(getComputers(), other.getComputers()); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(getDisplayName(), getBusyExecutors(), getTotalExecutors(), getComputers()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return toStringHelper("").add("displayName", getDisplayName()).add("busyExecutors", getBusyExecutors()).add( - "totalExecutors", getTotalExecutors()).add("computers", getComputers()); - } - - @Override - public int compareTo(ComputerView that) { - if (that == null) - return 1; - if (this == that) - return 0; - return this.getDisplayName().compareTo(that.getDisplayName()); - } - - - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Job.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Job.java deleted file mode 100644 index d7ef3428a..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Job.java +++ /dev/null @@ -1,154 +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.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Minimal info about a Job - */ -public class Job { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromJob(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - private String name; - private URI url; - private String color; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see Job#getName() - */ - public B name(String name) { - this.name = name; - return self(); - } - - /** - * @see Job#getUrl() - */ - public B url(URI url) { - this.url = url; - return self(); - } - - /** - * @see Job#getColor() - */ - public B color(String color) { - this.color = color; - return self(); - } - - public Job build() { - return new Job(this); - } - - protected B fromJob(Job in) { - return name(in.getName()).color(in.getColor()).url(in.getUrl()); - } - } - - private final String name; - private final String color; - private final URI url; - - protected Job(Builder builder) { - this.name = checkNotNull(builder.name, "name"); - this.color = checkNotNull(builder.color, "color"); - this.url = checkNotNull(builder.url, "url"); - } - - /** - * name of the job - */ - public String getName() { - return name; - } - - /** - * - * color of the job - */ - public String getColor() { - return color; - } - - /** - * - * url of the job - */ - public URI getUrl() { - return url; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Job that = Job.class.cast(o); - return equal(this.name, that.name) && equal(this.url, that.url) - && equal(this.color, that.color); - } - - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - Job that = Job.class.cast(o); - return equal(this.color, that.color); - } - - @Override - public int hashCode() { - return Objects.hashCode(name, url, color); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper("").add("name", name).add("url", url).add("color", - color); - } -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/JobDetails.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/JobDetails.java deleted file mode 100644 index 54a1bf4f3..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/JobDetails.java +++ /dev/null @@ -1,56 +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.jclouds.jenkins.v1.domain; - -import com.google.common.base.MoreObjects.ToStringHelper; - -public class JobDetails extends Job { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromJobDetails(this); - } - - public static class Builder> extends Job.Builder { - - @Override - public JobDetails build() { - return new JobDetails(this); - } - - public B fromJobDetails(JobDetails in) { - return fromJob(in); - } - } - - private static class ConcreteBuilder extends Builder { - } - - protected JobDetails(Builder builder) { - super(builder); - } - - @Override - public ToStringHelper string() { - return super.string(); // .add("field", field); - } - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/LastBuild.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/LastBuild.java deleted file mode 100644 index f97af6cf0..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/LastBuild.java +++ /dev/null @@ -1,286 +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.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Minimal info about a LastBuild - * - * GET http://host/job/project/lastBuild/api/json - */ -public class LastBuild { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromJob(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - private String id; - private URI url; - private String description; - private String building; - private String duration; - private String estimatedDuration; - private String fullDisplayName; - private String result; - private String timestamp; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see LastBuild#getId() - */ - public B id(String id) { - this.id = id; - return self(); - } - - /** - * @see LastBuild#getUrl() - */ - public B url(URI url) { - this.url = url; - return self(); - } - - /** - * @see LastBuild#getDescription() - */ - public B description(String description) { - this.description = description; - return self(); - } - - /** - * @see LastBuild#getBuilding() - */ - public B building(String building) { - this.building = building; - return self(); - } - - /** - * @see LastBuild#getDuration() - */ - public B duration(String duration) { - this.duration = duration; - return self(); - } - - /** - * @see LastBuild#getEstimatedDuration() - */ - public B estimatedDuration(String estimatedDuration) { - this.estimatedDuration = estimatedDuration; - return self(); - } - - /** - * @see LastBuild#getFullDisplayName() - */ - public B fullDisplayName(String fullDisplayName) { - this.fullDisplayName = fullDisplayName; - return self(); - } - - /** - * @see LastBuild#getResult() - */ - public B result(String result) { - this.result = result; - return self(); - } - - /** - * @see LastBuild#getTimestamp() - */ - public B timestamp(String timestamp) { - this.timestamp = timestamp; - return self(); - } - - public LastBuild build() { - return new LastBuild(this); - } - - protected B fromJob(LastBuild in) { - return id(in.getId()).url(in.getUrl()).description(in.getDescription()).building(in.getBuilding()) - .duration(in.getDuration()).estimatedDuration(in.getEstimatedDuration()) - .fullDisplayName(in.getFullDisplayName()).result(in.getResult()).timestamp(in.getTimestamp()); - } - } - - private final String id; - private final URI url; - private final String description; - private final String building; - private final String duration; - private final String estimatedDuration; - private final String fullDisplayName; - private final String result; - private final String timestamp; - - protected LastBuild(Builder builder) { - this.id = checkNotNull(builder.id, "id"); - this.url = checkNotNull(builder.url, "url"); - this.description = checkNotNull(builder.description, "description"); - this.building = checkNotNull(builder.building, "building"); - this.duration = checkNotNull(builder.duration, "duration"); - this.estimatedDuration = checkNotNull(builder.estimatedDuration, "estimatedDuration"); - this.fullDisplayName = checkNotNull(builder.fullDisplayName, "fullDisplayName"); - this.result = checkNotNull(builder.result, "result"); - this.timestamp = checkNotNull(builder.timestamp, "timestamp"); - } - - /** - * id of the lastBuild - */ - public String getId() { - return id; - } - - /** - * - * url of the lastBuild - */ - public URI getUrl() { - return url; - } - - /** - * - * building of the lastBuild - */ - public String getBuilding() { - return building; - } - - /** - * - * description of the lastBuild - */ - public String getDescription() { - return description; - } - - /** - * - * duration of the lastBuild - */ - public String getDuration() { - return duration; - } - - /** - * - * estimated duration of the lastBuild - */ - public String getEstimatedDuration() { - return estimatedDuration; - } - - /** - * - * full Display Name of the lastBuild - */ - public String getFullDisplayName() { - return fullDisplayName; - } - - /** - * - * result of the lastBuild - */ - public String getResult() { - return result; - } - - /** - * - * timestamp of the lastBuild - */ - public String getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - LastBuild that = LastBuild.class.cast(o); - return equal(this.id, that.id) - && equal(this.url, that.url) - && equal(this.building, that.building) - && equal(this.description, that.description) - && equal(this.duration, that.duration) - && equal(this.estimatedDuration, that.estimatedDuration) - && equal(this.fullDisplayName, that.fullDisplayName) - && equal(this.result, that.result) - && equal(this.timestamp, that.timestamp); - } - - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - LastBuild that = LastBuild.class.cast(o); - return equal(this.description, that.description); - } - - @Override - public int hashCode() { - return Objects.hashCode(id, url, description, duration, estimatedDuration, fullDisplayName, result, timestamp); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper("") - .add("id", id) - .add("url", url) - .add("description", description) - .add("duration", duration) - .add("estimatedDuration", estimatedDuration) - .add("fullDisplayName", fullDisplayName) - .add("result", result) - .add("timestamp", timestamp); - } -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Node.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Node.java deleted file mode 100644 index dbb0504b1..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Node.java +++ /dev/null @@ -1,163 +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.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.gson.annotations.SerializedName; - -/** - * @see api - * doc - */ -public class Node implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromNodeMetadata(this); - } - - public static class Builder { - protected String name; - protected String description; - protected Set jobs = ImmutableSet.of(); - - /** - * @see Node#getName() - */ - public Builder name(String name) { - this.name = checkNotNull(name, "name"); - return this; - } - - /** - * @see Node#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see Node#getJobs() - */ - public Builder jobs(Job... jobs) { - return jobs(ImmutableSet.copyOf(checkNotNull(jobs, "jobs"))); - } - - /** - * @see Node#getJobs() - */ - public Builder jobs(Set jobs) { - this.jobs = ImmutableSet.copyOf(checkNotNull(jobs, "jobs")); - return this; - } - - public Node build() { - return new Node(name, description, jobs); - } - - public Builder fromNodeMetadata(Node from) { - return name(from.getName()).description(from.getDescription()).jobs(from.getJobs()); - } - } - - @SerializedName("nodeName") - protected final String name; - @SerializedName("nodeDescription") - protected final String description; - protected final Set jobs; - - public Node(String name, String description, Set jobs) { - this.name = checkNotNull(name, "name"); - this.description = description; - this.jobs = ImmutableSet.copyOf(checkNotNull(jobs, "jobs")); - } - - /** - * - * @return the name of the node - */ - public String getName() { - return name; - } - - /** - * - * @return the description of the node - */ - public String getDescription() { - return description; - } - - /** - * @return the jobs on this node - */ - public Set getJobs() { - return jobs; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Node) { - final Node other = Node.class.cast(object); - return equal(getName(), other.getName()) && equal(getDescription(), other.getDescription()) - && equal(getJobs(), other.getJobs()); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(getName(), getDescription(), getJobs()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return toStringHelper("").add("name", getName()).add("description", getDescription()).add("jobs", getJobs()); - } - - @Override - public int compareTo(Node that) { - if (that == null) - return 1; - if (this == that) - return 0; - return this.getName().compareTo(that.getName()); - } - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerApi.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerApi.java deleted file mode 100644 index 2eb6ccc4c..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerApi.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.jclouds.jenkins.v1.features; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; - -/** - * Computer Services - * - * @see ComputerAsyncApi - * @see api doc - */ -public interface ComputerApi { - - /** - * @return overview of all configured computers - */ - ComputerView getView(); - - /** - * - * @param displayName display name of the computer - * @return computer or null if not found - */ - Computer get(String displayName); - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerAsyncApi.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerAsyncApi.java deleted file mode 100644 index 75cb2438e..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerAsyncApi.java +++ /dev/null @@ -1,65 +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.jclouds.jenkins.v1.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; -import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Computer Services - * - * @see ComputerApi - * @see api doc - */ -@RequestFilters(BasicAuthenticationUnlessAnonymous.class) -public interface ComputerAsyncApi { - - /** - * @see ComputerApi#getView - */ - @Named("ListComputers") - @GET - @Path("/computer/api/json") - @Consumes(MediaType.APPLICATION_JSON) - ListenableFuture getView(); - - /** - * @see ComputerApi#get - */ - @Named("GetComputer") - @GET - @Path("/computer/{displayName}/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("displayName") String displayName); - -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobApi.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobApi.java deleted file mode 100644 index 28a537bbe..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobApi.java +++ /dev/null @@ -1,58 +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.jclouds.jenkins.v1.features; - -import java.util.Map; -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.jenkins.v1.domain.LastBuild; - -/** - * Job Services - * - * @see JobAsyncApi - * @see api doc - */ -public interface JobApi { - - /** - * creates a job, given the payload - * - * @param displayName - * @param xml - */ - void createFromXML(String displayName, String xml); - - JobDetails get(String displayName); - - void delete(String displayName); - - /** - * Build a job via API - * - * If security is enabled, provide username/password of an account with build permission in the request. - * Another alternative (but deprecated) is to configure the 'Trigger builds remotely' section in the job configuration. - * - * @param displayName - */ - void build(String displayName); - - void buildWithParameters(String displayName, Map parameters); - - String fetchConfigXML(String displayName); - - LastBuild lastBuild(String displayName); -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobAsyncApi.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobAsyncApi.java deleted file mode 100644 index 91e451950..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobAsyncApi.java +++ /dev/null @@ -1,118 +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.jclouds.jenkins.v1.features; - -import java.util.Map; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.jenkins.v1.JenkinsFallbacks.VoidOn302Or404; -import org.jclouds.jenkins.v1.binders.BindMapToOptionalParams; -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.jenkins.v1.domain.LastBuild; -import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Job Services - * - * @see JobApi - * @see api doc - */ -@RequestFilters(BasicAuthenticationUnlessAnonymous.class) -public interface JobAsyncApi { - - /** - * @see JobApi#createFromXML - */ - @Named("CreateItem") - @POST - @Path("/createItem") - @Produces(MediaType.TEXT_XML) - ListenableFuture createFromXML(@QueryParam("name") String displayName, @BinderParam(BindToStringPayload.class) String xml); - - /** - * @see JobApi#get - */ - @Named("GetJob") - @GET - @Path("/job/{displayName}/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("displayName") String displayName); - - /** - * @see JobApi#delete - */ - @Named("DeleteJob") - @POST - @Path("/job/{displayName}/doDelete") - @Fallback(VoidOn302Or404.class) - ListenableFuture delete(@PathParam("displayName") String displayName); - - /** - * @see JobApi#buildJob - */ - @Named("Build") - @POST - @Path("/job/{displayName}/build") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture build(@PathParam("displayName") String displayName); - - /** - * @see JobApi#buildJobWithParameters - */ - @Named("BuildWithParameters") - @POST - @Path("/job/{displayName}/buildWithParameters") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture buildWithParameters(@PathParam("displayName") String displayName, - @BinderParam(BindMapToOptionalParams.class) Map parameters); - - /** - * @see JobApi#fetchConfigXML - */ - @Named("GetConfigXML") - @GET - @Path("/job/{displayName}/config.xml") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture fetchConfigXML(@PathParam("displayName") String displayName); - - /** - * @see JobApi#lastBuild - */ - @Named("GetLastBuild") - @GET - @Path("/job/{displayName}/lastBuild/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture lastBuild(@PathParam("displayName") String displayName); -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymous.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymous.java deleted file mode 100644 index d767b9744..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymous.java +++ /dev/null @@ -1,52 +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.jclouds.jenkins.v1.filters; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.jenkins.v1.JenkinsApiMetadata.ANONYMOUS_IDENTITY; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; - -@Singleton -public class BasicAuthenticationUnlessAnonymous implements HttpRequestFilter { - - private final Supplier creds; - private final BasicAuthentication auth; - - @Inject - public BasicAuthenticationUnlessAnonymous(@Provider Supplier creds, BasicAuthentication auth) { - this.creds = checkNotNull(creds, "creds"); - this.auth = checkNotNull(auth, "auth"); - } - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - if (ANONYMOUS_IDENTITY.equals(checkNotNull(creds.get().identity, "user"))) - return request; - return auth.filter(request); - } -} diff --git a/jenkins/src/main/java/org/jclouds/jenkins/v1/handlers/JenkinsErrorHandler.java b/jenkins/src/main/java/org/jclouds/jenkins/v1/handlers/JenkinsErrorHandler.java deleted file mode 100644 index 27e2a2373..000000000 --- a/jenkins/src/main/java/org/jclouds/jenkins/v1/handlers/JenkinsErrorHandler.java +++ /dev/null @@ -1,61 +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.jclouds.jenkins.v1.handlers; - -import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; - -/** - * This will parse and set an appropriate exception on the command object. - */ -// TODO: is there error spec someplace? let's type errors, etc. -@Singleton -public class JenkinsErrorHandler implements HttpErrorHandler { - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - byte[] data = closeClientButKeepContentStream(response); - String message = data != null ? new String(data) : null; - - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - break; - case 401: - case 403: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - } - command.setException(exception); - } -} diff --git a/jenkins/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/jenkins/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index c80a7f32a..000000000 --- a/jenkins/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.jenkins.v1.JenkinsApiMetadata diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiExpectTest.java deleted file mode 100644 index bc95e9d33..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiExpectTest.java +++ /dev/null @@ -1,46 +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.jclouds.jenkins.v1; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.ParseNodeTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "JenkinsApiExpectTest") -public class JenkinsApiExpectTest extends BaseJenkinsApiExpectTest { - - public void testGetMasterWhenResponseIs2xx() { - HttpRequest getMaster = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse getMasterResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/master.json")).build(); - - JenkinsApi apiWhenMasterExists = requestSendsResponse(getMaster, getMasterResponse); - - assertEquals(apiWhenMasterExists.getMaster().toString(), - new ParseNodeTest().expected().toString()); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiLiveTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiLiveTest.java deleted file mode 100644 index 290647599..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiLiveTest.java +++ /dev/null @@ -1,35 +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.jclouds.jenkins.v1; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "JenkinsApiLiveTest") -public class JenkinsApiLiveTest extends BaseJenkinsApiLiveTest { - - public void testGetMaster(){ - Node master = context.getApi().getMaster(); - assertNotNull(master); - assertNotNull(master.getName()); - assertNotNull(master.getJobs()); - } - -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiMetadataTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiMetadataTest.java deleted file mode 100644 index f13c8393e..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiMetadataTest.java +++ /dev/null @@ -1,31 +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.jclouds.jenkins.v1; - -import org.jclouds.View; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; - -@Test(groups = "unit", testName = "JenkinsApiMetadataTest") -public class JenkinsApiMetadataTest extends BaseApiMetadataTest { - public JenkinsApiMetadataTest() { - super(new JenkinsApiMetadata(), ImmutableSet.> of()); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsErrorHandlerTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsErrorHandlerTest.java deleted file mode 100644 index 0a7f70f69..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsErrorHandlerTest.java +++ /dev/null @@ -1,89 +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.jclouds.jenkins.v1; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.handlers.JenkinsErrorHandler; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "JenkinsErrorHandlerTest") -public class JenkinsErrorHandlerTest { - - @Test - public void test404WithHTMLDoesntBustParserAndMakesResourceNotFoundException() { - assertCodeMakes("GET", URI - .create("http://ci.jruby.org/computer/master/api/json"), - 404, "Not Found", "", ResourceNotFoundException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "text/plain", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - JenkinsErrorHandler function = new JenkinsErrorHandler(); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiExpectTest.java deleted file mode 100644 index d581d4ab3..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiExpectTest.java +++ /dev/null @@ -1,65 +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.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.ParseComputerTest; -import org.jclouds.jenkins.v1.parse.ParseComputerViewTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ComputerApiExpectTest") -public class ComputerApiExpectTest extends BaseJenkinsApiExpectTest { - - public void testGetComputerViewWhenResponseIs2xx() { - HttpRequest getComputerView = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/computer/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse getComputerViewResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/computerview.json")).build(); - - JenkinsApi apiWhenServersExist = requestSendsResponse(getComputerView, getComputerViewResponse); - - assertEquals(apiWhenServersExist.getComputerApi().getView().toString(), - new ParseComputerViewTest().expected().toString()); - } - - public void testGetComputerWhenResponseIs2xx() { - HttpRequest getComputer = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/computer/Ruboto/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse getComputerResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/computer.json")).build(); - - JenkinsApi apiWhenServersExist = requestSendsResponse(getComputer, getComputerResponse); - - assertEquals(apiWhenServersExist.getComputerApi().get("Ruboto").toString(), - new ParseComputerTest().expected().toString()); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiLiveTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiLiveTest.java deleted file mode 100644 index 76ac00fe9..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiLiveTest.java +++ /dev/null @@ -1,46 +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.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "ComputerApiLiveTest") -public class ComputerApiLiveTest extends BaseJenkinsApiLiveTest { - - public void testGetComputerView(){ - ComputerView view = getApi().getView(); - assertNotNull(view); - assertNotNull(view.getDisplayName()); - for (Computer computerFromView : view.getComputers()) { - assertNotNull(computerFromView.getDisplayName()); - if (!"master".equals(computerFromView.getDisplayName())) { - Computer computerFromGetRequest = getApi().get(computerFromView.getDisplayName()); - assertEquals(computerFromGetRequest, computerFromView); - } - } - } - - private ComputerApi getApi() { - return context.getApi().getComputerApi(); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiExpectTest.java deleted file mode 100644 index 2614e4d01..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiExpectTest.java +++ /dev/null @@ -1,160 +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.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.io.IOException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.LastBuildTest; -import org.jclouds.jenkins.v1.parse.ParseJobDetailsTest; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "JobApiExpectTest") -public class JobApiExpectTest extends BaseJenkinsApiExpectTest { - - public void testCreateJobStringWhenResponseIs2xx() throws IOException { - HttpRequest createJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/createItem?name=blagoo") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .payload(payloadFromResourceWithContentType("/sample_job.xml", "text/xml")) - .build(); - - HttpResponse createJobResponse = HttpResponse.builder().statusCode(200).build(); - - JenkinsApi createJobWhenCreated = requestSendsResponse(createJob, createJobResponse); - - createJobWhenCreated.getJobApi().createFromXML("blagoo", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - public void testDeleteJobWhenResponseIs2xx() { - HttpRequest deleteJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/job/blagoo/doDelete") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - HttpResponse deleteJobResponse = HttpResponse.builder().statusCode(200).build(); - - JenkinsApi deleteJobWhenDeleted = requestSendsResponse(deleteJob, deleteJobResponse); - - deleteJobWhenDeleted.getJobApi().delete("blagoo"); - } - - public void testDeleteJobWhenResponseIs404() { - HttpRequest deleteJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/job/blagoo/doDelete") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - HttpResponse deleteJobResponse = HttpResponse.builder().statusCode(404).build(); - - JenkinsApi deleteJobWhenDeleted = requestSendsResponse(deleteJob, deleteJobResponse); - - deleteJobWhenDeleted.getJobApi().delete("blagoo"); - } - - HttpRequest getJob = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/job/ddd/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testGetJobWhenResponseIs2xx() { - HttpResponse getJobResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/job.json")).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(getJob, getJobResponse); - assertEquals(apiWhenJobExists.getJobApi().get("ddd").toString(), - new ParseJobDetailsTest().expected().toString()); - } - - public void testGetJobWhenResponseIs404() { - HttpResponse getJobResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(getJob, getJobResponse); - assertNull(getJobWhenGetd.getJobApi().get("ddd")); - } - - HttpRequest buildJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/job/ddd/build") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testBuildJobWhenResponseIs2xx() { - HttpResponse buildJobResponse = HttpResponse.builder().statusCode(200).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(buildJob, buildJobResponse); - apiWhenJobExists.getJobApi().build("ddd"); - } - - public void testBuildJobWhenResponseIs404() { - HttpResponse getJobResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(buildJob, getJobResponse); - getJobWhenGetd.getJobApi().build("ddd"); - } - - HttpRequest fetchConfig = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/job/ddd/config.xml") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testFetchConfigXMLWhenResponseIs2xx() { - HttpResponse fetchConfigResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/sample_job.xml", "text/xml")).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(fetchConfig, fetchConfigResponse); - String configXML = apiWhenJobExists.getJobApi().fetchConfigXML("ddd"); - //TODO enable this assertion - //assertEquals(configXML, Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - public void testFetchConfigXMLWhenResponseIs404() { - HttpResponse fetchConfigResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(fetchConfig, fetchConfigResponse); - getJobWhenGetd.getJobApi().fetchConfigXML("ddd"); - } - - - HttpRequest lastBuild = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/job/ddd/lastBuild/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testLastBuildWhenResponseIs2xx() { - HttpResponse lastBuildResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/lastBuild.json")).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(lastBuild, lastBuildResponse); - assertEquals(apiWhenJobExists.getJobApi().lastBuild("ddd").toString(), - new LastBuildTest().expected().toString()); - } - - public void testLastBuildWhenResponseIs404() { - HttpResponse lastBuildResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(lastBuild, lastBuildResponse); - assertNull(getJobWhenGetd.getJobApi().lastBuild("ddd")); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiLiveTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiLiveTest.java deleted file mode 100644 index 8a8a776af..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiLiveTest.java +++ /dev/null @@ -1,104 +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.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.jenkins.v1.domain.LastBuild; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiLiveTest; -import org.jclouds.util.Strings2; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -@Test(groups = "live", testName = "JobApiLiveTest") -public class JobApiLiveTest extends BaseJenkinsApiLiveTest { - - public void testCreateJob() throws IOException { - getApi().delete("blagoo"); - getApi().createFromXML("blagoo", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - @Test(dependsOnMethods = "testCreateJob") - public void testFetchConfigXML() throws IOException { - String configXML = getApi().fetchConfigXML("blagoo"); - assertNotNull(configXML); - //TODO enable this assertion - //assertEquals(configXML, Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - @Test(dependsOnMethods = "testFetchConfigXML") - public void testGetJob() throws IOException { - JobDetails job = getApi().get("blagoo"); - assertNotNull(job); - assertEquals(job.getName(), "blagoo"); - } - - @Test(dependsOnMethods = "testGetJob") - public void testBuildJob() throws IOException { - getApi().build("blagoo"); - } - - @Test(dependsOnMethods = "testBuildJob") - public void testDeleteJob() { - getApi().delete("blagoo"); - } - - @Test(dependsOnMethods = "testDeleteJob") - public void testCreateJobWithParameters() throws IOException { - getApi().delete("jobWithParameters"); - getApi().createFromXML("jobWithParameters", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job_with_parameters.xml"))); - } - - @Test(dependsOnMethods = "testCreateJobWithParameters") - public void testBuildJobWithParameters() throws IOException { - Map parameters = ImmutableMap.of("name", "test1", "password", "secret"); - getApi().buildWithParameters("jobWithParameters", parameters); - } - - @Test(dependsOnMethods = "testBuildJobWithParameters") - public void testLastBuild() throws IOException { - LastBuild lastBuild = getApi().lastBuild("jobWithParameters"); - while(lastBuild == null || lastBuild.getResult() == null) { - lastBuild = getApi().lastBuild("jobWithParameters"); - } - assertEquals(lastBuild.getResult(), "SUCCESS"); - } - - @Test(dependsOnMethods = "testLastBuild") - public void testDeleteJobWithParameters() { - getApi().delete("jobWithParameters"); - } - - @AfterClass(groups = { "integration", "live" }) - @Override - protected void tearDownContext() { - getApi().delete("blagoo"); - getApi().delete("jobWithParameters"); - super.tearDownContext(); - } - - private JobApi getApi() { - return context.getApi().getJobApi(); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymousExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymousExpectTest.java deleted file mode 100644 index 4b6c6b06a..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymousExpectTest.java +++ /dev/null @@ -1,51 +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.jclouds.jenkins.v1.filters; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsApiMetadata; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.ParseComputerViewTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "BasicAuthenticationUnlessAnonymousExpectTest") -public class BasicAuthenticationUnlessAnonymousExpectTest extends BaseJenkinsApiExpectTest { - - public BasicAuthenticationUnlessAnonymousExpectTest(){ - identity = JenkinsApiMetadata.ANONYMOUS_IDENTITY; - } - - public void testWhenIdentityIsAnonymousNoAuthorizationHeader() { - HttpRequest getComputerView = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/computer/api/json") - .addHeader("Accept", "application/json").build(); - - HttpResponse getComputerViewResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/computerview.json")).build(); - - JenkinsApi apiWhenServersExist = requestSendsResponse(getComputerView, getComputerViewResponse); - - assertEquals(apiWhenServersExist.getComputerApi().getView().toString(), - new ParseComputerViewTest().expected().toString()); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiExpectTest.java deleted file mode 100644 index 6e01017be..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiExpectTest.java +++ /dev/null @@ -1,26 +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.jclouds.jenkins.v1.internal; - -import org.jclouds.jenkins.v1.JenkinsApi; - -/** - * Base class for writing Jenkins Expect tests - */ -public class BaseJenkinsApiExpectTest extends BaseJenkinsExpectTest { - -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiLiveTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiLiveTest.java deleted file mode 100644 index 40283768f..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiLiveTest.java +++ /dev/null @@ -1,53 +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.jclouds.jenkins.v1.internal; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.jenkins.v1.JenkinsApiMetadata; -import org.jclouds.jenkins.v1.JenkinsAsyncApi; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Tests behavior of {@code JenkinsApi} - */ -@Test(groups = "live") -public class BaseJenkinsApiLiveTest extends BaseContextLiveTest> { - - public BaseJenkinsApiLiveTest() { - provider = "jenkins"; - } - - protected RestContext jenkinsContext; - - @BeforeClass(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - jenkinsContext = context; - } - - @Override - protected TypeToken> contextType() { - return JenkinsApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsAsyncApiExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsAsyncApiExpectTest.java deleted file mode 100644 index 5426c79be..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsAsyncApiExpectTest.java +++ /dev/null @@ -1,35 +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.jclouds.jenkins.v1.internal; - -import java.util.Properties; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsAsyncApi; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * Base class for writing KeyStone Rest Api Expect tests - */ -public class BaseJenkinsAsyncApiExpectTest extends BaseJenkinsExpectTest { - public JenkinsAsyncApi createClient(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(JenkinsAsyncApi.class); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsExpectTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsExpectTest.java deleted file mode 100644 index 2d24b4237..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsExpectTest.java +++ /dev/null @@ -1,28 +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.jclouds.jenkins.v1.internal; - -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -/** - * Base class for writing Jenkins Expect tests - */ -public class BaseJenkinsExpectTest extends BaseRestApiExpectTest { - public BaseJenkinsExpectTest() { - provider = "jenkins"; - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/LastBuildTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/LastBuildTest.java deleted file mode 100644 index 8b4835a65..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/LastBuildTest.java +++ /dev/null @@ -1,51 +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.jclouds.jenkins.v1.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.LastBuild; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "LastBuildTest") -public class LastBuildTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/lastBuild.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public LastBuild expected() { - return LastBuild.builder() - .id("2012-07-11_04-02-37") - .url(URI.create("http://dal36.poweredman.com:8080/job/poweredman-web-build/139/")) - .description("test") - .duration("505777") - .building("false") - .estimatedDuration("942619") - .fullDisplayName("poweredman-web-build #139") - .timestamp("1341997357461") - .result("SUCCESS") - .build(); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerTest.java deleted file mode 100644 index 7d785770e..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerTest.java +++ /dev/null @@ -1,43 +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.jclouds.jenkins.v1.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ParseComputerTest") -public class ParseComputerTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/computer.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Computer expected() { - return Computer.builder() - .displayName("Ruboto") - .idle(true) - .offline(false) - .build(); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerViewTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerViewTest.java deleted file mode 100644 index f4b940418..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerViewTest.java +++ /dev/null @@ -1,58 +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.jclouds.jenkins.v1.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit", testName = "ParseComputerViewTest") -public class ParseComputerViewTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/computerview.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ComputerView expected() { - return ComputerView.builder() - .displayName("nodes") - .totalExecutors(4) - .busyExecutors(0) - .computers(ImmutableSet.builder() - .add(Computer.builder() - .displayName("master") - .idle(true) - .offline(false).build()) - .add(Computer.builder() - .displayName("Ruboto") - .idle(true) - .offline(false).build()) - .add(Computer.builder() - .displayName("winserver2008-x86") - .idle(true) - .offline(false).build()).build()).build(); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseJobDetailsTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseJobDetailsTest.java deleted file mode 100644 index 45af013f5..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseJobDetailsTest.java +++ /dev/null @@ -1,44 +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.jclouds.jenkins.v1.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ParseJobDetailsTest") -public class ParseJobDetailsTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/job.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public JobDetails expected() { - return JobDetails.builder() - .name("ddd") - .url(URI.create("http://localhost:8080/job/ddd/")) - .color("grey").build(); - } -} diff --git a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseNodeTest.java b/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseNodeTest.java deleted file mode 100644 index d2c8c1aad..000000000 --- a/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseNodeTest.java +++ /dev/null @@ -1,49 +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.jclouds.jenkins.v1.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.Job; -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ParseNodeTest") -public class ParseNodeTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/master.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Node expected() { - return Node.builder() - .name("") - .description("the master Jenkins node") - .jobs(Job.builder() - .name("ddd") - .url(URI.create("http://localhost:8080/job/ddd/")) - .color("grey").build()) - .build(); - } -} diff --git a/jenkins/src/test/resources/computer.json b/jenkins/src/test/resources/computer.json deleted file mode 100644 index 610126b49..000000000 --- a/jenkins/src/test/resources/computer.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "actions": [], - "displayName": "Ruboto", - "executors": [{}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": true, - "launchSupported": false, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1697591296, - "availableSwapSpace": 5626036224, - "totalPhysicalMemory": 4157317120, - "totalSwapSpace": 6568271872 - }, - "hudson.node_monitors.ArchitectureMonitor": "Linux (amd64)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 955 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 53646782464 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 53646782464 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": -309 - } - }, - "numExecutors": 1, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false -} \ No newline at end of file diff --git a/jenkins/src/test/resources/computerview.json b/jenkins/src/test/resources/computerview.json deleted file mode 100644 index e9b070469..000000000 --- a/jenkins/src/test/resources/computerview.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "busyExecutors": 0, - "computer": [{ - "actions": [], - "displayName": "master", - "executors": [{}, {}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": false, - "launchSupported": true, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1385115648, - "availableSwapSpace": 32208396288, - "totalPhysicalMemory": 8053207040, - "totalSwapSpace": 32218378240 - }, - "hudson.node_monitors.ArchitectureMonitor": "Linux (amd64)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 1 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 6235500544 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 79292284928 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": 0 - } - }, - "numExecutors": 2, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false - }, { - "actions": [], - "displayName": "Ruboto", - "executors": [{}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": true, - "launchSupported": false, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1684832256, - "availableSwapSpace": 5625421824, - "totalPhysicalMemory": 4157317120, - "totalSwapSpace": 6568271872 - }, - "hudson.node_monitors.ArchitectureMonitor": "Linux (amd64)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 856 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 53648973824 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 53648969728 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": -462 - } - }, - "numExecutors": 1, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false - }, { - "actions": [], - "displayName": "winserver2008-x86", - "executors": [{}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": true, - "launchSupported": false, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1117851648, - "availableSwapSpace": 1429299200, - "totalPhysicalMemory": 1781420032, - "totalSwapSpace": 1994350592 - }, - "hudson.node_monitors.ArchitectureMonitor": "Windows Server 2008 (x86)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 1 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 19072663552 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 19072663552 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": 71 - } - }, - "numExecutors": 1, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false - }], - "displayName": "nodes", - "totalExecutors": 4 -} \ No newline at end of file diff --git a/jenkins/src/test/resources/job.json b/jenkins/src/test/resources/job.json deleted file mode 100644 index ebf43f35f..000000000 --- a/jenkins/src/test/resources/job.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "actions": [], - "description": "", - "displayName": "ddd", - "displayNameOrNull": null, - "name": "ddd", - "url": "http://localhost:8080/job/ddd/", - "buildable": true, - "builds": [], - "color": "grey", - "firstBuild": null, - "healthReport": [], - "inQueue": false, - "keepDependencies": false, - "lastBuild": null, - "lastCompletedBuild": null, - "lastFailedBuild": null, - "lastStableBuild": null, - "lastSuccessfulBuild": null, - "lastUnstableBuild": null, - "lastUnsuccessfulBuild": null, - "nextBuildNumber": 1, - "property": [], - "queueItem": null, - "concurrentBuild": false, - "downstreamProjects": [], - "scm": {}, - "upstreamProjects": [] -} \ No newline at end of file diff --git a/jenkins/src/test/resources/lastBuild.json b/jenkins/src/test/resources/lastBuild.json deleted file mode 100644 index 3843687aa..000000000 --- a/jenkins/src/test/resources/lastBuild.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "actions": [ - { - "causes": [ - { - "shortDescription": "Started by GitHub push by " - } - ] - }, - { - }, - { - "buildsByBranchName": { - "origin/master": { - "buildNumber": 139, - "buildResult": null, - "revision": { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "branch": [ - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/HEAD" - }, - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/master" - } - ] - } - }, - "origin/HEAD": { - "buildNumber": 139, - "buildResult": null, - "revision": { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "branch": [ - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/HEAD" - }, - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/master" - } - ] - } - } - }, - "lastBuiltRevision": { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "branch": [ - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/HEAD" - }, - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/master" - } - ] - }, - "scmName": "" - }, - { - }, - { - }, - { - } - ], - "artifacts": [ - { - "displayPath": "poweredman-webapp-0.0.1-SNAPSHOT.zip", - "fileName": "poweredman-webapp-0.0.1-SNAPSHOT.zip", - "relativePath": "webapp/dist/poweredman-webapp-0.0.1-SNAPSHOT.zip" - } - ], - "building": false, - "description": "test", - "duration": 505777, - "estimatedDuration": 942619, - "fullDisplayName": "poweredman-web-build #139", - "id": "2012-07-11_04-02-37", - "keepLog": false, - "number": 139, - "result": "SUCCESS", - "timestamp": 1341997357461, - "url": "http://dal36.poweredman.com:8080/job/poweredman-web-build/139/", - "builtOn": "", - "changeSet": { - "items": [ - { - "affectedPaths": [ - "webapp/app/controllers/Application.java" - ], - "author": { - "absoluteUrl": "http://dal36.poweredman.com:8080/user/andrea.turli", - "fullName": "andrea.turli" - }, - "commitId": "aabf3da75ef2f4169de1136a93d5eec609314436", - "msg": "fixed signup process removing refuse Ebean.saveManyToManyAssociations(currentUser, \"companies\")", - "timestamp": 1341997059000, - "author (new)": { - "absoluteUrl": "http://dal36.poweredman.com:8080/user/andrea.turli", - "fullName": "andrea.turli" - }, - "comment": "fixed signup process removing refuse Ebean.saveManyToManyAssociations(currentUser, \"companies\")\n", - "date": "2012-07-11 03:57:39 +0200", - "id": "aabf3da75ef2f4169de1136a93d5eec609314436", - "msg (new)": "fixed signup process removing refuse Ebean.saveManyToManyAssociations(currentUser, \"companies\")", - "paths": [ - { - "editType": "edit", - "file": "webapp/app/controllers/Application.java" - } - ] - } - ], - "kind": null - }, - "culprits": [ - { - "absoluteUrl": "http://dal36.poweredman.com:8080/user/andrea.turli", - "fullName": "andrea.turli" - } - ] -} \ No newline at end of file diff --git a/jenkins/src/test/resources/logback.xml b/jenkins/src/test/resources/logback.xml deleted file mode 100644 index 9679b2e03..000000000 --- a/jenkins/src/test/resources/logback.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jenkins/src/test/resources/master.json b/jenkins/src/test/resources/master.json deleted file mode 100644 index 8e5c622b9..000000000 --- a/jenkins/src/test/resources/master.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "assignedLabels": [{}], - "mode": "NORMAL", - "nodeDescription": "the master Jenkins node", - "nodeName": "", - "numExecutors": 2, - "description": null, - "jobs": [{ - "name": "ddd", - "url": "http://localhost:8080/job/ddd/", - "color": "grey" - }], - "overallLoad": {}, - "primaryView": { - "name": "All", - "url": "http://localhost:8080/" - }, - "quietingDown": false, - "slaveAgentPort": 0, - "useCrumbs": false, - "useSecurity": false, - "views": [{ - "name": "All", - "url": "http://localhost:8080/" - }] -} \ No newline at end of file diff --git a/jenkins/src/test/resources/sample_job.xml b/jenkins/src/test/resources/sample_job.xml deleted file mode 100644 index 9b74eb35a..000000000 --- a/jenkins/src/test/resources/sample_job.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - false - - - true - false - false - false - - false - - - echo hello - - - - - \ No newline at end of file diff --git a/jenkins/src/test/resources/sample_job_with_parameters.xml b/jenkins/src/test/resources/sample_job_with_parameters.xml deleted file mode 100644 index 3c65002ea..000000000 --- a/jenkins/src/test/resources/sample_job_with_parameters.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - false - - - - - name - - - - - password - - - - - - - - true - false - false - - false - - false - - - echo hello - - - - - \ No newline at end of file