forked from fabric8io/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fabric8io#2354: Fix NullPointerException in ResourceCompare when …
…no resource is returned from fromServer.get() Somehow resource was being returned as `null` from `fromServer.get()` call due to no namespace being provided. Added a case of Null items in `ResourceCompare#equals`
- Loading branch information
1 parent
50c1e8d
commit dbdcafc
Showing
6 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
extensions/knative/tests/src/test/java/io/fabric8/knative/test/RouteTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed 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 io.fabric8.knative.test; | ||
|
||
import io.fabric8.knative.client.KnativeClient; | ||
import io.fabric8.knative.mock.KnativeServer; | ||
import io.fabric8.knative.serving.v1.Route; | ||
import io.fabric8.knative.serving.v1.RouteBuilder; | ||
import org.junit.Rule; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; | ||
|
||
import java.net.HttpURLConnection; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@EnableRuleMigrationSupport | ||
class RouteTest { | ||
@Rule | ||
public KnativeServer server = new KnativeServer(); | ||
|
||
@Test | ||
void testCreateOrReplace() { | ||
// Given | ||
Route route = new RouteBuilder() | ||
.withNewMetadata() | ||
.withName("helloworld-nodejs-red-blue1") | ||
.withNamespace("test") | ||
.endMetadata() | ||
.withNewSpec() | ||
.addNewTraffic() | ||
.withConfigurationName("greeter") | ||
.withPercent(100L) | ||
.endTraffic() | ||
.endSpec() | ||
.build(); | ||
server.expect().post().withPath("/apis/serving.knative.dev/v1/namespaces/test/routes") | ||
.andReturn(HttpURLConnection.HTTP_CONFLICT, route) | ||
.once(); | ||
server.expect().get().withPath("/apis/serving.knative.dev/v1/namespaces/test/routes/helloworld-nodejs-red-blue1") | ||
.andReturn(HttpURLConnection.HTTP_OK, route) | ||
.times(2); | ||
server.expect().put().withPath("/apis/serving.knative.dev/v1/namespaces/test/routes/helloworld-nodejs-red-blue1") | ||
.andReturn(HttpURLConnection.HTTP_OK, route) | ||
.once(); | ||
KnativeClient kn = server.getKnativeClient(); | ||
|
||
// When | ||
route = kn.routes().createOrReplaceWithNew() | ||
.withNewMetadata() | ||
.withName("helloworld-nodejs-red-blue1") | ||
.addToAnnotations("foo", "bar") | ||
.withNamespace("test") | ||
.endMetadata() | ||
.withNewSpec() | ||
.addNewTraffic() | ||
.withConfigurationName("greeter") | ||
.withPercent(100L) | ||
.endTraffic() | ||
.endSpec() | ||
.done(); | ||
|
||
// Then | ||
assertNotNull(route); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters