summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web')
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java98
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java95
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java94
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java93
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java68
5 files changed, 0 insertions, 448 deletions
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java
deleted file mode 100644
index be36aa83..00000000
--- a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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 org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow classifier codec unit tests.
- */
-public class FlowClassifierCodecTest {
-
- SfcCodecContext context;
- JsonCodec<FlowClassifier> flowClassifierCodec;
- /**
- * Sets up for each test. Creates a context and fetches the flow classifier
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- flowClassifierCodec = context.codec(FlowClassifier.class);
- assertThat(flowClassifierCodec, notNullValue());
- }
-
- /**
- * Reads in a flow classifier from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the flow classifier
- * @return decoded flow classifier
- * @throws IOException if processing the resource fails
- */
- private FlowClassifier getFlowClassifier(String resourceName) throws IOException {
- InputStream jsonStream = FlowClassifierCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- FlowClassifier flowClassifier = flowClassifierCodec.decode((ObjectNode) json, context);
- assertThat(flowClassifier, notNullValue());
- return flowClassifier;
- }
-
- /**
- * Checks that a simple flow classifier decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecFlowClassifierTest() throws IOException {
-
- FlowClassifier flowClassifier = getFlowClassifier("flowClassifier.json");
-
- assertThat(flowClassifier, notNullValue());
-
- FlowClassifierId flowClassifierId = FlowClassifierId.of("4a334cd4-fe9c-4fae-af4b-321c5e2eb051");
- TenantId tenantId = TenantId.tenantId("1814726e2d22407b8ca76db5e567dcf1");
-
- assertThat(flowClassifier.flowClassifierId().toString(), is(flowClassifierId.toString()));
- assertThat(flowClassifier.name(), is("flow1"));
- assertThat(flowClassifier.tenantId().toString(), is(tenantId.toString()));
- assertThat(flowClassifier.description(), is("flow classifier"));
- assertThat(flowClassifier.protocol(), is("tcp"));
- assertThat(flowClassifier.minSrcPortRange(), is(22));
- assertThat(flowClassifier.maxSrcPortRange(), is(4000));
- assertThat(flowClassifier.minDstPortRange(), is(80));
- assertThat(flowClassifier.maxDstPortRange(), is(80));
-
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java
deleted file mode 100644
index 02681db3..00000000
--- a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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 org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow rule codec unit tests.
- */
-public class PortChainCodecTest {
-
- SfcCodecContext context;
- JsonCodec<PortChain> portChainCodec;
- /**
- * Sets up for each test. Creates a context and fetches the flow rule
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- portChainCodec = context.codec(PortChain.class);
- assertThat(portChainCodec, notNullValue());
- }
-
- /**
- * Reads in a rule from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the rule
- * @return decoded flow rule
- * @throws IOException if processing the resource fails
- */
- private PortChain getPortChain(String resourceName) throws IOException {
- InputStream jsonStream = PortChainCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PortChain portChain = portChainCodec.decode((ObjectNode) json, context);
- assertThat(portChain, notNullValue());
- return portChain;
- }
-
- /**
- * Checks that a simple rule decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPortChainTest() throws IOException {
-
- PortChain portChain = getPortChain("portChain.json");
-
- assertThat(portChain, notNullValue());
-
- PortChainId portChainId = PortChainId.of("1278dcd4-459f-62ed-754b-87fc5e4a6751");
- TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- assertThat(portChain.portChainId().toString(), is(portChainId.toString()));
- assertThat(portChain.name(), is("PC2"));
- assertThat(portChain.tenantId().toString(), is(tenantId.toString()));
- assertThat(portChain.description(), is("Two flows and two port-pair-groups"));
-
- assertThat(portChain.flowClassifiers(), notNullValue());
- assertThat(portChain.portPairGroups(), notNullValue());
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java
deleted file mode 100644
index 7651e098..00000000
--- a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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 org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Port pair codec unit tests.
- */
-public class PortPairCodecTest {
-
- SfcCodecContext context;
- JsonCodec<PortPair> portPairCodec;
- /**
- * Sets up for each test. Creates a context and fetches the port pair
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- portPairCodec = context.codec(PortPair.class);
- assertThat(portPairCodec, notNullValue());
- }
-
- /**
- * Reads in a port pair from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the port pair
- * @return decoded port pair
- * @throws IOException if processing the resource fails
- */
- private PortPair getPortPair(String resourceName) throws IOException {
- InputStream jsonStream = PortPairCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PortPair portPair = portPairCodec.decode((ObjectNode) json, context);
- assertThat(portPair, notNullValue());
- return portPair;
- }
-
- /**
- * Checks that a simple port pair decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPortPairTest() throws IOException {
-
- PortPair portPair = getPortPair("portPair.json");
-
- assertThat(portPair, notNullValue());
-
- PortPairId portPairId = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- assertThat(portPair.portPairId().toString(), is(portPairId.toString()));
- assertThat(portPair.name(), is("PP1"));
- assertThat(portPair.tenantId().toString(), is(tenantId.toString()));
- assertThat(portPair.description(), is("SF-A"));
- assertThat(portPair.ingress().toString(), is("dace4513-24fc-4fae-af4b-321c5e2eb3d1"));
- assertThat(portPair.egress().toString(), is("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java
deleted file mode 100644
index de2ee001..00000000
--- a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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 org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow rule codec unit tests.
- */
-public class PortPairGroupCodecTest {
-
- SfcCodecContext context;
- JsonCodec<PortPairGroup> portPairGroupCodec;
- /**
- * Sets up for each test. Creates a context and fetches the flow rule
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- portPairGroupCodec = context.codec(PortPairGroup.class);
- assertThat(portPairGroupCodec, notNullValue());
- }
-
- /**
- * Reads in a rule from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the rule
- * @return decoded flow rule
- * @throws IOException if processing the resource fails
- */
- private PortPairGroup getPortPairGroup(String resourceName) throws IOException {
- InputStream jsonStream = PortPairGroupCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PortPairGroup portPairGroup = portPairGroupCodec.decode((ObjectNode) json, context);
- assertThat(portPairGroup, notNullValue());
- return portPairGroup;
- }
-
- /**
- * Checks that a simple rule decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPortPairGroupTest() throws IOException {
-
- PortPairGroup portPairGroup = getPortPairGroup("portPairGroup.json");
-
- assertThat(portPairGroup, notNullValue());
-
- PortPairGroupId portPairGroupId = PortPairGroupId.of("4512d643-24fc-4fae-af4b-321c5e2eb3d1");
- TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- assertThat(portPairGroup.portPairGroupId().toString(), is(portPairGroupId.toString()));
- assertThat(portPairGroup.name(), is("PG1"));
- assertThat(portPairGroup.tenantId().toString(), is(tenantId.toString()));
- assertThat(portPairGroup.description(), is("Two port-pairs"));
- assertThat(portPairGroup.portPairs(), notNullValue());
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java
deleted file mode 100644
index c56a4fcb..00000000
--- a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * 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 org.onosproject.vtnweb.web;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.CodecService;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.codec.impl.CodecManager;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Mock codec context for use in codec unit tests.
- */
-public class SfcCodecContext implements CodecContext {
-
- private final ObjectMapper mapper = new ObjectMapper();
- private final CodecManager codecManager = new CodecManager();
- private final VtnCodecRegistrator manager = new VtnCodecRegistrator();
-
- /**
- * Constructs a new mock codec context.
- */
- public SfcCodecContext() {
- codecManager.activate();
- manager.codecService = codecManager;
- manager.activate();
- }
-
- @Override
- public ObjectMapper mapper() {
- return mapper;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getService(Class<T> serviceClass) {
- // TODO
- return null;
- }
-
- @Override
- public <T> JsonCodec<T> codec(Class<T> entityClass) {
- return codecManager.getCodec(entityClass);
- }
-
- /**
- * Get the codec manager.
- *
- * @return instance of codec manager
- */
- public CodecService codecManager() {
- return codecManager;
- }
-}