Skip to content

Commit

Permalink
fix: folder checks
Browse files Browse the repository at this point in the history
arifBurakDemiray committed Sep 25, 2023
1 parent 3659d47 commit 9e39ad9
Showing 5 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package ly.count.java.demo;

import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;

public class BackendModeExample {
final static String DEVICE_ID = "device-id";
@@ -314,8 +313,10 @@ public static void main(String[] args) throws Exception {
String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" };
File sdkStorageRootDirectory = new File(String.join(File.separator, sdkStorageRootPath));

if(sdkStorageRootDirectory.mkdirs()){
System.out.println("Directory creation failed");
if (!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory())) {
if (!sdkStorageRootDirectory.mkdirs()) {
System.out.println("Directory creation failed");
}
}

// Main initialization call, SDK can be used after this one is done
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package ly.count.java.demo;

import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;
import ly.count.sdk.java.internal.Device;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;
import ly.count.sdk.java.internal.Device;

public class BackendModePerformanceTests {
final static String DEVICE_ID = "device-id";
@@ -27,8 +26,10 @@ private static void initSDK(int eventQueueSize, int requestQueueSize) {
String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" };
File sdkStorageRootDirectory = new File(String.join(File.separator, sdkStorageRootPath));

if(sdkStorageRootDirectory.mkdirs()){
System.out.println("Directory creation failed");
if (!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory())) {
if (!sdkStorageRootDirectory.mkdirs()) {
System.out.println("Directory creation failed");
}
}

// Main initialization call, SDK can be used after this one is done
7 changes: 4 additions & 3 deletions app-java/src/main/java/ly/count/java/demo/Example.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;
import ly.count.sdk.java.internal.LogCallback;
@@ -125,8 +124,10 @@ public static void main(String[] args) throws Exception {
String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" };
File sdkStorageRootDirectory = new File(String.join(File.separator, sdkStorageRootPath));

if(sdkStorageRootDirectory.mkdirs()){
System.out.println("Directory creation failed");
if (!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory())) {
if (!sdkStorageRootDirectory.mkdirs()) {
System.out.println("Directory creation failed");
}
}

Config config = new Config(COUNTLY_SERVER_URL, COUNTLY_APP_KEY, sdkStorageRootDirectory)
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package ly.count.sdk.java.internal;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.*;

@RunWith(JUnit4.class)
public class BackendModeTests {
private ModuleBackendMode moduleBackendMode;
@@ -25,12 +31,8 @@ public static void init() {
cc.setEventQueueSizeToSend(4).enableBackendMode();

// System specific folder structure
String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" };
File sdkStorageRootDirectory = new File(String.join(File.separator, sdkStorageRootPath));

if(sdkStorageRootDirectory.mkdirs()){
System.out.println("Directory creation failed");
}
File sdkStorageRootDirectory = TestUtils.getSdkStorageRootDirectory();
TestUtils.checkSdkStorageRootDirectoryExist(sdkStorageRootDirectory);

Countly.init(sdkStorageRootDirectory, cc);
}
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ static void checkSdkStorageRootDirectoryExist(File directory) {
}
}
}

/**
* Get current request queue from target folder
*

0 comments on commit 9e39ad9

Please sign in to comment.