-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load devfile schema for validation by it's apiVersion (#14834)
Signed-off-by: Michal Vala <mvala@redhat.com>
- Loading branch information
Showing
8 changed files
with
144 additions
and
22 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
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
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
54 changes: 54 additions & 0 deletions
54
...t/java/org/eclipse/che/api/workspace/server/devfile/schema/DevfileSchemaProviderTest.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,54 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
package org.eclipse.che.api.workspace.server.devfile.schema; | ||
|
||
import static org.eclipse.che.api.workspace.server.devfile.Constants.CURRENT_API_VERSION; | ||
import static org.testng.Assert.assertNotNull; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
import org.testng.annotations.Test; | ||
|
||
public class DevfileSchemaProviderTest { | ||
|
||
private final DevfileSchemaProvider devfileSchemaProvider = new DevfileSchemaProvider(); | ||
|
||
@Test | ||
public void shouldGetProperDevfileSchemaContent() throws IOException { | ||
String content = devfileSchemaProvider.getSchemaContent(CURRENT_API_VERSION); | ||
assertNotNull(content); | ||
assertTrue(content.contains("This schema describes the structure of the devfile object")); | ||
} | ||
|
||
@Test | ||
public void shouldGetProperDevfileSchemaContentAsReader() throws IOException { | ||
StringReader contentReader = devfileSchemaProvider.getAsReader(CURRENT_API_VERSION); | ||
assertNotNull(contentReader); | ||
|
||
StringBuilder contentBuilder = new StringBuilder(); | ||
int c; | ||
while ((c = contentReader.read()) != -1) { | ||
contentBuilder.append((char) c); | ||
} | ||
assertTrue( | ||
contentBuilder | ||
.toString() | ||
.contains("This schema describes the structure of the devfile object")); | ||
} | ||
|
||
@Test(expectedExceptions = IOException.class) | ||
public void shouldThrowExceptionWhenInvalidVersionRequested() throws IOException { | ||
devfileSchemaProvider.getSchemaContent("this_is_clearly_not_a_valid_schema_version"); | ||
} | ||
} |
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