summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java175
-rw-r--r--src/test/java/org/onap/music/unittests/MusicUtilTest.java20
2 files changed, 185 insertions, 10 deletions
diff --git a/src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java b/src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java
new file mode 100644
index 00000000..7d51465f
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java
@@ -0,0 +1,175 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.unittests;
+
+import static org.junit.Assert.*;
+import java.io.File;
+import org.apache.curator.test.TestingServer;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.music.exceptions.MusicLockingException;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.lockingservice.MusicLockState;
+import org.onap.music.lockingservice.MusicLockingService;
+import org.onap.music.lockingservice.ZkStatelessLockService;
+import org.onap.music.lockingservice.MusicLockState.LockStatus;
+
+public class MusicLockingServiceTest {
+
+ static MusicLockingService mLockHandle;
+ static TestingServer zkServer;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ zkServer = new TestingServer(2181,new File("/tmp/zk"));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println("####" + zkServer.getPort());
+ try {
+ mLockHandle = new MusicLockingService();
+ } catch (MusicServiceException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ zkServer.stop();
+ mLockHandle.close();
+ }
+
+ @Before
+ public void setUp() throws Exception {}
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testMusicLockingService() {
+ assertTrue(mLockHandle != null);
+ }
+
+ @Test
+ public void testGetzkLockHandle() {
+ ZkStatelessLockService lockHandle = mLockHandle.getzkLockHandle();
+ assertTrue(lockHandle != null);
+ }
+
+ @Test
+ public void testMusicLockingServiceString() {
+ // MusicLockingService mLockTest = new MusicLockingService("localhost");
+ // assertTrue(mLockTest != null);
+ // mLockTest.close();
+ }
+
+ @Test
+ public void testCreateLockaIfItDoesNotExist() {
+
+ mLockHandle.createLockaIfItDoesNotExist("/ks1.tb1.pk1");
+ MusicLockState mls = null;
+ try {
+ // mls = mLockHandle.
+ mls = mLockHandle.getLockState("ks1.tb1.pk1");
+ } catch (MusicLockingException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Lock Holder:" + mls.getLockHolder());
+ assertFalse(mls.getLeaseStartTime() > 0);
+ }
+
+ @Test
+ public void testSetLockState() {
+ MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+ mLockHandle.setLockState("ks1.tb1.pk1",musicLockState);
+ MusicLockState mls = null;
+ try {
+ mls = mLockHandle.getLockState("ks1.tb1.pk1");
+ } catch (MusicLockingException e) {
+ e.printStackTrace();
+ }
+ assertEquals(musicLockState.getLockHolder(), mls.getLockHolder());
+
+ }
+
+// @Test
+// public void testGetLockState() {
+// MusicLockState mls = null;
+// try {
+// mls = mLockHandle.getLockState("ks1.tb1.pk1");
+// } catch (MusicLockingException e) {
+// e.printStackTrace();
+// }
+// assertTrue(mls.getLockHolder().equals("id1"));
+// }
+
+// @Test
+// public void testCreateLockId() {
+//
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testIsMyTurn() {
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testUnlockAndDeleteId() {
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testDeleteLock() {
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testWhoseTurnIsIt() {
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testProcess() {
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testClose() {
+// fail("Not yet implemented"); // TODO
+// }
+//
+// @Test
+// public void testLockIdExists() {
+// fail("Not yet implemented"); // TODO
+// }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/MusicUtilTest.java b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
index 35ec3791..e540d646 100644
--- a/src/test/java/org/onap/music/unittests/MusicUtilTest.java
+++ b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
@@ -73,11 +73,11 @@ public class MusicUtilTest {
assertEquals(MusicUtil.getAllIds().get(0),"1");
}
- @Test
- public void testGetPublicIp() {
- MusicUtil.setPublicIp("10.0.0.1");
- assertEquals(MusicUtil.getPublicIp(),"10.0.0.1");
- }
+// @Test
+// public void testGetPublicIp() {
+// MusicUtil.setPublicIp("10.0.0.1");
+// assertEquals(MusicUtil.getPublicIp(),"10.0.0.1");
+// }
@Test
public void testGetAllPublicIps() {
@@ -124,11 +124,11 @@ public class MusicUtilTest {
assertEquals(MusicUtil.getVersion(),"1.0.0");
}
- @Test
- public void testGetMyZkHost() {
- MusicUtil.setMyZkHost("10.0.0.2");
- assertEquals(MusicUtil.getMyZkHost(),"10.0.0.2");
- }
+// @Test
+// public void testGetMyZkHost() {
+// MusicUtil.setMyZkHost("10.0.0.2");
+// assertEquals(MusicUtil.getMyZkHost(),"10.0.0.2");
+// }
@Test
public void testGetMyCassaHost() {
00; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.onap.so.adapters</groupId>
    <artifactId>etsi-sol003-lcm</artifactId>
    <version>1.6.0-SNAPSHOT</version>
  </parent>
  <artifactId>etsi-sol003-lcm-api</artifactId>
  <name>ETSI SOL003 Life Cycle Management Adapter API</name>
  <build>
    <plugins>
      <plugin>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-codegen-maven-plugin</artifactId>
        <version>${version-swagger-codegen}</version>
        <executions>
          <execution>
            <id>vnfmadapter</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${basedir}/src/main/resources/etsisol003adapter.yaml</inputSpec>
              <language>java</language>
              <library>retrofit2</library>
              <output>${project.build.directory}/generated-sources/etsisol003adapter</output>
              <apiPackage>org.onap.so.adapters.etsisol003adapter.lcm.v1.api</apiPackage>
              <modelPackage>org.onap.so.adapters.etsisol003adapter.lcm.v1.model</modelPackage>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
              <configOptions>
                <jackson>true</jackson>
                <sourceFolder>src/gen/java/main</sourceFolder>
                <withXml>true</withXml>
                <useRxJava2>true</useRxJava2>
                <serializableModel>true</serializableModel>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>sol003-vnf-lcn-api</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json</inputSpec>
              <language>java</language>
              <library>okhttp-gson</library>
              <output>${project.build.directory}/generated-sources/sol003-vnf-lcn</output>
              <apiPackage>org.onap.so.adapters.etsisol003adapter.lcm.lcn.api</apiPackage>
              <modelPackage>org.onap.so.adapters.etsisol003adapter.lcm.lcn.model</modelPackage>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
              <configOptions>
                <sourceFolder>src/gen/java/main</sourceFolder>
                <withXml>true</withXml>
                <useRxJava2>true</useRxJava2>
                <serializableModel>true</serializableModel>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>sol003-vnf-grant-api</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json</inputSpec>
              <language>java</language>
              <library>okhttp-gson</library>
              <output>${project.build.directory}/generated-sources/sol003-vnf-grant</output>
              <apiPackage>org.onap.so.adapters.etsisol003adapter.lcm.grant.api</apiPackage>
              <modelPackage>org.onap.so.adapters.etsisol003adapter.lcm.grant.model</modelPackage>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
              <configOptions>
                <generateSupportingFiles>false</generateSupportingFiles>
                <sourceFolder>src/gen/java/main</sourceFolder>
                <withXml>true</withXml>
                <useRxJava2>true</useRxJava2>
                <serializableModel>true</serializableModel>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.basedir}/target/generated-sources/vnfmadapter/src/gen/java/main</source>
                <source>${project.basedir}/target/generated-sources/sol003-vnf-lcn/src/gen/java/main</source>
                <source>${project.basedir}/target/generated-sources/sol003-vnf-grant/src/gen/java/main</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-codegen-maven-plugin</artifactId>
                    <goals>
                      <goal>generate</goal>
                    </goals>
                    <versionRange>[2.2.0,)</versionRange>
                  </pluginExecutionFilter>
                  <action>
                    <execute>
                      <runOnIncremental>false</runOnIncremental>
                    </execute>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <dependencies>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
      <version>${swagger-core-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.retrofit2</groupId>
      <artifactId>converter-gson</artifactId>
      <version>${retrofit-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.retrofit2</groupId>
      <artifactId>retrofit</artifactId>
      <version>${retrofit-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.retrofit2</groupId>
      <artifactId>converter-scalars</artifactId>
      <version>${retrofit-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.oltu.oauth2</groupId>
      <artifactId>org.apache.oltu.oauth2.client</artifactId>
      <version>${oltu-version}</version>
    </dependency>
    <dependency>
      <groupId>io.gsonfire</groupId>
      <artifactId>gson-fire</artifactId>
      <version>${gson-fire-version}</version>
    </dependency>
    <dependency>
      <groupId>org.threeten</groupId>
      <artifactId>threetenbp</artifactId>
      <version>${threetenbp-version}</version>
    </dependency>
    <dependency>
      <groupId>io.reactivex.rxjava2</groupId>
      <artifactId>rxjava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.squareup.retrofit2</groupId>
      <artifactId>adapter-rxjava2</artifactId>
      <version>${retrofit-version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>
    <dependency>
      <groupId>com.squareup.okio</groupId>
      <artifactId>okio</artifactId>
      <version>${okio-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp3</groupId>
      <artifactId>okhttp</artifactId>
      <version>${okhttp3-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp3</groupId>
      <artifactId>logging-interceptor</artifactId>
      <version>${okhttp3-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>logging-interceptor</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>okhttp</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>logging-interceptor</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
  </dependencies>
</project>